/* ===========================================================================
   Kneewise — bright, calm, legible at arm's length from a yoga mat.
   =========================================================================== */

:root {
  --bg: #f4f6f9;
  --bg-tint: #eaeff7;
  --surface: #ffffff;
  --surface-2: #f2f5f9;
  --line: #e0e6ee;
  --line-strong: #cdd6e2;

  --ink: #131a24;
  --muted: #566374;
  --faint: #8a95a5;

  --accent: #1f62c9;
  --accent-soft: #e8f0fd;
  --accent-ink: #14458f;

  --ok: #12805a;
  --ok-soft: #e2f5ec;
  --warn: #a86a00;
  --warn-soft: #fdf1dc;
  --bad: #c0362a;
  --bad-soft: #fdeae7;

  --radius: 16px;
  --pad: 16px;
  --shadow: 0 1px 2px rgba(19,26,36,.05), 0 6px 18px rgba(19,26,36,.05);
  --shadow-lift: 0 2px 6px rgba(19,26,36,.07), 0 14px 34px rgba(19,26,36,.09);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { letter-spacing: -.018em; }
h1 { font-size: 1.9rem; margin: 0 0 .35em; }
h2 { font-size: 1.32rem; margin: 0 0 .45em; }
h3 { font-size: 1.04rem; margin: 0 0 .5em; }
h4 { font-size: .9rem; margin: 0 0 .5em; color: var(--muted); }
p  { margin: 0 0 .8em; }
em { font-style: normal; color: var(--muted); }
strong { font-weight: 640; }

.pad { padding: var(--pad) var(--pad) 96px; max-width: 640px; margin: 0 auto; }
.lead { color: var(--muted); font-size: 1.06rem; }
.fine { font-size: .83rem; color: var(--faint); line-height: 1.5; }
.fine.warn { color: var(--warn); }
.meta { font-size: .84rem; color: var(--muted); margin-bottom: .6em; }

/* ---------- logo ---------- */
.logo-mark { display: grid; place-items: center; }
.logo-ring { fill: var(--accent-soft); stroke: none; }
.wordmark { display: flex; align-items: center; gap: 12px; }
.wordmark-text strong { display: block; font-size: 1.18rem; letter-spacing: -.02em; }
.wordmark-text span { display: block; font-size: .76rem; color: var(--faint); }

/* ---------- header + nav ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 10px) var(--pad) 10px;
  background: rgba(244,246,249,.88); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.hdr-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 640px; margin: 0 auto; }
.hdr-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hdr-phase { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 640; }
.hdr-week { font-size: 1.06rem; font-weight: 640; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  width: 38px; height: 38px; display: grid; place-items: center; color: var(--muted); font-size: 1rem;
}

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: rgba(255,255,255,.93); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: 0; color: var(--faint);
  padding: 12px 4px; font-size: .76rem; font-weight: 560; font-family: inherit;
}
.tabbar button.active { color: var(--accent); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.accent { background: linear-gradient(168deg, var(--accent-soft), var(--surface) 62%); border-color: #cfe0fa; }
.card.quiet { background: transparent; box-shadow: none; border-style: dashed; }
.card.flare { background: linear-gradient(168deg, var(--bad-soft), var(--surface) 62%); border-color: #f3cdc7; }
.card.good  { background: linear-gradient(168deg, var(--ok-soft), var(--surface) 62%); border-color: #c6e8d8; }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-card h3 { margin: 0; }

.big-num { font-size: 2.3rem; font-weight: 660; line-height: 1; letter-spacing: -.03em; }
.big-num.ok { color: var(--ok); } .big-num.mid { color: var(--warn); } .big-num.bad { color: var(--bad); }

/* ---------- buttons ---------- */
button, .secondary { font: inherit; font-family: inherit; cursor: pointer; }
.primary {
  background: var(--accent); color: #fff; border: 0;
  border-radius: 12px; padding: 14px 18px; font-weight: 640; width: 100%;
  box-shadow: 0 1px 2px rgba(31,98,201,.28), 0 6px 16px rgba(31,98,201,.22);
}
.primary:active { transform: translateY(1px); }
.primary.big { padding: 17px; font-size: 1.06rem; margin-top: 8px; }
.secondary {
  display: block; text-align: center; text-decoration: none;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 12px 16px; font-weight: 570;
}
.ghost { background: none; border: 0; color: var(--muted); padding: 12px; font-size: .9rem; }
.danger { background: var(--bad-soft); color: #8f2419; border: 1px solid #f0c4bd; border-radius: 12px; padding: 12px; font-weight: 570; }
.wide { width: 100%; display: block; margin-top: 8px; }
.file-label { cursor: pointer; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .86rem; color: var(--muted); margin-bottom: 6px; font-weight: 540; }
.field small { display: block; margin-top: 5px; color: var(--faint); font-size: .79rem; line-height: 1.45; }
.field input, .field select {
  width: 100%; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 11px; padding: 12px; font: inherit;
}
.field.inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field.inline > span { margin: 0; flex: 0 0 64px; }
.field.inline input { flex: 1; min-width: 120px; width: auto; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row .fine { margin-top: 2px; }
.switch { position: relative; width: 50px; height: 30px; flex: 0 0 50px; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch span {
  position: absolute; inset: 0; background: var(--line-strong); border-radius: 99px; transition: background .18s; pointer-events: none;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.22);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--muted);
  border-radius: 999px; padding: 9px 14px; font-size: .85rem;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 570; }
.chip.danger.on { background: var(--bad-soft); border-color: var(--bad); color: #8f2419; }

/* ---------- probe scale ---------- */
.probe-inst { font-size: 1.04rem; }
.probe-steps { margin: 10px 0 12px; padding-left: 20px; }
.probe-steps li { font-size: .89rem; color: var(--muted); margin-bottom: 5px; }
.scale-ends { display: flex; justify-content: space-between; font-size: .72rem; color: var(--faint); margin: -4px 0 8px; }
.scale { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; margin: 14px 0 10px; }
.dot-btn {
  aspect-ratio: 1; min-width: 0; padding: 0; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--muted); font-size: .8rem; font-weight: 640;
}
.dot-btn.dok  { border-color: #b7e0cd; color: var(--ok); }
.dot-btn.dmid { border-color: #f0d3a2; color: var(--warn); }
.dot-btn.dbad { border-color: #f0bdb5; color: var(--bad); }

/* ---------- gauge ---------- */
.gauge { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 8px; border: 1px solid var(--line); }
.gauge-fill { height: 100%; background: var(--ok); border-radius: 99px; transition: width .35s ease; }
.gauge-fill.warm { background: var(--warn); }
.gauge-fill.hot { background: var(--bad); }
.gauge-legend { display: flex; justify-content: space-between; font-size: .84rem; color: var(--muted); margin-bottom: 8px; }

/* ---------- status pill ---------- */
.status {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border-radius: 13px; border: 1px solid var(--line); background: var(--surface-2); margin-bottom: 12px;
}
.status-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 11px; background: var(--faint); }
.status.building     { background: var(--ok-soft);   border-color: #c6e8d8; }
.status.building .status-dot { background: var(--ok); }
.status.maintaining  { background: var(--accent-soft); border-color: #cfe0fa; }
.status.maintaining .status-dot { background: var(--accent); }
.status.overreaching { background: var(--warn-soft); border-color: #f0d3a2; }
.status.overreaching .status-dot { background: var(--warn); }
.status.detraining   { background: var(--bad-soft);  border-color: #f3cdc7; }
.status.detraining .status-dot { background: var(--bad); }
.status-text strong { display: block; font-size: 1rem; }

/* ---------- session preview ---------- */
.preview { list-style: none; margin: 4px 0 12px; padding: 0; }
.preview li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .93rem;
}
.preview li:last-child { border-bottom: 0; }
.preview li.preview-head {
  border-bottom: 0; padding: 12px 0 3px; font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.preview li.preview-head:first-child { padding-top: 4px; }
.preview em { color: var(--muted); font-size: .86rem; white-space: nowrap; }

/* ---------- session player ---------- */
.progressbar { height: 4px; background: var(--surface-2); border-radius: 99px; margin-bottom: 14px; overflow: hidden; border: 1px solid var(--line); }
.progressbar > div { height: 100%; background: var(--accent); transition: width .3s; }

.exercise-card { padding-bottom: 10px; }
.ex-head h2 { margin: 14px 0 2px; font-size: 1.5rem; }

.media {
  position: relative; width: 100%; aspect-ratio: 4/3;
  border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line);
}
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Photos get the same explicit cross-fade as drawings. They are opaque, so
   leaving the outgoing frame visible underneath happens to look right — but
   only by accident, and the two code paths should not behave differently. */
.media img { transition: opacity .35s ease; }
.media .frame-b { opacity: 0; }
.media.flip img:not(.frame-b) { opacity: 0; }
.media.flip .frame-b { opacity: 1; }
.media-figure { background: var(--surface); }
.media-figure .fig-frame { position: absolute; inset: 0; display: grid; place-items: center; padding: 4px; }
.media-figure .fig-frame svg { width: 100%; height: 100%; }
/* Drawings are TRANSPARENT, so unlike photos the outgoing frame must be faded
   out explicitly — otherwise both poses stack and you see a four-legged man.
   Note the specificity: `.media-figure .fig-frame` and `.media .frame-b` are
   both 0-2-0, so the later one wins. Every state below is therefore stated at
   a specificity that cannot be accidentally overridden by rule order. */
.media-figure .fig-frame          { opacity: 1; transition: opacity .3s ease; }
.media-figure .fig-frame.frame-b  { opacity: 0; }
.media-figure.flip .fig-frame     { opacity: 0; }
.media-figure.flip .fig-frame.frame-b { opacity: 1; }
.media-none { display: grid; place-items: center; aspect-ratio: 5/2; }
.media-ph { display: grid; place-items: center; gap: 6px; color: var(--faint); font-size: .8rem; }

.target { display: flex; align-items: baseline; gap: 10px; margin: 14px 0 12px; }
.target-num { font-size: 3.6rem; font-weight: 680; line-height: 1; letter-spacing: -.035em; }
.target-unit { font-size: 1.02rem; color: var(--muted); }
.each-side { display: block; font-size: .82rem; color: var(--accent-ink); letter-spacing: .04em; margin-top: 2px; }
.side-note {
  background: var(--accent-soft); border: 1px solid #cfe0fa; color: var(--accent-ink);
  border-radius: 10px; padding: 9px 11px; font-size: .84rem; margin-bottom: 10px;
}
.rotation-note {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; font-size: .84rem; color: var(--muted); margin-bottom: 10px;
}
.rotation-note .fine { display: block; margin-top: 3px; }
.hold-side { font-size: .84rem; color: var(--accent-ink); font-weight: 600; min-height: 1.2em; margin-bottom: 6px; }
.hold-num.leadin { color: var(--warn); }

.setup { font-size: .94rem; color: var(--muted); margin-bottom: 10px; }
.setup strong { color: var(--ink); }
.cues { margin: 0 0 12px; padding-left: 19px; }
.cues li { margin-bottom: 6px; font-size: .92rem; color: var(--muted); }

.knee-tag {
  font-size: .8rem; color: var(--warn); background: var(--warn-soft);
  border: 1px solid #f0d3a2; border-radius: 10px; padding: 9px 11px; margin-bottom: 12px;
}
.knee-tag.est { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.learn-more {
  width: 100%; background: none; border: 1px dashed var(--line-strong);
  color: var(--muted); border-radius: 11px; padding: 10px; font-size: .85rem;
  font-weight: 560; margin-bottom: 4px;
}
.learn-more:active { background: var(--surface-2); }
.evidence-note {
  font-size: .81rem; color: var(--muted); background: var(--surface-2);
  border-left: 3px solid var(--line-strong); border-radius: 0 8px 8px 0;
  padding: 10px 12px; margin-bottom: 12px; line-height: 1.5;
}

.holdtimer { text-align: center; margin: 14px 0; }
.hold-num { font-size: 4rem; font-weight: 680; font-variant-numeric: tabular-nums; margin-bottom: 8px; letter-spacing: -.035em; }
.hold-num.running { color: var(--accent); }
.hold-ring { display: block; margin: 0 auto 6px; }
.hold-ring circle { fill: none; stroke-width: 7; }
.hold-ring .bg { stroke: var(--surface-2); }
.hold-ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .95s linear; }

.logbox { border-top: 1px solid var(--line); padding-top: 15px; margin-top: 8px; }
.adjust { margin-top: 12px; }
.stepper { display: flex; gap: 8px; margin-top: 8px; align-items: stretch; }
.stepper button { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: 11px; width: 50px; font-size: 1.25rem; }
.stepper .secondary { width: auto; flex: 1; padding: 12px; }
.stepper input {
  flex: 1; min-width: 0; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 11px; text-align: center;
  font: 640 1.15rem/1 inherit; padding: 12px 4px;
}

.rest-card { text-align: center; }
.rest-num { font-size: 4.2rem; font-weight: 680; font-variant-numeric: tabular-nums; margin: 6px 0; letter-spacing: -.035em; color: var(--accent); }
.rest-next { color: var(--muted); font-size: .95rem; margin-bottom: 10px; }

/* ---------- sheets ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(19,26,36,.34);
  backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
  padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 20px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lift);
}
.sheet.tall { max-height: 92vh; }

.rir { display: grid; gap: 8px; margin-top: 12px; }
.rir-btn, .srpe-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
  border-radius: 12px; padding: 13px 14px;
}
.rir-btn:active, .srpe-btn:active { background: var(--accent-soft); }
.rir-btn strong, .srpe-btn strong { font-size: 1.15rem; min-width: 26px; color: var(--accent); }
.rir-btn span, .srpe-btn span { color: var(--muted); font-size: .9rem; }

.srpe { display: grid; gap: 6px; margin-top: 12px; }
.srpe-btn { padding: 11px 14px; }
.srpe-btn.s0 strong, .srpe-btn.s1 strong, .srpe-btn.s2 strong, .srpe-btn.s3 strong { color: var(--ok); }
.srpe-btn.s8 strong, .srpe-btn.s9 strong, .srpe-btn.s10 strong { color: var(--bad); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .axis { font-size: 9px; fill: var(--faint); }
.chart .band { fill: var(--ok-soft); }
.chart .line-main { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .area-fitness { fill: var(--accent-soft); }
.chart .line-fitness { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.chart .line-fatigue { fill: none; stroke: var(--warn); stroke-width: 2; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.chart .dot { fill: var(--accent); }
.chart .dot.ok { fill: var(--ok); } .chart .dot.mid { fill: var(--warn); } .chart .dot.bad { fill: var(--bad); }
.chart .bar-limit { fill: var(--surface-2); stroke: var(--line); }
.chart .bar-value { fill: var(--accent); }
.chart .bar-value.over { fill: var(--bad); }
.chart-empty { padding: 26px 10px; text-align: center; color: var(--faint); font-size: .86rem; background: var(--surface-2); border-radius: 12px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend .l-fit { background: var(--accent); }
.legend .l-fat { background: var(--warn); }

.meter { margin-bottom: 12px; }
.meter-head { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 5px; }
.meter-head strong { color: var(--muted); font-weight: 560; }
.meter-track { position: relative; height: 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.meter-zone { position: absolute; top: 0; bottom: 0; background: var(--ok-soft); }
.meter-fill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--accent); border-radius: 99px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px;
}
.stat b { display: block; font-size: 1.5rem; font-weight: 660; letter-spacing: -.02em; }
.stat span { font-size: .78rem; color: var(--faint); }

.levels { display: grid; gap: 15px; }
.level-top { display: flex; justify-content: space-between; font-size: .96rem; gap: 10px; }
.level-top em { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.level-bar { height: 7px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; margin: 6px 0 4px; overflow: hidden; }
.level-bar > div { height: 100%; background: var(--accent); border-radius: 99px; }
.level-bar.knee > div { background: var(--warn); }
.delta { font-size: .78rem; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.flat { color: var(--faint); } .delta.down { color: var(--bad); }
.maxed {
  margin-top: 6px; font-size: .79rem; line-height: 1.45; color: var(--accent-ink);
  background: var(--accent-soft); border: 1px solid #cfe0fa; border-radius: 9px; padding: 8px 10px;
}

.hist-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.hist-row:last-child { border-bottom: 0; }
.hist-right { text-align: right; display: grid; gap: 3px; }
.pill { background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; font-size: .76rem; color: var(--muted); }

/* ---------- library ---------- */
.lib-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  color: var(--ink); padding: 13px 0; text-align: left; font-size: .96rem;
}
.lib-row:last-child { border-bottom: 0; }
.lib-kp { font-size: .79rem; color: var(--warn); white-space: nowrap; font-weight: 570; }
.lib-kp.free { color: var(--ok); }
.lib-kp.hi { color: var(--bad); }
.kneebox { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px; font-size: .89rem; margin: 12px 0; line-height: 1.55; }

/* ---------- running ---------- */
.crit { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .93rem; color: var(--faint); }
.crit:last-child { border-bottom: 0; }
.crit.met { color: var(--ink); }
.crit .tick { color: var(--line-strong); font-size: 1rem; width: 18px; flex: 0 0 18px; }
.crit.met .tick { color: var(--ok); }

/* ---------- onboarding ---------- */
.onboard { padding-top: calc(env(safe-area-inset-top) + 28px); }
.onboard .wordmark { margin-bottom: 22px; }
.onboard .card { margin-top: 18px; }

.sync-badge { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--muted); }
.sync-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.sync-badge.on i { background: var(--ok); }
.sync-badge.off i { background: var(--faint); }

.banner {
  background: var(--accent-soft); border: 1px solid #cfe0fa; color: var(--accent-ink);
  border-radius: 12px; padding: 11px 13px; font-size: .85rem; margin-bottom: 14px;
}

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cal-nav strong { font-size: 1.02rem; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 5px; }
.cal-dow span { text-align: center; font-size: .7rem; color: var(--faint); font-weight: 600; letter-spacing: .04em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  position: relative; aspect-ratio: 1; border-radius: 9px; padding: 0;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: .82rem; display: grid; place-items: center;
}
.cal-cell.empty { border: 0; background: none; }
.cal-cell.done { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 640; }
.cal-cell.planned { background: var(--accent-soft); border-color: #cfe0fa; color: var(--accent-ink); }
.cal-cell.missed { background: var(--surface-2); border-style: dashed; border-color: var(--line-strong); color: var(--faint); }
.cal-cell.today, .cal-cell.today-due { border-color: var(--ink); border-width: 2px; color: var(--ink); font-weight: 640; }
.cal-cell.today-due { background: var(--accent-soft); }
.cal-day { line-height: 1; }
.cal-probe { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; }
.cal-probe.pok { background: var(--ok); }
.cal-probe.pmid { background: var(--warn); }
.cal-probe.pbad { background: var(--bad); }
.cal-cell.done .cal-probe.pok { background: #b8f0d8; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: .76rem; color: var(--muted); }
.cal-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--line); }
.cal-legend .k-done { background: var(--accent); border-color: var(--accent); }
.cal-legend .k-planned { background: var(--accent-soft); border-color: #cfe0fa; }
.cal-legend .k-missed { background: var(--surface-2); border-style: dashed; border-color: var(--line-strong); }
.cal-legend .k-today { background: var(--surface); border-color: var(--ink); border-width: 2px; }

.plan-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 11px 0; color: var(--ink);
}
.plan-row:last-of-type { border-bottom: 0; }
.plan-date { flex: 0 0 46px; text-align: center; }
.plan-date strong { display: block; font-size: .82rem; }
.plan-date span { font-size: .72rem; color: var(--faint); }
.plan-body { flex: 1; min-width: 0; }
.plan-body strong { font-size: .94rem; }
.plan-body .fine { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-meta { flex: 0 0 auto; font-size: .8rem; color: var(--faint); }

.preview-line { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .91rem; }
.preview-line:last-child { border-bottom: 0; }
.preview-line em { color: var(--faint); font-size: .84rem; white-space: nowrap; }

/* ---------- session phase + audio bar ---------- */
.phase-tag {
  display: inline-block; font-size: .72rem; font-weight: 640; letter-spacing: .07em;
  text-transform: uppercase; padding: 5px 10px; border-radius: 99px; margin-bottom: 12px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.phase-tag.warmup { background: var(--warn-soft); color: var(--warn); border-color: #f0d3a2; }
.phase-tag.main { background: var(--accent-soft); color: var(--accent-ink); border-color: #cfe0fa; }
.phase-tag.cooldown { background: var(--ok-soft); color: var(--ok); border-color: #c6e8d8; }

.audio-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.audio-toggle {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line-strong);
  color: var(--faint); border-radius: 10px; padding: 9px 8px; font-size: .8rem; font-weight: 560;
}
.audio-toggle.on { background: var(--accent-soft); border-color: #cfe0fa; color: var(--accent-ink); }

.evidence-note code {
  background: var(--surface); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: .88em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- update notice ---------- */
.update-bar {
  position: fixed; left: 12px; right: 12px; z-index: 70;
  bottom: calc(64px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff; border-radius: 13px;
  padding: 11px 12px; font-size: .86rem; box-shadow: var(--shadow-lift);
}
.update-bar span { flex: 1; }
.update-bar button {
  background: #fff; color: var(--ink); border: 0; border-radius: 9px;
  padding: 7px 13px; font-weight: 640; font-size: .84rem;
}
.update-bar button.later { background: transparent; color: #b9c3d2; font-weight: 500; }

/* ---------- version ---------- */
.version-line { margin-bottom: 8px; }
.version-line code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .95rem; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 9px; color: var(--ink);
}
.update-bar code { background: rgba(255,255,255,.16); border-radius: 5px; padding: 1px 5px; font-size: .92em; }

/* ---------- screen-awake indicator ---------- */
.awake-chip {
  flex: 1 0 100%; text-align: center; font-size: .76rem; font-weight: 560;
  border-radius: 9px; padding: 6px 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--faint);
}
.awake-chip.on { background: var(--ok-soft); border-color: #c6e8d8; color: var(--ok); }
.awake-chip.off { background: var(--warn-soft); border-color: #f0d3a2; color: var(--warn); }

/* ---------- recovery gate ---------- */
.recovery {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-radius: 11px; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.recovery strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.recovery span { flex: 1; font-size: .8rem; color: var(--muted); }
.recovery.ready { background: var(--ok-soft); border-color: #c6e8d8; }
.recovery.ready strong { color: var(--ok); }
.recovery.waiting { background: var(--warn-soft); border-color: #f0d3a2; }
.recovery.waiting strong { color: var(--warn); font-size: 1.5rem; }
.ready-anyway {
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted);
  border-radius: 8px; padding: 6px 11px; font-size: .78rem; font-weight: 560;
}
.primary:disabled, .secondary:disabled { opacity: .45; }

/* Screen-awake diagnostics: a plain, scrollable timeline. */
.awake-log {
  background: var(--sunken, #f2f4f7);
  border: 1px solid var(--line, #dfe3e8);
  border-radius: 10px;
  padding: 10px 12px;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  overflow: auto;
  max-height: 220px;
  margin: 8px 0;
}
.row-btns { display: flex; gap: 8px; }
.row-btns button { flex: 1; }

/* The wake log must be selectable — an installed iOS app fights you otherwise. */
.awake-log {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}
.env-report {
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}
.env-report strong { font-size: 14px; }
.env-report span { opacity: .85; }
.env-report code { font-size: 12px; word-break: break-all; }
.env-report.bad { background: #fdecec; border: 1px solid #f2b8b8; color: #7a1f1f; }
.env-report.ok  { background: #eaf7ee; border: 1px solid #b7e3c3; color: #14532d; }
