/* Tygr — one stylesheet, mobile-first (390 px), built to feel like an installed app.
   Brand = tiger orange on stripe black over warm paper. Data colours are the validated chart palette (--s1…--s6,
   checked against --surface in both themes); status colours are reserved for state and always come with an icon
   or a word. Contrast: body and muted text ≥ 4.5:1, button labels ≥ 5.8:1 in both themes. */
:root {
  color-scheme: light;
  --plane: #f6f2eb; --surface: #fffdf9; --surface-2: #f0e9df; --surface-3: #e6dccd;
  --ink: #14110e; --ink-2: #57514a; --muted: #716a61;
  --line: #e6ddcf; --rule: #cbbfae;
  --brand: #eb6834; --brand-ink: #b4461c; --on-brand: #14110e; --brand-soft: #fbe4d8;
  --bar: #14110e; --bar-2: #221d19; --bar-line: #3a322b; --bar-ink: #fff7ef; --bar-muted: #b3a595;
  /* chart series, fixed order */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  --a: var(--s1); --a-soft: #cde2fb; --a-strong: #1c5cab; --b: var(--s2); --de: #b9b0a3;
  /* sequential ramp (muscle map), even OKLab lightness steps toward the surface; dark mode has its own */
  --q0: 16%; --q1: 38%; --q2: 66%;
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b; --success-ink: #006300; --critical-ink: #a32424; --warn-soft: #fdecc4;
  --shadow: 0 1px 2px rgba(20,17,14,.05), 0 10px 28px -20px rgba(20,17,14,.45);
  --r: 18px; --r-sm: 12px; --tabbar: 62px; --gap: 12px;
  --ease: cubic-bezier(.2,.8,.2,1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0e0c0a; --surface: #1a1714; --surface-2: #24201c; --surface-3: #2e2924;
    --ink: #fff7ef; --ink-2: #cdbfae; --muted: #9a8f82; --line: #2e2924; --rule: #3d3630;
    --brand: #f07a45; --brand-ink: #f39468; --brand-soft: #3a2318; --bar: #070605;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
    --a-soft: #1b3f6e; --a-strong: #2a78d6; --de: #5d554c;
    --success-ink: #3fbf3f; --critical-ink: #ef8a8a; --warn-soft: #3d2f0c; --seg-on: #3a332c;
    --q0: 30%; --q1: 52%; --q2: 76%;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 30px -20px rgba(0,0,0,.9);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0e0c0a; --surface: #1a1714; --surface-2: #24201c; --surface-3: #2e2924;
  --ink: #fff7ef; --ink-2: #cdbfae; --muted: #9a8f82; --line: #2e2924; --rule: #3d3630;
  --brand: #f07a45; --brand-ink: #f39468; --brand-soft: #3a2318; --bar: #070605;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --a-soft: #1b3f6e; --a-strong: #2a78d6; --de: #5d554c;
  --success-ink: #3fbf3f; --critical-ink: #ef8a8a; --warn-soft: #3d2f0c; --seg-on: #3a332c;
  --q0: 30%; --q1: 52%; --q2: 76%;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 30px -20px rgba(0,0,0,.9);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 70px; }
html, body { overflow-x: clip; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 14px);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
a { color: var(--brand-ink); }
h1 { font-size: 26px; margin: 0; letter-spacing: -.03em; line-height: 1.1; font-weight: 800; }
h2 { font-size: 12px; margin: 0 0 12px; color: var(--ink-2); font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 700; }
p { margin: 0 0 10px; }
button { font: inherit; color: inherit; }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 99; background: var(--brand); color: var(--on-brand); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* page-to-page navigation cross-fades like an app instead of flashing white (browsers without it just navigate) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--bar); color: var(--bar-ink); padding-top: env(safe-area-inset-top); }
.topbar::after { content: ""; display: block; height: 2px; background: var(--brand); }
.topbar__in { max-width: 1120px; margin: 0 auto; padding: 6px 12px; display: flex; align-items: center; gap: 10px; min-height: 50px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--bar-ink); font-weight: 800; font-size: 19px; letter-spacing: -.035em; }
.brand img { width: 34px; height: 34px; flex: none; }
.topbar__tools { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.iconlink { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; color: var(--bar-ink); text-decoration: none; border: 0; background: none; cursor: pointer; }
.iconlink:hover, .iconlink[aria-current="page"] { background: var(--bar-2); }
.iconlink[aria-current="page"] { color: var(--brand); }
.nav-desktop { display: none; gap: 2px; margin-left: 18px; }
.nav-desktop a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 11px; text-decoration: none; color: #d9cbbb; font-size: 14.5px; font-weight: 650; }
.nav-desktop a .ic { width: 18px; height: 18px; }
.nav-desktop a:hover { background: var(--bar-2); color: #fff; }
.nav-desktop a[aria-current="page"] { background: var(--brand); color: var(--on-brand); }
.nav-desktop button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 11px; border: 1px solid var(--bar-line); background: var(--bar-2); color: var(--bar-ink); font-size: 14.5px; font-weight: 700; cursor: pointer; margin-left: 8px; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
.tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 700; border: 0; background: none; cursor: pointer; padding: 0; }
.tabbar a .ic { transition: transform .18s var(--ease); }
.tabbar a:active .ic { transform: scale(.88); }
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"] .ic { color: var(--brand-ink); stroke-width: 2.3; }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.tabbar__ai span { width: 54px; height: 54px; margin-top: -24px; border-radius: 18px; background: var(--brand); color: var(--on-brand);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 18px -8px rgba(235,104,52,.9); border: 3px solid var(--surface); transition: transform .15s var(--ease); }
.tabbar__ai:active span { transform: scale(.93); }
.tabbar__ai span .ic { width: 27px; height: 27px; stroke-width: 2.3; }
.tabbar button.tabbar__ai { color: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 14px 14px 28px; }
@media (min-width: 820px) { main { padding: 22px 20px 56px; } }
@media (min-width: 1100px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .nav-desktop { display: flex; }
}

/* ---------- toasts ---------- */
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--r-sm); margin-bottom: 12px; font-size: 14px;
  border: 1px solid; transition: opacity .6s, max-height .6s, margin .6s, padding .6s; max-height: 400px; overflow: hidden; }
.toast .ic { width: 20px; height: 20px; margin-top: 1px; }
.toast--ok { background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.toast--ok .ic { color: var(--success-ink); }
.toast--error, .msg--error { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.msg--error { border: 1px solid; border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.toast--error .ic { color: var(--critical-ink); }
.toast--fade { opacity: 0; max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
.toast form { margin: 0 0 0 auto; }

/* ---------- layout ---------- */
.grid { display: grid; gap: var(--gap); }
.grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
.grid > *, .stack > * { min-width: 0; }
@media (min-width: 820px) {
  .grid { gap: 14px; }
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stack { display: flex; flex-direction: column; gap: var(--gap); }
/* wide screens: long pages flow into two columns, card by card */
@media (min-width: 1000px) {
  .stack--cols { display: block; columns: 2; column-gap: 16px; }
  .stack--cols > * { break-inside: avoid; margin: 0 0 16px; }
}
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > input, .row > select { min-width: 0; }
.row--tight { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.spacer { margin-left: auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 15px; box-shadow: var(--shadow); min-width: 0; }
@media (min-width: 820px) { .card { padding: 18px; } }
.card--flush { padding: 0; overflow: hidden; }
.card--alert { border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card__head h2 { margin: 0; }
.pageheader { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 14px; }
.pageheader .sub { color: var(--muted); font-size: 13.5px; }
.section-link { font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }

/* segmented control: the sub-pages of a tab, and period switches */
.segbar { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 13px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.segbar::-webkit-scrollbar { display: none; }
.segbar a { flex: 1 0 auto; text-align: center; padding: 8px 8px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.segbar a[aria-current="page"], .segbar a[aria-current="true"] { background: var(--seg-on, var(--surface)); color: var(--ink); box-shadow: 0 1px 3px rgba(20,17,14,.14); }

/* ---------- hero: the day's energy ---------- */
.hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.hero__ring { position: relative; width: 136px; height: 136px; flex: none; }
.hero__ring .ring { width: 100%; height: 100%; }
.hero__num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.05; }
.hero__num b { font-size: 34px; font-weight: 800; letter-spacing: -.04em; }
.hero__num span { font-size: 12px; color: var(--ink-2); font-weight: 650; margin-top: 2px; }
.hero__facts { display: grid; gap: 9px; }
.fact { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink-2); }
.fact b { color: var(--ink); font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fact > span { min-width: 0; }
.fact small { display: block; font-size: 11.5px; color: var(--muted); }
.ring { transform: rotate(-90deg); width: 42px; height: 42px; flex: none; }
.ring__track { fill: none; stroke: var(--a-soft); }
.ring__fill { fill: none; stroke: var(--a); stroke-linecap: round; transition: stroke-dasharray .5s var(--ease); }
.ring__fill--over { stroke: var(--warning); }

/* nutrient rows: value against a target (reach) or a line (stay under) */
.nuts { display: grid; gap: 11px; margin-top: 14px; }
@media (min-width: 560px) { .nuts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; } }
.nut__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13.5px; margin-bottom: 4px; }
.nut__top span:first-child { font-weight: 650; }
.nut__v { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }
.nut__v b { color: var(--ink); font-size: 14px; }
.track { height: 7px; background: var(--a-soft); border-radius: 4px; overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--a); border-radius: 4px; max-width: 100%; transition: width .5s var(--ease); }
.nut--high .track { background: var(--warn-soft); }
.nut--high .track > span { background: var(--warning); }
.nut--low .nut__v b::before { content: "▼ "; font-size: 10px; }
.nut--high .nut__v b::before { content: "▲ "; font-size: 10px; }
.nut__gap { margin: -2px 0 4px; font-size: 12px; }
.meter .nut__gap { margin: 4px 0 0; }
.meter--high .track { background: var(--warn-soft); }
.meter--high .track > span { background: var(--warning); }
.meter--high .meter__v::before { content: "▲ "; font-size: 10px; }
.meter--low .meter__v::before { content: "▼ "; font-size: 10px; }
.qchips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.pmeals { margin-top: 14px; }
.pmeals .qchips { margin-top: 6px; }
.weekbal { margin: 10px 0 0; color: var(--ink-2); }
.weekbal b { color: var(--ink); }
.weekbal--high b::before { content: "▲ "; font-size: 10px; }
.weekbal--low b::before { content: "▼ "; font-size: 10px; }

/* ---------- the day's log ---------- */
.meal { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.meal:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.meal__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.meal__head b { font-size: 14px; }
.meal__head span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 8px; margin: 0 -8px; width: calc(100% + 16px); border: 0; background: none; border-radius: 11px;
  text-align: left; cursor: pointer; color: var(--ink); text-decoration: none; min-height: 46px; }
.entry:hover, .entry:active { background: var(--surface-2); }
.entry__main { flex: 1; min-width: 0; }
.entry__title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.entry__meta { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry__val { text-align: right; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.25; }
.entry__val b { color: var(--ink); font-size: 14.5px; font-weight: 700; }
.entry__time { width: 38px; flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry__ico { width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.entry--off { opacity: .5; }
/* My foods: a saved food's row with its amount and Log button underneath */
.myfood + .myfood { border-top: 1px solid var(--line); }
.myfood__log { display: flex; align-items: center; gap: 6px; padding: 0 0 10px; }
.myfood__log input { width: 76px; flex: none; }
.myfood__log select { width: auto; flex: none; max-width: 120px; }
.myfood__left { margin-left: auto; white-space: nowrap; }
.entry--sub { padding-left: 24px; min-height: 38px; }
.entry--sub .entry__title { font-size: 14px; }
details.dish > summary { list-style: none; }
details.dish > summary::-webkit-details-marker { display: none; }
details.dish[open] > summary .chev { transform: rotate(90deg); }
.chev { display: inline-block; transition: transform .15s; color: var(--muted); font-size: 12px; width: 12px; }
.addline { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--rule); background: none; color: var(--ink-2);
  font-size: 14px; font-weight: 650; cursor: pointer; margin-top: 10px; }
.addline:hover { border-color: var(--brand); color: var(--ink); }
.addline .ic { width: 18px; height: 18px; }
.dayswitch { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.weekstrip a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 2px 6px; border-radius: 12px; text-decoration: none; color: var(--ink-2); font-size: 11px; font-weight: 700; }
.weekstrip a b { font-size: 15px; color: var(--ink); }
.weekstrip a[aria-current="true"] { background: var(--bar); color: var(--bar-muted); }
.weekstrip a[aria-current="true"] b { color: var(--bar-ink); }
.weekstrip i { display: block; width: 22px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.weekstrip i u { display: block; height: 100%; background: var(--a); }

/* ---------- next up / agenda / tasks ---------- */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li { display: grid; grid-template-columns: 54px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: start; }
.agenda li:last-child { border-bottom: 0; }
.agenda li > div { min-width: 0; }
.agenda time { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
.agenda .now time { color: var(--brand-ink); }
.agenda .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.agenda .meta .ic { width: 14px; height: 14px; vertical-align: -2px; }
.agenda .past { opacity: .5; }
.maplink { color: inherit; text-decoration: none; }
.maplink:hover { text-decoration: underline; }
.stream { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--brand-ink); text-decoration: none; }
.stream:hover { text-decoration: underline; }
.daylabel { font-size: 12px; font-weight: 750; color: var(--ink-2); margin: 16px 0 2px; text-transform: uppercase; letter-spacing: .06em; }
.daylabel:first-child { margin-top: 0; }
.task { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task__check { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid var(--rule); background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: transparent; padding: 0; transition: transform .12s; }
.task__check:active { transform: scale(.85); }
.task__check .ic { width: 18px; height: 18px; stroke-width: 2.6; }
.task__check:hover { border-color: var(--a-strong); color: var(--a-strong); }
.task--done .task__check { background: var(--a-strong); border-color: var(--a-strong); color: #fff; }
.task--done .task__title { text-decoration: line-through; color: var(--muted); }
.task__body { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 2px 0; cursor: pointer; color: var(--ink); }
.task__title { overflow-wrap: anywhere; }
.task__due { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.task--overdue .task__due { color: var(--critical-ink); font-weight: 700; }
.task-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.task-add input[type=datetime-local] { grid-column: 1 / -1; min-width: 0; }
@media (min-width: 620px) { .task-add { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; } .task-add input[type=datetime-local] { grid-column: auto; } }

/* ---------- tiles, stats ---------- */
.tiles { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface-2); border-radius: 14px; padding: 11px 12px; min-width: 0; text-decoration: none; color: var(--ink); display: block; }
.tile__label { font-size: 12px; color: var(--ink-2); font-weight: 650; }
.tile__val { font-size: 21px; font-weight: 780; letter-spacing: -.025em; line-height: 1.2; }
.tile__val small { font-size: 12.5px; font-weight: 650; color: var(--ink-2); letter-spacing: 0; }
.tile__sub { font-size: 11.5px; color: var(--muted); }
.tile .track { margin-top: 6px; height: 5px; }
.delta { font-size: 12px; font-weight: 700; white-space: nowrap; }
.delta--good { color: var(--success-ink); }
.delta--bad { color: var(--critical-ink); }
.stat { background: var(--surface-2); border-radius: 14px; padding: 10px 14px; min-width: 96px; flex: 1; }
.stat__v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat__v small { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.stat__l { font-size: 12px; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin-bottom: 10px; }
.stats .stat { min-width: 0; padding: 9px 11px; }
.stats .stat__v { font-size: 20px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bigfig { font-size: 48px; font-weight: 800; letter-spacing: -.045em; line-height: 1; }
.bigfig small { font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--ink-2); }
.big { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; max-width: 560px; }
.chart__bar { fill: var(--a); }
.chart--b .chart__bar { fill: var(--b); }
.chart__bar--over { fill: var(--warning); }
.chart__empty { fill: var(--surface-3); }
.chart__base { stroke: var(--rule); stroke-width: 1; }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__target { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .7; }
.chart__value { font-size: 10.5px; fill: var(--ink-2); text-anchor: middle; font-weight: 700; }
.chart__value--end { text-anchor: end; fill: var(--ink); font-size: 11.5px; }
.chart__tick { font-size: 10.5px; fill: var(--muted); text-anchor: middle; }
.chart__axis { font-size: 10.5px; fill: var(--muted); text-anchor: end; font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke: var(--a); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__line--muted { stroke: var(--de); }
.chart__end { fill: var(--a); stroke: var(--surface); stroke-width: 2; }
.chart__end--muted { fill: var(--de); }
.chart__dot { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.5; }
.chart__burn { stroke: var(--b); stroke-width: 3; stroke-linecap: round; }
.chart__burn-ring { stroke: var(--surface); stroke-width: 7; stroke-linecap: round; }
.chart__hit { fill: transparent; }
.chart__day:hover .chart__hit, .chart__day:focus .chart__hit { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.chart [data-tip], .donut [data-tip], .stackbar [data-tip] { outline: none; cursor: pointer; }
.chart path[data-tip]:hover, .chart path[data-tip]:focus, .donut__seg:hover, .donut__seg:focus, .stackbar__seg:hover { filter: brightness(1.12); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin: 2px 0 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; background: var(--a); }
.legend i.l-b { height: 3px; width: 14px; border-radius: 2px; background: var(--b); vertical-align: 3px; }
.legend i.l-line { height: 3px; width: 14px; border-radius: 2px; vertical-align: 3px; }
.legend i.l-muted { background: var(--de); }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--ink-2); }
.s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); } .s4 { --c: var(--s4); } .s5 { --c: var(--s5); } .s6 { --c: var(--s6); }
/* muscle map: one sequential ramp (series 2) from fresh to tired, mixed toward the surface so it flips in dark mode */
.bodymap { display: block; width: 100%; max-width: 420px; height: auto; margin: 4px auto 6px; }
.bodymap__body { fill: var(--surface-3); }
.bodymap__outline { fill: none; stroke: var(--rule); stroke-width: 1.2px; vector-effect: non-scaling-stroke; pointer-events: none; }
.bodymap__m { fill: var(--m); stroke: var(--surface); stroke-width: 2px; vector-effect: non-scaling-stroke; outline: none; }
.bodymap__m:hover, .bodymap__m:focus-visible { stroke: var(--ink); }
.m0 { --m: color-mix(in oklab, var(--s2) var(--q0), var(--surface)); }
.m1 { --m: color-mix(in oklab, var(--s2) var(--q1), var(--surface)); }
.m2 { --m: color-mix(in oklab, var(--s2) var(--q2), var(--surface)); }
.m3 { --m: var(--s2); }
.legend i.m0, .legend i.m1, .legend i.m2, .legend i.m3 { background: var(--m); }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--c); flex: none; }
.donutwrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; }
.donutwrap > * { min-width: 0; }
.donutbox { position: relative; width: 132px; height: 132px; }
.donut { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.donut__track { fill: none; stroke: var(--surface-2); }
.donut__seg { fill: none; stroke: var(--c); }
.donutbox__mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.donutbox__mid b { font-size: 19px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.donutbox__mid span { font-size: 11.5px; color: var(--ink-2); font-weight: 650; }
.keylist { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13.5px; }
.keylist li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.keylist li span.grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keylist b { white-space: nowrap; }
.keylist b { font-variant-numeric: tabular-nums; font-weight: 700; }
.keylist small { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 32px; text-align: right; }
.stackbar { width: 100%; height: 22px; display: block; }
.stackbar__seg { fill: var(--c); }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table > summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 650; list-style: none; }
.chart-table > summary::-webkit-details-marker { display: none; }
.chart-table > summary::before { content: "▸ "; }
.chart-table[open] > summary::before { content: "▾ "; }
.chart-table table { margin-top: 6px; font-size: 13px; }
.chart-table th, .chart-table td { padding: 6px 8px; }
.tip { position: fixed; z-index: 80; pointer-events: none; background: var(--bar); color: var(--bar-ink); font-size: 12.5px; font-weight: 650; padding: 6px 9px; border-radius: 9px;
  max-width: 240px; box-shadow: 0 6px 20px rgba(0,0,0,.3); opacity: 0; transition: opacity .1s; line-height: 1.3; }
.tip--on { opacity: 1; }

/* ---------- meters (ranked bars) ---------- */
.meter + .meter { margin-top: 10px; }
.meter__top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 4px; }
.meter__top > span:first-child { flex: none; }
.meter__v { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; min-width: 0; }
.meter .track { background: var(--surface-2); }
a.meter--link { display: block; color: inherit; text-decoration: none; border-radius: 10px; padding: 4px 6px; margin: 0 -6px; }
a.meter--link:hover, .meter--on { background: var(--surface-2); }

/* ---------- lists & tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.list > li:last-child { border-bottom: 0; }
.list > li:first-child { padding-top: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nums { font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
thead th { color: var(--muted); font-weight: 650; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 8px 16px; border-radius: 13px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn .ic { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover { filter: brightness(1.06); background: var(--brand); }
.btn--dark { background: var(--bar); border-color: var(--bar); color: var(--bar-ink); }
.btn--dark:hover { background: var(--bar-2); }
.btn--sm { min-height: 34px; padding: 5px 11px; font-size: 13.5px; border-radius: 10px; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { color: var(--critical-ink); }
.btn--danger:hover { border-color: var(--critical); }
.btn--done { background: var(--a-strong); border-color: var(--a-strong); color: #fff; }
.btn--slip:hover { border-color: var(--critical); color: var(--critical-ink); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }
input, select, textarea { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); width: 100%; min-height: 44px; }
textarea { min-height: 0; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--brand); }
input[type=file] { padding: 8px; }
input.sm { padding: 6px 8px; font-size: 14px; border-radius: 9px; min-height: 34px; }
label { font-size: 13px; color: var(--ink-2); font-weight: 650; display: block; margin-bottom: 5px; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 4px 12px; }
.check { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 14.5px; min-height: 40px; cursor: pointer; color: var(--ink); font-weight: 500; }
.check--top { align-items: flex-start; padding: 6px 0; }  /* a label with a second line under it */
.check--top input { flex: none; margin-top: 2px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
/* a number with − and + either side: the thumb-friendly way to fix a value */
.stepper { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: stretch; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: var(--surface-2); font-size: 20px; font-weight: 700; cursor: pointer; color: var(--ink); min-height: 44px; }
.stepper button:active { background: var(--surface-3); }
.stepper input { border: 0; border-radius: 0; text-align: center; padding: 8px 2px; font-variant-numeric: tabular-nums; font-weight: 700; min-width: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper--sm { grid-template-columns: 30px minmax(0, 1fr) 30px; border-radius: 10px; }
.stepper--sm button { min-height: 38px; font-size: 17px; }
.stepper--sm input { min-height: 38px; font-size: 15px; padding: 4px 0; }

/* ---------- misc ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 700; white-space: nowrap; border: 0; }
.chip--good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--success-ink); }
.chip--warn { background: var(--warn-soft); color: var(--ink); }
.chip--bad { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical-ink); }
.chip--on { background: color-mix(in srgb, var(--a) 18%, transparent); color: var(--ink); }
a.chip { text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; padding: 4px 0; }
.advice { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; white-space: pre-line; }
.banner { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "▾"; color: var(--muted); }
details.fold[open] > summary::after { content: "▴"; }
.insight { border-left: 3px solid var(--brand); }
.insight__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.insight__head h2 { margin: 0; }
.insight__head .ic { width: 18px; height: 18px; color: var(--brand-ink); }
.insight p { font-size: 14.5px; }
.insight ul { margin: 0; padding: 0 0 0 18px; font-size: 14px; }
.insight li { margin-bottom: 5px; }
.insight__foot { font-size: 12px; color: var(--muted); margin-top: 8px; }
.coach__headline { margin: 0 0 8px; font-weight: 650; }
.coach .list li { align-items: flex-start; }
.daysum { display: flex; gap: 10px; flex-wrap: wrap; margin: -4px 0 6px; color: var(--ink-2); }
.jump { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.jump a { font-size: 13px; font-weight: 700; text-decoration: none; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.score { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.score__ring { position: relative; width: 76px; height: 76px; flex: none; }
.score__ring .ring { width: 100%; height: 100%; }
.score__ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; letter-spacing: -.03em; }

/* ---------- bottom sheets ---------- */
dialog.sheet { border: 0; padding: 0; border-radius: 22px 22px 0 0; width: 100%; max-width: 560px; margin: auto auto 0; background: var(--surface); color: var(--ink);
  max-height: 92dvh; box-shadow: 0 -20px 60px rgba(0,0,0,.35); overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .26s var(--ease); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 620px) { dialog.sheet { border-radius: 22px; margin: auto; } }
dialog.sheet::backdrop { background: rgba(10,8,6,.55); backdrop-filter: blur(2px); }
.sheet__grab { width: 38px; height: 4px; border-radius: 2px; background: var(--rule); margin: 8px auto 0; flex: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px 8px; flex: none; }
.sheet__head h3 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet__body { padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.sheet__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.sheet__actions .btn--primary { flex: 1; }
.sheet__more { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fields .wide { grid-column: 1 / -1; }
.fields label { margin-bottom: 4px; }
.fields--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.exrow { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.exrow__nums { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.exrow__nums label { font-size: 11px; margin: 0 0 2px; text-align: center; }
.iconbtn { border: 0; background: transparent; border-radius: 10px; min-width: 34px; min-height: 34px; cursor: pointer; color: var(--ink-2); font-size: 15px; display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:hover, .iconbtn--on { background: var(--surface-2); color: var(--ink); }

/* ---------- the assistant ---------- */
#assistant { max-height: 94dvh; }
.ai__thread { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 10px; overflow-y: auto; overscroll-behavior: contain; min-height: 60px; flex: 1; }
.ai__me { align-self: flex-end; max-width: 86%; background: var(--bar); color: var(--bar-ink); padding: 8px 12px; border-radius: 16px 16px 4px 16px; font-size: 15px; overflow-wrap: anywhere; }
.ai__it { align-self: flex-start; max-width: 94%; background: var(--surface-2); padding: 10px 12px; border-radius: 16px 16px 16px 4px; font-size: 15px; }
.ai__it p { margin: 0 0 6px; white-space: pre-line; }
.ai__it p:last-child { margin-bottom: 0; }
.ai__changes { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13.5px; display: grid; gap: 3px; color: var(--ink-2); }
.ai__changes li { overflow-wrap: anywhere; }
.ai__btns { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; min-height: 34px; }  /* "undone" keeps the button's height: nothing shifts */
.ai__undone { text-decoration: line-through; opacity: .6; }
.ai__line { display: block; width: 100%; padding: 2px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.ai__day { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.ai__portions { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 14px; }
.ai__portions button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
.ai__portions button[disabled] { opacity: .4; cursor: default; }
.ai__wait { align-self: flex-start; color: var(--muted); font-size: 14px; padding: 4px 2px; }
.ai__wait::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; text-align: left; overflow: hidden; vertical-align: bottom; }
.ai__wait--queued { color: var(--ink-2); background: var(--surface-2); border-radius: 12px; padding: 7px 10px; }
.ai__wait--queued::before { content: "⏳ "; }
.ai__wait--queued::after { content: none; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
.ai__hello { color: var(--muted); font-size: 14px; padding: 2px 2px 6px; }
.ai__hello b { color: var(--ink); }
.ai__form { flex: none; border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); }
.ai__input { display: flex; gap: 8px; align-items: flex-end; }
.ai__input textarea { flex: 1; resize: none; min-height: 46px; max-height: 140px; padding: 11px 13px; border-radius: 16px; background: var(--surface-2); border-color: transparent; line-height: 1.35; }
.ai__input textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }
.ai__send { width: 46px; height: 46px; flex: none; border-radius: 15px; border: 0; background: var(--brand); color: var(--on-brand); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ai__send[disabled] { opacity: .5; }
.ai__tools { display: flex; gap: 6px; margin-top: 8px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.ai__tools::-webkit-scrollbar { display: none; }
.tool { height: 38px; padding: 0 12px; margin: 0; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.tool .ic { width: 18px; height: 18px; }
.tool:hover { border-color: var(--brand); color: var(--ink); }
.tool--on { background: var(--brand-soft); border-color: var(--brand); color: var(--ink); }
.ai__photo { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.ai__photo img { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 16px 8px; scrollbar-width: none; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chips form { flex: none; margin: 0; }
.chip-btn { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 11px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; max-width: 190px; text-decoration: none; flex: none; }
.chip-btn:hover { border-color: var(--brand); }
.chip-btn[disabled] { opacity: .5; cursor: progress; }  /* logging: a second tap is ignored */
.chip-btn b { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 166px; }
.chip-btn small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.scanner { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4/3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner::after { content: ""; position: absolute; left: 12%; right: 12%; top: 36%; bottom: 36%; border: 3px solid var(--brand); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.product { display: flex; gap: 12px; align-items: center; margin: 12px 0; }
.product img { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; background: #fff; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }

/* ---------- habits ---------- */
.habit { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.habit:last-child { border-bottom: 0; }
.habit__main { flex: 1; min-width: 170px; }
.habit__name { font-weight: 700; }
.habit__streak { text-align: right; min-width: 70px; }
.dots { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; margin-top: 8px; max-width: 340px; }
.dot { width: 100%; aspect-ratio: 1; min-width: 0; border-radius: 5px; padding: 0; cursor: pointer; background: var(--surface-2); border: 1px solid var(--line); font-size: 10px; line-height: 1; color: #fff; }
.dot--hit { background: var(--a); border-color: var(--a); }
.dot--slip { background: var(--critical); border-color: var(--critical); }
.dot--today { outline: 2px solid var(--ink-2); outline-offset: 1px; }
.dot[disabled] { opacity: .3; cursor: default; }
.hchips { display: flex; gap: 8px; flex-wrap: wrap; }
.hchips form { margin: 0; }
.hchip { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 13px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 700; font-size: 14px; min-height: 44px; }
.hchip small { color: var(--muted); font-weight: 650; font-variant-numeric: tabular-nums; }
.hchip--on { background: var(--a-strong); border-color: var(--a-strong); color: #fff; }
.hchip--on small { color: #dbe9fb; }

/* ---------- strength ---------- */
.lift { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.lift:last-child { border-bottom: 0; }
.lift__main { flex: 1; min-width: 0; }
.lift__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lift__name { font-weight: 750; }
.lift__next { margin-top: 5px; background: var(--surface-2); border-radius: 10px; padding: 7px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.pr { font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 1px 7px; border-radius: 6px; background: var(--bar); color: var(--bar-ink); vertical-align: 2px; }
.spark { flex: none; }
.spark polyline { fill: none; stroke: var(--a); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--a); }

/* ---------- study ---------- */
.sitem { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sitem:last-child { border-bottom: 0; }
.sitem .task__check { margin-top: 2px; }
.sitem__top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.sitem__title { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.sitem__course { font-size: 12px; font-weight: 800; letter-spacing: .02em; text-decoration: none; color: var(--ink-2); }
.sitem__when { text-align: right; min-width: 74px; }
.sitem--done { opacity: .55; }
.sitem--done .sitem__title { text-decoration: line-through; }
.sitem--done .task__check { background: var(--a-strong); border-color: var(--a-strong); color: #fff; }
.kind { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.kind--test, .kind--exam { background: var(--bar); color: var(--bar-ink); border-color: var(--bar); }
.kind--deadline { background: color-mix(in srgb, var(--brand) 16%, var(--surface)); color: var(--ink); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.countdown { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.countdown--late { color: var(--critical-ink); }
.course-card { display: block; text-decoration: none; color: var(--ink); transition: border-color .15s; }
.course-card:hover { border-color: var(--brand); }
.course-card__head { display: flex; justify-content: space-between; align-items: center; }
.course-code { font-size: 12.5px; font-weight: 850; letter-spacing: .04em; color: var(--brand-ink); }
.course-card__name { font-size: 17px; font-weight: 750; margin: 2px 0 8px; letter-spacing: -.01em; }
.course-card__next { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 14px; }
.course-card__warn { display: flex; gap: 7px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.course-card__warn .ic { width: 16px; height: 16px; color: var(--brand-ink); margin-top: 1px; }
.item-edit { margin: -4px 0 8px 40px; }
.item-form { margin-top: 10px; }
.import-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; font-size: 14px; color: var(--ink); font-weight: 400; cursor: pointer; }
.import-row input { margin-top: 2px; flex: none; }

/* ---------- money ---------- */
.amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount--in { color: var(--success-ink); }
.tx--internal { opacity: .6; }

/* ---------- settings & onboarding ---------- */
.setrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.setrow:last-child { border-bottom: 0; }
.setrow .ic { color: var(--muted); }
.setrow small { display: block; color: var(--muted); font-size: 12.5px; }
.choice { display: grid; gap: 8px; }
.choice label { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--rule); border-radius: 14px; cursor: pointer; margin: 0; color: var(--ink); font-size: 15px; font-weight: 600; }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice small { display: block; font-weight: 400; color: var(--ink-2); font-size: 13px; }
.choice input { margin-top: 2px; flex: none; }
.steps { display: flex; gap: 5px; margin-bottom: 16px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.steps i.on { background: var(--brand); }

/* ---------- compact mode: minimal text, denser layout ---------- */
.compact .explain, .compact .hint, .compact .pageheader .sub, .compact .tile__sub, .compact .legend, .compact .insight__foot { display: none !important; }
.compact main { padding-top: 10px; }
.compact .stack, .compact .grid { gap: 8px; }
.compact .card { padding: 11px 12px; border-radius: 14px; }
.compact .card__head { margin-bottom: 8px; }
.compact h1 { font-size: 21px; }
.compact .pageheader { margin-bottom: 8px; }
.compact .entry { min-height: 38px; padding-top: 5px; padding-bottom: 5px; }
.compact .list > li, .compact .sitem, .compact .task, .compact .lift, .compact .habit { padding-top: 7px; padding-bottom: 7px; }
.compact .agenda li { padding: 6px 0; }
.compact .hero__ring { width: 112px; height: 112px; }
.compact .hero__num b { font-size: 28px; }

@media print { .topbar, .tabbar, .btn, form, dialog { display: none !important; } }
/* ---------- wins: a pill and a short burst for an everyday win, a card for a big one ---------- */
.wins { position: fixed; z-index: 70; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 64px); display: grid; gap: 8px;
  justify-items: center; padding: 0 16px; pointer-events: none; }
.winpill { display: flex; align-items: center; gap: 10px; max-width: 420px; width: 100%; padding: 10px 14px; border-radius: 16px;
  background: var(--surface); color: var(--ink); border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: var(--shadow); opacity: 0; transform: translateY(-14px) scale(.96); transition: opacity .25s var(--ease), transform .35s var(--ease); }
.winpill--in { opacity: 1; transform: none; }
.winpill--out { opacity: 0; transform: translateY(-10px); }
.winpill__emoji { font-size: 26px; line-height: 1; }
.winpill--in .winpill__emoji { animation: win-pop .55s var(--ease); }
.winpill__text { display: grid; min-width: 0; }
.winpill__text b { font-size: 15px; }
.winpill__text small { color: var(--ink-2); font-size: 13px; }
.ai__thread .winpill { position: static; opacity: 1; transform: none; box-shadow: none; margin: 4px 0; }
.wincard { border: 0; border-radius: 24px; padding: 26px 22px 18px; width: min(92vw, 380px); background: var(--surface); color: var(--ink);
  text-align: center; box-shadow: var(--shadow); overflow: visible; }
.wincard[open] { animation: win-card .45s var(--ease); }
.wincard::backdrop { background: rgba(10,8,6,.55); backdrop-filter: blur(2px); }
.wincard__emoji { font-size: 64px; line-height: 1; margin-bottom: 8px; animation: win-pop .7s var(--ease); }
.wincard h2 { font-size: 23px; letter-spacing: -.02em; text-transform: none; color: var(--ink); font-weight: 800; margin: 0 0 4px; }
.wincard__detail { color: var(--ink-2); margin: 0 0 14px; }
.wincard__more { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; display: grid; gap: 6px; }
.wincard__more li { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; font-size: 14px; }
.wincard__more small { color: var(--ink-2); }
.wincard form { margin: 4px 0 0; }
.wincard__link { display: inline-block; margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.confetti { inset: 0; pointer-events: none; z-index: 80; overflow: visible; }
.confetti i { position: absolute; width: 7px; height: 11px; border-radius: 2px; background: var(--c); opacity: 0;
  animation: confetti 1.15s cubic-bezier(.15,.7,.3,1) forwards; }
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) + 120px)) rotate(var(--rot)); } }
@keyframes win-pop { 0% { transform: scale(.3); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes win-card { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
.streakchip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); font-weight: 800; font-size: 15px; text-decoration: none; font-variant-numeric: tabular-nums; }
.streakchip--lit { background: var(--brand-soft); color: var(--ink); }
.streakchip:not(.streakchip--lit) span { filter: grayscale(1); opacity: .6; }  /* today not logged yet: the flame waits */
.streakcard { display: flex; align-items: center; gap: 16px; }
.streakcard__fig { display: flex; align-items: center; gap: 4px; }
.streakcard__flame { font-size: 40px; line-height: 1; }
.tiles--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles--4 .tile { padding: 9px 8px; display: flex; flex-direction: column; justify-content: space-between; }
.tiles--4 .tile__label { font-size: 11.5px; }
.shelf { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.shelf__item { display: grid; justify-items: center; gap: 2px; text-align: center; padding: 12px 6px 10px; border-radius: 14px;
  background: var(--surface-2); font-size: 13px; line-height: 1.25; }
.shelf__emoji { font-size: 30px; line-height: 1.1; }
.winrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.winrow:first-of-type { border-top: 0; }
.winrow__emoji { font-size: 20px; width: 26px; text-align: center; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- tab swipe ---------- */
.tabpeek { position: fixed; top: 50%; z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 64px; padding: 10px 12px; border-radius: 18px; background: var(--surface); color: var(--muted);
  box-shadow: 0 6px 24px rgb(0 0 0 / .18); font-size: 12px; font-weight: 700; pointer-events: none;
  opacity: 0; transition: opacity .15s, background .15s, color .15s; }
.tabpeek[data-side="right"] { right: 12px; }
.tabpeek[data-side="left"] { left: 12px; }
.tabpeek .ic { width: 24px; height: 24px; }
.tabpeek--on { opacity: 1; }
.tabpeek--armed { background: var(--brand); color: var(--on-brand); }

/* ---------- Mind: check-in, mood calendar, writing, letters ---------- */
.checkin__q { font-size: 18px; font-weight: 750; letter-spacing: -.01em; margin: 0 0 12px; }
.faces { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.face { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 2px 7px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; margin: 0; transition: transform .12s var(--ease), border-color .12s; }
.face > span { font-size: 30px; line-height: 1.1; }
.face small { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.face:hover { border-color: var(--brand); }
.face:active { transform: scale(.94); }
.faces--pick .face input { position: absolute; opacity: 0; pointer-events: none; }
.faces--pick .face:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.faces--pick .face:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.faces--sm { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 8px; }
.faces--sm .face > span { font-size: 22px; }
.feel { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.feel__chip { margin: 0; cursor: pointer; }
.feel__chip input { position: absolute; opacity: 0; pointer-events: none; }
.feel__chip span { display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--rule); font-size: 13.5px; font-weight: 650; color: var(--ink-2); }
.feel__chip input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--ink); }
.feel__chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.moodchip { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 34px; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 19px; cursor: pointer; }
.letterdue { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent); background: color-mix(in srgb, var(--brand) 9%, var(--surface)); }
.letterdue__env { font-size: 30px; }
.letterdue b, .letterdue .small { display: block; }
.otd__text { font-size: 15px; color: var(--ink-2); font-style: italic; }
.mood1 { --mc: color-mix(in oklab, var(--s1) 16%, var(--surface)); }
.mood2 { --mc: color-mix(in oklab, var(--s1) 32%, var(--surface)); }
.mood3 { --mc: color-mix(in oklab, var(--s1) 50%, var(--surface)); }
.mood4 { --mc: color-mix(in oklab, var(--s1) 72%, var(--surface)); }
.mood5 { --mc: var(--s1); }
.moodcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 8px; }
.moodcal__wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.moodcal__d { aspect-ratio: 1; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--mc, var(--surface-2)); outline: none; cursor: default; }
.moodcal__d[data-tip] { cursor: pointer; }
.moodcal__d:focus-visible, .moodcal__d[data-tip]:hover { box-shadow: 0 0 0 2px var(--ink); }
.moodcal__d.is-today { box-shadow: inset 0 0 0 2px var(--brand); }
.moodcal__d.is-future { background: none; border: 1px dashed var(--line); }
.moodlegend { align-items: center; gap: 4px; }
.moodlegend i { background: var(--mc); margin: 0; }
.moodlegend span { margin: 0 4px; }
.write__prompt { display: flex; align-items: flex-start; gap: 6px; font-size: 17px; font-weight: 700; line-height: 1.35; margin: 0 0 12px; }
.write__prompt--sheet { font-size: 16px; color: var(--ink-2); font-weight: 650; }
.iconlink--ink { color: var(--ink-2); width: 34px; height: 34px; margin: -6px -6px 0 auto; font-size: 19px; flex: none; }
.iconlink--ink:hover { background: var(--surface-2); }
.writing { font-size: 17px; line-height: 1.6; min-height: 42vh; resize: vertical; background: var(--surface); }
.writing__more { margin-top: 8px; }
.writing__more summary { cursor: pointer; list-style: none; padding: 4px 0; }
.mind__month { margin: 14px 0 2px; font-size: 13px; color: var(--muted); }
.entry--tall { align-items: flex-start; }
.entry__wrap { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14.5px; line-height: 1.4; }
.sealed { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px; background: var(--surface-2); margin-bottom: 12px; }
.sealed > span { font-size: 34px; }
.sealed p { margin: 0; }
.letter { font-size: 16.5px; line-height: 1.6; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); }
.letter p:last-child { margin: 0; }
.choice--wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 10px; }
.choice--wrap label { padding: 10px; font-size: 14px; align-items: center; }
.helpcard { border-left: 3px solid var(--s1); margin-bottom: 12px; }
.helpcard p { font-size: 14.5px; }
.helpcard a { font-weight: 750; }
.reflection { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border-left: 3px solid var(--brand); font-size: 15px; }
.reflection p:last-child { margin: 0; }
.reflect__q { font-style: italic; color: var(--ink-2); }

/* ---------- Read: the library ---------- */
.cover { flex: none; display: block; border-radius: 6px; object-fit: cover; background: var(--surface-2);
  box-shadow: 0 1px 2px rgba(20,17,14,.18), 0 6px 14px -8px rgba(20,17,14,.5); }
.cover--sm { width: 44px; height: 64px; }
.cover--lg { width: 86px; height: 126px; }
.cover--t { display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 7px 6px 6px 9px; color: var(--ink);
  background: color-mix(in oklab, var(--c) 24%, var(--surface)); border-left: 4px solid var(--c); }
.cover--t b { font-size: 9px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; }
.cover--lg.cover--t b { font-size: 13px; -webkit-line-clamp: 6; }
.cover--t small { font-size: 10px; color: var(--ink-2); }
.continue { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--ink); }
.continue__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.continue__title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.continue .track { margin: 4px 0 2px; }
.track--thin { height: 4px; margin-top: 6px; display: block; }
.addbook { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 8px; }
.addbook label.btn { margin: 0; color: var(--on-brand); font-size: 15px; }
.bookrow { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.bookrow:last-child { border-bottom: 0; }
.bookrow__open { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; padding: 10px 0; text-decoration: none; color: var(--ink); }
.bookrow__main { flex: 1; min-width: 0; }
.bookrow .iconbtn { font-size: 20px; min-width: 42px; min-height: 42px; }
.found { list-style: none; margin: 8px 0 0; padding: 0; }
.found li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.found li .grow > * { display: block; }
.found b { font-size: 14.5px; line-height: 1.3; }
.found form { margin: 0; flex: none; }
.continue--sm { gap: 12px; } .continue--sm .ic { color: var(--muted); flex: none; }
