:root {
  --bg: #08080a; --card: #131317; --card2: #1a1a20; --line: #26262e; --text: #ececf1; --muted: #9b9ba8;
  --accent: #E84A8A; --accent-ink: #1a0810; --good: #8fe0b0; --warn: #ffcf8f; --bad: #ff8f8f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar: 68px; --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* App shell (v13): html/body locked to the screen; #app scrolls; tab bar is a normal flex child.
   Avoids iOS position:fixed + visualViewport quirks that left the bar floating mid-screen after resume. */
html { height: 100%; background: var(--bg); }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
body {
  position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden;
  display: flex; flex-direction: column; overscroll-behavior-y: none;
}
#app { flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.2px; margin: 0 0 8px; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.06rem; }
a { color: var(--accent); }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; } .tiny { font-size: 0.75rem; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }

/* Sticky app bar: stays at the top while scrolling (back arrow always reachable) */
.appbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; min-height: calc(env(safe-area-inset-top) + 60px);
  background: rgba(8, 8, 10, 0.88); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.appbar h1 { margin: 0; font-size: 1.3rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .back { width: 48px; height: 48px; border-radius: 14px; border: 0; background: transparent; color: var(--accent); display: grid; place-items: center; font-size: 1.6rem; cursor: pointer; margin-left: -6px; }
.appbar .back:active { background: var(--card2); }
.appbar .bar-action { min-height: 44px; }

main { padding: 12px 14px 24px; max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.card.tone-good { border-color: #2c4a3a; } .card.tone-warn { border-color: #5a4626; } .card.tone-info { border-color: #2a3350; }
.card h3 { margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

button, .btn { font: inherit; min-height: 48px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
button:active, .btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-big { min-height: 60px; font-size: 1.1rem; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }
button:disabled { opacity: 0.5; }
input, select, textarea { font: inherit; color: var(--text); background: #0f0f13; border: 1px solid var(--line); border-radius: 12px; min-height: 48px; padding: 10px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { text-decoration: none; display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { min-height: 44px; border: 0; background: transparent; border-radius: 10px; }
.seg button.on { background: var(--card2); color: var(--accent); font-weight: 600; }

/* Bottom tab bar: flex child of the app shell (not position:fixed - that floated mid-screen on iOS) */
.tabbar { flex: 0 0 auto; z-index: 60; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(12, 12, 15, 0.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
body.typing .tabbar, body.typing .update-banner { visibility: hidden; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 0.75rem; min-height: 56px; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); }

/* Rings */
.rings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; }
.ring svg { display: block; margin: 0 auto; }
.ring-bg { stroke: #24242c; } .ring-val { fill: var(--text); font-size: 15px; font-weight: 700; } .ring-sub { fill: var(--muted); font-size: 10px; }
.ring-label { font-size: 0.8rem; margin-top: 2px; } .ring-sub2 { font-size: 0.7rem; color: var(--muted); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; min-height: 56px; width: 100%; background: none; border: 0; border-radius: 0; text-align: left; color: inherit; text-decoration: none; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .chev { color: var(--muted); font-size: 1.3rem; }
.kpi { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 650; background: var(--card2); border: 1px solid var(--line); }
.q-excellent { background: #1d3b2b; color: #8fe0b0; border-color: #2c5a40; } .q-good { background: #243b1d; color: #c4e08f; border-color: #3b5a2c; }
.q-poor { background: #3f311a; color: #ffcf8f; border-color: #5a4626; } .q-bad { background: #401c1c; color: #ff9f9f; border-color: #5a2626; } .q-unknown { color: var(--muted); }
.score-dial { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; font-family: var(--serif); border: 6px solid; }

/* Training */
.setrow { display: grid; grid-template-columns: 30px 1fr 1fr 64px; gap: 8px; align-items: center; padding: 6px 0; }
.setrow .num { color: var(--muted); text-align: center; font-weight: 600; }
.setrow input { text-align: center; font-size: 1.15rem; min-height: 54px; padding: 6px; }
.setrow .tick { min-height: 60px; min-width: 60px; padding: 0; font-size: 1.6rem; border-radius: 16px; }
.setrow.done .tick { background: var(--good); color: #0b2a19; border-color: var(--good); }
.setrow.warm .num { color: #666; }
.target { font-size: 0.8rem; color: var(--accent); text-align: center; }
.timer { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 10px); z-index: 55; background: var(--card2); border: 1px solid var(--accent); border-radius: 18px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.timer .t { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; flex: 1; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 92px; padding: 6px 4px; text-align: center; font-size: 0.72rem; display: flex; flex-direction: column; gap: 3px; align-items: stretch; color: var(--text); }
.day.today { border-color: var(--accent); }
.day .dn { color: var(--muted); font-size: 0.7rem; }
.pill { border-radius: 8px; padding: 2px 3px; background: var(--card2); line-height: 1.2; }
.pill.lift { background: #22305a; color: #cfdcff; } .pill.run { background: #1e3b2d; color: #bfeccc; } .pill.mob { background: #3b2f1e; color: #f1d9b0; } .pill.core { background: #3a1f3b; color: #f0c4f1; } .pill.done { outline: 1px solid var(--good); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #22222a; stroke-width: 1; } .chart .axis { fill: var(--muted); font-size: 10px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* Sheets and toasts */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet { background: var(--card); width: 100%; max-height: 88vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 14px); z-index: 90; background: #e9eeff; color: #0b1430; padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: 90vw; }
video.scan { width: 100%; border-radius: 14px; background: #000; aspect-ratio: 4/3; object-fit: cover; }
.credit { font-size: 0.75rem; color: var(--muted); }
.steps-list li { margin: 6px 0; }
ol.method { padding-left: 20px; } ol.method li { margin-bottom: 8px; }
table.t { width: 100%; border-collapse: collapse; font-size: 0.9rem; } table.t td, table.t th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; } table.t td.n, table.t th.n { text-align: right; }
.working { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; background: #0e0e12; border: 1px solid var(--line); border-radius: 12px; padding: 10px; white-space: pre-wrap; }
.tabbar[hidden] { display: none; }

/* Oct 2026 update */
.toast-undo { display: flex; align-items: center; gap: 12px; }
.toast-undo .btn-sm { background: #0b1430; color: #e9eeff; border-color: #0b1430; min-height: 36px; }
.update-banner { position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 8px); z-index: 95; }
.update-banner button { width: 100%; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.ss-badge { background: #3a1f3b; color: #f0c4f1; border-color: #5a2e5b; }
.card.superset { border-left: 3px solid #b88ad0; }
.sess-clock .kpi { font-size: 1.4rem; }
.sess-clock.on #sessPace, .sess-clock.start #sessPace { color: var(--good); } .sess-clock.behind #sessPace, .sess-clock.over #sessPace { color: var(--warn); }
.plates { display: flex; gap: 4px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.plate { display: inline-grid; place-items: center; min-width: 34px; padding: 0 6px; border-radius: 6px; font-weight: 700; font-size: .8rem; color: #0b0b0e; background: #ccc; }
.plate.p25 { background: #ff8f8f; height: 64px; } .plate.p20 { background: #8fb0ff; height: 60px; } .plate.p15 { background: #ffcf8f; height: 54px; } .plate.p10 { background: #8fe0b0; height: 48px; }
.plate.p5 { background: #e9eeff; height: 40px; } .plate.p2_5 { background: #c9a0ff; height: 34px; } .plate.p1_25 { background: #b0b0b8; height: 30px; }
.hx-row { display: grid; grid-template-columns: 1fr 110px; gap: 8px; align-items: center; padding: 4px 0; border-top: 1px solid var(--line); }
.hx-row input { text-align: center; font-size: 1.1rem; }
.hx-split { padding: 6px 0; border-top: 1px solid var(--line); } .hx-split input[type=range] { min-height: 36px; padding: 0; }
.photo-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-compare figure { margin: 0; text-align: center; } .photo-compare img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: #000; }
.photo-grid { display: grid; gap: 8px; margin-top: 8px; } .photo-day .row { gap: 6px; }
.photo-thumb { padding: 0; min-height: 0; border-radius: 10px; overflow: hidden; width: 64px; height: 86px; } .photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aisle-order .item { min-height: 48px; padding: 4px 2px; }
.water-bar { height: 10px; border-radius: 999px; background: #1a2233; overflow: hidden; } .water-bar span { display: block; height: 100%; background: #7fc8ff; border-radius: 999px; }
.day-nav strong { font-size: 0.95rem; }
/* v12: unplanned sports and activities */
.vh { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
fieldset.plain { border: 0; padding: 0; margin: 0 0 10px; min-width: 0; } fieldset.plain legend { padding: 0; margin-bottom: 6px; }
.chips.wrap { flex-wrap: wrap; overflow-x: visible; }
label.chip { cursor: pointer; position: relative; } label.chip:has(input:focus-visible), .seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg label { min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 10px; cursor: pointer; position: relative; }
.seg label.on { background: var(--card2); color: var(--accent); font-weight: 600; }
.activity-burn { margin-top: 10px; padding: 8px 10px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); }

/* Lift Planner extras */
.reorder { display: flex; flex-direction: column; gap: 4px; }
.reorder button { min-height: 40px; min-width: 44px; padding: 4px 8px; }
.ex-type { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.prog-day { border-left: 3px solid var(--accent); padding-left: 10px; margin-bottom: 12px; }
.onboard-steps { counter-reset: step; }
.onboard-steps .field label::before { counter-increment: step; }
