/* Coach components. Requires tokens.css first.
   Fonts: <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap" rel="stylesheet"> */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: var(--t-body); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
a:hover { color: var(--accent-pressed); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.tnum { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.screen {
  max-width: 430px; margin: 0 auto; min-height: 100dvh;
  padding: 32px var(--gutter) calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--card-gap);
}
.stack { display: flex; flex-direction: column; gap: var(--card-gap); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.screen-header { display: flex; flex-direction: column; gap: 6px; padding: 0 4px 8px; }
.eyebrow, .card-label {
  font: var(--t-label); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 0;
}
.title { font: var(--t-title); letter-spacing: -.015em; margin: 0; }
.lede { font: var(--t-body); color: var(--ink-2); margin: 0; }
.section-title {
  display: flex; align-items: center; gap: 10px; margin: 20px 0 0; padding: 0 4px;
  font: var(--t-heading);
}
.section-title::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--dot, var(--accent)); }
.subhead { display: flex; justify-content: space-between; align-items: baseline; padding: 20px 4px 4px; }
.subhead h2 { margin: 0; font: 700 22px/28px var(--font-display); }
.subhead span { font-size: 14px; color: var(--ink-3); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-card);
  padding: var(--card-pad); box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.card--hero { border-radius: var(--r-hero); padding: 24px; gap: 10px; }
.card--flat { box-shadow: none; }
.card--active { border: 2px solid var(--accent); box-shadow: 0 8px 24px rgba(31,94,84,.10); }
.card--error { border-color: var(--error-border); }
.card--tint { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.card h2, .card h3 { margin: 0; }
.card-title { font: 800 26px/32px var(--font-display); letter-spacing: -.01em; margin: 0; }
.card-heading { font: 700 18px/24px var(--font-display); margin: 0; }
.card p { margin: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: 14px; line-height: 20px; }
a.card { text-decoration: none; color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap-primary); padding: 0 20px; width: 100%;
  border: 0; border-radius: var(--r-button);
  background: var(--accent); color: var(--on-accent);
  font: 600 17px/1 var(--font-body); text-decoration: none;
}
.btn:hover { background: var(--accent-pressed); color: var(--on-accent); }
.btn:disabled { background: #F1EEE8; color: var(--ink-3); border: 1px solid var(--hairline); cursor: default; }
.btn--secondary { min-height: 52px; background: var(--card); color: var(--ink); border: 1px solid var(--control-border); font-size: 16px; }
.btn--secondary:hover { background: var(--ground); color: var(--ink); }
.btn--quiet { min-height: var(--tap); background: var(--sunken); color: var(--ink); font-size: 15px; width: auto; }
.btn--quiet:hover { background: #E6E1D8; color: var(--ink); }
.btn--text { min-height: var(--tap); background: transparent; color: var(--accent); padding: 0; width: auto; font-size: 16px; }
.btn--text:hover { background: transparent; color: var(--accent-pressed); }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-pill); border: 0; flex-shrink: 0;
  background: var(--sunken); color: var(--ink); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn--plain { background: transparent; color: var(--ink-2); width: var(--tap); height: var(--tap); border-radius: var(--r-field); }
.change-link {
  display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 0 20px;
  border-radius: var(--r-card); border: 1px dashed #CFC8BB; text-decoration: none; color: var(--ink-2); font-size: 16px;
}
.change-link b { color: var(--accent); font-weight: 600; }

/* ---------- Chips, segmented, switch ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: var(--tap); min-width: 64px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--control-border); background: var(--card); color: var(--ink);
  font: 500 15px/1 var(--font-body);
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.segmented { display: flex; gap: 4px; background: var(--sunken); border-radius: var(--r-button); padding: 4px; }
.segmented > button {
  flex: 1; min-height: 44px; border: 0; border-radius: 12px; background: transparent;
  color: var(--ink-2); font: 600 14px/1 var(--font-body);
}
.segmented > button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(28,30,29,.12); }
.switch {
  width: 52px; height: 32px; padding: 3px; border: 0; border-radius: var(--r-pill);
  background: var(--control-border); display: flex; justify-content: flex-start; flex-shrink: 0;
}
.switch::after { content: ""; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }
.stepper { display: inline-flex; align-items: center; background: var(--sunken); border-radius: var(--r-field); padding: 2px; }
.stepper button { width: 44px; height: 44px; border: 0; background: transparent; font: 600 20px/1 var(--font-body); }
.stepper output { min-width: 58px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 1–5 scale (check-in) ---------- */
.scale { border: 1px solid var(--hairline); border-radius: var(--r-card); background: var(--card); padding: 18px 16px 14px; margin: 0; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 12px; }
.scale legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.scale-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.scale-name { font: 700 18px/24px var(--font-display); }
.scale-word { font: 600 16px/24px var(--font-body); color: var(--accent); }
.scale-track { display: flex; gap: 4px; background: var(--sunken); border-radius: var(--r-button); padding: 4px; }
.scale-track button { flex: 1; height: 52px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); font: 600 17px/1 var(--font-body); }
.scale-track button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 6px rgba(31,94,84,.25); }
.scale-ends { display: flex; justify-content: space-between; font: var(--t-caption); font-weight: 400; color: var(--ink-3); padding: 0 4px; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field-label { font: 600 14px/20px var(--font-body); color: var(--ink-2); }
.input, .textarea {
  width: 100%; border: 1px solid var(--control-border); border-radius: var(--r-field);
  background: var(--card); color: var(--ink); font: 500 16px/24px var(--font-body);
}
.input { height: 52px; padding: 0 16px; }
.textarea { padding: 14px 16px; resize: none; font-weight: 400; }
.input:focus, .textarea:focus { border: 1.5px solid var(--accent); outline: none; }
.input--num { text-align: center; font: 600 18px/1 var(--font-body); font-variant-numeric: tabular-nums; padding: 0 4px; }
.input--num::-webkit-outer-spin-button, .input--num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Badges, status, summary line, banner ---------- */
.badge { display: inline-flex; align-items: center; flex-shrink: 0; white-space: nowrap; height: 26px; padding: 0 10px; border-radius: var(--r-pill); background: var(--sunken); color: var(--ink-2); font: 600 12px/1 var(--font-body); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--ok { background: var(--ok-bg); color: var(--ok-fg); }
.status {
  display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-radius: var(--r-pill);
  font: 600 13px/1 var(--font-body); background: var(--info-bg); color: var(--info-fg); width: fit-content; white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--info-dot); }
.status--warn { background: var(--warn-bg); color: var(--warn-fg); } .status--warn::before { background: var(--warn-dot); }
.status--ok { background: var(--ok-bg); color: var(--ok-fg); } .status--ok::before { background: var(--ok-dot); }
.status--high { background: var(--high-bg); color: var(--high-fg); } .status--high::before { background: var(--high-dot); }
.status--error { background: var(--error-bg); color: var(--error-fg); } .status--error::before { background: var(--error-dot); }
.summary-line {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--r-button);
  font: var(--t-callout); text-decoration: none; background: var(--info-bg); color: var(--ink-2);
}
.summary-line::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--info-dot); }
.summary-line--warn { background: var(--warn-bg); color: var(--warn-ink); } .summary-line--warn::before { background: var(--warn-dot); }
.summary-line--ok { background: var(--ok-bg); color: var(--ok-ink); } .summary-line--ok::before { background: var(--ok-dot); }
.banner {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 16px; border-radius: 18px;
  background: var(--accent-soft); color: var(--ink); text-decoration: none;
}
.banner-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--card); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.banner-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 15px; line-height: 20px; }
.banner-text b { font-weight: 600; }
.banner-text span { color: var(--accent); font-weight: 600; font-size: 14px; }
.alert {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-button);
  background: var(--error-bg); color: var(--error-fg); font: var(--t-callout);
}
.alert::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--error-dot); flex-shrink: 0; margin-top: 7px; }

/* ---------- Progress, error, offline ---------- */
.progress-dots { display: flex; gap: 8px; }
.progress-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: dot 1.2s infinite ease-in-out; }
.progress-dots span:nth-child(2) { animation-delay: .2s; }
.progress-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.progress-bar { height: 4px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.progress-bar > i { display: block; height: 100%; width: var(--p, 40%); background: var(--accent); border-radius: inherit; transition: width .4s; }
.progress-bar--indeterminate > i { width: 35%; animation: slide 1.6s infinite ease-in-out; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.state-title { font: 800 24px/30px var(--font-display); margin: 0; }
.card--error .state-title { color: var(--error-fg); }
.checklist { display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 21px; margin: 0; padding: 0; list-style: none; }
.checklist li { display: flex; gap: 10px; align-items: center; }
.checklist li[data-done="false"] { color: var(--ink-2); }
.offline-bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-field);
  background: var(--offline-bg); color: var(--offline-fg); font: 500 14px/20px var(--font-body);
}
@media (prefers-reduced-motion: reduce) { .progress-dots span, .progress-bar--indeterminate > i { animation: none; } }

/* ---------- Session steps and set logging ---------- */
.step { display: flex; gap: 14px; align-items: center; }
.step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--sunken); color: var(--ink-2); font: 700 14px/32px var(--font-display); text-align: center; flex-shrink: 0; }
.step-num--current { background: var(--accent-soft); color: var(--accent); }
.step-num--done { background: var(--accent); color: #fff; }
.step-body { flex: 1; display: flex; flex-direction: column; }
.step-body b { font-size: 16px; line-height: 22px; font-weight: 600; }
.step-body span { font-size: 14px; line-height: 20px; color: var(--ink-2); }
.step-list { display: flex; flex-direction: column; }
.step-list > .step { padding: 16px 0; border-bottom: 1px solid var(--divider); }
.step-list > .step:last-child { border-bottom: 0; }
.set-grid { display: grid; grid-template-columns: 44px minmax(0,1fr) 16px minmax(0,1fr) 52px; gap: 8px; align-items: center; }
.set-grid--head { font: 600 12px/16px var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.set-grid .x { text-align: center; color: var(--ink-3); }
.set-grid .n { font: 700 16px/1 var(--font-display); color: var(--ink-2); }
.tick { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--control-border); background: var(--card); color: var(--control-border); display: flex; align-items: center; justify-content: center; padding: 0; }
.tick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.diff { display: flex; gap: 12px; font-size: 15px; line-height: 22px; }
.diff-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--sunken); color: var(--ink-2); font: 700 13px/22px var(--font-body); text-align: center; flex-shrink: 0; }
.diff-mark--add { background: var(--accent-soft); color: var(--accent); }
.diff s { color: var(--ink-3); }

/* ---------- Week strip ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 4px; text-align: center; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; text-decoration: none; color: var(--ink); }
.week-day small { font: 600 12px/16px var(--font-body); color: var(--ink-3); }
.week-day i { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--control-border); background: var(--card); display: flex; align-items: center; justify-content: center; font: 700 13px/1 var(--font-body); font-style: normal; color: var(--ink-4); }
.week-day span { font-size: 11px; line-height: 14px; color: var(--ink-2); }
.week-day[data-state="done"] i { background: var(--accent); border-color: var(--accent); color: #fff; }
.week-day[data-state="today"] i { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.week-day[data-state="rest"] i { border-color: var(--gridline); }

/* ---------- List rows (week days, earlier reviews, daily values) ---------- */
.list { display: flex; flex-direction: column; padding: 4px 8px; }
.list-row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 8px 12px; border-bottom: 1px solid var(--divider); text-decoration: none; color: var(--ink); }
.list-row:last-child { border-bottom: 0; }
.list-row .date { width: 44px; display: flex; flex-direction: column; align-items: center; }
.list-row .date small { font: 600 12px/16px var(--font-body); color: var(--ink-3); }
.list-row .date b { font: 700 18px/22px var(--font-display); }
.list-row .main { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.list-row .main b { font-size: 15px; line-height: 21px; font-weight: 600; }
.list-row .main span { font-size: 13px; line-height: 18px; color: var(--ink-3); }
.disclosure { display: flex; justify-content: space-between; align-items: center; min-height: 56px; width: 100%; border: 0; background: transparent; padding: 0; font: 700 16px/1 var(--font-display); color: var(--ink); }

/* ---------- Bottom navigation ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--hairline);
  padding: 6px 6px calc(18px + env(safe-area-inset-bottom));
}
.nav-inner { display: flex; width: 100%; max-width: 430px; }
.nav a {
  flex: 1; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; color: var(--ink-3); font: 500 12px/16px var(--font-body);
}
.nav a > span:first-child { width: 56px; height: 30px; border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center; }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.nav a[aria-current="page"] > span:first-child { background: var(--accent-soft); }
.nav svg { width: 22px; height: 22px; }

/* ---------- Bottom panel (sheet) ---------- */
.sheet-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 430px; margin: 0 auto; max-height: 92dvh; overflow: auto;
  background: var(--card); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-sheet);
  padding: 10px var(--gutter) calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px;
  animation: sheet-in .28s cubic-bezier(.2,.8,.2,1);
}
.sheet-grip { width: 40px; height: 5px; border-radius: var(--r-pill); background: var(--control-border); align-self: center; flex-shrink: 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-title { font: 800 24px/30px var(--font-display); margin: 0; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

/* ---------- Trends ---------- */
.readiness { border-radius: var(--r-hero); padding: 24px; gap: 10px; margin-top: 8px; }
.readiness-word { display: flex; align-items: center; gap: 12px; font: 800 28px/34px var(--font-display); letter-spacing: -.01em; }
.readiness-word::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--dot); }
.metric { gap: 4px; }
.metric-head { display: flex; justify-content: space-between; align-items: center; font: 600 15px/20px var(--font-body); color: var(--ink-2); }
.metric-head svg { color: var(--ink-4); }
.metric-value { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.metric-value b { font: 700 40px/46px var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric-value span { font: 600 16px/22px var(--font-body); color: var(--ink-2); }
.metric-sub { font-size: 14px; line-height: 20px; color: var(--ink-2); }
.metric-delta { font-size: 13px; line-height: 18px; color: var(--ink-3); }
.metric .status { margin-top: 8px; }
.chart { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.chart svg { display: block; overflow: visible; max-width: 100%; height: auto; }
.axis-x { display: flex; justify-content: space-between; font: var(--t-axis); color: var(--ink-3); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font: 400 12px/16px var(--font-body); color: var(--ink-2); }
.legend span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.metric-rows { display: flex; flex-direction: column; margin-top: 8px; }
.metric-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--divider); }
.metric-row > div { flex: 1; display: flex; flex-direction: column; }
.metric-row small { font-size: 14px; line-height: 20px; color: var(--ink-2); }
.metric-row b { font: 700 24px/30px var(--font-display); font-variant-numeric: tabular-nums; }
.metric-row b em { font: 600 14px/1 var(--font-body); font-style: normal; color: var(--ink-2); margin-left: 4px; }
.felt { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.felt small { font: 600 13px/18px var(--font-body); color: var(--ink-2); }
.felt-note { margin: 6px 0 0; font: 400 12px/16px var(--font-body); color: var(--ink-3); }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.stat-tile { background: var(--card); border: 1px solid var(--hairline); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-tile small { font-size: 13px; color: var(--ink-3); }
.stat-tile b { font: 700 26px/32px var(--font-display); font-variant-numeric: tabular-nums; }
.stat-tile b em { font: 600 13px/1 var(--font-body); font-style: normal; color: var(--ink-2); margin-left: 3px; }
.stat-tile span { font-size: 12px; color: var(--ink-3); }
.value-row { display: flex; align-items: center; gap: 12px; min-height: 48px; border-top: 1px solid var(--divider); }
.value-row .d { flex: 1; font-size: 15px; }
.value-row .bar { width: 70px; height: 6px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.value-row .bar i { display: block; height: 100%; border-radius: inherit; background: var(--c); width: var(--w); }
.value-row .v { width: 64px; text-align: right; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.value-row .note { font: 600 12px/1 var(--font-body); color: var(--warn-fg); }
.back-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); padding-right: 12px; font: 600 16px/1 var(--font-body); text-decoration: none; }
