/* ATM Half 2026 · pre-dawn Bangkok
   indigo night sky · sodium-streetlight amber · race-bib condensed type */

:root {
  --bg: #0E1220;
  --card: #181D2E;
  --card2: #1E2438;
  --line: #262D44;
  --ink: #ECEDF4;
  --ink2: #9AA2BC;
  --mut: #6A7190;
  --amber: #F5A623;
  --amber-soft: rgba(245, 166, 35, 0.14);
  --amber-ink: #171223;
  --ok: #5BC08C;
  --base: #2AA18E;
  --build: #C9821C;
  --peak: #D95379;
  --taper: #9D7BEA;
  --disp: 'Avenir Next Condensed', 'HelveticaNeue-CondensedBold', 'Arial Narrow', system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--body);
  color: var(--ink);
  background: linear-gradient(180deg, #0E1220 0%, #131024 62%, #1B1430 100%) fixed;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
a { color: var(--amber); }

/* ── header ─────────────────────────────────────── */
.top {
  padding: calc(14px + env(safe-area-inset-top)) 18px 10px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.wordmark, .top-race {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--mut);
  white-space: nowrap;
}
.top-race { color: var(--ink2); }

main { padding: 6px 16px 24px; max-width: 560px; margin: 0 auto; }

/* ── bib hero (signature) ───────────────────────── */
.bib {
  position: relative;
  background: var(--amber);
  color: var(--amber-ink);
  border-radius: 14px;
  padding: 30px 18px 18px;
  text-align: center;
  transform: rotate(-1.1deg);
  margin: 14px 6px 22px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}
.bib::before, .bib::after {
  content: '';
  position: absolute; top: 12px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}
.bib::before { left: 26px; }
.bib::after { right: 26px; }
.bib-strip {
  font-family: var(--disp); font-weight: 700;
  font-size: 13px; letter-spacing: 0.18em;
}
.bib-num {
  font-family: var(--disp); font-weight: 800;
  font-size: clamp(76px, 27vw, 128px);
  line-height: 0.98;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.bib-sub {
  font-family: var(--disp); font-weight: 700;
  font-size: 14px; letter-spacing: 0.16em;
  border-top: 2px solid rgba(23, 18, 35, 0.25);
  margin-top: 10px; padding-top: 9px;
}

/* ── cards / sections ───────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.card.accent { border-color: rgba(245, 166, 35, 0.45); background: linear-gradient(180deg, var(--amber-soft), var(--card) 55%); }

.eyebrow {
  font-family: var(--disp); font-weight: 700;
  font-size: 12px; letter-spacing: 0.16em;
  color: var(--mut);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.h-disp {
  font-family: var(--disp); font-weight: 700;
  font-size: 22px; letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ── stat tiles ─────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 10px 10px; text-align: center;
}
.tile .v {
  font-family: var(--disp); font-weight: 800; font-size: 30px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile .v small { font-size: 17px; font-weight: 700; color: var(--ink2); }
.tile .l { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mut); margin-top: 5px; }

/* ── today workout card ─────────────────────────── */
.today-run { display: flex; gap: 12px; align-items: flex-start; }
.today-run .txt { flex: 1; }
.today-run .w-title { font-size: 16.5px; font-weight: 650; line-height: 1.35; }
.today-run .w-meta { color: var(--ink2); font-size: 13px; margin-top: 5px; line-height: 1.45; }

.bigcheck {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card2);
  display: grid; place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.bigcheck svg { width: 22px; height: 22px; fill: none; stroke: var(--mut); stroke-width: 3; }
.bigcheck.on { background: var(--ok); border-color: var(--ok); }
.bigcheck.on svg { stroke: #0c2417; }

/* ── phase chips / legend ───────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink2); }
.chip i { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ── mileage ramp chart ─────────────────────────── */
.ramp { padding: 6px 2px 0; }
.ramp-bars { display: flex; align-items: flex-end; gap: 2px; height: 86px; margin-top: 20px; }
.ramp-bar {
  flex: 1; min-width: 0; position: relative;
  border-radius: 4px 4px 0 0;
  padding: 0; display: block; overflow: visible;
}
.ramp-bar.cur { outline: 2px solid var(--amber); outline-offset: 1px; }
.ramp-bar .lab {
  position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; color: var(--ink2);
  font-variant-numeric: tabular-nums;
}
.ramp-x { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10.5px; color: var(--mut); }
.ramp-bar .tick {
  position: absolute; left: -1px; right: -1px; height: 2px;
  background: #fff; opacity: 0.9; border-radius: 1px;
}
.tickchip { width: 9px; height: 2px; border-radius: 1px; background: #fff; flex: none; }

#tip {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--card2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; color: var(--ink);
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
  opacity: 0; transition: opacity 0.12s;
  white-space: nowrap;
}
#tip.show { opacity: 1; }

/* ── week cards ─────────────────────────────────── */
.week { border-left: 3px solid var(--line); }
.week.cur { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(245,166,35,0.35); }
.week-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.week-head .wn {
  font-family: var(--disp); font-weight: 800; font-size: 21px;
  min-width: 46px; font-variant-numeric: tabular-nums;
}
.week-head .wd { flex: 1; }
.week-head .wd .dates { font-size: 12.5px; color: var(--ink2); }
.week-head .wd .focus { font-size: 13px; margin-top: 2px; line-height: 1.35; }
.week-head .wkm {
  font-family: var(--disp); font-weight: 700; font-size: 15px;
  color: var(--ink2); font-variant-numeric: tabular-nums; white-space: nowrap;
  text-align: right;
}
.week-head .wkm .ran { display: block; font-size: 11px; color: var(--ok); letter-spacing: 0.04em; }
.week-head .phase-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.week-head .caret { color: var(--mut); font-size: 11px; transition: transform 0.15s; }
.week.open .caret { transform: rotate(90deg); }

.days { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }
.day {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; width: 100%; text-align: left;
  border-bottom: 1px solid rgba(38, 45, 68, 0.5);
}
.day:last-child { border-bottom: none; }
.day .dow {
  font-family: var(--disp); font-weight: 700; font-size: 13px;
  letter-spacing: 0.06em; color: var(--mut); min-width: 34px;
}
.day .w { flex: 1; font-size: 14px; line-height: 1.4; }
.day.rest .w { color: var(--mut); }
.day.key .w { font-weight: 650; }
.day.today-row { background: var(--amber-soft); border-radius: 8px; padding-left: 8px; padding-right: 6px; }
.day .cb {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card2);
  display: grid; place-items: center;
}
.day .cb svg { width: 13px; height: 13px; fill: none; stroke: transparent; stroke-width: 3.2; }
.day.done .cb { background: var(--ok); border-color: var(--ok); }
.day.done .cb svg { stroke: #0c2417; }
.day.done .w { text-decoration: line-through; color: var(--mut); font-weight: 400; }
.day.auto .w { text-decoration: none; color: var(--ink); }
.day .act { display: block; color: var(--ok); font-size: 12px; margin-top: 2px; font-family: var(--mono); }
.day.race-row .w { color: var(--amber); font-weight: 750; }

/* ── pace calculator ────────────────────────────── */
.pace-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.pace-row input {
  width: 90px; padding: 9px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card2); color: var(--ink);
  font-family: var(--mono); font-size: 16px; text-align: center;
}
.pace-row .go {
  background: var(--amber); color: var(--amber-ink);
  font-family: var(--disp); font-weight: 700; letter-spacing: 0.08em;
  padding: 9px 16px; border-radius: 9px; font-size: 14px;
}
.pace-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 14px; }
.pace-grid .k { color: var(--ink2); }
.pace-grid .p { font-family: var(--mono); font-size: 13.5px; }
.pace-grid .p b { color: var(--amber); font-weight: 650; }

/* ── checklist ──────────────────────────────────── */
.group-head { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 8px; }
.group-head .h-disp { flex: 1; font-size: 19px; }
.group-head .prog { font-family: var(--mono); font-size: 12.5px; color: var(--mut); }
.group-head .prog.full { color: var(--ok); }
.ck {
  display: flex; align-items: flex-start; gap: 11px;
  width: 100%; text-align: left; padding: 9px 2px;
  border-bottom: 1px solid rgba(38, 45, 68, 0.5);
}
.ck:last-child { border-bottom: none; }
.ck .cb {
  flex: none; width: 24px; height: 24px; border-radius: 7px; margin-top: 1px;
  border: 2px solid var(--line); background: var(--card2);
  display: grid; place-items: center;
}
.ck .cb svg { width: 13px; height: 13px; fill: none; stroke: transparent; stroke-width: 3.2; }
.ck.done .cb { background: var(--ok); border-color: var(--ok); }
.ck.done .cb svg { stroke: #0c2417; }
.ck .t { flex: 1; font-size: 14px; line-height: 1.45; }
.ck.done .t { color: var(--mut); text-decoration: line-through; }
.ck .t a { font-weight: 600; }
.ck.hot .t { font-weight: 650; }

/* ── race day ───────────────────────────────────── */
.reg-grid { display: flex; gap: 14px; align-items: center; }
.reg-grid > div { flex: 1; min-width: 0; }
.reg-name { font-family: var(--disp); font-weight: 700; font-size: 18px; letter-spacing: 0.04em; }
.reg-cat { font-size: 12px; color: var(--ink2); margin-top: 2px; line-height: 1.4; }
.reg-code { font-family: var(--mono); font-size: 17px; color: var(--amber); margin-top: 8px; letter-spacing: 0.06em; }
.reg-btn {
  display: inline-block; margin-top: 10px;
  background: var(--amber); color: var(--amber-ink);
  font-family: var(--disp); font-weight: 700; letter-spacing: 0.08em; font-size: 13px;
  padding: 8px 12px; border-radius: 9px; text-decoration: none;
}
.reg-qr { flex: none; width: 110px; height: 110px; border-radius: 10px; background: #fff; image-rendering: pixelated; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fact { background: var(--card2); border-radius: 10px; padding: 10px 11px; }
.fact .k { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mut); }
.fact .v { font-size: 14px; font-weight: 650; margin-top: 3px; line-height: 1.35; }
.fact.wide { grid-column: 1 / -1; }

.tl { list-style: none; }
.tl li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid rgba(38,45,68,0.5); }
.tl li:last-child { border-bottom: none; }
.tl .tt {
  font-family: var(--mono); font-size: 13px; color: var(--amber);
  min-width: 50px; padding-top: 1px; font-variant-numeric: tabular-nums;
}
.tl .tx { flex: 1; font-size: 14px; line-height: 1.45; }
.tl li.big .tx { font-weight: 700; color: var(--amber); }

.ptable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ptable th {
  font-family: var(--disp); font-weight: 700; font-size: 12px; letter-spacing: 0.08em;
  color: var(--mut); text-transform: uppercase; text-align: right;
  padding: 4px 6px; border-bottom: 1px solid var(--line);
}
.ptable th:first-child { text-align: left; }
.ptable td {
  font-family: var(--mono); font-size: 12.5px; text-align: right;
  padding: 7px 6px; border-bottom: 1px solid rgba(38,45,68,0.5); color: var(--ink2);
}
.ptable td:first-child { text-align: left; font-family: var(--disp); font-weight: 700; font-size: 15px; color: var(--ink); }
.ptable tr:last-child td { border-bottom: none; }
.ptable tr.dim td { color: var(--mut); }

.course { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--ink2); line-height: 1.7; }
.course b { color: var(--ink); font-weight: 650; }
.course .arr { color: var(--mut); }

.note { font-size: 12.5px; color: var(--mut); line-height: 1.5; margin-top: 9px; }

/* ── tab bar ────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex;
  background: rgba(14, 18, 32, 0.92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0 4px; color: var(--mut); border-radius: 10px;
}
.tab svg { width: 21px; height: 21px; fill: currentColor; }
.tab span {
  font-family: var(--disp); font-weight: 700; font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tab.on { color: var(--amber); }

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