:root {
  color-scheme: dark;
  --bg-0: #0b0a09;
  --bg-1: #131110;
  --bg-2: #1a1816;
  --bg-3: #221f1c;
  --bg-4: #2b2723;
  --line: rgba(255, 245, 230, 0.08);
  --line-strong: rgba(255, 245, 230, 0.15);
  --ink-0: #f5f1ea;
  --ink-1: #d6cfc2;
  --ink-2: #9a9285;
  --ink-3: #6a6358;
  --accent: #e8693a;
  --accent-2: #f0794a;
  --accent-soft: rgba(232, 105, 58, 0.13);
  --danger: #d94a4a;
  --good: #6a9a5a;
  --warn: #c9a14a;
  --blue: #6fa5c8;
  --topbar-bg: rgba(11, 10, 9, 0.92);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
  --photo-runner: url("/static/photos/pacekeeper/runner.jpg");
  --photo-track: url("/static/photos/pacekeeper/track.jpg");
  --photo-dawn: url("/static/photos/pacekeeper/dawn.jpg");
  --photo-tune: url("/static/photos/pacekeeper/tune.jpg");
  --photo-data: url("/static/photos/pacekeeper/data.jpg");
  --photo-stadium: url("/static/photos/pacekeeper/stadium.jpg");
  --photo-overview: url("/static/photos/pacekeeper/overview.jpg");
  --photo-config: url("/static/photos/pacekeeper/config.jpg");
  --photo-watch: url("/static/photos/pacekeeper/watch.jpg");
  --photo-zones: url("/static/photos/pacekeeper/zones.jpg");
  --photo-load: url("/static/photos/pacekeeper/load.jpg");
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: var(--sans);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-0: #f5f1ea;
  --bg-1: #fffaf3;
  --bg-2: #f0ebe2;
  --bg-3: #e8dfd3;
  --bg-4: #ddd2c2;
  --line: rgba(49, 38, 27, 0.11);
  --line-strong: rgba(49, 38, 27, 0.2);
  --ink-0: #171412;
  --ink-1: #342c24;
  --ink-2: #746a5e;
  --ink-3: #978c7f;
  --accent: #d85d31;
  --accent-2: #e8693a;
  --accent-soft: rgba(216, 93, 49, 0.13);
  --danger: #c83e3e;
  --good: #4f854b;
  --warn: #a27b24;
  --blue: #477f9f;
  --topbar-bg: rgba(255, 250, 243, 0.92);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg-0: #f5f1ea;
    --bg-1: #fffaf3;
    --bg-2: #f0ebe2;
    --bg-3: #e8dfd3;
    --bg-4: #ddd2c2;
    --line: rgba(49, 38, 27, 0.11);
    --line-strong: rgba(49, 38, 27, 0.2);
    --ink-0: #171412;
    --ink-1: #342c24;
    --ink-2: #746a5e;
    --ink-3: #978c7f;
    --accent: #d85d31;
    --accent-2: #e8693a;
    --accent-soft: rgba(216, 93, 49, 0.13);
    --danger: #c83e3e;
    --good: #4f854b;
    --warn: #a27b24;
    --blue: #477f9f;
    --topbar-bg: rgba(255, 250, 243, 0.92);
  }
}

* {
  box-sizing: border-box;
  letter-spacing: 0 !important;
}

[hidden],
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent);
  color: #1a0e07;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
strong {
  color: var(--ink-0);
}

h1 {
  margin-bottom: 8px;
  font-family: var(--serif);
  font-size: clamp(34px, 3.3vw, 48px);
  font-weight: 500;
  line-height: 1.04;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

code {
  border-radius: 6px;
  background: var(--bg-3);
  padding: 2px 6px;
}

.muted,
.stat-note {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
}

.page-kicker,
.stat-label,
.detail-metric span,
.race-metrics span,
th {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

.build-version,
.build-footer {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

.page-header .build-version {
  position: relative;
  z-index: 1;
  margin-bottom: 8px;
  color: rgba(255, 245, 230, 0.66);
}

.build-footer {
  margin-top: 16px;
  padding-top: 4px;
  text-align: right;
}

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-0);
}

.mobile-topbar,
.mobile-menu-toggle,
.mobile-menu-backdrop {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: var(--bg-1);
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg-3);
}

.brand-mark img,
.account-avatar img,
.profile-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand-name {
  display: block;
  color: var(--ink-0);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1;
}

.brand-tagline,
.account-label {
  display: block;
  margin-top: 4px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section {
  padding: 20px 10px 6px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
}

.nav-section:first-child {
  padding-top: 0;
}

.nav a {
  min-height: 34px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink-1);
  font-size: 13px;
  line-height: 1.2;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--ink-2);
}

.nav-icon svg,
.theme-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.nav a:hover {
  background: var(--bg-2);
  color: var(--ink-0);
}

.nav a:hover .nav-icon {
  border-color: var(--line-strong);
  color: var(--ink-0);
}

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav a.active .nav-icon {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-2));
  color: var(--accent);
}

.theme-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 3px;
}

.theme-toggle button {
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0;
  color: var(--ink-2);
}

.theme-toggle button:hover {
  background: var(--bg-3);
  color: var(--ink-0);
}

.theme-toggle button.active,
.theme-toggle button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.profile-theme-choice label:has(input:checked) {
  border-color: rgba(232, 105, 58, 0.42);
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-toggle-mobile {
  display: none;
}

.theme-toggle-floating {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 75;
  width: 112px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
}

.sidebar-account {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-link {
  min-height: 54px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px;
  color: var(--ink-1);
}

.account-link:hover,
.account-link.active {
  background: var(--bg-2);
}

.account-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: linear-gradient(135deg, #6a4a3a, #3a2a22);
  color: var(--ink-0);
  font-family: var(--serif);
}

.account-copy {
  min-width: 0;
}

.account-name,
.account-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-name {
  display: block;
  color: var(--ink-0);
  font-size: 12px;
}

.logout {
  margin: 0;
}

.content {
  width: 100%;
  min-width: 0;
  padding: 32px 32px 72px;
}

.page-header,
.home-hero {
  position: relative;
  min-height: 178px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 18px;
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  background:
    var(--page-photo, var(--photo-runner)) center / cover no-repeat,
    var(--bg-2);
  background-clip: padding-box;
}

.page-header::before,
.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.78)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.14));
  pointer-events: none;
}

.page-header > div:first-child,
.home-hero > div:first-child {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
}

.page-header .muted,
.home-hero .muted {
  max-width: 560px;
  color: rgba(255, 245, 230, 0.72);
}

.page-header > .actions,
.page-header > .status,
.page-header > .hero-disconnect {
  position: absolute;
  top: 28px;
  right: 32px;
  z-index: 2;
}

.page-header button.secondary,
.page-header .button.secondary,
.home-hero button.secondary,
.home-hero .button.secondary {
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(255, 255, 255, 0.32);
  color: var(--ink-0);
}

.page-header button.secondary:hover,
.page-header .button.secondary:hover,
.home-hero button.secondary:hover,
.home-hero .button.secondary:hover {
  background: rgba(0, 0, 0, 0.72);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}

.route-home {
  --page-photo: var(--photo-overview);
}

.route-setup {
  --page-photo: var(--photo-stadium);
}

.route-config {
  --page-photo: var(--photo-config);
}

.route-plan {
  --page-photo: var(--photo-track);
}

.route-zones {
  --page-photo: var(--photo-zones);
}

.route-load {
  --page-photo: var(--photo-load);
}

.route-changes {
  --page-photo: var(--photo-tune);
}

.route-log {
  --page-photo: var(--photo-data);
}

.route-garmin {
  --page-photo: var(--photo-watch);
}

.route-m365 {
  --page-photo: var(--photo-stadium);
}

.route-profile {
  --page-photo: var(--photo-dawn);
}

.home-hero {
  min-height: 340px;
  background:
    var(--photo-overview) center 42% / cover no-repeat,
    var(--bg-2);
  background-clip: padding-box;
}

.route-home .home-hero h1 {
  max-width: none;
  font-size: clamp(38px, 3.25vw, 54px);
  white-space: nowrap;
}

.route-home .home-hero > div:first-child {
  width: min(1180px, 100%);
}

.hero-countdown {
  white-space: nowrap;
}

.home-hero-metrics {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.home-hero-metrics div {
  border-top: 1px solid rgba(255, 245, 230, 0.18);
  padding-top: 12px;
}

.home-hero-metrics span,
.home-hero-metrics strong {
  display: block;
}

.home-hero-metrics strong {
  margin-top: 6px;
  color: #fff;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
}

button,
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #1a0e07;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 120ms ease;
}

button:hover,
.button:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #1a0e07;
}

button:active,
.button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary,
.button.secondary,
.logout button {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-1);
  font-weight: 500;
}

button.secondary:hover,
.button.secondary:hover,
.logout button:hover {
  background: var(--bg-2);
  border-color: var(--line-strong);
  color: var(--ink-0);
}

button.danger,
.button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

button.danger.ghost,
.button.danger.ghost {
  background: transparent;
  border-color: rgba(217, 74, 74, 0.4);
  color: var(--danger);
}

button.danger.ghost:hover,
.button.danger.ghost:hover {
  background: rgba(217, 74, 74, 0.08);
  border-color: var(--danger);
  color: var(--danger);
}

button.compact,
.button.compact {
  min-height: 34px;
  padding: 7px 11px;
}

.icon-only {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 20px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--ink-0);
  padding: 11px 12px;
  font: inherit;
  font-size: 13px;
  outline: 0;
}

input,
select {
  height: 48px;
  min-height: 48px;
}

input[type="file"] {
  height: auto;
  padding: 10px 12px;
}

input[type="color"] {
  padding: 5px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch,
input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 5px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

.field-stack {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

label .hint,
.field-hint {
  color: var(--ink-3);
  font-weight: 400;
}

.field-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-group legend {
  margin-bottom: 7px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
}

.time-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(62px, 1fr));
  gap: 10px;
}

.time-picker label {
  color: var(--ink-2);
  font-size: 12px;
}

.time-picker-prominent input {
  font-size: 18px;
  font-weight: 700;
}

.grid,
.dashboard-grid,
.form-grid,
.stat-grid {
  display: grid;
  gap: 16px;
}

.grid {
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.wallpaper-layout .form-grid {
  align-items: start;
}

.wallpaper-config-form h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.wallpaper-section {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.wallpaper-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wallpaper-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
  gap: 12px;
  align-items: end;
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.span-4 {
  grid-column: span 4;
}

.span-6 {
  grid-column: span 6;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: 1 / -1;
}

.stack {
  display: grid;
  gap: 16px;
}

.compact-stack {
  gap: 8px;
}

.topline,
.page-header .actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions.end {
  justify-content: flex-end;
}

.panel,
.week,
.race-card,
.zone,
.metric,
.log-entry,
.stat-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
}

.panel,
.week,
.race-card,
.zone,
.metric,
.log-entry,
.empty-state {
  padding: 20px;
}

.stat-card {
  min-height: 124px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 20px;
}

.stat-value {
  color: var(--ink-0);
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
}

.stat-value.small,
.zone-value {
  font-size: 22px;
}

.stat-value-button {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.stat-value-button:hover {
  color: var(--accent-2);
}

.goal-probability-current {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 16px;
}

.goal-probability-current strong {
  display: block;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 500;
  line-height: 1;
}

.goal-probability-chart {
  margin-top: 18px;
  overflow-x: auto;
}

.goal-probability-chart svg {
  display: block;
  min-width: 620px;
  width: 100%;
  height: auto;
}

.goal-chart-grid,
.goal-chart-axis {
  stroke: var(--line);
  stroke-width: 1;
}

.goal-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.goal-chart-point {
  fill: var(--bg-1);
  stroke: var(--accent);
  stroke-width: 3;
}

.goal-chart-label,
.goal-chart-date,
.goal-chart-percent {
  fill: var(--ink-2);
  font-family: var(--mono);
  font-size: 12px;
}

.goal-chart-percent {
  fill: var(--ink-1);
  font-weight: 700;
  text-anchor: middle;
}

.goal-probability-history {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.goal-probability-row {
  display: grid;
  grid-template-columns: 130px 64px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.goal-probability-row span {
  color: var(--ink-2);
  font-size: 13px;
}

.goal-probability-row strong {
  color: var(--accent);
}

.goal-probability-row p {
  margin: 0;
  color: var(--ink-1);
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.alert,
.warning {
  border: 1px solid rgba(201, 161, 74, 0.32);
  border-radius: 8px;
  background: rgba(201, 161, 74, 0.12);
  color: var(--ink-1);
  padding: 13px 15px;
}

.alert strong {
  color: var(--warn);
}

.alert.danger {
  border-color: rgba(217, 74, 74, 0.32);
  background: rgba(217, 74, 74, 0.12);
}

.alert.success {
  border-color: rgba(106, 154, 90, 0.32);
  background: rgba(106, 154, 90, 0.12);
}

.status,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(106, 154, 90, 0.32);
  border-radius: 999px;
  background: rgba(106, 154, 90, 0.12);
  color: #8eb87e;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill.neutral {
  border-color: var(--line);
  background: var(--bg-3);
  color: var(--ink-2);
}

.pill.warning,
.status.pending,
.status.syncing {
  border-color: rgba(201, 161, 74, 0.32);
  background: rgba(201, 161, 74, 0.12);
  color: var(--warn);
}

.pill.recovery {
  border-color: rgba(91, 122, 143, 0.38);
  background: rgba(91, 122, 143, 0.14);
  color: #8eb5cc;
}

.pill.current {
  border-color: rgba(232, 105, 58, 0.48);
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.danger,
.status.error,
.status.disconnected {
  border-color: rgba(217, 74, 74, 0.34);
  background: rgba(217, 74, 74, 0.12);
  color: #e36a6a;
}

.status-dot {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 999px;
  background: var(--ink-3);
  box-shadow: 0 0 0 4px rgba(255, 245, 230, 0.06);
}

.status-dot.connected,
.status-dot.active {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(106, 154, 90, 0.14);
}

.status-dot.warning,
.status-dot.pending,
.status-dot.syncing {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(201, 161, 74, 0.14);
}

.status-dot.danger,
.status-dot.error,
.status-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(217, 74, 74, 0.14);
}

.sync-progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
}

.sync-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.sync-progress.indeterminate .sync-progress-bar {
  width: 35% !important;
  animation: sync-progress 1.2s ease-in-out infinite;
}

.sync-meta {
  font-size: 12px;
}

.setup-assistant {
  display: grid;
  gap: 12px;
}

.setup-step {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  padding: 18px;
}

.setup-step.complete {
  border-color: rgba(106, 154, 90, 0.28);
}

.setup-step-check {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 13px;
}

.setup-step.complete .setup-step-check {
  border-color: rgba(106, 154, 90, 0.46);
  background: rgba(106, 154, 90, 0.14);
  color: #8eb87e;
}

.setup-step-copy h2 {
  margin-bottom: 6px;
}

.setup-step-note {
  margin: 10px 0 0;
  color: var(--warn);
  font-size: 12px;
  line-height: 1.45;
}

@keyframes sync-progress {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(320%);
  }
}

.command-bar,
.connection-health,
.plan-command-panel,
.load-dashboard {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.command-bar {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
}

.command-primary,
.command-status,
.connection-health,
.plan-command-panel,
.load-gauge-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  padding: 18px;
}

.command-primary,
.connection-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.command-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.command-primary h2,
.command-status h2,
.plan-command-panel h2,
.load-gauge-card h2 {
  margin-bottom: 6px;
  font-size: 19px;
}

.today-workout-link {
  color: var(--ink-0);
  text-decoration-color: rgba(106, 154, 90, 0.65);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.today-workout-link:hover {
  color: var(--good);
}

.ops-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.connection-list,
.log-toolbar {
  display: grid;
  gap: 12px;
}

.plan-health-strip,
.connection-health-meta,
.plan-command-metrics {
  display: grid;
  gap: 10px;
}

.plan-overview-panel {
  display: grid;
  gap: 24px;
}

.plan-overview-panel .topline {
  margin-bottom: 2px;
}

.plan-overview-panel .plan-health-strip {
  margin-top: 4px;
}

.plan-overview-metrics {
  gap: 26px 32px;
  padding-top: 6px;
}

.plan-overview-events {
  margin-top: 8px;
}

.plan-health-strip,
.plan-command-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.connection-health {
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.9fr);
  align-items: center;
}

.connection-health-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plan-health-strip div,
.connection-health-meta div,
.plan-command-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 12px;
}

.plan-health-strip strong,
.connection-health-meta strong,
.plan-command-metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.connection-health-meta span,
.plan-command-metrics span {
  color: var(--ink-3);
  font-size: 11px;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(160px, 2fr) minmax(80px, 0.6fr);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 12px;
}

.plan-overview-events .event-row {
  grid-template-columns: minmax(130px, 0.7fr) minmax(260px, 1fr) minmax(100px, 0.45fr);
  gap: 24px;
  padding: 18px 20px;
}

.event-row span,
.event-row em {
  color: var(--ink-2);
  font-style: normal;
  font-weight: 700;
}

.config-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
}

.config-steps {
  position: sticky;
  top: 24px;
  align-self: start;
  display: grid;
  gap: 8px;
}

.config-steps a,
.config-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-1);
  color: var(--ink-1);
  padding: 12px;
}

.config-steps a {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 13px;
}

.config-steps a:hover,
.config-steps a.active {
  border-color: rgba(232, 105, 58, 0.42);
  background: var(--accent-soft);
  color: var(--accent);
}

.config-summary {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  color: var(--ink-2);
  font-size: 12px;
}

.config-workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.config-step-panel {
  scroll-margin-top: 24px;
}

.config-step-panel h2,
.section-head h2 {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 750;
}

.checks,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.checks label,
.segmented label,
.toggle-line {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 10px 12px;
  cursor: pointer;
}

.checks input,
.segmented input,
.toggle-line input {
  width: auto;
  min-height: 0;
  accent-color: var(--accent);
}

.day-toggle-grid label {
  min-width: 70px;
  justify-content: center;
}

.toggle-line {
  width: fit-content;
}

.blocked-list,
.blocked-rows {
  display: grid;
  gap: 12px;
}

.blocked-list-header,
.blocked-row {
  display: grid;
  gap: 12px;
}

.blocked-list-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.blocked-row {
  grid-template-columns: minmax(160px, 0.75fr) minmax(220px, 1fr) auto;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 12px;
}

.strava-workflow,
.strava-status-grid {
  display: grid;
  gap: 12px;
}

.strava-workflow {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.strava-step {
  min-width: 0;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 14px;
}

.strava-step > span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.strava-step code {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.strava-status-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.sticky-actions {
  grid-column: 2;
  display: flex;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  padding: 12px;
}

.plan-filter-bar,
.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plan-filter-bar .active,
.segmented-control .active {
  border-color: rgba(232, 105, 58, 0.42);
  background: var(--accent-soft);
  color: var(--accent);
}

.plan-week {
  overflow: hidden;
  padding: 0;
}

.plan-week.is-current {
  border-color: rgba(232, 105, 58, 0.42);
}

.plan-week.is-current .week-summary {
  background:
    linear-gradient(90deg, rgba(232, 105, 58, 0.18), rgba(232, 105, 58, 0.04) 58%, transparent),
    var(--bg-2);
  box-shadow: inset 4px 0 0 var(--accent);
}

.plan-week[hidden],
.workout-button[hidden] {
  display: none !important;
}

.week-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.week-summary::-webkit-details-marker,
.zone-logic summary::-webkit-details-marker,
.adjustment-entry summary::-webkit-details-marker {
  display: none;
}

.week-summary h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 15px;
}

.week-current-pill,
.week-recovery-pill {
  padding: 3px 8px;
  font-size: 9px;
}

.week-summary-metrics,
.workout-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.week-summary-metrics span,
.workout-meta-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-2);
  padding: 4px 8px;
  font-size: 11px;
}

.week-workouts {
  border-top: 1px solid var(--line);
}

.workout,
.workout-button {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink-1);
  padding: 14px 16px;
  text-align: left;
}

.workout-button:hover {
  background: var(--bg-2);
  color: var(--ink-0);
}

.workout:last-child {
  border-bottom: 0;
}

.workout.is-completed {
  background: rgba(106, 154, 90, 0.08);
  box-shadow: inset 3px 0 0 rgba(106, 154, 90, 0.42);
}

.workout.is-intermediate {
  background: rgba(201, 161, 74, 0.09);
  box-shadow: inset 3px 0 0 rgba(201, 161, 74, 0.45);
}

.workout-date {
  display: grid;
  gap: 3px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11px;
}

.workout-date .workout-time {
  color: var(--ink-1);
}

.workout-title {
  color: var(--ink-0);
  font-size: 14px;
  font-weight: 700;
}

.workout .muted {
  margin: 4px 0 8px;
}

.workout-status-pill {
  align-self: center;
}

.missed-indicator,
.linked-indicator {
  display: inline-flex;
  margin-left: 8px;
  border-radius: 999px;
  background: rgba(217, 74, 74, 0.14);
  color: #e36a6a;
  padding: 3px 8px;
  font-size: 11px;
}

.race-card {
  border-color: rgba(232, 105, 58, 0.32);
  background: linear-gradient(135deg, rgba(232, 105, 58, 0.10), transparent), var(--bg-1);
}

.race-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #163f5f;
  color: #fff;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.race-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.race-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 14px;
}

.race-metrics strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.race-note {
  margin-top: 16px;
  color: var(--ink-2);
}

.load-dashboard {
  grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(160px, 0.7fr));
}

.load-gauge-card {
  min-height: 190px;
}

.acwr-gauge {
  position: relative;
  height: 16px;
  margin-top: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c9a14a 0 22%, #6a9a5a 22% 72%, #c9a14a 72% 84%, #d94a4a 84% 100%);
}

.acwr-gauge span {
  position: absolute;
  top: -7px;
  left: clamp(7px, var(--value), calc(100% - 7px));
  z-index: 1;
  width: 6px;
  height: 30px;
  border: 1px solid rgba(11, 10, 9, 0.86);
  border-radius: 999px;
  background: var(--ink-0);
  box-shadow: 0 0 0 2px rgba(255, 245, 230, 0.2), 0 8px 18px rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
}

.gauge-scale,
.chart-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--ink-3);
  font-size: 11px;
}

.load-chart-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.load-chart {
  --load-row-count: 1;
  min-width: max(100%, calc(var(--load-row-count) * 48px));
  height: 220px;
  display: grid;
  grid-template-columns: repeat(var(--load-row-count), minmax(32px, 1fr));
  align-items: stretch;
  gap: 4px;
  padding-top: 16px;
}

.load-chart-day {
  height: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 22px;
  gap: 6px;
}

.load-chart-bars {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}

.load-chart-date {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}

.load-bar {
  width: 42%;
  min-height: 4px;
  border-radius: 3px 3px 0 0;
}

.load-bar.acute,
.chart-legend .acute {
  background: var(--accent);
}

.load-bar.chronic,
.chart-legend .chronic {
  background: rgba(255, 245, 230, 0.26);
}

.load-chart-bars i {
  position: absolute;
  left: 50%;
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  transform: translateX(-50%);
  background: var(--good);
}

.load-chart-bars i.warning {
  background: var(--warn);
}

.load-chart-bars i.danger {
  background: var(--danger);
}

.chart-legend {
  justify-content: flex-start;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 2px;
}

.chart-legend .acwr {
  border-radius: 999px;
  background: var(--good);
}

.chart-legend .acwr-watch {
  background: var(--warn);
}

.chart-legend .acwr-risk {
  background: var(--danger);
}

.load-trend-empty {
  min-height: 190px;
  display: grid;
  align-content: center;
  gap: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 245, 230, 0.035), transparent), var(--bg-2);
  padding: 22px;
}

.load-mini-days {
  max-width: 360px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.load-mini-days span {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-4);
}

.load-mini-days span.filled {
  background: var(--accent);
}

.metric-details {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 14px;
  font-size: 14px;
}

.load-history-card {
  padding: 16px;
}

.zone-band-grid {
  display: grid;
  gap: 12px;
}

.zone-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(180px, 0.65fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.zone-card .topline {
  margin: 0;
}

.zone-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.zone-band-visual {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #6a9a5a, #9aa15a, #c9a14a, #e8693a, #d94a4a);
}

.zone-band-visual span {
  display: block;
  width: var(--size);
  height: 100%;
  margin-left: var(--start);
  border-radius: inherit;
  background: #fff5e6;
}

.zone-logic summary {
  cursor: pointer;
  list-style: none;
}

.log-toolbar {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  align-items: end;
}

.search-field {
  gap: 6px;
}

.adjustment-timeline .log-entry {
  max-height: none;
}

.adjustment-entry {
  overflow: hidden;
  padding: 0;
}

.adjustment-entry summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.adjustment-entry summary h2 {
  margin: 4px 0 0;
  line-height: 1.32;
}

.adjustment-entry:not([open]) summary h2 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.adjustment-entry summary::after {
  content: "Öffnen";
  grid-column: 1 / -1;
  color: var(--ink-3);
  font-size: 11px;
}

.adjustment-entry[open] summary::after {
  content: "Schliessen";
}

.adjustment-detail-body {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 0 18px 18px;
}

.analysis-block {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 14px;
}

.analysis-block p {
  margin: 0;
  line-height: 1.58;
}

.change-list {
  margin: 0;
  padding-left: 20px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: var(--bg-1);
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-2);
}

td {
  color: var(--ink-1);
}

tr:hover td {
  background: var(--bg-2);
}

tr:last-child td {
  border-bottom: 0;
}

.app-log-table {
  min-width: 1080px;
}

.technical-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.technical-header h1 {
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 650;
  line-height: 1.2;
}

.technical-header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

.technical-log {
  padding: 0;
  overflow: hidden;
}

.technical-log-toolbar {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.technical-log-search input {
  height: 38px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
}

.technical-log-table-wrap {
  max-height: calc(100vh - 280px);
  min-height: 420px;
  overflow: auto;
  scrollbar-color: var(--accent) var(--bg-2);
}

.technical-log-table {
  min-width: 1120px;
  table-layout: fixed;
  background: #0f0e0d;
  font-family: var(--mono);
  font-size: 11px;
}

.technical-log-table th,
.technical-log-table td {
  padding: 8px 10px;
  vertical-align: top;
}

.technical-log-table th {
  background: #181613;
}

.technical-log-table tr:hover td {
  background: rgba(255, 245, 230, 0.035);
}

.technical-log-table th:nth-child(1),
.technical-log-table td:nth-child(1) {
  width: 142px;
}

.technical-log-table th:nth-child(2),
.technical-log-table td:nth-child(2) {
  width: 86px;
}

.technical-log-table th:nth-child(3),
.technical-log-table td:nth-child(3) {
  width: 120px;
}

.technical-log-table th:nth-child(4),
.technical-log-table td:nth-child(4) {
  width: 160px;
}

.technical-log-table th:nth-child(6),
.technical-log-table td:nth-child(6) {
  width: 80px;
  text-align: right;
}

.technical-details-control {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.technical-undelete-form {
  display: inline;
}

.technical-message {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.mono-cell {
  overflow: hidden;
  color: var(--ink-2);
  font-family: var(--mono);
  text-overflow: ellipsis;
}

.nowrap {
  white-space: nowrap;
}

.technical-level {
  display: inline-block;
  min-width: 58px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
  color: var(--ink-1);
  text-align: center;
  text-transform: uppercase;
}

.technical-level-error {
  border-color: rgba(217, 74, 74, 0.45);
  color: #ff9b9b;
}

.technical-level-warning {
  border-color: rgba(201, 161, 74, 0.45);
  color: #e8c36a;
}

.technical-level-info {
  border-color: rgba(106, 154, 90, 0.45);
  color: #a8d794;
}

.technical-level-debug {
  color: var(--ink-3);
}

.technical-details-control {
  text-align: right;
}

.technical-details-toggle {
  min-height: 26px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 10px;
}

.technical-details-row td {
  padding: 0;
  background: #0b0a09;
}

.technical-details-row pre {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #0b0a09;
  color: var(--ink-1);
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.wrap-cell {
  max-width: 420px;
  white-space: normal;
}

.detail-chip {
  display: inline-flex;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--ink-2);
  padding: 4px 8px;
  font-size: 12px;
}

.route-garmin .activity-list .table-wrap,
.route-log .table-wrap {
  max-height: 620px;
  scrollbar-color: var(--accent) var(--bg-2);
}

.route-garmin .activity-list table,
.route-log table {
  font-size: 11.5px;
}

.route-garmin .activity-list td,
.route-garmin .activity-list th,
.route-log td,
.route-log th {
  padding: 10px 12px;
}

.route-garmin .activity-list td:last-child,
.route-garmin .activity-list th:last-child {
  position: sticky;
  right: 0;
  background: var(--bg-1);
  box-shadow: -12px 0 18px rgba(11, 10, 9, 0.72);
}

.profile-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.profile-photo {
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-3);
  color: var(--accent);
  font-family: var(--serif);
  font-size: 42px;
}

.file-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-picker-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallpaper-current-background {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  max-width: 520px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
}

.wallpaper-current-background img {
  width: 86px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
}

.wallpaper-current-background .hint {
  display: block;
  margin-top: 3px;
}

.wallpaper-advanced summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
}

.wallpaper-advanced[open] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.wallpaper-advanced[open] summary {
  grid-column: 1 / -1;
}

.wallpaper-preview,
.wallpaper-background-preview {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-3);
  object-fit: cover;
}

.wallpaper-preview {
  aspect-ratio: 16 / 9;
}

.wallpaper-background-preview {
  margin-top: 8px;
  aspect-ratio: 16 / 10;
}

.wallpaper-metric {
  min-height: auto;
  padding: 14px 16px;
}

.danger-panel,
.danger-zone {
  border-color: rgba(217, 74, 74, 0.32);
  background: linear-gradient(180deg, rgba(217, 74, 74, 0.08), transparent 58%), var(--bg-1);
}

.confirm-dialog,
.detail-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  color: var(--ink-1);
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
}

.detail-dialog[open] {
  display: flex;
  flex-direction: column;
}

.confirm-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 22px;
}

.confirm-dialog::backdrop,
.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.detail-dialog-inner,
.detail-dialog-content {
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.detail-dialog-content {
  flex: 1 1 auto;
}

.detail-dialog-header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  padding: 22px;
}

.detail-dialog-header > div:first-child {
  min-width: 0;
}

.detail-dialog-actions {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.detail-section {
  display: grid;
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.detail-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 12px;
}

.detail-metric strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.detail-inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 1fr);
  align-items: end;
  gap: 12px;
}

.detail-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.analysis-text {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 12px;
  white-space: pre-wrap;
}

.analysis-panel {
  display: grid;
  gap: 12px;
}

.analysis-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.analysis-kpi {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 10px;
}

.analysis-kpi span,
.analysis-card h4 {
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.analysis-kpi strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.analysis-kpi small {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 12px;
}

.analysis-icon {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-2));
  color: var(--accent);
}

.analysis-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.analysis-card-grid {
  display: grid;
  gap: 10px;
}

.analysis-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 12px;
}

.analysis-card h4 {
  margin: 1px 0 6px;
}

.analysis-card p,
.analysis-card ul {
  margin: 0;
  color: var(--ink-1);
  line-height: 1.55;
}

.analysis-card ul {
  padding-left: 18px;
}

.analysis-card-risk {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
  background: color-mix(in srgb, var(--danger) 7%, var(--bg-2));
}

.analysis-card-risk .analysis-icon {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--bg-2));
  color: var(--danger);
}

.route-map-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}

.route-map {
  display: block;
  width: 100%;
  aspect-ratio: 2.32 / 1;
}

.route-leaflet-map {
  width: 100%;
  min-height: 310px;
  aspect-ratio: 2.32 / 1;
  background: var(--bg-2);
}

.route-segments line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 6;
}

.route-shadow line {
  fill: none;
  stroke: rgba(0, 0, 0, 0.22);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 10;
  transform: translate(0, 2px);
}

.route-start {
  fill: var(--good);
  stroke: #fff;
  stroke-width: 3;
}

.route-end {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 3;
}

.route-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 14px;
  color: var(--ink-2);
  font-size: 12px;
}

.route-legend i {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(205 78% 44%), hsl(122 78% 44%), hsl(40 78% 44%));
}

.route-note {
  padding: 0 14px 14px;
}

.elevation-profile-card {
  margin-top: 12px;
}

.elevation-profile-empty {
  padding-bottom: 2px;
}

.elevation-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 2px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.elevation-profile {
  display: block;
  width: 100%;
  height: auto;
}

.elevation-grid-line {
  stroke: rgba(23, 20, 18, 0.12);
  stroke-width: 1;
}

.elevation-axis-tick {
  stroke: var(--ink-3);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.elevation-area {
  fill: rgba(239, 124, 69, 0.16);
}

.elevation-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.elevation-axis-label {
  fill: var(--ink-2);
  font-size: 9px;
  font-weight: 650;
  font-family: var(--font-ui);
}

.elevation-axis-unit {
  fill: var(--ink-3);
  font-size: 8px;
  font-weight: 650;
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 480px;
  background: var(--bg-0);
}

.login-photo {
  display: flex;
  min-height: 100vh;
  align-items: flex-end;
  overflow: hidden;
  padding: 40px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.55)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.05)),
    var(--photo-runner) center / cover no-repeat,
    var(--bg-2);
}

.login-quote {
  max-width: 620px;
}

.login-quote h1 {
  color: #fff;
  font-size: clamp(60px, 7vw, 88px);
  line-height: 0.95;
}

.login-quote h1 span {
  display: block;
}

.login-quote .muted {
  max-width: 440px;
  margin-top: 24px;
  color: rgba(255, 245, 230, 0.72);
  font-size: 14px;
}

.login-form {
  width: 100%;
  height: 100%;
  align-content: center;
  border: 0;
  border-radius: 0;
  background: var(--bg-1);
  padding: 60px 56px;
}

.login-form-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-form h1 {
  font-size: 56px;
}

@media (max-width: 1120px) {
  .shell,
  .login,
  .command-bar,
  .connection-health,
  .plan-command-panel,
  .load-dashboard,
  .config-shell {
    grid-template-columns: 1fr;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    background: var(--topbar-bg);
    padding: 12px 16px;
    backdrop-filter: blur(18px);
  }

  .mobile-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink-0);
  }

  .mobile-brand .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .mobile-brand .brand-name {
    font-size: 17px;
  }

  .mobile-brand .brand-tagline {
    font-size: 8px;
  }

  .theme-toggle-floating {
    display: none;
  }

  .theme-toggle-mobile {
    width: 96px;
    display: grid;
    flex: 0 0 96px;
    margin-left: auto;
  }

  .mobile-menu-toggle {
    position: relative;
    z-index: 90;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--bg-2);
    color: var(--ink-0);
    padding: 0;
  }

  .mobile-menu-icon,
  .mobile-menu-icon::before,
  .mobile-menu-icon::after {
    width: 18px;
    height: 2px;
    display: block;
    border-radius: 999px;
    background: currentColor;
    transition: transform 160ms ease, opacity 160ms ease;
  }

  .mobile-menu-icon {
    position: relative;
  }

  .mobile-menu-icon::before,
  .mobile-menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
  }

  .mobile-menu-icon::before {
    top: -6px;
  }

  .mobile-menu-icon::after {
    top: 6px;
  }

  .mobile-menu-open .mobile-menu-icon {
    background: transparent;
  }

  .mobile-menu-open .mobile-menu-icon::before {
    transform: translateY(6px) rotate(45deg);
  }

  .mobile-menu-open .mobile-menu-icon::after {
    transform: translateY(-6px) rotate(-45deg);
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: block;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(4px);
  }

  .mobile-menu-backdrop[hidden] {
    display: none;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(320px, calc(100vw - 48px));
    height: 100dvh;
    transform: translateX(-105%);
    border-right-color: var(--line-strong);
    box-shadow: 24px 0 48px rgba(0, 0, 0, 0.34);
    transition: transform 190ms ease;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-top: 22px;
  }

  .mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  .nav {
    display: flex;
    flex-direction: column;
  }

  .nav-section {
    grid-column: auto;
  }

  .sidebar-account {
    margin-top: 0;
  }

  .content {
    padding: 20px 16px 64px;
  }

  .page-header,
  .home-hero {
    margin-bottom: 16px;
    border-radius: 8px;
  }

  .home-hero {
    min-height: 300px;
    padding: 24px;
    background-position: center top;
  }

  .route-home .home-hero h1,
  .page-header h1 {
    font-size: clamp(34px, 7.5vw, 46px);
    line-height: 1.06;
    white-space: normal;
  }

  .page-header .muted,
  .home-hero .muted {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.45;
  }

  .home-hero-metrics strong {
    font-size: 26px;
  }

  .command-bar,
  .setup-step,
  .panel,
  .week,
  .race-card,
  .zone,
  .metric,
  .log-entry,
  .empty-state,
  .stat-card {
    border-radius: 8px;
  }

  .panel,
  .setup-step,
  .week,
  .race-card,
  .zone,
  .metric,
  .log-entry,
  .empty-state {
    padding: 18px;
  }

  .setup-step {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .setup-step .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .page-header > .actions,
  .page-header > .status,
  .page-header > .hero-disconnect {
    position: static;
  }

  .config-steps {
    position: static;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .config-summary,
  .sticky-actions {
    grid-column: 1 / -1;
  }

  .ops-grid,
  .plan-command-metrics,
  .plan-health-strip,
  .connection-health-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-4,
  .span-6,
  .span-8,
  .span-12 {
    grid-column: 1 / -1;
  }

  .zone-card {
    grid-template-columns: 1fr;
  }

  .login-photo {
    min-height: 360px;
  }

  .login-form {
    min-height: 440px;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 14px 14px 56px;
  }

  .mobile-topbar {
    min-height: 68px;
    padding-inline: 14px;
  }

  .mobile-brand .brand-name {
    font-size: 16px;
  }

  .mobile-menu-toggle {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .page-header,
  .home-hero {
    min-height: 220px;
    padding: 20px;
  }

  .page-header h1,
  .home-hero h1,
  .route-home .home-hero h1 {
    font-size: 33px;
  }

  .page-header .muted,
  .home-hero .muted {
    font-size: 14px;
  }

  .home-hero-metrics {
    gap: 12px;
  }

  .home-hero-metrics div {
    padding-top: 10px;
  }

  .home-hero-metrics span {
    font-size: 12px;
  }

  .home-hero-metrics strong {
    font-size: 24px;
  }

  .command-bar {
    padding: 18px;
  }

  .command-primary {
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 14px;
  }

  .command-primary h2,
  .command-status strong,
  .panel h2 {
    font-size: 20px;
  }

  .stat-card {
    min-height: 112px;
    padding: 16px;
  }

  .stat-value {
    font-size: 30px;
  }

  .goal-probability-current,
  .goal-probability-row {
    grid-template-columns: 1fr;
  }

  .home-hero-metrics,
  .ops-grid,
  .plan-command-metrics,
  .plan-health-strip,
  .plan-overview-events .event-row,
  .connection-health-meta,
  .zone-metrics,
  .log-toolbar,
  .config-steps,
  .blocked-list-header,
  .blocked-row,
  .week-summary,
  .command-status,
  .profile-row,
  .detail-inline-form {
    grid-template-columns: 1fr;
  }

  .workout,
  .workout-button {
    grid-template-columns: 1fr;
  }

  .detail-dialog-header {
    flex-direction: column;
  }

  .detail-dialog-actions {
    width: 100%;
  }

  button,
  .button {
    width: 100%;
  }

  .mobile-menu-toggle {
    width: 42px;
  }
}

@media (max-width: 420px) {
  .content {
    padding-inline: 12px;
  }

  .page-header,
  .home-hero {
    min-height: 210px;
    padding: 18px;
  }

  .page-header h1,
  .home-hero h1,
  .route-home .home-hero h1 {
    font-size: 30px;
  }

  .sidebar {
    width: min(300px, calc(100vw - 42px));
  }
}
