/* AI Coach. Every colour is a token so the palette can be swapped in one place. */
:root {
  color-scheme: light;
  --bg: #f7f5f2; --card: #ffffff; --ink: #1d1b19; --muted: #6b655e; --line: #e7e2db;
  --brand: #d9531f; --brand-2: #b8431a; --brand-ink: #ffffff; --brand-soft: #fcebe2;
  --good: #2f7d6b; --good-soft: #e1f0eb; --warn: #9a6512; --warn-soft: #fbf1df; --bad: #b8432f; --bad-soft: #fbe8e4;
  --ring-track: #efe9e2; --top: #1d1b19; --top-ink: #ffffff;
  --chart: #d9531f; --chart-soft: #f2c3ae; --chart-wash: rgba(217, 83, 31, .10);
  --shadow: 0 6px 20px rgba(40, 28, 16, .06);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141210; --card: #1e1b18; --ink: #f1ece6; --muted: #a39b92; --line: #332e29;
    --brand: #ff7a45; --brand-2: #ff9a70; --brand-ink: #1b0f08; --brand-soft: #3a2519;
    --good: #5cc2a5; --good-soft: #17302a; --warn: #e8b35c; --warn-soft: #33291a; --bad: #f08a75; --bad-soft: #3a211c;
    --ring-track: #2c2723; --top: #0d0c0b; --top-ink: #f1ece6; --shadow: none;
    --chart: #e8642f; --chart-soft: #6e3721; --chart-wash: rgba(232, 100, 47, .12);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141210; --card: #1e1b18; --ink: #f1ece6; --muted: #a39b92; --line: #332e29;
  --brand: #ff7a45; --brand-2: #ff9a70; --brand-ink: #1b0f08; --brand-soft: #3a2519;
  --good: #5cc2a5; --good-soft: #17302a; --warn: #e8b35c; --warn-soft: #33291a; --bad: #f08a75; --bad-soft: #3a211c;
  --ring-track: #2c2723; --top: #0d0c0b; --top-ink: #f1ece6; --shadow: none;
    --chart: #e8642f; --chart-soft: #6e3721; --chart-wash: rgba(232, 100, 47, .12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 16px/1.5 ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
a { color: var(--brand); }
.num { font-variant-numeric: tabular-nums; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.015em; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lede { color: var(--muted); margin: 0 0 18px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }

/* top bar + tabs */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--top); color: var(--top-ink);
          padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.topbar-inner { max-width: 880px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--top-ink); text-decoration: none; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.topnav { display: flex; gap: 2px; margin-left: auto; }
.topnav a { color: var(--top-ink); opacity: .78; text-decoration: none; padding: 7px 11px; border-radius: 9px; font-size: .9rem; white-space: nowrap; }
.topnav a.active { background: rgba(255,255,255,.14); opacity: 1; font-weight: 700; }
.app-refresh { display: inline-flex; align-items: center; gap: 5px; color: var(--top-ink); text-decoration: none; white-space: nowrap;
               padding: 7px 10px; border-radius: 9px; background: rgba(255,255,255,.1); font-size: .86rem; font-weight: 700; }
.app-refresh:hover { background: rgba(255,255,255,.18); }
.top-more { display: none; color: var(--top-ink); text-decoration: none; line-height: 0; margin-left: auto; padding: 8px; opacity: .85; }
.top-more svg { width: 24px; height: 24px; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .topnav { display: none; }
  .app-refresh { margin-left: auto; }
  .top-more { display: block; margin-left: 0; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line);
            padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tabbar a { flex: 1; text-align: center; color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 700; padding: 3px 0; }
  .tabbar a svg { display: block; margin: 0 auto 2px; width: 24px; height: 24px; }
  .tabbar a.active { color: var(--brand); }
  .shell { padding-bottom: 100px !important; }
}
.shell { max-width: 880px; margin: 0 auto; padding: 20px 16px 60px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.card.tight { padding: 14px 16px; }
.card.hero { background: var(--brand); color: var(--brand-ink); border: 0; }
.card.hero .muted, .card.hero a { color: var(--brand-ink); opacity: .85; }
.card.soft { background: var(--brand-soft); border-color: transparent; box-shadow: none; }
.card.done { opacity: .78; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid-2.stack-sm, .grid-3.stack-sm { grid-template-columns: minmax(0, 1fr); } }
.grid > .card { margin-bottom: 0; }
.label { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 4px; }
.card.hero .label { color: var(--brand-ink); opacity: .8; }
.big { font-size: 1.25rem; font-weight: 800; line-height: 1.25; margin: 0 0 4px; }
.kpi { font-size: 1.6rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--line); color: var(--ink); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.notice { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; background: var(--good-soft); color: var(--ink); border: 1px solid transparent; }
.notice.bad { background: var(--bad-soft); }
.notice.warn { background: var(--warn-soft); }

/* forms + buttons */
button, .btn { appearance: none; border: 0; border-radius: 14px; background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 800;
               padding: 12px 18px; min-height: 48px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:active, .btn:active { transform: scale(.98); }
button.ghost, .btn.ghost { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
button.quiet, .btn.quiet { background: var(--bg); color: var(--ink); border: 1px solid var(--line); font-weight: 700; }
button.small, .btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 11px; }
button.link { background: none; color: var(--brand); padding: 0; min-height: 0; font-weight: 700; }
button.danger { background: var(--bad); color: #fff; }
button.full, .btn.full { width: 100%; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
label { display: block; font-weight: 700; margin: 12px 0 6px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 46px; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; accent-color: var(--brand); margin: 0; flex: none; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto; flex: 1; min-width: 90px; }
form.inline-form label { margin: 0; }

/* choice rows (onboarding, check-in) */
.choices { display: grid; gap: 10px; }
.choices.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choices.cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.choice { position: relative; display: flex; align-items: center; gap: 12px; margin: 0; padding: 14px 16px; min-height: 56px; border: 2px solid var(--line);
          border-radius: 14px; background: var(--card); font-weight: 700; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:checked)::after { content: "✓"; margin-left: auto; color: var(--brand); font-weight: 900; }
.choice:has(input:focus-visible) { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.choices.cols-7 .choice, .choices.cols-4 .choice, .choices.cols-3 .choice { justify-content: center; padding: 12px 4px; text-align: center; }
.choices.cols-7 .choice::after, .choices.cols-4 .choice::after, .choices.cols-3 .choice::after { display: none; }
.choice .sub { display: block; font-weight: 500; font-size: .85rem; color: var(--muted); }
.steps { display: flex; gap: 6px; margin: 0 0 18px; }
.steps span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps span.on { background: var(--brand); }

/* today */
.greet { margin: 4px 0 14px; }
.routine { display: grid; gap: 12px; }
.task { display: flex; gap: 14px; align-items: flex-start; }
.task .ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.task .ico svg { width: 24px; height: 24px; }
.task.is-done .ico { background: var(--good-soft); color: var(--good); }
.task .body { flex: 1; min-width: 0; }
.task .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; text-decoration: none; color: inherit; }
.ring-cap { font-size: .75rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; flex: none;
        background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--ring-track) 0); display: grid; place-items: center; }
.ring > span { width: 58px; height: 58px; border-radius: 50%; background: var(--card); display: grid; place-items: center; text-align: center; line-height: 1.1; padding: 0 4px; }
.ring strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ring.good { background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--ring-track) 0); }
.bar { height: 10px; border-radius: 6px; background: var(--ring-track); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.bar.good > i { background: var(--good); }
.bar.over > i { background: var(--warn); }
.habit { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.habit:first-child { border-top: 0; }
.habit .tick { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--good); font-size: 1.2rem;
               font-weight: 900; padding: 0; min-height: 0; display: grid; place-items: center; }
.habit.on .tick { background: var(--good); border-color: var(--good); color: #fff; }
.counter { display: flex; align-items: center; gap: 6px; }
.counter button { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 12px; font-size: 1.2rem; }
.coach-note { display: flex; gap: 12px; align-items: flex-start; }
.coach-note .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 900; flex: none; }

/* lists + tables */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 0; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.list > li:first-child { border-top: 0; }
.list .meta { margin-left: auto; text-align: right; white-space: nowrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; border-top: 0; }
td.num, th.num { text-align: right; }

/* week */
.week { display: grid; gap: 10px; }
.day { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; }
.day .when { text-align: center; padding-top: 4px; }
.day .when b { display: block; font-size: 1.05rem; }
.day .when span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.day.today .when b { color: var(--brand); }
.day.past { opacity: .72; }
.chipset { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line);
        font-size: .88rem; font-weight: 700; color: var(--ink); text-decoration: none; cursor: pointer; min-height: 36px; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
button.chip { font-weight: 700; }

/* exercises */
.ex { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.ex:first-child { border-top: 0; }
.ex .n { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 900; display: grid; place-items: center;
         flex: none; font-size: .9rem; cursor: pointer; }
.ex.checked .n { background: var(--good); color: #fff; }
.ex.checked .what { text-decoration: line-through; opacity: .6; }
.ex .how { display: inline-flex; align-items: center; gap: 5px; flex: none; min-height: 36px; padding: 5px 10px; border-radius: 11px; border: 1px solid var(--line);
           background: var(--bg); color: var(--ink); text-decoration: none; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ex .how .play { color: var(--brand); font-size: .7rem; }
.ex .how:active { background: var(--brand-soft); }

/* food */
.meal-block + .meal-block { margin-top: 6px; }
.food-row { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.food-row:first-child { border-top: 0; }
.food-row .kc { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.tabs { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; background: transparent; color: var(--muted); min-height: 40px; padding: 6px; border-radius: 10px; font-size: .9rem; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.confirm-row { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.confirm-row:first-child { border-top: 0; }
.confirm-row .nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.confirm-row .nums input { min-height: 40px; padding: 8px; text-align: right; }
.confirm-row .nums label { margin: 0 0 2px; font-size: .72rem; color: var(--muted); }
.macro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: center; }
.macro b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.macro span { font-size: .75rem; color: var(--muted); font-weight: 700; }
#scanner { width: 100%; aspect-ratio: 4/3; background: #000; border-radius: 16px; overflow: hidden; position: relative; }
#scanner video { width: 100%; height: 100%; object-fit: cover; }
#scanner::after { content: ""; position: absolute; left: 12%; right: 12%; top: 40%; bottom: 40%; border: 3px solid var(--brand); border-radius: 12px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg .changes { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: .85rem; }
.msg .changes li { margin: 2px 0; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 4px; }
@media (max-width: 760px) { .composer { bottom: calc(62px + env(safe-area-inset-bottom)); } }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 48px; height: 48px; max-height: 160px; }
.typing { align-self: flex-start; color: var(--muted); font-size: .9rem; }

/* progress */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px; background: var(--brand); min-height: 3px; }
.bars .b i.good { background: var(--good); }
.bars .b i.low { background: var(--ring-track); }
.bars .b span { font-size: .68rem; color: var(--muted); font-weight: 700; text-align: center; line-height: 1.15; }
.bars { height: 140px; }
@media (max-width: 760px) { .kpis .kpi { font-size: 1.35rem; } }
.dots { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dots .d { aspect-ratio: 1; border-radius: 10px; background: var(--ring-track); display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: var(--muted); }
.dots .d.s1 { background: color-mix(in srgb, var(--good) 30%, var(--ring-track)); color: var(--ink); }
.dots .d.s2 { background: color-mix(in srgb, var(--good) 60%, var(--ring-track)); color: var(--ink); }
.dots .d.s3 { background: var(--good); color: #fff; }
.dots .d.today { outline: 2px solid var(--brand); outline-offset: 1px; }
svg.chart { width: 100%; height: 160px; display: block; }
svg.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .pt { fill: var(--brand); }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }

/* welcome + auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 26px; box-shadow: var(--shadow); }
.welcome { min-height: calc(100vh - 80px); display: flex; flex-direction: column; justify-content: center; max-width: 460px; margin: 0 auto; padding: 20px 4px; }
.welcome .mark { width: 88px; height: 88px; border-radius: 24px; margin-bottom: 22px; }
.welcome h1 { font-size: 2.1rem; }
.error { color: var(--bad); font-weight: 700; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 2px 6px; overflow-wrap: anywhere; }
pre.code { padding: 12px; white-space: pre-wrap; }
ol.howto { padding-left: 22px; } ol.howto li { margin: 0 0 10px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } button:active, .btn:active { transform: none; } }

/* menu (More page) */
.card.menu { padding: 4px 0; }
.menu-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line); min-height: 60px; }
.menu-row:first-child { border-top: 0; }
.menu-row strong { display: block; font-size: 1rem; }
.menu-row .sub { display: block; font-size: .85rem; color: var(--muted); margin-top: 1px; }
.menu-row .chev { color: var(--muted); font-size: 1.5rem; line-height: 1; }
.menu-row:active { background: var(--bg); }

/* plan meal ideas */
.meal-list { list-style: none; margin: 8px 0 0; padding: 0; }
.meal-list li { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; font-size: .92rem; line-height: 1.35; }
.meal-list .slot { flex: none; width: 80px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.meal-list a { color: var(--ink); text-decoration: none; }
.meal-list li.done a { color: var(--muted); }

/* progress stat row */
.kpi-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.kpi-row > div + div { border-left: 1px solid var(--line); }
.kpi-row span { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; line-height: 1.25; margin-top: 4px; }
@media (max-width: 760px) { .day { grid-template-columns: 50px 1fr; gap: 10px; } .meal-list .slot { width: 74px; } }
.ring.lg { width: 90px; height: 90px; }
.ring.lg > span { width: 70px; height: 70px; }
.ring.lg strong { font-size: 1rem; }

/* ---------- Overview ---------- */
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg a { flex: 1; text-align: center; padding: 8px 4px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: .9rem; text-decoration: none; }
.seg a.on { background: var(--brand); color: var(--brand-ink); }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.hero { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; margin: 2px 0 4px; }
.streak { font-weight: 800; font-size: .95rem; }
.meter-wrap { flex: 1 1 140px; max-width: 260px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.meter { position: relative; width: 100%; height: 10px; border-radius: 6px; background: var(--ring-track); }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--chart); }
.meter b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: .55; border-radius: 1px; }
.delta { display: inline-block; font-size: .78rem; font-weight: 700; color: var(--muted); margin-top: 2px; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; padding-top: 0; border-top: 0; }
.tile-v { font-size: 1.35rem; font-weight: 800; line-height: 1.15; }
.tile-v .muted { font-size: .85rem; font-weight: 700; }
@media (max-width: 760px) { .tiles:not(.two) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.colchart { position: relative; height: 150px; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; align-items: end;
            border-bottom: 1px solid var(--line); }
.colchart .col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: pointer; outline-offset: 1px; }
.colchart .col i { display: block; width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; }
.colchart .col i.hit { background: var(--chart); }
.colchart .col i.miss { background: var(--chart-soft); }
.colchart .col i.none { height: 3px; background: var(--ring-track); border-radius: 2px; }
.colchart .col.hover i, .colchart .col:focus-visible i { filter: brightness(1.1); box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--muted); }
.colchart.months .col i { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); }
.colchart.months .col i.track { background: var(--ring-track); }
.colchart .target { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--ink); opacity: .45; z-index: 1; pointer-events: none; }
.colchart .target span { position: absolute; right: 0; top: -18px; font-size: .7rem; font-weight: 700; color: var(--ink); background: var(--card); padding: 0 4px; border-radius: 4px; }
.colaxis { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; margin-top: 4px; }
.colaxis span { text-align: center; font-size: .68rem; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: visible; }
.keyrow { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.keyrow span { display: inline-flex; align-items: center; gap: 6px; }
.k { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.k.hit { background: var(--chart); } .k.miss { background: var(--chart-soft); } .k.track { background: var(--ring-track); }
.k.line { height: 0; width: 14px; border-top: 1.5px solid var(--ink); opacity: .55; border-radius: 0; }

.linechart { position: relative; height: 160px; margin: 14px 0 0 36px; }
.linechart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.linechart .grid { stroke: var(--line); stroke-width: 1; }
.linechart .area { fill: var(--chart-wash); }
.linechart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linechart .yl { position: absolute; left: -36px; font-size: .68rem; color: var(--muted); font-weight: 700; transform: translateY(-50%); }
.linechart .yl.top { top: 0; } .linechart .yl.bot { top: 100%; }
.linechart .pt { position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; cursor: pointer; }
.linechart .pt::after { content: ""; position: absolute; left: 7px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--chart); box-shadow: 0 0 0 2px var(--card); opacity: 0; }
.linechart .pt.end::after, .linechart .pt.hover::after, .linechart .pt:focus-visible::after { opacity: 1; }

.cal-head, .cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-head { margin: 12px 0 5px; }
.cal-head span { text-align: center; font-size: .7rem; font-weight: 800; color: var(--muted); }
.cal .c { aspect-ratio: 1; max-height: 46px; border-radius: 9px; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.cal .c.done { background: var(--chart); color: #fff; font-size: 1rem; }
.cal .c.partial { background: var(--chart-soft); color: var(--ink); font-size: 1rem; }
.cal .c.missed { background: var(--card); box-shadow: inset 0 0 0 2px var(--chart-soft); color: var(--ink); }
.cal .c.planned { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--muted); color: var(--ink); }
.cal .c.rest { background: var(--ring-track); }
.cal .c.none, .cal .c.out { background: transparent; cursor: default; }
.cal .c.none { color: var(--line); }
.cal .c.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.cal .c.hover { filter: brightness(1.08); }
.k.c-done { background: var(--chart); } .k.c-partial { background: var(--chart-soft); } .k.c-missed { box-shadow: inset 0 0 0 2px var(--chart-soft); }
.k.c-planned { box-shadow: inset 0 0 0 1.5px var(--muted); } .k.c-rest { background: var(--ring-track); }
.hab + .hab { margin-top: 12px; }

.tip { position: absolute; z-index: 50; background: var(--ink); color: var(--bg); border-radius: 10px; padding: 7px 10px; font-size: .8rem; line-height: 1.3;
       pointer-events: none; max-width: 240px; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.tip strong { display: block; font-size: .95rem; }
.tip span { opacity: .8; }
.planned { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; padding: 9px 12px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--line); }
.planned .lbl { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.planned a { color: var(--ink); text-decoration: none; font-weight: 700; }
.planned.followed { border-style: solid; border-color: var(--good); background: var(--good-soft); }
.planned.followed a { color: var(--ink); }
.planned form { margin-left: auto; }

/* tap-to-open sections (static/fold.js) */
details.fold-panel { padding: 0; }
details.fold-panel > summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; min-height: 56px; cursor: pointer; list-style: none;
                               -webkit-tap-highlight-color: transparent; border-radius: var(--radius); }
details.fold-panel > summary::-webkit-details-marker { display: none; }
details.fold-panel > summary h2 { flex: 1; min-width: 0; margin: 0 !important; }
details.fold-panel > summary .fold-extra { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; text-align: right; }
details.fold-panel > summary .fold-extra > * { min-width: 0; }
details.fold-panel > summary:active { background: var(--bg); }
details.fold-panel[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
details.fold-panel > .section-body { padding: 14px 18px 18px; min-width: 0; }
details.fold-panel > .section-body > .fold-actions { justify-content: flex-end; margin-bottom: 10px; }
.section-chevron { flex: none; font-size: 1.5rem; line-height: 1; color: var(--brand); transition: transform .15s; }
details.fold-panel[open] > summary .section-chevron { transform: rotate(90deg); }
.grid > details.fold-panel { align-self: start; }
@media (prefers-reduced-motion: reduce) { .section-chevron { transition: none; } }
@media print { details.fold-panel > summary .section-chevron { display: none; } }
