@font-face { font-family: 'Sohne'; src: url('./fonts/sohne-regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Sohne'; src: url('./fonts/sohne-semi-bold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem;

  --radius-sm: 0.375rem; --radius-md: 0.625rem; --radius-lg: 1rem; --radius-full: 9999px;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-display: 'Sohne', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Sohne', 'Helvetica Neue', Arial, sans-serif;
  --si-green: #0da575;
  --si-border: #d2cfcb;
  --si-ink: #13212e;

  /* Warm linen surfaces */
  --color-bg: #f6f1ea;
  --color-surface: #fbf8f3;
  --color-surface-2: #ffffff;
  --color-surface-offset: #efe8de;
  --color-divider: #e3dbcf;
  --color-border: oklch(0.35 0.03 60 / 0.16);

  --color-text: #2b2420;
  --color-text-muted: #6e645c;
  --color-text-faint: #a89e94;
  --color-text-inverse: #fbf8f3;

  /* Primary: deep evergreen */
  --color-primary: #2f4f43;
  --color-primary-hover: #243e34;

  /* Data roles */
  --color-flush: #b23a3a;        /* hot flush */
  --color-flush-hover: #962e2f;
  --color-flush-soft: #f3dcd8;
  --color-carb: #c4862a;         /* starchy / sweet */
  --color-carb-soft: #f4e6cc;
  --color-low: #5f8063;          /* mostly protein, fat, veg */
  --color-low-soft: #dfe8dc;

  --shadow-sm: 0 1px 2px oklch(0.3 0.03 60 / 0.08);
  --shadow-md: 0 6px 20px oklch(0.3 0.03 60 / 0.10);
  --content: 34rem;
}

body { background: var(--color-bg); }

.skip { position: absolute; left: -999px; top: var(--space-2); background: var(--color-surface-2); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); z-index: 50; }
.skip:focus { left: var(--space-2); }

.shell { max-width: var(--content); margin-inline: auto; padding-inline: var(--space-4); padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom)); }

.si-topbar { border-bottom: 1px solid var(--si-border); background: var(--color-bg); }
.si-topbar__inner { max-width: 72rem; margin-inline: auto; padding: 14px var(--space-4); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.si-topbar__brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.si-topbar__logo img { display: block; height: 32px; width: auto; }
.si-topbar__title { margin: 0; padding-left: 16px; border-left: 1px solid var(--si-border); font-family: var(--font-body); font-weight: 600; font-size: 15px; line-height: 1.25; letter-spacing: -0.01em; color: var(--si-ink); text-decoration: none; }
.si-topbar__title span { color: var(--color-flush); }
.dayprog { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.dayprog[hidden] { display: none; }
.progress-track { position: relative; width: 16rem; height: 3px; background: var(--si-border); border-radius: 999px; }
.progress-fill { height: 100%; background: var(--si-green); border-radius: 999px; transition: width .4s cubic-bezier(.16,1,.3,1); }
.p2mark { position: absolute; left: 50%; top: -3px; width: 2px; height: 9px; background: var(--color-text-faint); border-radius: 1px; }
.dayprog__label { font-size: 13px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 760px) { .progress-track { width: 8rem; } }
@media (max-width: 560px) {
  .si-topbar__inner { padding: 10px var(--space-4); align-items: flex-end; }
  .si-topbar__brand { flex-direction: column; align-items: flex-start; gap: 6px; }
  .si-topbar__logo img { height: 26px; }
  .si-topbar__title { padding-left: 0; border-left: 0; font-size: 14px; }
  .dayprog { flex-direction: column; align-items: flex-end; gap: 6px; padding-bottom: 2px; }
  .progress-track { width: 6.5rem; }
}

h1, h2, h3 { font-weight: 600; }
h1 { font-family: var(--font-display); font-size: var(--text-xl); letter-spacing: -0.015em; line-height: 1.1; }
h2 { font-family: var(--font-body); font-weight: 600; font-size: var(--text-lg); line-height: 1.25; }
h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--text-base); }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-8); }

.card { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.card.flat { background: var(--color-surface); box-shadow: none; }
.eyebrow { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted); font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 48px; padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-ghost { background: transparent; color: var(--color-primary); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: var(--color-surface-offset); }
.btn-link { color: var(--color-primary); font-size: var(--text-sm); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; padding-inline: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.bigactions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.bigbtn { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: var(--space-4); min-height: 9.5rem; padding: var(--space-5); border-radius: var(--radius-lg); text-align: left; box-shadow: var(--shadow-md); }
.bigbtn .lbl { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; }
.bigbtn .sub { font-size: var(--text-xs); opacity: 0.85; }
.bigbtn svg { width: 28px; height: 28px; }
.bigbtn-flush { background: var(--color-flush); color: #fff; }
.bigbtn-flush:hover { background: var(--color-flush-hover); }
.bigbtn-meal { background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border); }
.bigbtn-meal:hover { background: var(--color-surface); }

/* Chips & segmented */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { min-height: 44px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); border: 1px solid var(--color-border); background: var(--color-surface-2); font-size: var(--text-sm); color: var(--color-text); }
.chip[aria-pressed='true'] { background: var(--color-carb-soft); border-color: var(--color-carb); color: #6b4510; font-weight: 600; }
.chip.low[aria-pressed='true'] { background: var(--color-low-soft); border-color: var(--color-low); color: #2f4a32; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--space-2); }
.seg button { min-height: 52px; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-surface-2); font-size: var(--text-sm); font-weight: 500; padding: var(--space-2); }
.seg button[aria-pressed='true'] { background: var(--color-primary); color: var(--color-text-inverse); border-color: var(--color-primary); }
.seg.flush button[aria-pressed='true'] { background: var(--color-flush); border-color: var(--color-flush); }

fieldset { border: 0; }
legend, .label { font-weight: 600; font-size: var(--text-sm); margin-bottom: var(--space-2); display: block; }
.field input[type='email'], .field input[type='time'], .field input[type='date'] { width: 100%; min-height: 48px; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); font-size: var(--text-base); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--text-sm); color: var(--color-text-muted); }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--color-primary); flex: none; }
.err { color: var(--color-flush); font-size: var(--text-sm); }
.ok { color: var(--color-low); font-size: var(--text-sm); font-weight: 600; }

/* Sheet (modal) */
.sheet-backdrop { position: fixed; inset: 0; background: oklch(0.2 0.02 60 / 0.42); display: flex; align-items: flex-end; justify-content: center; z-index: 40; animation: fade 160ms ease-out; }
.sheet { background: var(--color-bg); width: 100%; max-width: var(--content); max-height: 92dvh; overflow-y: auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-6) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); animation: rise 220ms cubic-bezier(0.16, 1, 0.3, 1); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-5); }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-full); color: var(--color-text-muted); }
.iconbtn:hover { background: var(--color-surface-offset); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Timeline */
.timeline { list-style: none; }
.timeline li { display: grid; grid-template-columns: 3.5rem 12px 1fr auto; gap: var(--space-3); align-items: start; padding-block: var(--space-3); border-top: 1px solid var(--color-divider); }
.timeline li:first-child { border-top: 0; }
.timeline time { font-size: var(--text-sm); color: var(--color-text-muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.dot { width: 12px; height: 12px; border-radius: var(--radius-full); margin-top: 6px; }
.dot.flush { background: var(--color-flush); }
.dot.carb { background: var(--color-carb); }
.dot.low { background: var(--color-low); }
.dot.night { background: #6f5a7e; }
.tl-main { font-size: var(--text-sm); }
.tl-main strong { font-weight: 600; display: block; font-size: var(--text-sm); }
.tl-main span { color: var(--color-text-muted); }
.del { font-size: var(--text-xs); color: var(--color-text-muted); min-height: 44px; padding-inline: var(--space-2); margin-top: -12px; }
.del:hover { color: var(--color-flush); }

.empty { text-align: left; padding: var(--space-6) var(--space-2); color: var(--color-text-muted); font-size: var(--text-sm); }

/* Progress */
.progress { display: grid; grid-template-columns: repeat(28, 1fr); gap: 2px; }
.progress i.p2 { margin-left: 6px; }
.progress i { height: 6px; border-radius: 3px; background: var(--color-divider); }
.progress i.done { background: var(--color-primary); }
.progress i.today { background: var(--color-carb); }

/* Tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: color-mix(in oklab, var(--color-bg) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--color-divider); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.tabs-inner { max-width: var(--content); margin-inline: auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current='page'] { color: var(--color-primary); font-weight: 600; }

/* Report */
.stat-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.stat { border-radius: var(--radius-md); padding: var(--space-4); }
.stat.carb { background: var(--color-carb-soft); }
.stat.low { background: var(--color-low-soft); }
.stat .num { font-family: var(--font-display); font-size: var(--text-xl); line-height: 1; font-variant-numeric: tabular-nums; }
.stat .cap { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-2); }
.headline { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.3; }

.bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 120px; border-bottom: 1px solid var(--color-divider); }
.bars div { background: var(--color-flush); border-radius: 2px 2px 0 0; min-height: 0; }
.bars-x { display: grid; grid-template-columns: repeat(24, 1fr); font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-1); }
.bars-x span { text-align: center; }
.mealrow { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin-top: var(--space-2); height: 10px; }
.mealrow i { border-radius: 2px; }

.daychart { display: grid; grid-template-columns: repeat(14, 1fr); gap: var(--space-1); align-items: end; height: 140px; }
.daycol { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 2px; }
.daycol .c { width: 70%; background: var(--color-carb); border-radius: 2px 2px 0 0; }
.daycol .f { width: 70%; background: var(--color-flush); border-radius: 2px; }
.daylabels { display: grid; grid-template-columns: repeat(14, 1fr); gap: var(--space-1); font-size: var(--text-xs); color: var(--color-text-faint); text-align: center; margin-top: var(--space-1); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--text-xs); color: var(--color-text-muted); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.note { background: var(--color-surface-offset); border-radius: var(--radius-md); padding: var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); }
.hero-intro { padding-top: var(--space-4); }
.steps { list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 2rem 1fr; gap: var(--space-3); padding-block: var(--space-3); border-top: 1px solid var(--color-divider); font-size: var(--text-sm); }
.steps li:first-child { border-top: 0; }
.steps li::before { content: counter(s); font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-flush); line-height: 1.1; }
.footer { margin-top: var(--space-12); font-size: var(--text-xs); color: var(--color-text-faint); }
.footer a { color: var(--color-text-muted); }

.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--color-text); color: var(--color-text-inverse); padding: var(--space-3) var(--space-5); border-radius: var(--radius-full); font-size: var(--text-sm); z-index: 60; animation: rise 200ms ease-out; white-space: nowrap; }

@media print {
  .tabs, .dayprog, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .shell { max-width: 100%; padding: 0; }
}

.daycol.p2 { border-left: 1px dashed var(--color-text-faint); }
.daylabels.parts { grid-template-columns: 1fr 1fr; }
.daylabels.parts span { border-top: 1px solid var(--color-divider); padding-top: var(--space-1); }
.ba { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.ba th, .ba td { padding: var(--space-2) var(--space-1); border-top: 1px solid var(--color-divider); text-align: right; vertical-align: bottom; }
.ba thead th { border-top: 0; font-weight: 600; line-height: 1.2; }
.ba thead th span { display: block; font-weight: 400; font-size: var(--text-xs); color: var(--color-text-muted); }
.ba th[scope=row] { text-align: left; font-weight: 400; color: var(--color-text-muted); }
.ba td:last-child { color: var(--color-low); font-weight: 600; }
.plainlist { list-style: none; display: grid; gap: var(--space-3); font-size: var(--text-sm); }
.plainlist li { padding-left: var(--space-4); position: relative; }
.plainlist li::before { content: ""; position: absolute; left: 0; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--color-low); }
.ba thead th { white-space: nowrap; }

.chiphead { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin: var(--space-3) 0 var(--space-2); }
.chiphead:first-of-type { margin-top: var(--space-1); }

.flow { list-style: none; display: grid; gap: var(--space-1); margin: var(--space-2) 0; font-size: var(--text-sm); }
.flow li { background: var(--color-bg); border: 1px solid var(--color-divider); border-radius: var(--radius-md, 8px); padding: var(--space-2) var(--space-3); text-align: center; position: relative; }
.flow li:not(:last-child)::after { content: "\2193"; display: block; position: absolute; left: 50%; bottom: -0.95em; transform: translateX(-50%); color: var(--color-text-faint); font-size: var(--text-xs); line-height: 1; z-index: 1; }
.flow li + li { margin-top: var(--space-2); }
.flow li.end { background: var(--color-flush); border-color: var(--color-flush); color: #fff; font-weight: 600; }
#why-h ~ p a { color: var(--color-primary); font-weight: 600; text-underline-offset: 3px; }

.lead { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.25; color: var(--color-text-muted); }
.card p a { color: var(--color-primary); font-weight: 600; text-underline-offset: 3px; }
.nw { white-space: nowrap; }

.opts { list-style: none; display: grid; gap: var(--space-4); }
.opt { border-top: 1px solid var(--color-divider); padding-top: var(--space-4); display: grid; gap: var(--space-2); }
.opt:first-child { border-top: 0; padding-top: 0; }
.opt h3 { font-size: var(--text-base); font-weight: 600; }
.opt .btn { margin-top: var(--space-1); }
.opt-share { border-top: 1px solid var(--color-divider); padding-top: var(--space-4); display: grid; gap: var(--space-1); }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
#opts-h { margin-bottom: var(--space-2); }

.print-only { display: none; }
@media print { .print-only { display: block; } .screen-only { display: none !important; } }
.finish-box { margin-top: var(--space-2); }
.note a { color: var(--color-primary); font-weight: 600; text-underline-offset: 3px; }

/* ---------- symptom check ---------- */
.sym { display: flex; flex-direction: column; gap: var(--space-1); }
.sym-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.sym-top output { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.sym-ends { display: flex; justify-content: space-between; font-size: var(--text-xs, 0.8rem); color: var(--color-text-muted); }
input[type=range] { width: 100%; accent-color: var(--color-primary); min-height: 32px; }
.ba.sym-t td, .ba.sym-t thead th { text-align: center; }
.sym-t th[scope=row] { text-align: left; }
.better { color: var(--color-low); font-weight: 600; }
.worse { color: var(--color-flush); font-weight: 600; }

/* ---------- today extras ---------- */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.row2 > * { width: 100%; text-align: center; justify-content: center; }
.row2 > :only-child { grid-column: 1 / -1; }
.ontrack { border-left: 4px solid var(--color-carb); }
.ontrack.is-good { border-left-color: var(--color-low); }
.daycheck { border-left: 4px solid var(--color-primary); }
.weekone { background: var(--color-low-soft); }
.install { border: 1px dashed var(--color-primary); }

/* ---------- repeat meal ---------- */
.repeat-box { display: flex; flex-direction: column; gap: var(--space-1); }
.repeat-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1.5px solid var(--color-primary); background: var(--color-surface-2); color: var(--color-text); text-align: left; cursor: pointer; font: inherit; }
.repeat-btn:hover { background: var(--color-low-soft); }
.repeat-k { font-weight: 600; color: var(--color-primary); }
.repeat-v { font-size: 0.9rem; color: var(--color-text-muted); }
#main { padding-top: var(--space-6); }
