/* Complete Athlete (personal) — Design 01 direction: calm charcoal surfaces, warm white text, teal actions.
   Mustard + clock + "Over by" is reserved for rest overtime; violet + check for achievements. */
:root[data-theme="dark"] {
  --primary: #11757a;          /* primary button, white text (contrast 5.4:1) */
  --primary-hover: #138990;
  --on-primary: #ffffff;
  --accent: #66d4d1;           /* selected state / links on dark */
  --brand-surface: #1b2224;
  --on-brand: #f3f6f4;
  --on-brand-muted: #b2bec1;
  --brand-line: #334044;
  --brand-track: #2a3436;
  --brand-button: #11757a;
  --brand-button-text: #ffffff;
  --nav: #151b1c;
  --nav-text: #b2bec1;
  --nav-active: #66d4d1;
  --splash: #111516;
  --bg: #111516;
  --card: #1b2224;
  --raised: #222b2d;
  --input-bg: #222b2d;
  --light-gray: #232c2e;
  --line: #334044;
  --track: #4a5a5e;
  --text: #f3f6f4;
  --text-2: #b2bec1;
  --success: #66d4d1;
  --success-soft: #17393a;
  --overtime: #d6ad49;
  --on-overtime: #1a1608;
  --milestone: #a8a1ff;
  --milestone-soft: #26244a;
  --on-milestone: #15123a;
  --danger: #f09b92;
}
:root[data-theme="light"] {
  --primary: #0d5e62;
  --primary-hover: #0b5054;
  --on-primary: #ffffff;
  --accent: #0d5e62;
  --brand-surface: #0d5e62;
  --nav: #1b2224;
  --nav-active: #66d4d1;
  --splash: #0d5e62;
  --bg: #f4f6f5;
  --card: #ffffff;
  --raised: #ffffff;
  --line: #d5dddc;
  --text: #111516;
  --text-2: #4b5759;
  --success: #0d6b6f;
  --success-soft: #e0f1f0;
  --overtime: #d6ad49;
  --on-overtime: #1a1608;
  --milestone: #5b52d6;
  --milestone-soft: #ecebff;
  --on-milestone: #ffffff;
  --danger: #b3261e;
}

body { font-size: 16px; }
.tiny { font-size: 13px; }
.muted { font-size: 14px; }
.card { border: 1px solid var(--line); box-shadow: none; }
.btn { min-height: 48px; }
.btn-sm { min-height: 44px; }
.btn-secondary { border-color: var(--line); }
:root[data-theme="dark"] .btn-secondary { border-color: #4a5a5e; }
a { color: var(--accent); }
.btn, .tab, .seg, .card a.btn { text-decoration: none; }
.splash .wordmark { line-height: 1.05; }
.tab { min-width: 0; }
.tab span { font-size: 11px; }

/* Header row with settings */
.ca-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 4px 10px; }
.ca-head h1 { margin: 0; }
.icon-link { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; color: var(--text); }
.icon-link .ic { width: 24px; height: 24px; }
.icon-link:hover { background: var(--light-gray); }

/* Period switch and exact range */
.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 4px 12px; }
.period-bar .segmented { margin: 0; flex: 0 0 auto; }
.period-range { font-size: 14px; color: var(--text-2); }
.period-nav { display: flex; gap: 4px; margin-left: auto; }
.period-nav button { min-width: 44px; min-height: 44px; }

/* Cards with one destination */
.ca-card { display: block; color: var(--text); text-decoration: none; padding: 14px 16px; margin: 0 0 12px; }
.ca-card h2 { font-size: 17px; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.ca-card .big { font-size: 26px; font-weight: 700; line-height: 1.15; }
.ca-card .row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }
.ca-card .row:first-of-type { border-top: 0; }
.ca-card .row span:first-child { color: var(--text-2); }
.ca-card .go { margin-left: auto; color: var(--text-2); display: inline-flex; }
.ca-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 640px) { .ca-grid { grid-template-columns: 1fr 1fr; gap: 0 12px; } }

.today-card { border-left: 4px solid var(--accent); }
.obs-list { list-style: none; margin: 0 0 12px; padding: 0; }
.obs-list li { margin: 0 0 8px; }
.obs-list a { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.obs-kind { flex: 0 0 auto; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); min-width: 86px; }
.obs-achievement .obs-kind { color: var(--milestone); }

/* Status chips: colour is never the only cue (text + icon). */
.state { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--light-gray); color: var(--text); }
.state .ic { width: 15px; height: 15px; }
.state-overtime { background: var(--overtime); color: var(--on-overtime); }
.state-milestone { background: var(--milestone); color: var(--on-milestone); }
.state-unknown, .state-partial { background: var(--light-gray); color: var(--text-2); }
.state-ok { background: var(--success-soft); color: var(--success); }

/* Resume bar outside the player */
.resume-bar { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 52px; padding: 8px 14px; border-radius: 12px; background: var(--primary); color: var(--on-primary); font-weight: 700; text-decoration: none; }
.resume-bar[hidden] { display: none; }
body.has-resume .page { padding-bottom: calc(var(--tabbar-h) + 84px); }
body.in-session .resume-bar { display: none; }

/* Player */
.player { padding: 16px; margin: 0 0 14px; }
.player-ex { font-size: 22px; font-weight: 700; margin: 2px 0 4px; }
.player-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.player-box { background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.player-box .label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.player-box .value { font-size: 24px; font-weight: 700; }
.player-main { width: 100%; min-height: 60px; font-size: 18px; }
.player-secondary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.player-setup { font-size: 14px; color: var(--text-2); }
.running-clock { font-variant-numeric: tabular-nums; }

/* Actual rest panel */
.rest-inner .rest-time, .rest-big { font-variant-numeric: tabular-nums; }
.rest-over { display: inline-flex; align-items: center; gap: 6px; background: var(--overtime); color: var(--on-overtime); font-weight: 700; border-radius: 8px; padding: 4px 10px; }
.rest-over .ic { width: 16px; height: 16px; }
.rest-panel .rest-inner { gap: 10px; }
.rest-note-btn { min-height: 44px; }

/* Intervals table */
.interval-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }

/* Charts: bars with an accessible table alternative */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-2); font-size: 11px; font-family: inherit; }
.chart .bar { fill: var(--accent); }
.chart .bar-partial { fill: none; stroke: var(--accent); stroke-dasharray: 3 2; }
.chart .axis { stroke: var(--line); }
.chart .target { stroke: var(--text); stroke-dasharray: 4 3; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dot { fill: var(--accent); }
.chart .trend { fill: none; stroke: var(--milestone); stroke-width: 2; stroke-dasharray: 5 3; }
.chart-panel { margin: 0 0 10px; padding: 12px 14px; }
.chart-panel h3 { font-size: 14px; margin: 6px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--text-2); font-weight: 600; }

/* Forms */
.inline-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0 10px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; cursor: pointer; }
.radio-card input { margin-top: 4px; width: 20px; height: 20px; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--success-soft); }
textarea.input { min-height: 88px; }

/* Body map */
.body-wrap { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .body-wrap { grid-template-columns: 220px 1fr; } }
.body-canvas { background: #eef1f0; border-radius: 12px; padding: 10px; }
.body-canvas svg { width: 100%; max-width: 220px; display: block; margin: 0 auto; }
.body-canvas .silhouette { fill: #c9d2d0; stroke: #111516; stroke-width: 1.5; }
.body-canvas .target-outline { fill: none; stroke: #111516; stroke-width: 1.5; stroke-dasharray: 5 4; }
.body-canvas .region { fill: transparent; stroke: transparent; cursor: pointer; }
.body-canvas .region.toward { fill: rgba(17,117,122,.35); }
.body-canvas .region.within { fill: rgba(17,117,122,.65); }
.body-canvas .region.maintain { fill: rgba(91,82,214,.35); }
.body-canvas .region.measure { fill: rgba(0,0,0,.08); stroke: #4b5759; stroke-dasharray: 3 2; }
.body-canvas .region.is-selected { stroke: #111516; stroke-width: 2.5; }
.unpersonalized { display: inline-block; font-size: 12px; font-weight: 700; color: #111516; background: #ffe7a3; padding: 2px 8px; border-radius: 6px; }

/* Celebration */
.celebrate { border: 1px solid var(--milestone); background: var(--milestone-soft); }
.celebrate h2 { color: var(--milestone); }
@media (prefers-reduced-motion: no-preference) { .celebrate { animation: ca-pop .4s ease-out; } }
@keyframes ca-pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* Voice */
.voice-state { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.voice-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
@media (prefers-reduced-motion: no-preference) { .voice-recording .voice-dot { animation: ca-blink 1s infinite; } }
@keyframes ca-blink { 50% { opacity: .2; } }

.settings-list a { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 8px 16px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.settings-list a:first-child { border-top: 0; }
.danger-text { color: var(--danger); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.pill-btn { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 14px; }
.pill-btn.is-on { border-color: var(--accent); background: var(--success-soft); color: var(--text); font-weight: 700; }

@media (max-width: 360px) {
  .player-grid { grid-template-columns: 1fr; }
  .period-nav { margin-left: 0; }
}
