/* My Baby Pill — "foil & indigo" */
:root {
  --bg: #EDEFF5;          /* aluminium backing */
  --surface: #FFFFFF;
  --surface-2: #F6F7FB;
  --ink: #1D2042;         /* deep indigo */
  --ink-2: #4B4F74;
  --ink-3: #8A8DAA;
  --line: #DADDE9;
  --berry: #B4306A;       /* accent */
  --berry-ink: #FFFFFF;
  --berry-soft: #F7DCE8;
  --sage: #2F8A63;
  --sage-soft: #DCEFE5;
  --amber: #C9811A;
  --amber-soft: #FBEBD2;
  --red: #C93A4E;
  --red-soft: #F9DDE1;
  --foil-a: #C9CDDA;
  --foil-b: #F4F5F9;
  --pill: #FFFFFF;
  --crease: rgba(29, 32, 66, .25);
  --hollow: rgba(29, 32, 66, .16);
  --shadow: 0 1px 2px rgba(29, 32, 66, .06), 0 8px 24px rgba(29, 32, 66, .07);
  --r-lg: 28px; --r-md: 16px; --r-sm: 10px;
  --font-d: 'Bricolage Grotesque', 'Avenir Next', system-ui, sans-serif;
  --font-b: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabbar: 72px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14162A; --surface: #1D2040; --surface-2: #242852; --ink: #ECEBF7; --ink-2: #B7B8D6; --ink-3: #7D80A6;
    --line: #2E3260; --berry: #F0679F; --berry-ink: #1D0A14; --berry-soft: #3E1D33; --sage: #5CC593; --sage-soft: #183A2D;
    --amber: #F0AE4B; --amber-soft: #3B2D14; --red: #F06F80; --red-soft: #3F1B24;
    --foil-a: #3B3F68; --foil-b: #5A5F8F; --pill: #F4F3FA; --crease: rgba(255,255,255,.35); --hollow: rgba(10,10,30,.45); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14162A; --surface: #1D2040; --surface-2: #242852; --ink: #ECEBF7; --ink-2: #B7B8D6; --ink-3: #7D80A6;
  --line: #2E3260; --berry: #F0679F; --berry-ink: #1D0A14; --berry-soft: #3E1D33; --sage: #5CC593; --sage-soft: #183A2D;
  --amber: #F0AE4B; --amber-soft: #3B2D14; --red: #F06F80; --red-soft: #3F1B24;
  --foil-a: #3B3F68; --foil-b: #5A5F8F; --pill: #F4F3FA; --crease: rgba(255,255,255,.35); --hollow: rgba(10,10,30,.45); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--font-b); font-size: 16px; line-height: 1.45; min-height: 100dvh; overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { font-family: var(--font-d); margin: 0; letter-spacing: -0.02em; }

.screen { max-width: 480px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 20px) 18px calc(var(--tabbar) + env(safe-area-inset-bottom) + 28px); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.greet { color: var(--ink-2); font-size: 15px; }
.greet b { color: var(--ink); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--berry-soft); color: var(--berry); display: grid; place-items: center; font-family: var(--font-d); font-weight: 700; }

/* ---------- today: status ---------- */
.status h1 { font-size: clamp(34px, 10vw, 44px); font-weight: 760; line-height: 1.02; font-variation-settings: 'opsz' 96; }
.status p { margin: 8px 0 0; color: var(--ink-2); max-width: 32ch; }
.status .kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.dot.taken { background: var(--sage); } .dot.due { background: var(--berry); animation: beat 1.6s infinite; }
.dot.missed { background: var(--red); } .dot.taken_late { background: var(--amber); }
@keyframes beat { 50% { transform: scale(1.5); opacity: .6; } }

/* ---------- the blister pack ---------- */
.blister { margin: 22px -4px 0; padding: 18px 16px 16px; border-radius: 22px; position: relative;
  background: linear-gradient(135deg, var(--foil-b) 0%, var(--foil-a) 38%, var(--foil-b) 55%, var(--foil-a) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -1px 0 rgba(0,0,0,.06), var(--shadow); }
.blister::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(115deg, transparent 0 14px, rgba(255,255,255,.12) 14px 15px); }
.blister-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; position: relative; z-index: 1; }
.blister-head b { font-family: var(--font-d); color: var(--ink); font-size: 15px; }
.bgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px 6px; position: relative; z-index: 1; }
.wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--ink-2); padding-bottom: 2px; }
.cell { aspect-ratio: 1; display: grid; place-items: center; position: relative; }
.bubble { width: 100%; max-width: 44px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; border: 0; padding: 0;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.9), rgba(255,255,255,.25) 45%, rgba(29,32,66,.08) 70%);
  box-shadow: inset 0 -2px 4px rgba(29,32,66,.12), 0 1px 1px rgba(255,255,255,.6); transition: transform .2s; }
.bubble .tab { width: 64%; aspect-ratio: 1; border-radius: 50%; background: var(--pill);
  box-shadow: inset 0 -2px 3px rgba(29,32,66,.15), 0 1px 2px rgba(29,32,66,.2); }
.bubble.popped { background: radial-gradient(circle at 50% 50%, var(--hollow), transparent 72%); box-shadow: none; }
.bubble.popped::before { content: ''; width: 60%; height: 2px; background: var(--crease); transform: rotate(-35deg); border-radius: 2px; position: absolute; }
.bubble.popped::after { content: ''; width: 34%; height: 2px; background: var(--crease); transform: rotate(40deg) translate(4px, 4px); border-radius: 2px; position: absolute; }
.bubble.popped .tab { display: none; }
.cell .mark { position: absolute; bottom: 2px; right: 6%; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--surface); }
.mark.late { background: var(--amber); } .mark.missed { background: var(--red); }
.bubble.missed .tab { box-shadow: inset 0 -2px 3px rgba(29,32,66,.15), 0 0 0 2.5px var(--red); }
.bubble.today { animation: nudge 2.4s ease-in-out infinite; }
.bubble.today .tab { box-shadow: inset 0 -2px 3px rgba(29,32,66,.15), 0 0 0 3px var(--berry), 0 0 0 7px color-mix(in srgb, var(--berry) 25%, transparent); }
.bubble.dim { opacity: .45; }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.bubble.pop .tab { animation: popout .7s cubic-bezier(.3,1.4,.5,1) forwards; }
@keyframes popout { 30% { transform: scale(1.25); } 100% { transform: translateY(-60px) scale(.3) rotate(160deg); opacity: 0; } }

/* ---------- primary action ---------- */
.cta { margin-top: 20px; width: 100%; min-height: 60px; border: 0; border-radius: 999px; background: var(--berry); color: var(--berry-ink);
  font-family: var(--font-d); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; box-shadow: 0 10px 24px color-mix(in srgb, var(--berry) 35%, transparent); transition: transform .12s; }
.cta:active { transform: scale(.98); }
.cta.done { background: var(--sage-soft); color: var(--sage); box-shadow: none; }
.undo { display: block; margin: 10px auto 0; background: none; border: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; padding: 8px; }

.facts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 22px 2px 0; font-size: 14px; color: var(--ink-2); }
.facts span { display: inline-flex; gap: 7px; align-items: center; }
.facts svg { width: 16px; height: 16px; color: var(--ink-3); }
.facts .warn { color: var(--amber); } .facts .warn svg { color: var(--amber); }

/* ---------- panels ---------- */
.panel { background: var(--surface); border-radius: var(--r-lg); padding: 20px; margin-top: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.panel h3 { font-size: 15px; font-weight: 700; margin: 16px 0 8px; color: var(--ink-2); font-family: var(--font-b); letter-spacing: 0; }
.panel.guide { border: 2px solid var(--amber); background: var(--amber-soft); box-shadow: none; }
.panel.guide.over { border-color: var(--red); background: var(--red-soft); }
.guide ol { margin: 0; padding-left: 22px; } .guide li { margin: 6px 0; }
.guide .small { font-size: 13px; color: var(--ink-2); margin: 12px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: transparent; border-radius: 999px; padding: 8px 13px; font-size: 14px; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.b[aria-pressed="true"] { background: var(--berry); border-color: var(--berry); color: var(--berry-ink); }
.drops { display: inline-flex; gap: 1px; } .drops i { width: 6px; height: 9px; background: currentColor; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; display: block; opacity: .9; }
.moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mood { border: 1.5px solid var(--line); background: transparent; border-radius: var(--r-md); padding: 8px 0 6px; display: grid; justify-items: center; gap: 2px; font-size: 12px; color: var(--ink-2); }
.mood span { font-size: 24px; line-height: 1.1; }
.mood[aria-pressed="true"] { border-color: var(--berry); background: var(--berry-soft); color: var(--ink); }
textarea { width: 100%; min-height: 84px; border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px; background: var(--surface-2); resize: vertical; }
.linkbtn { background: none; border: 0; color: var(--berry); font-weight: 700; padding: 10px 0 0; }

.nudge-row { display: flex; gap: 8px; }
.nudge-row input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 999px; padding: 12px 16px; background: var(--surface-2); }
.btn { border: 0; border-radius: 999px; padding: 12px 18px; background: var(--ink); color: var(--bg); font-weight: 700; min-height: 46px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.berry { background: var(--berry); color: var(--berry-ink); }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 18px; }
.wday { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); background: none; border: 0; padding: 6px 0; border-radius: 12px; }
.wday b { font-family: var(--font-d); font-size: 17px; color: var(--ink); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.wday.is-today b { background: var(--ink); color: var(--bg); }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.cal-head h1 { font-size: 30px; text-transform: capitalize; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.iconbtn svg { width: 20px; height: 20px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .wd { padding-bottom: 6px; }
.cday { aspect-ratio: .82; border: 0; border-radius: 14px; background: var(--surface); display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center; padding: 6px 0 7px; position: relative; font-family: var(--font-d); font-size: 16px; font-weight: 600; }
.cday.empty { background: transparent; }
.ind { height: 8px; display: inline-flex; gap: 3px; }
.ind i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.ind .taken { background: var(--sage); } .ind .taken_late { background: var(--amber); } .ind .missed { background: transparent; box-shadow: inset 0 0 0 2px var(--red); }
.ind .bleed { background: var(--berry); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; }
.cday.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.cday.future { color: var(--ink-3); background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-top: 16px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- stats ---------- */
.big { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 12px; }
.big div { display: grid; gap: 2px; }
.big b { font-family: var(--font-d); font-size: 40px; font-weight: 760; line-height: 1; letter-spacing: -0.03em; }
.big small { color: var(--ink-2); font-size: 14px; }
.big .hero b { font-size: 76px; color: var(--berry); }
.big .hero { grid-column: 1 / -1; }
.chart svg { width: 100%; height: auto; display: block; }
.muted { color: var(--ink-2); font-size: 14px; margin: 8px 0 0; }

/* ---------- settings ---------- */
.rows { display: grid; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); min-height: 58px; }
.row:last-child { border-bottom: 0; }
.row label, .row .lbl { flex: 1; }
.row select, .row input[type="time"], .row input[type="number"] { border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 10px; background: var(--surface-2); min-width: 96px; }
.row input[type="number"] { width: 84px; min-width: 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 8px 14px; font-weight: 700; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch:checked { background: var(--sage); } .switch:checked::after { transform: translateX(20px); }
.pill-ok { color: var(--sage); font-weight: 700; } .pill-off { color: var(--ink-3); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabbar nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a { display: grid; justify-items: center; gap: 3px; text-decoration: none; color: var(--ink-3); font-size: 12px; padding: 6px 0; border-radius: 14px; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabbar a[aria-current="page"] svg { color: var(--berry); }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 17, 40, .45); z-index: 40; animation: fade .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow: auto; background: var(--bg);
  border-radius: 28px 28px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.2,.9,.3,1); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-inner { max-width: 480px; margin: 0 auto; }
.sheet .sheet-title { font-size: 26px; }
.sheet .sheet-title::first-letter { text-transform: uppercase; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; align-content: center; gap: 28px; max-width: 380px; margin: 0 auto; padding: 24px; }
.login h1 { font-size: 46px; line-height: 1; font-weight: 780; }
.mini-blister { display: flex; gap: 8px; }
.mini-blister i { width: 26px; height: 26px; border-radius: 50%; background: var(--pill); box-shadow: inset 0 -2px 3px rgba(29,32,66,.15), 0 0 0 5px var(--foil-a); display: block; }
.mini-blister i:nth-child(3) { box-shadow: inset 0 -2px 3px rgba(29,32,66,.15), 0 0 0 5px var(--foil-a), 0 0 0 8px var(--berry); }
.pinbox { display: flex; gap: 10px; }
.pinbox input { flex: 1; min-width: 0; font-family: var(--font-d); font-size: 28px; letter-spacing: .3em; text-align: center; padding: 14px; border-radius: 18px; border: 2px solid var(--line); background: var(--surface); }
.err { color: var(--red); min-height: 1.4em; margin: 0; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 18px); transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 700; z-index: 60; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.burst { position: fixed; pointer-events: none; z-index: 70; font-size: 22px; animation: rise 1.2s ease-out forwards; }
@keyframes rise { to { transform: translate(var(--dx), -160px) rotate(var(--rot)); opacity: 0; } }

.skeleton { height: 60vh; display: grid; place-items: center; color: var(--ink-3); }

/* ================================================================
   Motion & polish
   One easing family: quick out, soft landing. Entrance animations only
   play when an element is NEW (the app updates the page in place).
   ================================================================ */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.3, 1.35, .5, 1); --ease-in: cubic-bezier(.4, 0, 1, 1); }
#app { min-height: 100dvh; }
button, a, .cday, .bubble, .chip, .mood { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.page-title { font-size: 32px; }
.btn-pair { display: flex; gap: 6px; }
.missed-txt { color: var(--red); }

/* press feedback */
.chip, .mood, .btn, .cta, .iconbtn, .cday, .seg button, .linkbtn, .undo, .bubble {
  transition: transform .16s var(--ease-out), background-color .22s, color .22s, border-color .22s, box-shadow .25s, opacity .2s;
}
.chip:active, .mood:active, .btn:active, .iconbtn:active, .cday:active { transform: scale(.94); }
.cta:active, .cta.pressed { transform: scale(.97); }
.bubble:active { transform: scale(.9); }

/* selected states get a small pop when they become selected */
.mood[aria-pressed="true"] span { display: inline-block; animation: pop .38s var(--ease-spring); }
.chip[aria-pressed="true"] { animation: pop .3s var(--ease-spring); }
@keyframes pop { 40% { transform: scale(1.14); } }

/* busy buttons: spinner instead of text */
.btn[aria-busy="true"], .cta[aria-busy="true"] { color: transparent !important; position: relative; pointer-events: none; }
.btn[aria-busy="true"]::after, .cta[aria-busy="true"]::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--ink-3) 45%, transparent); border-top-color: var(--berry); animation: spin .7s linear infinite;
}
.cta[aria-busy="true"]::after { border-color: color-mix(in srgb, var(--berry-ink) 40%, transparent); border-top-color: var(--berry-ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* pages: slide in from the side you're going to */
.screen { animation: pageIn .32s var(--ease-out) backwards; }
.screen[data-dir="fwd"] { animation-name: pageInFwd; }
.screen[data-dir="back"] { animation-name: pageInBack; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes pageInFwd { from { opacity: 0; transform: translateX(22px); } }
@keyframes pageInBack { from { opacity: 0; transform: translateX(-22px); } }

/* today: status text, button and pills change smoothly */
.status { animation: fadeUp .38s var(--ease-out) backwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
.cta-wrap { animation: ctaIn .42s var(--ease-spring) backwards; }
@keyframes ctaIn { from { opacity: 0; transform: scale(.92); } }
.cta.done, .cta.success { display: flex; align-items: center; justify-content: center; gap: 8px; }
.cta.success { background: var(--sage); color: #fff; box-shadow: 0 10px 24px color-mix(in srgb, var(--sage) 35%, transparent); animation: pop .4s var(--ease-spring); }
.cta-check { display: inline-flex; width: 22px; height: 22px; }
.cta-check svg { width: 100%; height: 100%; }
.check-path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .45s .12s var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.sheet-taken { display: flex; align-items: center; gap: 8px; color: var(--sage); font-weight: 700; }
.bubble.popped::before, .bubble.popped::after { animation: crease .35s var(--ease-out) backwards; }
@keyframes crease { from { opacity: 0; transform: rotate(-35deg) scaleX(.2); } }
.guide { animation: fadeUp .4s var(--ease-out) backwards; }

/* calendar: months slide, new dots pop in */
.cal[data-dir="next"] { animation: calNext .32s var(--ease-out) backwards; }
.cal[data-dir="prev"] { animation: calPrev .32s var(--ease-out) backwards; }
@keyframes calNext { from { opacity: 0; transform: translateX(30px); } }
@keyframes calPrev { from { opacity: 0; transform: translateX(-30px); } }
.cal-head h1 { animation: fadeUp .3s var(--ease-out) backwards; }
.ind i { animation: dotIn .32s var(--ease-spring) backwards; }
@keyframes dotIn { from { opacity: 0; transform: scale(.2); } }

/* stats: chart bars grow from the line */
.bar { transform-box: fill-box; animation: grow .55s var(--ease-out) backwards; }
.bar.down { transform-origin: top; }
.bar.up { transform-origin: bottom; }
@keyframes grow { from { transform: scaleY(0); } }
.big > div { animation: fadeUp .4s var(--ease-out) backwards; }
.big > div:nth-child(2) { animation-delay: 40ms; } .big > div:nth-child(3) { animation-delay: 80ms; }
.big > div:nth-child(4) { animation-delay: 120ms; } .big > div:nth-child(5) { animation-delay: 160ms; }

/* tab bar: a soft pill slides to the active tab */
.tabbar nav { position: relative; }
.tabbar a { position: relative; z-index: 1; transition: color .25s; }
.tab-ind { position: absolute; top: 6px; left: 0; width: 25%; height: 32px; pointer-events: none;
  transform: translateX(calc(var(--i) * 100%)); transition: transform .42s var(--ease-spring); }
.tab-ind::before { content: ''; position: absolute; left: 50%; top: 0; width: 60px; height: 32px; margin-left: -30px; border-radius: 999px; background: var(--berry-soft); }
.tabbar a[aria-current="page"] svg { animation: pop .4s var(--ease-spring); }

/* language switch: the white pill slides */
.seg { position: relative; gap: 0; }
.seg button { position: relative; z-index: 1; min-width: 46px; transition: color .25s; }
.seg button[aria-pressed="true"] { background: transparent; box-shadow: none; }
.seg-ind { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 999px; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.12); transform: translateX(calc(var(--i) * 100%)); transition: transform .38s var(--ease-spring); }

/* bottom sheet: slides up, slides back down, follows your finger */
.scrim { animation: none; opacity: 0; transition: opacity .32s var(--ease-out); }
.sheet { animation: none; transform: translateY(100%); transition: transform .4s cubic-bezier(.2, .9, .25, 1); will-change: transform; overscroll-behavior: contain; }
#sheet-root.open .scrim { opacity: 1; }
#sheet-root.open .sheet { transform: translateY(0); }
#sheet-root.closing .scrim { opacity: 0; transition-duration: .28s; }
#sheet-root.closing .sheet { transform: translateY(100%); transition: transform .3s var(--ease-in); }
.grab-zone { margin: -10px -18px 2px; padding: 10px 0 12px; touch-action: none; cursor: grab; }
.sheet .grab { margin: 0 auto; }
.sheet .sheet-title { touch-action: none; }
html.sheet-open, html.sheet-open body { overflow: hidden; }

/* toast: springs in */
#toast { transition: opacity .22s, transform .4s var(--ease-spring); }

/* login: wrong PIN shakes */
.pinbox.shake { animation: shake .42s var(--ease-out); }
@keyframes shake { 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(3px); } }
.login > * { animation: fadeUp .5s var(--ease-out) backwards; }
.login > *:nth-child(2) { animation-delay: 60ms; } .login > *:nth-child(3) { animation-delay: 120ms; }

/* loading placeholders */
.sk { display: block; border-radius: 14px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-line { height: 14px; margin: 10px 0; }
.sk-title { height: 44px; width: 80%; margin: 16px 0 12px; }
.sk-block { height: 280px; margin-top: 22px; border-radius: 22px; }
.sk-btn { height: 60px; border-radius: 999px; margin-top: 20px; }
.sk-chart { height: 180px; }
.cday.sk { box-shadow: none; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ================================================================
   App frame: the window never scrolls. #app fills the screen, each page
   scrolls inside it, and the tab bar is part of the frame, so it can't move
   (address bar, animations, keyboard or zoom can't push it around).
   ================================================================ */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
#app { position: relative; height: 100%; height: 100dvh; overflow: hidden; contain: layout paint; }
.screen, .login {
  position: absolute; inset: 0; max-width: none; margin: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  padding-left: max(18px, calc(50% - 222px)); padding-right: max(18px, calc(50% - 222px));
}
.screen::-webkit-scrollbar, .login::-webkit-scrollbar { display: none; }
.login { min-height: 0; padding: 24px max(24px, calc(50% - 166px)); }
.tabbar { position: absolute; transition: transform .3s var(--ease-out); }
html.typing .tabbar { transform: translateY(110%); }
html.typing .screen { padding-bottom: 28px; }

/* month summary + units */
.month-sum { margin-top: 22px; }
.sum-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sum-grid div { display: grid; gap: 2px; animation: fadeUp .35s var(--ease-out) backwards; }
.sum-grid div:nth-child(2) { animation-delay: 40ms; } .sum-grid div:nth-child(3) { animation-delay: 80ms; } .sum-grid div:nth-child(4) { animation-delay: 120ms; }
.sum-grid b { font-family: var(--font-d); font-size: 28px; font-weight: 760; letter-spacing: -0.03em; line-height: 1; }
.sum-grid small { color: var(--ink-2); font-size: 12px; line-height: 1.25; }
.sum-grid .bad b { color: var(--red); }
.unit { font-size: .45em; font-weight: 700; color: var(--ink-2); margin-left: 3px; letter-spacing: 0; }
.big .hero .unit { font-size: .3em; color: var(--berry); }

/* pull to refresh */
#ptr { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 6px); z-index: 30; width: 40px; height: 40px; margin-left: -20px;
  border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--berry);
  transform: translateY(-64px); opacity: 0; pointer-events: none; }
#ptr svg { width: 22px; height: 22px; }
#ptr.armed svg { color: var(--berry); }
#ptr.spinning svg { animation: spin .8s linear infinite; }
#ptr.settle { transition: transform .3s var(--ease-out), opacity .3s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
  .check-path { stroke-dashoffset: 0; }
}
