/* Ravo's single cyan identity (Documentations/BRAND_SYSTEM.md), dark and light, following the device by default */

:root {
  color-scheme: dark;
  --canvas: #080f1c;
  --panel: #101a2b;
  --panel-2: #19243a;
  --line: #2b3850;
  --text: #f3f7ff;
  --muted: #aab8ce;
  --primary: #32b8ec;
  --on-primary: #0a0a12;
  --accent: #65d5fa;
  --soft: #2b3850;
  --on-soft: #f3f7ff;
  --error: #ff7b87;
  --error-bg: #4a1721;
  --warn: #f3c969;
  --mark-a: #32b8ec;
  --mark-b: #65d5fa;
  --radius: 18px;
  --press: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: Inter, Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

:root[data-theme="light"] {
  color-scheme: light;
  --canvas: #ffffff;
  --panel: #f3f7fb;
  --panel-2: #eaf1f8;
  --line: #d2dfea;
  --text: #152236;
  --muted: #526479;
  --accent: #006b91;
  --soft: #ddf4fe;
  --on-soft: #003c55;
  --error: #b51c35;
  --error-bg: #ffdadd;
  --warn: #8a5a00;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="device"] {
    color-scheme: light;
    --canvas: #ffffff;
    --panel: #f3f7fb;
    --panel-2: #eaf1f8;
    --line: #d2dfea;
    --text: #152236;
    --muted: #526479;
    --accent: #006b91;
    --soft: #ddf4fe;
    --on-soft: #003c55;
    --error: #b51c35;
    --error-bg: #ffdadd;
    --warn: #8a5a00;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--text); min-height: 100dvh; }
#app { min-height: 100dvh; }
h1, h2, p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 10; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 10px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
/* Headings get focus on each new screen for screen readers; no ring for that */
[tabindex="-1"]:focus { outline: none; }
.boot { padding: 32px; color: var(--muted); }
.loading { color: var(--muted); padding: 12px 0; }

/* Screens slide in like BlaBlaCar's flow; reduced motion turns this off */
.screen { animation: 260ms var(--ease-out) both; }
.screen.enter-forward { animation-name: slide-from-right; }
.screen.enter-back { animation-name: slide-from-left; }
@keyframes slide-from-right { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes slide-from-left { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }

/* Buttons: compress to 95% and spring back, without delaying the action */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 24px; border-radius: var(--radius); border: 1px solid transparent;
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
  transition: transform 220ms var(--press), background-color 150ms, opacity 150ms;
}
.btn:active:not(:disabled) { transform: scale(0.95); transition-duration: 90ms; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-secondary { background: var(--soft); color: var(--on-soft); }
.btn-ghost { background: transparent; color: var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px;
  background: transparent; border: 0; color: var(--text); cursor: pointer;
  transition: transform 220ms var(--press), background-color 150ms;
}
.icon-btn:hover { background: var(--panel); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.round { width: 56px; height: 56px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 12px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger, .menu-item.danger { color: var(--error); }
.link-btn:disabled { opacity: 0.5; cursor: default; }

/* Question screens: one big question, one answer, the action at the bottom */
.q-screen { width: min(100%, 600px); margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: 8px 20px 0; }
.q-top { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.q-progress { flex: 1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.q-progress-fill { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width 300ms var(--ease-out); }
.q-count { color: var(--muted); font-size: 13px; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.q-main { flex: 1; padding: 16px 0 32px; display: flex; flex-direction: column; gap: 20px; }
.q-title { font-size: clamp(28px, 7vw, 38px); line-height: 1.12; letter-spacing: -0.02em; font-weight: 800; outline: none; }
.q-help { color: var(--muted); font-size: 17px; }
.q-actions {
  position: sticky; bottom: 0; display: flex; flex-direction: column; gap: 10px;
  padding: 16px 0 max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--canvas) 75%, transparent);
}
.q-actions .btn { width: 100%; }
@media (min-width: 720px) {
  .q-screen { padding-top: 32px; }
  .q-actions { flex-direction: row-reverse; justify-content: flex-start; }
  .q-actions .btn { width: auto; min-width: 180px; }
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
  min-height: 64px; padding: 14px 16px 14px 20px; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
  transition: transform 220ms var(--press), border-color 150ms, background-color 150ms;
}
.option:hover { border-color: var(--primary); }
.option:active { transform: scale(0.98); }
.option[aria-checked="true"], .option[aria-pressed="true"] { border-color: var(--primary); background: var(--soft); }
.option .icon { color: var(--muted); flex: none; }
.option-text { display: flex; flex-direction: column; gap: 2px; }
.option-text strong { font-size: 18px; }
.option-text small { color: var(--muted); font-size: 14px; }

.field {
  display: block; width: 100%; min-height: 56px; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.field:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
.big-field { font-size: 22px; font-weight: 700; min-height: 64px; }
.field-note { color: var(--muted); font-size: 15px; }
.field-note.subtle { font-size: 13px; }
.field-label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; color: var(--muted); }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.stepper-value { flex: 1; display: flex; flex-direction: column; align-items: center; }
.stepper-input {
  width: 100%; max-width: 220px; text-align: center; font-size: 56px; font-weight: 800; letter-spacing: -0.03em;
  background: transparent; border: 0; border-bottom: 2px solid var(--line); color: var(--text); font-variant-numeric: tabular-nums;
  appearance: textfield; -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-input:focus { outline: none; border-bottom-color: var(--primary); }
.stepper-unit { color: var(--muted); font-weight: 600; margin-top: 4px; }

.day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.chip {
  min-height: 56px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-weight: 700; cursor: pointer; transition: transform 220ms var(--press), background-color 150ms, border-color 150ms;
}
.chip:active { transform: scale(0.95); }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
@media (max-width: 420px) { .day-grid { grid-template-columns: repeat(4, 1fr); } }

.minute-rows { display: flex; flex-direction: column; gap: 10px; }
.minute-row { display: grid; grid-template-columns: 1fr 1.2fr; align-items: center; gap: 12px; font-weight: 700; }
.custom-peak { margin-top: 4px; }

.race-picker { display: flex; flex-direction: column; gap: 16px; }
.race-list { display: flex; flex-direction: column; gap: 18px; }
.race-group { display: flex; flex-direction: column; gap: 8px; }
.race-month { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.race-date { color: var(--accent); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

.summary { display: flex; flex-direction: column; gap: 14px; }
.summary-lead { font-weight: 600; }
.summary-list { margin: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.summary-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.summary-row:last-child { border-bottom: 0; }
.summary-row dt { color: var(--muted); font-size: 13px; grid-column: 1; }
.summary-row dd { margin: 0; font-weight: 700; grid-column: 1; }
.summary-row .link { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 600; }

.alert { padding: 12px 16px; border-radius: 14px; font-weight: 600; }
.alert-error { background: var(--error-bg); color: var(--error); }
.alert-info { background: var(--soft); color: var(--on-soft); }
.error-slot:empty { display: none; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.segmented button { min-height: 48px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; cursor: pointer; color: var(--muted); }
.segmented button[aria-selected="true"] { background: var(--soft); color: var(--on-soft); }
.account-form { display: flex; flex-direction: column; gap: 14px; }
.account-form .btn { width: 100%; margin-top: 6px; }
.agree { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; color: var(--muted); line-height: 1.45; }
.agree input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }

.success { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 48px 0; text-align: center; font-size: 22px; font-weight: 800; }
.success-art { color: var(--primary); }
.success-circle { fill: none; stroke: currentColor; stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 300ms ease-out forwards; }
.success-tick { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw 170ms 300ms ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Numbers roll in digit by digit for occasional totals */
.rolling { display: inline-flex; overflow: hidden; font-variant-numeric: tabular-nums; }
.roll-digit, .roll-char { display: inline-block; animation: roll-in 420ms var(--ease-out) both; }
@keyframes roll-in { from { transform: translateY(70%); opacity: 0; } to { transform: none; opacity: 1; } }

/* Welcome */
.welcome { width: min(100%, 640px); margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: 32px 20px 0; }
.welcome-main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 24px 0; }
.welcome-mark .mark { display: block; }
.welcome-title { font-size: clamp(36px, 9vw, 56px); line-height: 1.05; letter-spacing: -0.03em; font-weight: 800; }
.welcome-sub { color: var(--muted); font-size: 18px; }
.welcome-points { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.welcome-points li { padding-left: 28px; position: relative; font-weight: 600; }
.hints { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.hints li { padding-left: 28px; position: relative; font-weight: 600; }
.hints li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.reason { padding: 4px 16px 12px; }
.reason summary { padding: 12px 0; }
.welcome-points li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.mark .mark-a { fill: var(--mark-a); }
.mark .mark-b { fill: var(--mark-b); }

/* Plan */
.plan-screen { width: min(100%, 880px); margin: 0 auto; padding: 0 16px 48px; }
.app-top { display: flex; align-items: center; justify-content: space-between; min-height: 72px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--canvas) 92%, transparent); backdrop-filter: blur(8px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.menu-wrap { position: relative; }
.dots, .dots::before, .dots::after { display: block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.dots { position: relative; }
.dots::before, .dots::after { content: ""; position: absolute; left: 0; }
.dots::before { top: -9px; }
.dots::after { top: 9px; }
.menu { position: absolute; right: 0; top: 52px; min-width: 220px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 6px; display: flex; flex-direction: column; box-shadow: 0 12px 32px rgb(0 0 0 / 0.3); }
.menu-item { text-align: left; background: none; border: 0; padding: 12px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.menu-item:hover { background: var(--panel); }
.plan-content { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card h2 { font-size: 20px; letter-spacing: -0.01em; }
.hero { background: linear-gradient(140deg, var(--panel-2), var(--panel)); gap: 8px; }
.hero-title { font-size: clamp(28px, 6vw, 40px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 800; }
.hero-sub { color: var(--muted); }
.countdown { font-size: 18px; font-weight: 700; color: var(--accent); display: flex; align-items: baseline; gap: 4px; margin-top: 6px; }
.countdown .rolling { font-size: 44px; font-weight: 800; color: var(--text); letter-spacing: -0.03em; }
.review-card { border-color: var(--primary); background: var(--soft); color: var(--on-soft); }
.review-card .btn { align-self: flex-start; }
.week-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.week-km { font-size: 15px; color: var(--muted); white-space: nowrap; }
.week-km .rolling { font-size: 32px; font-weight: 800; color: var(--text); }
.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 8px; transition: width 600ms var(--ease-out); }
.sessions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.session { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.session:last-child { border-bottom: 0; }
.session-day { display: flex; flex-direction: column; font-weight: 800; }
.session-day small, .session-what small { color: var(--muted); font-weight: 500; font-size: 13px; }
.session-what { display: flex; flex-direction: column; }
.pill { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill-ok { background: var(--primary); color: var(--on-primary); }
.pill-now { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.pill-warn { background: transparent; color: var(--warn); border: 1.5px solid var(--warn); }
.pill-quiet { background: var(--panel-2); color: var(--muted); }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.logged, .run-list, .changes, .flags, .reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.logged li { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.logged li:last-child { border-bottom: 0; }
.run-list li, .flags li, .reasons li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.run-list li:last-child, .flags li:last-child, .reasons li:last-child { border-bottom: 0; }
.reasons li { color: var(--muted); font-size: 15px; }

.weeks { display: flex; flex-direction: column; gap: 8px; }
.week { border: 1px solid var(--line); border-radius: 16px; background: var(--canvas); overflow: hidden; }
.week.is-current { border-color: var(--primary); }
.week summary, details summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; }
.week summary::-webkit-details-marker, details summary::-webkit-details-marker { display: none; }
.week-name, .week-total { display: flex; flex-direction: column; font-weight: 800; }
.week-total { text-align: right; }
.week-name small, .week-total small { color: var(--muted); font-weight: 500; font-size: 13px; }
/* Card expand: fast start, slow finish */
details[open] > :not(summary) { animation: expand 350ms var(--ease-out); }
@keyframes expand { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.week-sessions { list-style: none; margin: 0; padding: 0 16px 12px; }
.week-sessions li { display: grid; grid-template-columns: 76px 1fr auto; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.km { text-align: right; font-weight: 700; display: flex; flex-direction: column; }
.week-sessions .what { display: flex; flex-direction: column; gap: 2px; }
.week-sessions .what small { color: var(--muted); font-size: 13px; }
.adjusted { color: var(--accent); font-weight: 600; font-size: 12px; }

.section-title { font-size: 18px; margin-top: 4px; }
.changes li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.change-what { display: flex; flex-direction: column; gap: 2px; }
.change-what small { color: var(--muted); }
.change-km { white-space: nowrap; font-weight: 800; }
.change-km s { color: var(--muted); font-weight: 500; }
.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.scale-btn { min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-weight: 800; font-size: 18px; cursor: pointer; transition: transform 220ms var(--press); }
.scale-btn:active { transform: scale(0.94); }
.scale-btn[aria-checked="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.week-runs { display: flex; flex-direction: column; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

.fitness { display: flex; flex-direction: column; gap: 16px; }
.race-fields { display: grid; gap: 12px; }
@media (min-width: 560px) { .race-fields { grid-template-columns: 1.2fr 1fr 1.2fr; } }
.welcome-note { margin: 0; }
.test-card { display: flex; flex-direction: column; gap: 10px; }
.test-card h2 { margin: 0; }
.test-card p { margin: 0; }
.consent { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.consent .check { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; cursor: pointer; }
.consent .check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.consent p { margin: 0; }
