:root {
  --bg: #f2f5f1;
  --ink: #172e25;
  --muted: #475b51;
  --faint: #52675b;
  --card: #ffffff;
  --on-accent: #fff;
  --line: #dce5dd;
  --accent: #22634b;
  --accent-soft: #e6f2e9;
  --work: #635bff;
  --pace: #335c9a;
  --easy: #09825d;
  --recovery: #09825d;
  --warmup: #e6a817;
  --cooldown: #3d5afe;
  --pause: #8898aa;
  --better: #0d7a4f;
  --better-bg: #e7f8ef;
  --worse: #a11d3a;
  --worse-bg: #fde8ee;
  --hover: #f4f7f4;
  --shadow: 0 2px 5px rgba(50, 50, 93, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #101a16;
  --ink: #edf5ef;
  --muted: #b5c9be;
  --faint: #a0b6a9;
  --card: #17241e;
  --on-accent: #10291e;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #91d7b0;
  --accent-soft: #263d31;
  --work: #9d97ff;
  --pace: #a9c5f2;
  --easy: #3dd68c;
  --recovery: #3dd68c;
  --better: #8ef0c0;
  --better-bg: rgba(9, 130, 93, 0.28);
  --worse: #ffb4c4;
  --worse-bg: rgba(223, 27, 65, 0.28);
  --hover: rgba(255, 255, 255, 0.04);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; }
h1, h2, h3 { font-family: var(--sans); font-weight: 600; letter-spacing: -0.02em; margin: 0; color: var(--ink); }
h1 { font-size: clamp(29px, 4vw, 42px); line-height: 1.12; letter-spacing: -0.045em; }
h2 { font-size: 16px; letter-spacing: -0.01em; }
h3 { font-size: 13px; font-weight: 600; letter-spacing: 0; }

.app { display: flex; min-height: 100vh; align-items: stretch; }
.side {
  width: 210px;
  flex: 0 0 210px;
  background: #142f25;
  color: #f1faf3;
  padding: 26px 16px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; color: inherit; padding: 0 8px 32px; }
.brand:hover { text-decoration: none; }
.brand strong { font-size: 18px; font-weight: 600; letter-spacing: -0.03em; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
  color: #c1d6c8;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.side nav a:hover, .theme-toggle:hover { background: #204737; color: #fff; text-decoration: none; }
.side nav a[aria-current] { background: #2c5543; color: #fff; box-shadow: inset 3px 0 #a3e0ad; }
.theme-toggle {
  margin-top: auto;
  background: transparent;
  color: #c1d6c8;
  border: 1px solid #406052;
  align-self: flex-start;
}
.side :focus-visible { outline-color: #a3e0ad; }
.when-dark { display: none; }
html[data-theme="dark"] .when-light { display: none; }
html[data-theme="dark"] .when-dark { display: inline; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1160px; margin: 0 auto; padding: 42px 36px 60px; }
.page-head { margin: 0 0 26px; }
.page-head-actions, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.lede, .muted, .u, .when { color: var(--muted); }
.lede { max-width: 62ch; margin: 6px 0 0; font-size: 14px; }
.notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--ink);
  border-radius: 8px;
  font-size: 13px;
}
.notice.bad { background: var(--worse-bg); color: var(--worse); }

.card, .panel, .track, .sync, .drop {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card, .panel { padding: 20px 22px; margin: 0 0 16px; }
.card > h2, .panel > h2, .panel > h3, .pins > h2 { margin: 0 0 10px; font-size: 17px; }

.stats, .metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}
.stats > div, .metrics > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  text-align: left;
}
.track .metrics { margin: 16px 18px 4px; }
.track .metrics > div { box-shadow: none; }
.k {
  display: block;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 4px;
}
.v, .big {
  display: block;
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--ink);
}
.u { display: block; font-size: 12px; margin-top: 6px; }

.track { padding: 0 0 8px; margin: 0 0 20px; }
.track-h {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 16px 18px 0;
  background: transparent;
  border: 0;
}
.track-h h2 { font-size: 16px; }
.track .chart-box, .track .section, .track .muted, .track .table-wrap, .track .sessions, .track .empty-note { margin-left: 18px; margin-right: 18px; }
.track .section { margin-top: 18px; padding-top: 0; border: 0; }

.env-switch { display: flex; gap: 6px; }
.env-switch button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  margin: 0;
}
.env-switch button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.delta { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 500; }
.delta.down, .delta.up, .delta.flat { padding: 2px 8px; border-radius: 999px; }
.delta.down { color: var(--better); background: var(--better-bg); }
.delta.up { color: var(--worse); background: var(--worse-bg); }
.delta.flat { color: var(--muted); background: var(--hover); }

.chart-box { position: relative; height: 220px; margin: 8px 18px 4px; }
.chart-box.tall { height: 260px; }

.hr-chip {
  display: inline-block;
  min-width: 2.4em;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  background: var(--hover);
  color: var(--ink);
}
.hr-chip.z-easy { background: #e7f8ef; color: #0d7a4f; }
.hr-chip.z-steady { background: #fff6d8; color: #8a5a00; }
.hr-chip.z-tempo { background: #ffefe4; color: #9a4310; }
.hr-chip.z-hard { background: #fde8ee; color: #a11d3a; }
html[data-theme="dark"] .hr-chip.z-easy { background: rgba(9, 130, 93, 0.25); color: #b6f3d2; }
html[data-theme="dark"] .hr-chip.z-steady { background: rgba(230, 168, 23, 0.22); color: #ffe7a3; }
html[data-theme="dark"] .hr-chip.z-tempo { background: rgba(232, 93, 4, 0.22); color: #ffd0b0; }
html[data-theme="dark"] .hr-chip.z-hard { background: rgba(223, 27, 65, 0.25); color: #ffc2ce; }

.section { font-size: 13px; }
.reps th, .reps td { text-align: right; }
.reps th:first-child, .reps td:first-child { text-align: left; }
.sessions { list-style: none; margin: 4px 18px 12px; padding: 0; }
.sessions li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
}
.sessions a { color: var(--ink); font-weight: 500; }
.sessions a:hover { color: var(--accent); }
.sessions .hr-chip { justify-self: end; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; vertical-align: middle; border-bottom: 1px solid var(--line); }
thead th {
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: right;
  background: transparent;
}
thead th:first-child { text-align: left; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-family: var(--sans); font-size: 13px; }
.phase { font-weight: 500; white-space: nowrap; }
.phase.work { color: var(--accent); }
.watch { color: var(--faint); font-weight: 400; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 500;
  background: var(--hover);
  color: var(--muted);
  border: 0;
}
.badge.kind { background: var(--accent-soft); color: var(--accent); }
.badges { display: flex; gap: 6px; align-items: center; margin-top: 8px; }

.bar { display: flex; height: 8px; margin: 12px 18px; border-radius: 999px; overflow: hidden; background: var(--hover); }
.bit { height: 100%; min-width: 1px; }
.bit.warmup, .legend i.warmup { background: #f2c14e; }
.bit.work, .legend i.work { background: #635bff; }
.bit.recovery, .legend i.recovery { background: #80e9ff; }
.bit.cooldown, .legend i.cooldown { background: #3d5afe; }
.bit.pause, .legend i.pause { background: #c1c9d2; }
.bit.steady, .legend i.steady { background: #15be53; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; list-style: none; padding: 0 18px; margin: 0 0 8px; color: var(--faint); font-size: 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 6px; }

.import-row { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 16px; }
.sync, .drop { padding: 16px; margin: 0 0 16px; }
.sync { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.sync span, .drop-copy span { color: var(--muted); font-size: 13px; }
.drop { position: relative; border-style: dashed; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.filters { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.filters a {
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.filters a:hover { text-decoration: none; color: var(--ink); }
.filters a.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

button, .btn {
  font: 500 13px/1.2 var(--sans);
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.05); text-decoration: none; }
button:disabled { opacity: 0.52; cursor: not-allowed; }
button.ghost, a.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.mono { font-family: var(--mono); }
pre.standard {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--hover);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  line-height: 1.6;
}
.standard-list { margin: 12px 0 0; padding-left: 18px; color: var(--muted); }
.standard-list li { margin: 6px 0; }
button.danger { background: transparent; color: var(--worse); border: 1px solid var(--line); }
input, select {
  font: 14px var(--sans);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 10px;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
label small { font-weight: 400; color: var(--faint); }
form.belt, .settings, .stack-form, .pair { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings input, .settings select { width: 100%; min-width: 0; }
.form-actions { grid-column: 1 / -1; margin-top: 4px; }
.choice { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); }
.km { width: 7rem; }
.belt-card p, .notes p { color: var(--muted); max-width: 72ch; margin: 0 0 10px; }
.back { margin: 0 0 12px; font-size: 13px; }
.danger-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.pin-list { list-style: none; margin: 0; padding: 0; }
.pin-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.pin-list li div { display: flex; flex-direction: column; gap: 2px; }
.pin-actions, .pin-actions form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sessions { list-style: none; margin: 4px 18px 12px; padding: 0; }
.sessions li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 10px 2px;
  border-top: 1px solid var(--line);
}
.sessions a { color: var(--ink); font-weight: 500; }
.sessions .hr-chip { justify-self: end; }
.empty-note { color: var(--muted); margin: 12px 18px 16px; }
.section { margin-bottom: 6px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.workout-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.workout-option {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.workout-option strong { overflow-wrap: anywhere; font-family: var(--mono); font-size: 13px; }
.workout-option span { color: var(--muted); font-size: 12px; }
.workout-option:hover, .workout-option[aria-current] { border-color: var(--accent); text-decoration: none; }
.workout-option[aria-current] { background: var(--accent-soft); box-shadow: inset 0 -2px var(--accent); }
.section-head h2 { margin: 0; font-size: 18px; }
.inset-metrics { margin: 16px 0; grid-template-columns: repeat(auto-fit, minmax(min(135px, 100%), 1fr)); }
.inset-metrics > div { background: var(--hover); box-shadow: none; }
.workout-progress .chart-box, .detail .chart-box { margin: 12px 0; }
.workout-progress .sessions { margin: 0; }
.workout-progress .disclosure { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; margin: 12px 0 16px; }
.disclosure > summary { cursor: pointer; font-weight: 600; }
.disclosure[open] > summary { margin-bottom: 12px; }
.timeline-card .bar { margin: 12px 0; }
.timeline-card .legend { padding: 0; }
.detail .when { margin: 0 0 6px; }
.detail .controls > section { margin: 0; box-shadow: none; }
.detail .danger-row { margin-top: 18px; flex-wrap: wrap; }
.detail .table-wrap, .workout-progress .table-wrap { width: 100%; }
.table-wrap th { white-space: nowrap; }
.log-table th:nth-child(2), .log-table th:nth-child(3) { text-align: left; }
.log-table td:first-child a { white-space: nowrap; }
.log-table .watch { display: block; }
tbody tr:last-child td { border-bottom: 0; }
.form-card { max-width: 840px; }
.form-card p { color: var(--muted); max-width: 65ch; }
.form-card > :last-child { margin-bottom: 0; }
.form-card input, .form-card select, .controls input, .controls select { max-width: 100%; }
.stack-form label { min-width: 0; }
[data-garmin-settings] { margin-top: 16px; }
[data-garmin-result]:empty { display: none; }
[data-garmin-request] > p { flex-basis: 100%; margin: 0; }
.library-list { list-style: none; margin: 0; padding: 0; }
.library-row { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.library-row:last-child { padding-bottom: 0; }
.library-row h3 { font: 500 14px var(--mono); overflow-wrap: anywhere; }
.library-row p { margin: 4px 0 0; }
.library-actions { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; }
.workout-tools { display: grid; gap: 10px; justify-items: start; }
.workout-tools [data-garmin-result] { display: block; max-width: 55ch; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .side {
    width: 100%;
    flex-basis: auto;
    height: auto;
    position: static;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
  }
  .brand { padding: 0; }
  .brand img { width: 28px; height: 28px; }
  .side nav { flex-direction: row; grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; }
  .side nav a { padding: 7px 9px; font-size: 13px; }
  .side nav a[aria-current] { box-shadow: inset 0 -2px #a3e0ad; }
  .theme-toggle { grid-column: 2; grid-row: 1; padding: 6px 9px; }
  main { padding: 24px 16px 40px; }
  .big, .v { font-size: 23px; }
}
@media (max-width: 520px) {
  .workout-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .settings { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card, .panel { padding: 15px; }
  .chart-box.tall { height: 235px; }
  .sessions li { gap: 8px; }
}

.signout { margin: 8px 0 0; }
.signin-page main { display: grid; min-height: 100vh; place-items: center; }
.signin-card { width: min(100%, 470px); padding: clamp(20px, 5vw, 36px); }
.signin-card h1 { margin-top: 12px; }
.signin-card button { margin-top: 22px; }
.signin-card [data-signin-status]:empty { display: none; }
@media (max-width: 800px) {
  .side:has(.signout) { grid-template-columns: 1fr auto auto; }
  .side:has(.signout) nav { grid-column: 1 / -1; }
  .signout { grid-column: 3; grid-row: 1; margin: 0; }
}
