/* Fôlego. Ideia central: a fase é a cor da tela inteira (azul-cobalto correndo, menta caminhando),
   e a próxima fase sobe do pé da tela como uma maré quando a troca se aproxima. */

@property --wave-x {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

:root {
  --chalk: #F3F5F0;
  --surface: #FFFFFF;
  --ink: #151A35;
  --muted: #586079;
  --line: #DCE0D6;
  --soft: rgba(21, 26, 53, 0.06);

  --run: #2340F5;
  --run-ink: #FFFFFF;
  --walk: #A6E3B8;
  --walk-ink: #0E3A24;
  --walk-strong: #18995A;
  --idle: #151A35;
  --idle-ink: #F3F5F0;
  --danger: #C23A22;
  --warn: #D49A00;

  --bg: var(--chalk);
  --fg: var(--ink);

  --f-display: 'Big Shoulders', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --f-text: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121733;
    --surface: #1B2146;
    --fg: #E8EBF6;
    --muted: #9DA5C3;
    --line: #2C335F;
    --soft: rgba(232, 235, 246, 0.07);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121733;
  --surface: #1B2146;
  --fg: #E8EBF6;
  --muted: #9DA5C3;
  --line: #2C335F;
  --soft: rgba(232, 235, 246, 0.07);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.5 var(--f-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
small { font-size: 0.72em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

:focus-visible { outline: 3px solid var(--run); outline-offset: 2px; border-radius: 8px; }

.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* ---------- Estrutura ---------- */

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 4px) 16px calc(var(--tabbar-h) + var(--safe-b) + 32px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}

.wordmark {
  font: 800 34px/1 var(--f-display);
  letter-spacing: -0.01em;
}

.page-title {
  font: 800 34px/1 var(--f-display);
}

.section-title {
  font: 700 22px/1.2 var(--f-display);
  margin: 28px 0 10px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-weight: 700;
  margin-left: -6px;
  padding: 8px 6px;
}

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  background: var(--soft);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn.primary { background: var(--ink); color: var(--chalk); }
:root[data-resolved-theme="dark"] .btn.primary { background: var(--chalk); color: var(--ink); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { color: var(--danger); }
.btn.ghost.danger { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.btn-sm { min-height: 42px; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 20px; height: 20px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.link {
  background: none;
  border: 0;
  padding: 0;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--soft);
  color: inherit;
  flex: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.gps-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.gps-good { background: var(--walk-strong); }
.gps-fair { background: var(--warn); }
.gps-weak, .gps-denied, .gps-error, .gps-unsupported { background: var(--danger); }
.gps-searching { animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- Seletores segmentados e interruptores ---------- */

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--soft);
}
.seg button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  padding: 0 12px;
  white-space: nowrap;
}
.seg button[aria-checked="true"] { background: var(--fg); color: var(--bg); }
.seg-mode { margin: 18px 0 14px; }
.seg-mode button { min-height: 46px; font-size: 17px; }
.seg-sm { border-radius: 12px; padding: 3px; }
.seg-sm button { min-height: 36px; font-size: 15px; padding: 0 10px; border-radius: 9px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: var(--line);
  flex: none;
  transition: background 0.15s;
}
.switch-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch input:checked + .switch-ui { background: var(--run); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--run); outline-offset: 2px; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.check input { width: 20px; height: 20px; accent-color: var(--run); }

/* ---------- Tela Treino ---------- */

.week-line { color: var(--muted); margin-top: 2px; }
.week-line strong { color: var(--fg); }

.presets {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px 14px;
  padding: 2px 16px 4px;
  scrollbar-width: none;
}
.presets::-webkit-scrollbar { display: none; }
.preset {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  flex: none;
}
.preset button { border: 0; background: none; min-height: 38px; padding: 0 14px; font-size: 15px; font-weight: 700; }
.preset .preset-x { padding: 0 10px 0 0; margin-left: -6px; display: grid; place-items: center; }
.preset .preset-x .icon { width: 16px; height: 16px; }
.preset.is-on { border-color: var(--fg); background: var(--fg); color: var(--bg); }

.bands { display: grid; gap: 6px; }
.band {
  border-radius: 22px;
  padding: 16px 16px 14px;
  background: var(--band-bg);
  color: var(--band-fg);
  --band-soft: color-mix(in srgb, var(--band-fg) 14%, transparent);
}
.band-run { --band-bg: var(--run); --band-fg: var(--run-ink); }
.band-walk { --band-bg: var(--walk); --band-fg: var(--walk-ink); }
.band-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.band-head h2 { font: 800 28px/1 var(--f-display); }
.band .seg { background: var(--band-soft); }
.band .seg button[aria-checked="true"] { background: var(--band-fg); color: var(--band-bg); }
.stepper {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  margin-top: 8px;
}
.band-value {
  text-align: center;
  font: 800 clamp(52px, 17vw, 76px)/1 var(--f-display);
  letter-spacing: -0.01em;
}
.step {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--band-soft, var(--soft));
  touch-action: manipulation;
}
.step:disabled { opacity: 0.35; }
.step-sm { width: 40px; height: 40px; }
.step-sm .icon { width: 20px; height: 20px; }

.panel {
  margin-top: 10px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px 14px;
}
.panel > * + * { border-top: 1px solid var(--line); }
.row-reps, .row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 60px;
  padding: 8px 0;
  flex-wrap: wrap;
}
.row-label { font-weight: 700; }
.row-hint { color: var(--muted); font-size: 15px; }
.mini-stepper { display: flex; align-items: center; gap: 8px; }
.mini-stepper output { min-width: 3.4em; text-align: center; font: 700 24px/1 var(--f-display); }
.row-reps .mini-stepper output { min-width: 1.6em; font-size: 30px; }

.plan-summary { margin: 14px 2px 0; color: var(--muted); }
.plan-summary .link { color: var(--fg); margin-left: 4px; }

.free-explain { display: grid; gap: 14px; }
.free-explain p { color: var(--muted); }
.free-explain .row-toggle { border-radius: 18px; background: var(--surface); border: 1px solid var(--line); padding: 8px 14px; }

.start-wrap {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  margin-top: 18px;
  z-index: 3;
}
.btn.start {
  width: 100%;
  min-height: 68px;
  border-radius: 20px;
  background: var(--ink);
  color: var(--chalk);
  font: 800 32px/1 var(--f-display);
  letter-spacing: 0.01em;
}
:root[data-resolved-theme="dark"] .btn.start { background: var(--chalk); color: var(--ink); }

.resume {
  margin: 4px 0 10px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 2px solid var(--run);
  display: grid;
  gap: 10px;
}

/* ---------- Barra de abas e barra "corrida em andamento" ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.tabbar a[aria-current="page"] { color: var(--fg); }
.tabbar a[aria-current="page"]::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 30%;
  right: 30%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--run);
}
.tabbar[hidden], .livebar[hidden] { display: none; }

.livebar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px);
  z-index: 11;
  max-width: 536px;
  margin: 0 auto;
}
.livebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 16px;
  background: var(--run);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.livebar span { margin-left: auto; opacity: 0.85; }
body[data-route="setup"] .livebar { bottom: calc(var(--tabbar-h) + var(--safe-b) + 92px); }

/* ---------- Tela da corrida ---------- */

body[data-route="run"] { overflow: hidden; }
body[data-route="run"] .page { padding: 0; }

.run {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-areas: "faces" "controls";
  background: var(--idle);
  color: var(--idle-ink);
  user-select: none;
  -webkit-user-select: none;
  z-index: 20;
}
.run.map-on {
  grid-template-rows: 172px 1fr auto;
  grid-template-areas: "faces" "map" "controls";
}
.faces { grid-area: faces; position: relative; overflow: hidden; container-type: size; }
.map-pane { grid-area: map; position: relative; background: var(--chalk); }
.map-pane[hidden] { display: none; }
.controls { grid-area: controls; }

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 12px) 20px 14px;
  background: var(--face-bg);
  color: var(--face-fg);
  transition: background-color 0.2s;
}
.face[data-fam="run"] { --face-bg: var(--run); --face-fg: var(--run-ink); --face-soft: rgba(255, 255, 255, 0.18); }
.face[data-fam="walk"] { --face-bg: var(--walk); --face-fg: var(--walk-ink); --face-soft: rgba(14, 58, 36, 0.13); }
.face[data-fam="idle"], .face:not([data-fam]) { --face-bg: var(--idle); --face-fg: var(--idle-ink); --face-soft: rgba(255, 255, 255, 0.12); }

/* A maré: a mesma tela, na cor da próxima fase, recortada de baixo para cima com uma onda no topo. */
.face-tide {
  pointer-events: none;
  transition: none;
  --top: calc((1 - var(--tide, 0)) * 100cqh);
  --wave-h: calc(min(1, var(--tide, 0) * 18) * 18px);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 18' preserveAspectRatio='none'%3E%3Cpath d='M0 10 Q40 0 80 10 T160 10 V18 H0Z'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 18' preserveAspectRatio='none'%3E%3Cpath d='M0 10 Q40 0 80 10 T160 10 V18 H0Z'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
  -webkit-mask-size: 160px var(--wave-h), 100% 100cqh;
  mask-size: 160px var(--wave-h), 100% 100cqh;
  -webkit-mask-repeat: repeat-x, no-repeat;
  mask-repeat: repeat-x, no-repeat;
  -webkit-mask-position: var(--wave-x) calc(var(--top) - var(--wave-h) + 1px), 0 var(--top);
  mask-position: var(--wave-x) calc(var(--top) - var(--wave-h) + 1px), 0 var(--top);
  animation: wave 1.4s linear infinite;
}
@keyframes wave { to { --wave-x: 160px; } }

.face-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.face .chip-gps { border: 0; background: var(--face-soft); color: inherit; }
.face .gps-good { background: #4BE08A; }
.face[data-fam="walk"] .gps-good { background: var(--walk-strong); }
.face-rep { font-weight: 700; font-size: 16px; text-align: center; }
.face .icon-btn { background: var(--face-soft); }
.icon-btn-ghost { width: 44px; }

.face-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}
.phase-label { font: 800 clamp(30px, 10cqw, 54px)/1 var(--f-display); }
.clock {
  font: 800 min(36cqw, 34cqh)/0.86 var(--f-display);
  letter-spacing: -0.015em;
  margin: 0.06em 0 0.04em -0.03em;
  white-space: nowrap;
}
.clock .d { display: inline-block; width: 0.5em; text-align: center; }
.clock .c { display: inline-block; width: 0.2em; text-align: center; }
.clock .unit { font-size: 0.3em; margin-left: 0.1em; letter-spacing: 0; }
.clock-sub { font-weight: 700; font-size: clamp(18px, 5.4cqw, 24px); opacity: 0.86; }
.lane { margin-top: 18px; height: 6px; border-radius: 3px; background: var(--face-soft); overflow: hidden; }
.lane i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: currentColor; border-radius: 3px; }
.lane:has(span:empty) { visibility: hidden; }

.face-stats {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding-top: 14px;
  border-top: 1.5px solid var(--face-soft);
}
.face-stats dt { font-size: 14px; font-weight: 700; opacity: 0.78; }
.face-stats dd { margin: 0; font: 800 clamp(30px, 9cqw, 44px)/1.05 var(--f-display); white-space: nowrap; }
.face-stats dd small { font-size: 0.5em; font-weight: 700; }
.face-stats .d { display: inline-block; width: 0.5em; text-align: center; }
.face-stats .c { display: inline-block; width: 0.2em; text-align: center; }
.face-hint { min-height: 1.4em; margin-top: 8px; font-size: 14px; font-weight: 700; opacity: 0.85; }

.pulse-dot {
  display: inline-block;
  width: 0.36em;
  height: 0.36em;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.2s ease-in-out infinite;
}

/* Com o mapa aberto, a fase vira uma faixa compacta. */
@container (max-height: 260px) {
  .face { padding-top: calc(var(--safe-t) + 8px); padding-bottom: 10px; }
  .face-stats, .face-hint, .lane { display: none; }
  .face-main { flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 12px; justify-content: flex-start; }
  .phase-label { font-size: 30px; width: 100%; }
  .clock { font-size: 72px; }
  .clock-sub { font-size: 17px; }
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(14px + var(--safe-b));
  background: var(--idle);
}
.icon-btn-lg { width: 62px; height: 62px; background: rgba(255, 255, 255, 0.1); color: var(--idle-ink); }
.icon-btn-lg .icon { width: 28px; height: 28px; }
.btn-toggle {
  flex: 1;
  min-height: 74px;
  border-radius: 20px;
  border: 0;
  font: 800 32px/1 var(--f-display);
  touch-action: manipulation;
}
.btn-toggle[data-fam="run"] { background: var(--run); color: var(--run-ink); }
.btn-toggle[data-fam="walk"] { background: var(--walk); color: var(--walk-ink); }
.btn-ctl { flex: 1; min-height: 62px; border-radius: 18px; font-size: 18px; }
.btn-ctl.ghost { color: var(--idle-ink); border-color: rgba(255, 255, 255, 0.3); }
.btn-ctl.wide { flex: 1; }
.btn-light { background: var(--chalk); color: var(--ink); }

.pause-layer, .lock-layer { position: absolute; inset: 0; z-index: 5; }
.pause-layer[hidden], .lock-layer[hidden] { display: none; }
.pause-layer {
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  background: rgba(21, 26, 53, 0.95);
  color: var(--idle-ink);
}
.pause-card { display: grid; gap: 14px; width: min(420px, 100%); }
.pause-title { font: 800 72px/0.9 var(--f-display); }
.pause-stats { font-size: 20px; opacity: 0.86; margin-bottom: 12px; }
.btn-xl { min-height: 74px; border-radius: 20px; font: 800 30px/1 var(--f-display); }
.btn-run { background: var(--run); color: #fff; }
.btn-hold {
  position: relative;
  overflow: hidden;
  min-height: 62px;
  border-radius: 18px;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: var(--idle-ink);
  isolation: isolate;
}
.btn-hold::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--danger);
  transform: scaleX(var(--hold, 0));
  transform-origin: left;
}
.lock-layer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px calc(var(--safe-b) + 108px);
  background: transparent;
  touch-action: none;
}
.btn-unlock {
  background: var(--chalk);
  color: var(--ink);
  border: 0;
  min-height: 58px;
  padding: 0 24px;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(21, 26, 53, 0.35);
}
.btn-unlock::before { background: var(--walk); }
.lock-layer.nudge .btn-unlock { animation: nudge 0.4s; }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Mapas e percurso em SVG ---------- */

.route-svg { display: block; width: 100%; height: 100%; }
.route-line { fill: none; stroke: var(--fg); stroke-linecap: round; stroke-linejoin: round; }
.route-run { stroke: var(--run); }
.route-walk { stroke: var(--walk-strong); }
.route-start { fill: var(--walk-strong); stroke: var(--surface); stroke-width: 2.5; }
.route-end { fill: var(--fg); stroke: var(--surface); stroke-width: 2.5; }
.route-fallback { position: absolute; inset: 0; background: var(--surface); }
.map-pane .route-fallback { background: var(--chalk); }
.map-pane .route-start, .map-pane .route-end { stroke: var(--chalk); }

/* ---------- Detalhe da corrida ---------- */

.saved-note {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--walk);
  color: var(--walk-ink);
  font-weight: 700;
  font-size: 15px;
}
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-name { font: 800 clamp(34px, 10vw, 46px)/1 var(--f-display); }
.detail-date { color: var(--muted); margin-top: 6px; }
.detail-map {
  position: relative;
  height: min(62vw, 340px);
  min-height: 240px;
  margin: 16px -16px 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
@media (min-width: 592px) { .detail-map { margin: 16px 0 0; border-radius: 22px; border: 1px solid var(--line); } }
.detail-map.is-empty { display: grid; place-items: center; padding: 24px; color: var(--muted); text-align: center; height: auto; min-height: 140px; }
.legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.key { display: inline-block; width: 18px; height: 6px; border-radius: 3px; }
.key-run { background: var(--run); }
.key-walk { background: var(--walk-strong); margin-left: 10px; }

.big-stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 0;
}
.big-stats dt { font-size: 14px; color: var(--muted); font-weight: 700; }
.big-stats dd { margin: 0; font: 800 clamp(38px, 12vw, 56px)/1 var(--f-display); white-space: nowrap; }
.big-stats small { font-size: 0.42em; margin-left: 2px; }

.split-share { margin-top: 24px; }
.share-bar { height: 14px; border-radius: 7px; background: var(--walk); overflow: hidden; }
.share-bar span { display: block; height: 100%; width: calc(var(--share) * 100%); background: var(--run); }
.share-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.share-cols h3 { font: 700 20px/1.1 var(--f-display); margin-bottom: 2px; }
.share-run h3 { color: var(--run); }
:root[data-resolved-theme="dark"] .share-run h3 { color: #8EA0FF; }
.share-walk h3 { color: var(--walk-strong); }
:root[data-resolved-theme="dark"] .share-walk h3 { color: var(--walk); }
.share-cols p { font-size: 16px; }

.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.mini-stats dt { font-size: 14px; color: var(--muted); }
.mini-stats dd { margin: 0; font-weight: 700; }

.splits { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.splits th { text-align: left; font-size: 14px; color: var(--muted); font-weight: 700; padding: 0 0 6px; }
.splits td { padding: 8px 0; border-top: 1px solid var(--line); }
.splits td:first-child { width: 3.6em; font-weight: 700; }
.splits td:nth-child(2) { width: 4.6em; font-weight: 700; }
.split-bar { display: inline-block; vertical-align: middle; height: 10px; border-radius: 5px; width: calc(var(--w) * 100%); max-width: calc(100% - 7em); min-width: 6px; background: var(--run); opacity: 0.85; }
.splits tr.is-best .split-bar { opacity: 1; }
.best { margin-left: 8px; font-size: 13px; font-weight: 700; color: var(--run); }
:root[data-resolved-theme="dark"] .best { color: #8EA0FF; }

.phase-list { list-style: none; margin: 0; padding: 0; counter-reset: ph; }
.ph {
  display: grid;
  grid-template-columns: 1fr auto 5.2em 3.6em;
  gap: 10px;
  align-items: center;
  padding: 10px 0 10px 14px;
  border-top: 1px solid var(--line);
  position: relative;
  font-variant-numeric: tabular-nums;
}
.ph::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 5px; border-radius: 3px; }
.ph-run::before { background: var(--run); }
.ph-walk::before { background: var(--walk-strong); }
.ph-type { font-weight: 700; }
.ph-type em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 14px; }
.ph-num { text-align: right; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.detail-actions + .small { margin-top: 10px; }

/* ---------- Histórico ---------- */

.week-hero { margin-top: 4px; }
.week-big { font: 800 clamp(84px, 30vw, 128px)/0.86 var(--f-display); letter-spacing: -0.02em; }
.week-big small { font-size: 0.3em; margin-left: 6px; letter-spacing: 0; }
.week-sub { color: var(--muted); margin-top: 8px; }
.weeks { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; height: 120px; margin-top: 18px; align-items: end; }
.week-col { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; }
.week-bar { align-self: end; height: max(4px, calc(var(--h) * 100%)); border-radius: 6px 6px 2px 2px; background: color-mix(in srgb, var(--fg) 16%, transparent); }
.week-col.is-now .week-bar { background: var(--run); }
.week-lbl { font-size: 12px; color: var(--muted); text-align: center; }

.records dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.records dl > div { padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.records dt { font-size: 13px; color: var(--muted); font-weight: 700; line-height: 1.25; }
.records dd { margin: 6px 0 0; font: 800 28px/1 var(--f-display); white-space: nowrap; }
.records dd small { font-size: 0.5em; }

.run-list { list-style: none; margin: 0; padding: 0; }
.run-item {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
}
.run-thumb { width: 76px; height: 76px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.run-meta { display: grid; min-width: 0; }
.run-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-date { color: var(--muted); font-size: 15px; }
.run-nums { display: grid; justify-items: end; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.run-nums strong { font: 800 30px/1 var(--f-display); color: var(--fg); }
.run-nums strong small { font-size: 0.5em; }

.empty { display: grid; justify-items: start; gap: 18px; margin-top: 30px; }
.empty p { color: var(--muted); max-width: 32ch; }
.empty-art { display: grid; gap: 6px; width: 150px; }
.empty-art span { height: 34px; border-radius: 12px; }
.lane-run { background: var(--run); }
.lane-walk { background: var(--walk); width: 62%; }

/* ---------- Ajustes ---------- */

.group { margin-bottom: 8px; }
.group .row, .group > .switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 60px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.group .row { flex-wrap: wrap; }
.group > .switch { justify-content: flex-start; }
.group > .switch .row-text { order: -1; flex: 1; }
.row-text { display: grid; }
.row-text small { color: var(--muted); font-size: 14px; line-height: 1.35; }
.group-text { color: var(--muted); margin-bottom: 12px; max-width: 60ch; }
.test-btn { margin-top: 6px; }
.input-unit { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.input-unit input {
  width: 5.2em;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  text-align: right;
}
.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.code-box code { font: 700 clamp(16px, 5.1vw, 24px)/1.1 var(--f-display); letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.sync-line { color: var(--muted); font-size: 15px; margin: 10px 0 12px; min-height: 1.5em; }
.use-code { display: grid; gap: 10px; margin: 14px 0; }
.use-code[hidden] { display: none; }
.group .btn-row + .btn, .use-code + .btn { margin-top: 10px; }
.field { display: grid; gap: 6px; font-weight: 700; font-size: 15px; }
.field input {
  min-height: 50px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 18px;
  font-weight: 400;
}
.about { color: var(--muted); font-size: 14px; margin-top: 32px; }

/* ---------- Diálogos e avisos ---------- */

dialog.sheet {
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  padding: 24px 20px calc(20px + var(--safe-b));
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  color: var(--fg);
}
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 26px; } }
dialog.sheet::backdrop { background: rgba(21, 26, 53, 0.55); }
dialog.sheet h2 { font: 800 30px/1.05 var(--f-display); margin-bottom: 8px; }
dialog.sheet p { color: var(--muted); }
dialog.sheet form { display: grid; gap: 10px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.sheet-actions .btn.danger:not(.ghost) { background: var(--danger); color: #fff; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--chalk);
  font-weight: 700;
  font-size: 15px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
:root[data-resolved-theme="dark"] #toast { background: var(--chalk); color: var(--ink); }
#toast.is-on { opacity: 1; transform: translate(-50%, 0); }
#toast.is-error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .face-tide { animation: none; }
}
