:root {
  --bg: #fafafa;
  --fg: #111111;
  --muted: #8a8a8a;
  --line: #e6e6e6;
  --accent: #2f6df6;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* liquid glass */
  --glass-bg: rgba(255, 255, 255, .45);
  --glass-border: rgba(255, 255, 255, .8);
  --glass-shadow: 0 10px 30px rgba(0, 0, 0, .08), inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -1px 0 rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
/* soft blobs behind the glass so refraction is visible */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; border-radius: 50%; filter: blur(80px); opacity: .35; pointer-events: none;
  animation: drift 28s ease-in-out infinite alternate;
}
body::before { width: 46vw; height: 46vw; left: -10vw; top: -10vw; background: radial-gradient(circle, var(--accent), transparent 70%); }
body::after  { width: 40vw; height: 40vw; right: -8vw; bottom: -12vw; background: radial-gradient(circle, #f2b63c, transparent 70%); animation-delay: -14s; }
@keyframes drift { to { transform: translate(6vw, 4vw) scale(1.1); } }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.hidden { display: none !important; }

/* ---------- liquid glass primitives ---------- */
.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  overflow: hidden;
}
.glass::before { /* moving specular highlight */
  content: ""; position: absolute; inset: -60%;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.55) 50%, transparent 60%);
  transform: translateX(-60%);
  animation: sheen 7s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen { 0%, 60% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }

.glass-btn {
  position: relative;
  padding: 10px 24px;
  border-radius: 999px;
  letter-spacing: .02em;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  overflow: hidden;
  transition: transform .25s cubic-bezier(.2,.8,.2,1.4), box-shadow .25s, background .25s;
}
.glass-btn::before {
  content: ""; position: absolute; inset: -60%;
  background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,.7) 50%, transparent 58%);
  transform: translateX(-60%);
  animation: sheen 6s ease-in-out infinite;
  pointer-events: none;
}
.glass-btn:hover { transform: translateY(-1px) scale(1.03); background: rgba(255,255,255,.65); box-shadow: 0 14px 34px rgba(0,0,0,.1), inset 0 1px 0 #fff; }
.glass-btn:active { transform: scale(.97); }
.glass-btn.open { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.glass-btn.small { padding: 7px 18px; font-size: 14px; align-self: flex-start; }
.glass-btn.icon { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: 14px; }

.link-btn { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.link-btn:hover { color: var(--fg); }

/* ---------- layout ---------- */
.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 480px) 1fr;
  align-items: center;
  padding: 48px;
}
.col { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.col-left { align-items: flex-start; }
.col-right { align-items: flex-end; }

/* ---------- center ---------- */
.col-center { position: relative; gap: 20px; }
.stack {
  position: relative;
  width: 360px; height: 360px;
  --r: 130px; /* orbit radius */
}
.stack .bottle {
  position: absolute;
  left: 50%; top: 50%;
  width: 40px; height: 100px;
  margin: -50px 0 0 -20px;
  animation: orbit 24s linear infinite;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.1));
}
.stack .bottle img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stack .bottle.empty { opacity: .15; filter: grayscale(1); animation-duration: 45s; }
/* travel around the ring; the trailing rotate cancels self-rotation so cans stay upright */
@keyframes orbit {
  from { transform: rotate(var(--a)) translateY(calc(-1 * var(--r))) rotate(calc(-1 * var(--a))); }
  to   { transform: rotate(calc(var(--a) + 360deg)) translateY(calc(-1 * var(--r))) rotate(calc(-1 * var(--a) - 360deg)); }
}

.today {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) translateY(-20px);
  width: 170px; height: 170px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 50%;
  pointer-events: none;
}
.today-label { display: block; font-size: 12px; letter-spacing: .2em; color: var(--muted); }
.today-count { display: block; font-size: 56px; font-weight: 300; line-height: 1; margin-top: 2px; }
.today-count.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.15); color: var(--accent); } }

.today-flavors {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  font-size: 13px; color: var(--muted);
  min-height: 20px;
}
.today-flavors li::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--c); margin-right: 6px; vertical-align: middle;
}

/* ---------- forms / picker (inside the user glass) ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form input {
  font: inherit; color: var(--fg);
  border: 0; border-bottom: 1px solid rgba(0,0,0,.12);
  padding: 6px 0; outline: none; background: transparent;
}
.form input:focus { border-bottom-color: var(--accent); }
.error { color: #c0392b; font-size: 13px; margin: 0; min-height: 1em; }

.picker { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
.flavors { display: flex; justify-content: space-between; width: 100%; overflow: hidden; padding-top: 4px; }
.flavor {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
  transform: translateY(-160px); opacity: 0;
  animation: fall .55s cubic-bezier(.2,.9,.3,1.15) forwards;
  animation-delay: var(--d);
  transition: transform .15s, color .15s;
  border-radius: 12px; padding: 6px;
}
.flavor img { width: 40px; height: 100px; object-fit: contain; display: block; filter: drop-shadow(0 6px 8px rgba(0,0,0,.1)); }
.flavor:hover { color: var(--fg); }
.flavor:hover img { transform: translateY(-4px) scale(1.05); transition: transform .15s; }
@keyframes fall { to { transform: translateY(0); opacity: 1; } }

.logged { width: 100%; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.logged-title { letter-spacing: .15em; font-size: 11px; margin-bottom: 4px; }
.logged-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,.06); color: var(--fg);
}
.logged-item::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.logged-item span { flex: 1; }
.logged-item small { color: var(--muted); font-size: 11px; }
.remove {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,.6); border: 1px solid var(--glass-border);
  display: grid; place-items: center; color: var(--muted); font-size: 15px; line-height: 1;
  transition: transform .2s, color .2s, background .2s;
}
.remove:hover { color: var(--fg); background: #fff; transform: scale(1.1); }

/* ---------- liquid glass component ----------
   .lg-wrap keeps the closed footprint in the layout; .lg is the glass body that swells.
   Per-instance vars (inline): --w0 closed width, --rad0 closed radius, --wo open width.
   JS sets --h (target height) and --top (upward shift to stay in viewport). */
.lg-wrap { position: relative; width: var(--w0); height: 44px; z-index: 100; } /* above the orbit/counter; no perspective here so fixed positioning stays viewport-relative */

.lg {
  position: absolute; top: var(--top, 0px);
  width: var(--w, var(--w0)); height: var(--h, 44px);
  border-radius: var(--rad, var(--rad0));
  z-index: 100;
  will-change: transform, width, height;
  background:
    radial-gradient(120% 90% at var(--gx, 18%) 10%, rgba(255,255,255,.75), rgba(255,255,255,0) 55%),
    linear-gradient(135deg, rgba(255,255,255,.55), rgba(255,255,255,.22));
  border: 1px solid rgba(255,255,255,.9);
  box-shadow:
    0 24px 50px -18px rgba(0,0,0,.22),
    0 2px 6px rgba(0,0,0,.05),
    inset 0 1px 1px rgba(255,255,255,1),
    inset 1px 0 1px rgba(255,255,255,.7),
    inset 0 -10px 18px -12px rgba(0,0,0,.12),
    inset -10px 0 18px -14px rgba(0,0,0,.08);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  overflow: hidden;
  transition:
    width  .75s cubic-bezier(.32, 1.45, .45, 1),
    height .85s cubic-bezier(.32, 1.35, .45, 1) .06s,
    top    .85s cubic-bezier(.32, 1.35, .45, 1) .06s,
    left   .85s cubic-bezier(.32, 1.35, .45, 1) .06s,
    border-radius .9s cubic-bezier(.4, 1.6, .5, 1),
    box-shadow .8s ease, transform .25s cubic-bezier(.2,.8,.2,1.4);
  cursor: pointer;
}
.lg--left  { left: 0;  transform-origin: 22px 22px; --gx: 18%; }
.lg--right { right: 0; transform-origin: calc(100% - 48px) 22px; --gx: 82%; }

/* specular band sweeping across as it swells */
.lg::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 45%, rgba(255,255,255,.15) 52%, transparent 65%);
  transform: translateX(-110%) skewX(-8deg);
  transition: transform 1.1s cubic-bezier(.2,.7,.2,1);
}
.lg--right::before { transform: translateX(110%) skewX(8deg); }
/* caustic glow at the origin corner, thins as the glass spreads */
.lg::after {
  content: ""; position: absolute; top: -30px; width: 120px; height: 120px; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.9), rgba(255,255,255,0) 70%);
  opacity: .9; transition: opacity .8s ease, transform .8s ease;
}
.lg--left::after  { left: -30px; }
.lg--right::after { right: -30px; }
.lg:hover:not(.open) { transform: translateY(-1px) scale(1.04); }
.lg:active:not(.open) { transform: scale(.97); }

.lg.open {
  --w: var(--wo); --rad: 26px;
  cursor: default;
  box-shadow:
    0 40px 80px -24px rgba(0,0,0,.28),
    0 4px 10px rgba(0,0,0,.05),
    inset 0 1px 1px rgba(255,255,255,1),
    inset 1px 0 1px rgba(255,255,255,.7),
    inset 0 -14px 26px -16px rgba(0,0,0,.14),
    inset -14px 0 26px -18px rgba(0,0,0,.1);
}
.lg--left.open::before  { transform: translateX(110%) skewX(-8deg); }
.lg--right.open::before { transform: translateX(-110%) skewX(8deg); }
.lg.open::after { opacity: .35; transform: scale(2.2); }

/* 3D: tilt toward the viewer while swelling, settle flat; mirrored for the right side */
.lg--left.swell  { animation: swellL .95s cubic-bezier(.3, 1.2, .4, 1) both; }
.lg--right.swell { animation: swellR .95s cubic-bezier(.3, 1.2, .4, 1) both; }
@keyframes swellL {
  0%   { transform: none; border-radius: var(--rad0); }
  22%  { transform: perspective(1100px) rotateX(-12deg) rotateY(9deg) scale(1.04); border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%; }
  55%  { transform: perspective(1100px) rotateX(4deg) rotateY(-3deg) scale(1.015); border-radius: 34px 22px 30px 26px; }
  100% { transform: none; border-radius: 26px; }
}
@keyframes swellR {
  0%   { transform: none; border-radius: var(--rad0); }
  22%  { transform: perspective(1100px) rotateX(-12deg) rotateY(-9deg) scale(1.04); border-radius: 60% 40% 45% 55% / 45% 55% 40% 60%; }
  55%  { transform: perspective(1100px) rotateX(4deg) rotateY(3deg) scale(1.015); border-radius: 22px 34px 26px 30px; }
  100% { transform: none; border-radius: 26px; }
}
.lg--left.shrink  { animation: shrinkL .5s cubic-bezier(.5, 0, .7, .3) both; }
.lg--right.shrink { animation: shrinkR .5s cubic-bezier(.5, 0, .7, .3) both; }
@keyframes shrinkL { 40% { transform: perspective(1100px) rotateX(6deg) rotateY(-5deg) scale(1.02); } 100% { transform: none; } }
@keyframes shrinkR { 40% { transform: perspective(1100px) rotateX(6deg) rotateY(5deg) scale(1.02); } 100% { transform: none; } }

/* label (icon / name) dissolves into the glass */
.lg-label {
  position: absolute; top: 0; height: 44px; width: var(--w0); z-index: 2;
  display: grid; place-items: center; color: var(--fg); letter-spacing: .02em;
  transition: opacity .3s ease, transform .5s cubic-bezier(.32, 1.4, .45, 1);
}
.lg--left .lg-label { left: 0; }
.lg--right .lg-label { right: 0; }
.lg.open .lg-label { opacity: 0; transform: scale(.6); pointer-events: none; }

/* content surfaces once the glass has mostly formed */
.lg-body {
  position: relative; z-index: 2;
  width: var(--wo); padding: 26px;
  opacity: 0; transform: translateY(10px) scale(.98);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.lg--right .lg-body { margin-left: auto; }
.lg.open .lg-body { opacity: 1; transform: none; pointer-events: auto; transition-delay: .32s; transition-duration: .5s; }
.lg-body--user { padding: 22px; }
.body-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; letter-spacing: .15em; color: var(--muted); margin-bottom: 14px; }

.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 6px; }
.cal-grid .day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 13px; border: 1px solid transparent; transition: background .15s;
}
.cal-grid .day:hover { background: rgba(255,255,255,.7); }
.cal-grid .day.has { font-weight: 500; }
.cal-grid .day.is-today { border-color: var(--fg); }
.cal-grid .day.selected { background: var(--fg); color: var(--bg); }
.cal-grid .day small { font-size: 10px; color: var(--accent); line-height: 1; }
.cal-grid .day.selected small { color: var(--bg); }
.cal-grid .day.future { color: #ccc; pointer-events: none; }

.day-log { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid rgba(0,0,0,.08); font-size: 14px; min-height: 40px; color: var(--muted); }
.day-log ul { list-style: none; margin: 8px 0 0; padding: 0; color: var(--fg); }
.day-log li { display: flex; justify-content: space-between; padding: 4px 0; }

@media (orientation: portrait) {
  .layout { grid-template-columns: 1fr; gap: 32px; padding: 32px 24px; }
  .col-left, .col-right { align-items: center; }
  .stack { width: 300px; height: 300px; --r: 115px; }
}

/* mobile: the glass detaches from its column and swells to a centred, screen-wide sheet.
   JS adds .fixed (and sets --left/--top in viewport px) for the duration of the open state. */
.lg.fixed { position: fixed; left: var(--left, 0px); right: auto; top: var(--top, 0px); z-index: 100; }
.lg.snap  { transition: none !important; }
.lg.fixed .lg-body { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
html.lock, html.lock body { overflow: hidden; touch-action: none; }
