/* everyday — trail dark.
   Pine charcoal field, fern green identity, blaze orange reserved for race day.
   Type: Barlow Condensed (bib numerals + labels), system sans for prose. */

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/barlow-condensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/barlow-condensed-700.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #12170E;
  --surface: #1A2114;
  --surface-2: #242C1B;
  --ink: #F2F1E5;
  --ink-2: #AEB49C;
  --ink-3: #8A9178; /* notes/dow letters ≥4.5:1 on --bg and --surface */
  --fern: #7FB069;
  --fern-soft: rgba(127, 176, 105, 0.14);
  --moss: #9DA87B;
  --blaze: #FF6B35;
  --line: rgba(242, 241, 229, 0.08);
  --track: rgba(242, 241, 229, 0.1);
  --radius: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", var(--font-sans);
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --tabs-h: 64px;
  /* Faint topographic contours — the one texture in the app. */
  --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 320'%3E%3Cg fill='none' stroke='%23F2F1E5' stroke-opacity='0.05' stroke-width='1.3'%3E%3Cpath d='M300 110 C300 84 322 66 348 68 C374 70 392 88 390 112 C388 136 366 152 340 150 C314 148 300 136 300 110 Z'/%3E%3Cpath d='M272 112 C270 72 306 42 352 46 C398 50 424 80 420 118 C416 156 378 180 334 176 C290 172 274 152 272 112 Z'/%3E%3Cpath d='M244 114 C240 60 292 18 356 24 C420 30 456 72 450 124 C444 176 392 208 328 202 C264 196 248 168 244 114 Z'/%3E%3Cpath d='M216 116 C210 48 278 -6 360 2 C442 10 488 64 480 130 C472 196 406 236 322 228 C238 220 222 184 216 116 Z'/%3E%3Cpath d='M60 250 C60 232 76 220 96 222 C116 224 128 238 126 256 C124 274 106 284 88 282 C70 280 60 268 60 250 Z'/%3E%3Cpath d='M36 252 C34 222 62 200 98 203 C134 206 154 228 151 258 C148 288 116 306 82 302 C48 298 38 282 36 252 Z'/%3E%3C/g%3E%3C/svg%3E");
}

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

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

:focus-visible { outline: 2px solid var(--fern); outline-offset: 2px; border-radius: 6px; }

::selection { background: var(--fern-soft); }

/* Data labels — condensed caps, bib style. (Version hashes opt back into true mono.) */
.mono {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ---------- shell ---------- */

.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 14px) 18px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
}

/* ---------- header ---------- */

.hdr { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }

.hdr-date { font-family: var(--font-display); font-size: 33px; font-weight: 700; line-height: 1.04; letter-spacing: 0.005em; }
.hdr-date .dot { color: var(--fern); }

.hdr-sub { margin-top: 4px; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.hdr-sub .mono { font-size: 12.5px; color: var(--ink-3); }

.hdr-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; padding-top: 3px; }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.icon-btn:active { background: var(--surface-2); }

.pill-btn {
  height: 44px; padding: 0 15px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--fern);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.badge {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
}
.badge-cutback { color: var(--moss); border: 1px solid rgba(157, 168, 123, 0.45); }
.badge-race { color: var(--bg); background: var(--blaze); font-weight: 700; }
.badge-sim { color: var(--ink-2); border: 1px solid var(--line); background: var(--surface); }

/* ---------- hero ring ---------- */

.hero { position: relative; display: flex; flex-direction: column; align-items: center; padding: 10px 0 22px; }
.hero::before {
  content: "";
  position: absolute; inset: -14px -18px 0;
  background: var(--topo) center / cover no-repeat;
  pointer-events: none;
}
.hero > * { position: relative; }

.ring-wrap { position: relative; width: 216px; height: 216px; }
.ring { width: 100%; height: 100%; display: block; }

.seg { fill: none; stroke: var(--track); stroke-width: 13; transition: stroke 0.25s ease; }
.seg.on { stroke: var(--fern); }
.ring-wrap.race .seg.on { stroke: var(--blaze); }

.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.pct { font-family: var(--font-display); font-weight: 700; font-size: 76px; line-height: 1; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; }
.pct-sym { font-size: 30px; font-weight: 600; color: var(--ink-2); margin-left: 3px; }
.ring-sub { margin-top: 6px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.ring-wrap.complete .ring { filter: drop-shadow(0 0 16px rgba(127, 176, 105, 0.3)); }
.ring-wrap.race.complete .ring { filter: drop-shadow(0 0 16px rgba(255, 107, 53, 0.32)); }
@keyframes ring-pulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.045); }
  100% { transform: scale(1); }
}
.ring-wrap.pulse { animation: ring-pulse 0.6s ease; }

.session-line { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.chip {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
}
.chip-fern { color: var(--fern); border-color: rgba(127, 176, 105, 0.4); }
.chip-blaze { color: var(--bg); background: var(--blaze); border-color: var(--blaze); font-weight: 700; }

/* ---------- week strip ---------- */

.strip { display: flex; align-items: center; gap: 4px; margin-bottom: 22px; }

.strip-nav { width: 38px; height: 56px; color: var(--ink-3); font-size: 20px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; }
.strip-nav:active { background: var(--surface); }
.strip-nav[disabled] { opacity: 0.25; pointer-events: none; }

.strip-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; flex: 1; }

.day-chip {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 7px;
  border-radius: 12px;
  border: 1px solid transparent;
  min-height: 56px;
}
.chip-dow { font-family: var(--font-display); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; color: var(--ink-3); text-transform: uppercase; }
.chip-num { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip-bar { width: 20px; height: 3px; border-radius: 2px; background: var(--track); overflow: hidden; }
.chip-bar i { display: block; height: 100%; background: var(--fern); border-radius: 2px; }

.day-chip.sel { background: var(--surface); border-color: var(--line); }
.day-chip.sel .chip-num { color: var(--ink); }
.day-chip.today { border-color: rgba(127, 176, 105, 0.55); }
.day-chip.today .chip-dow { color: var(--fern); }
.day-chip.future { opacity: 0.55; }

/* ---------- checklist ---------- */

.group { margin-bottom: 20px; }

.eyebrow {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.eyebrow .mono { color: var(--ink-3); font-size: 12px; }

.rows { list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 14px;
  min-height: 56px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }

/* Checkbox = a little blaze mark (vertical rect, like paint on a trunk). */
.box {
  width: 23px; height: 29px; flex-shrink: 0;
  border-radius: 7px;
  border: 1.5px solid var(--ink-3);
  display: grid; place-items: center;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.box svg { width: 14px; height: 14px; opacity: 0; transform: scale(0.6); transition: opacity 0.18s ease, transform 0.18s ease; }

.row-main { flex: 1; min-width: 0; }
.row-label { display: block; font-size: 16px; font-weight: 550; letter-spacing: -0.005em; }
.row-label .reps { font-family: var(--font-display); font-weight: 600; font-size: 13.5px; color: var(--ink-2); margin-left: 7px; letter-spacing: 0.04em; white-space: nowrap; }
.row-note { display: block; font-size: 13px; color: var(--ink-3); margin-top: 2px; }

.row[aria-checked="true"] .box { background: var(--fern); border-color: var(--fern); }
.row[aria-checked="true"] .box svg { opacity: 1; transform: scale(1); stroke: var(--bg); }
.row[aria-checked="true"] .row-label { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); text-decoration-thickness: 1px; }
.row[aria-checked="true"] .row-label .reps { color: var(--ink-3); }

.row.disabled { pointer-events: none; }
.list.future .row { opacity: 0.7; }

/* ---------- cards (countdown / post-race) ---------- */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 22px;
  text-align: center;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--topo) center / cover no-repeat;
  pointer-events: none;
}
.card > * { position: relative; }
.card .eyebrow { justify-content: center; }
.card .eyebrow::after { content: none; }
.count-num { font-family: var(--font-display); font-size: 84px; font-weight: 700; line-height: 1.02; color: var(--fern); font-variant-numeric: tabular-nums; }
.count-num.blaze { color: var(--blaze); }
.card-line { color: var(--ink-2); font-size: 14px; margin-top: 6px; }
.card-stats { display: flex; justify-content: center; gap: 26px; margin-top: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--font-display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; font-family: var(--font-display); font-weight: 600; }

/* ---------- plan view ---------- */

.plan-hero { display: flex; align-items: center; gap: 18px; padding: 6px 2px 20px; }
.plan-hero .ring-wrap { width: 92px; height: 92px; flex-shrink: 0; }
.plan-hero .mini-pct { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-hero-copy h2 { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.05; }
.plan-hero-copy p { font-size: 13px; color: var(--ink-2); margin-top: 3px; font-variant-numeric: tabular-nums; }

.phase-hd {
  position: sticky; top: 0; z-index: 2;
  background: linear-gradient(var(--bg) 82%, transparent);
  padding: 10px 2px 8px;
}

.week-row {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
}
.week-row:active { background: var(--surface-2); }
.week-row.current { border-color: rgba(127, 176, 105, 0.45); }
.week-n { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.05em; color: var(--ink-3); width: 34px; flex-shrink: 0; }
.week-main { flex: 1; min-width: 0; }
.week-title { font-size: 14px; font-weight: 600; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.week-meta { font-family: var(--font-display); font-weight: 600; font-size: 12px; color: var(--ink-3); letter-spacing: 0.06em; margin-top: 3px; text-transform: uppercase; }
.week-bar { height: 3px; border-radius: 2px; background: var(--track); margin-top: 8px; overflow: hidden; }
.week-bar i { display: block; height: 100%; background: var(--fern); }

.week-dots { display: flex; gap: 4px; flex-shrink: 0; }
.dot-day { width: 7px; height: 7px; border-radius: 50%; background: var(--track); }
.dot-day.partial { background: rgba(127, 176, 105, 0.4); }
.dot-day.full { background: var(--fern); }

.week-expand { margin: -2px 0 10px; border-left: 2px solid var(--line); padding-left: 10px; margin-left: 16px; }
.mini-day {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  text-align: left;
  font-size: 13px;
}
.mini-day:active { background: var(--surface); }
.mini-day .md-date { font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: 0.05em; color: var(--ink-3); width: 58px; flex-shrink: 0; text-transform: uppercase; }
.mini-day .md-session { flex: 1; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-day .md-pct { font-family: var(--font-display); font-weight: 600; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.mini-day .md-pct.full { color: var(--fern); }

/* ---------- tab bar ---------- */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 8px);
  background: rgba(18, 23, 14, 0.86);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 200px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0 4px;
  border-radius: 12px;
  color: var(--ink-3);
}
.tab svg { width: 22px; height: 22px; }
.tab span { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.tab.active { color: var(--fern); }

/* ---------- settings sheet ---------- */

#sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 22px);
  animation: sheet-up 0.25s ease;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--ink-3); opacity: 0.5; margin: 2px auto 14px; }
.sheet-panel h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-bottom: 14px; }

.sheet-row {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 2px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  text-align: left;
}
.sheet-row .sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.sheet-row .mono { font-family: var(--font-mono); font-weight: 400; font-size: 11px; letter-spacing: 0; color: var(--ink-2); }
.sheet-row.action { color: var(--fern); font-weight: 600; }
.sheet-row.danger { color: var(--blaze); }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%) translateY(8px);
  z-index: 30;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 86vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast button { color: var(--fern); font-weight: 700; margin-left: 10px; }

/* ---------- motion ---------- */

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