/* Layout: one phone-width column, a football-field progress strip on top, big plate-style numbers in the gym.
   Color: stadium-night navy, chalk white, pylon orange. Phase colors come from bumper plates. */
:root {
  --bg: #EDF0F4;
  --surface: #FFFFFF;
  --surface-2: #E2E7EE;
  --ink: #101C2E;
  --muted: #55657A;
  --line: #CFD7E1;
  --accent: #C8430A;
  --accent-ink: #FFFFFF;
  --good: #14774A;
  --warn: #9A6A0B;
  --bad: #B3321F;
  --turf: #1F6E3F;
  --turf-2: #1A6036;
  --plate-blue: #1F5FBF;
  --plate-yellow: #E8B923;
  --plate-green: #2E8B57;
  --plate-red: #C9302C;
  --plate-white: #F4F6F8;
  --plate-orange: #E8691E;
  --plate-ink: #2B3A50;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Barlow", -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C1524;
    --surface: #152236;
    --surface-2: #1E2F48;
    --ink: #EDF2F8;
    --muted: #9BADC2;
    --line: #2A3D58;
    --accent: #FF7D33;
    --accent-ink: #1E0C02;
    --good: #4CCB8A;
    --warn: #E9B949;
    --bad: #FF8A75;
    --plate-ink: #8FA3BC;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 500 16px/1.45 var(--body);
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  overscroll-behavior-y: none;
}
body.resting { padding-bottom: calc(148px + env(safe-area-inset-bottom, 0px)); }
#app { max-width: 560px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.boot { padding-top: 40vh; text-align: center; color: var(--muted); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .01em; line-height: 1.02; text-wrap: balance; }
h1 { font-size: 46px; font-weight: 900; }
h2 { font-size: 26px; }
h3 { font-size: 21px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.stack { display: grid; gap: 12px; }
.section { margin-top: 28px; display: grid; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; min-width: 0; }

/* top bar */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; margin-bottom: 4px;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.brand { font-family: var(--display); font-weight: 900; font-size: 20px; letter-spacing: .02em; text-transform: uppercase; line-height: 1; }
.brand b { color: var(--accent); font-weight: 900; }
.top-right { display: flex; align-items: center; gap: 6px; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 0 4px; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.sync.pending i { background: var(--warn); }
.sync.off i { background: var(--bad); }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.iconbtn svg { width: 22px; height: 22px; }

/* field strip */
.field { display: grid; gap: 6px; }
.field svg { display: block; width: 100%; height: auto; border-radius: 6px; }
.field-cap { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); }
.field-cap strong { color: var(--ink); font-weight: 700; }

/* phase chip */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(128,128,128,.5); flex: none; }
.c-white { background: var(--plate-white); }
.c-blue { background: var(--plate-blue); }
.c-yellow { background: var(--plate-yellow); }
.c-red { background: var(--plate-red); }
.c-orange { background: var(--plate-orange); }
.c-green { background: var(--plate-green); }
.c-ink { background: var(--plate-ink); }
.chip.test { background: var(--accent); color: var(--accent-ink); }
.chip.deload { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* week day strip */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 16px; }
.day { min-height: 58px; border-radius: 6px; display: grid; justify-items: center; align-content: center; gap: 3px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.day b { font-family: var(--display); font-size: 19px; font-weight: 800; color: var(--ink); line-height: 1; }
.day.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.day .mk { height: 12px; font-size: 12px; line-height: 12px; font-weight: 700; }
.mk.done { color: var(--good); }
.mk.partial { color: var(--warn); }
.mk.missed { color: var(--bad); }

/* session */
.sess-head { margin-top: 18px; display: grid; gap: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--muted); font-size: 15px; }
.notice { border-left: 3px solid var(--accent); padding: 8px 12px; background: var(--surface); border-radius: 0 6px 6px 0; font-size: 15px; }
.notice.coach { border-left-color: var(--plate-blue); }
.notice b { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.warm { padding: 2px 14px; gap: 0; }
.warm summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; justify-content: space-between; list-style: none; }
.warm summary::-webkit-details-marker { display: none; }
.warm summary::after { content: "+"; font-size: 22px; color: var(--muted); }
.warm[open] summary::after { content: "\2212"; }
.warm ul { margin: 0; padding: 0 0 6px 18px; color: var(--muted); }

.ex { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; min-width: 0; }
.ex.complete { border-color: var(--good); }
.ex-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ex-top > div { min-width: 0; }
.big { font-family: var(--display); font-weight: 900; font-size: 38px; line-height: 1; }
.big small { font-size: 18px; font-weight: 800; color: var(--muted); margin-left: 3px; }
.presc { font-weight: 600; }
.cue { font-size: 14px; color: var(--muted); }
.plates { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.plate { min-width: 30px; height: 26px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 3px; font-weight: 700; font-size: 13px; color: #fff; }
.p45 { background: var(--plate-blue); }
.p35 { background: var(--plate-yellow); color: #1a1405; }
.p25 { background: var(--plate-green); }
.p10 { background: var(--plate-white); color: #1a2433; border: 1px solid #a9b4c2; }
.p5 { background: var(--plate-red); }
.p2 { background: #6C7A8C; }
.setrows { display: grid; gap: 6px; }
.setrow { display: grid; grid-template-columns: 26px 1fr 14px 1fr 48px; gap: 6px; align-items: center; }
.setrow .n { color: var(--muted); font-size: 14px; font-weight: 700; text-align: center; }
.setrow .x { color: var(--muted); text-align: center; }
.setrow input { width: 100%; min-width: 0; height: 46px; text-align: center; font-size: 18px; font-weight: 700; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; }
.setrow.done input { background: transparent; color: var(--muted); }
.setrow .tag { grid-column: 2 / -1; font-size: 13px; color: var(--muted); margin-top: -2px; }
.tick { width: 48px; height: 46px; border-radius: 6px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); background: var(--bg); }
.tick svg { width: 22px; height: 22px; }
.setrow.done .tick { background: var(--good); border-color: var(--good); color: var(--surface); }
.rpepick { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.rpepick button { height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-weight: 700; font-size: 15px; color: var(--muted); }
.rpepick button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); font-weight: 700; color: var(--muted); }
.pill.done { background: var(--good); border-color: var(--good); color: var(--surface); }
.pill.wide { width: auto; padding: 0 18px; border-radius: 8px; }
.metric { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.metric input, .field-in { width: 100%; height: 46px; padding: 0 10px; font-size: 18px; font-weight: 700; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.lastlog { font-size: 13px; color: var(--muted); }
.rpes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rpe { height: 46px; border: 1px solid var(--line); border-radius: 6px; font-weight: 700; background: var(--bg); }
.rpe.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
textarea { width: 100%; min-height: 72px; padding: 10px; font-size: 16px; font-weight: 500; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.btn { min-height: 50px; padding: 0 18px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-weight: 800; font-size: 21px; text-transform: uppercase; letter-spacing: .03em; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-family: var(--body); font-size: 16px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.btn.block { width: 100%; }
.btn.slim { min-height: 46px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-weight: 600; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: grid; gap: 2px; min-width: 0; }
.stat .v { font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 1; }
.stat .l { font-size: 13px; color: var(--muted); }

/* rest timer */
#rest { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); z-index: 24; background: var(--ink); color: var(--bg); padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#rest .t { font-family: var(--display); font-size: 32px; font-weight: 900; line-height: 1; }
#rest button { min-height: 44px; min-width: 56px; padding: 0 10px; font-weight: 700; border: 1px solid currentColor; border-radius: 6px; }

/* tabs */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
#tabs button { height: 64px; display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
#tabs button svg { width: 24px; height: 24px; }
#tabs button.on { color: var(--accent); }

/* plan */
.phase { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.phase-head { width: 100%; padding: 14px; text-align: left; display: grid; gap: 4px; }
.phase-head .row h3 { display: flex; align-items: center; gap: 8px; }
.phase-body { padding: 0 14px 12px; display: grid; gap: 4px; }
.wk { border-top: 1px solid var(--line); }
.wk-head { width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; font-weight: 600; }
.wk-head .dts { display: flex; gap: 3px; flex: none; }
.wk-head .dts i { width: 9px; height: 9px; border-radius: 2px; background: var(--surface-2); }
.wk-head .dts i.done { background: var(--good); }
.wk-head .dts i.partial { background: var(--warn); }
.wk-head .dts i.missed { background: var(--bad); }
.wk-now { color: var(--accent); }
.dayrow { width: 100%; min-height: 46px; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; padding-left: 10px; font-size: 15px; }
.dayrow .mk { font-weight: 700; font-size: 13px; }

/* progress */
.lift { display: grid; gap: 4px; }
.lift + .lift { border-top: 1px solid var(--line); padding-top: 10px; }
.lift .row { align-items: baseline; }
.lift .cur { font-family: var(--display); font-size: 28px; font-weight: 900; line-height: 1; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; min-width: 4px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.seg button { min-height: 44px; border-radius: 6px; font-weight: 600; font-size: 14px; background: var(--surface-2); color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--bg); }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; overflow: visible; }
.chart .axis { fill: var(--muted); font: 600 11px var(--body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .guide { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 5; fill: none; }
.chart .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .pt.est { fill: var(--surface); stroke: var(--accent); }
.chart .lab { fill: var(--ink); font: 700 12px var(--body); }
.chart-tip { min-height: 20px; font-size: 14px; color: var(--muted); }
.grid6 { display: grid; grid-template-columns: 56px repeat(6, 1fr); gap: 4px; align-items: center; font-size: 13px; }
.grid6 .h { text-align: center; color: var(--muted); font-weight: 600; }
.grid6 .wl { color: var(--muted); font-weight: 600; }
.cell { height: 30px; border-radius: 4px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: transparent; }
.cell.done { background: var(--good); color: var(--surface); }
.cell.partial { background: var(--warn); color: var(--surface); }
.cell.missed { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cell.off { background: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.mtable { width: 100%; border-collapse: collapse; font-size: 15px; }
.mtable th { text-align: right; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 0 0 6px 8px; font-weight: 700; }
.mtable th:first-child, .mtable td:first-child { text-align: left; padding-left: 0; }
.mtable td { text-align: right; padding: 8px 0 8px 8px; border-top: 1px solid var(--line); }
.addm { display: grid; grid-template-columns: 1fr 88px auto; gap: 6px; }
select.field-in { font-size: 15px; font-weight: 600; padding: 0 6px; min-width: 0; }
.note { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.note:first-child { border-top: 0; padding-top: 0; }
.note .who { font-size: 13px; color: var(--muted); font-weight: 600; }
.note p { overflow-wrap: anywhere; }
.check { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; width: 100%; text-align: left; min-height: 46px; }
.check .bx { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; color: transparent; }
.check .bx svg { width: 18px; height: 18px; }
.check.on .bx { background: var(--good); border-color: var(--good); color: var(--surface); }
.log { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 50px; text-align: left; border-top: 1px solid var(--line); }
.log:first-of-type { border-top: 0; }

/* fuel */
.macro { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.meal { display: grid; grid-template-columns: 92px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.meal:first-child { border-top: 0; padding-top: 0; }
.meal b { font-weight: 700; }
.lbl { display: grid; gap: 4px; font-size: 14px; color: var(--muted); font-weight: 600; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rule { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.rule:first-child { border-top: 0; padding-top: 0; }
.rule b { font-weight: 700; }

/* settings + lock */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; padding: calc(env(safe-area-inset-top, 0px) + 8px) max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.sheet-in { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; }
.lock { min-height: 80vh; display: grid; align-content: center; gap: 16px; padding: 24px 0; }
.err { color: var(--bad); font-weight: 600; font-size: 15px; }
#toast { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); left: 50%; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 6px; font-weight: 600; font-size: 15px; max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: no-preference) {
  .bar i { transition: width .3s ease; }
}
