:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #666666;
  --dim: #9a9a9a;
  --coal: #ffffff;
  --coal-2: #f3f3f3;
  --panel: rgba(255, 255, 255, 0.98);
  --line: rgba(0, 0, 0, 0.11);
  --gold: #d84a43;
  --copper: #1f6f8f;
  --ember: #d84a43;
  --green: #317645;
  --blue: #1f6f8f;
  --body-bg: #ffffff;
  --grid-lines:
    linear-gradient(rgba(0,0,0,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.035) 1px, transparent 1px);
  --rail-bg: rgba(255, 255, 255, 0.96);
  --soft-bg: #f6f6f6;
  --button-bg: #ffffff;
  --hero-bg:
    linear-gradient(180deg, rgba(7, 16, 19, 0.82), rgba(15, 107, 126, 0.38) 42%, rgba(255,255,255,.98) 43%),
    linear-gradient(135deg, #0d1b1f 0%, #39a9b9 48%, #ffffff 49%);
  --brand-bg: #161616;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f5efe2;
  --muted: #b6ab99;
  --dim: #6f675d;
  --coal: #11100e;
  --coal-2: #181613;
  --panel: rgba(31, 28, 23, 0.82);
  --line: rgba(245, 239, 226, 0.14);
  --green: #83c86e;
  --blue: #78a6d8;
  --body-bg:
    radial-gradient(circle at 8% 18%, rgba(227, 179, 78, 0.18), transparent 28%),
    linear-gradient(135deg, #0d0c0a 0%, #17120f 48%, #231713 100%);
  --grid-lines:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  --rail-bg: rgba(12, 11, 10, 0.72);
  --soft-bg: rgba(255,255,255,.04);
  --button-bg: rgba(255,255,255,.04);
  --hero-bg:
    linear-gradient(115deg, rgba(17,16,14,.92), rgba(31,20,14,.8)),
    repeating-linear-gradient(90deg, transparent 0 24px, rgba(227,179,78,.06) 24px 25px);
  --brand-bg: linear-gradient(145deg, rgba(227,179,78,.22), rgba(255,92,46,.12));
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--body-bg);
  color: var(--ink);
  font-family: Manrope, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: var(--grid-lines);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button, select, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

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

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

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(227,179,78,.42);
  background: var(--brand-bg);
  color: var(--gold);
  font-family: "Archivo Black", sans-serif;
  letter-spacing: 0;
  box-shadow: inset 0 0 18px rgba(227,179,78,.12);
}

body:not([data-theme="dark"]) .brand-mark {
  color: #ffffff;
  border-color: #161616;
  box-shadow: none;
}

.brand p, .eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .15em;
  font-weight: 800;
}

body:not([data-theme="dark"]) .brand p,
body:not([data-theme="dark"]) .eyebrow {
  color: #d84a43;
}

.brand strong { font-size: 18px; }

.rail-tabs {
  display: grid;
  gap: 8px;
}

.nav-btn, .profile-toggle button, .day-pills button, .ghost-btn, .check-btn, .theme-toggle {
  border: 1px solid var(--line);
  background: var(--button-bg);
  color: var(--ink);
  min-height: 42px;
  border-radius: 8px;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.nav-btn {
  text-align: left;
  padding: 12px 14px;
  font-weight: 800;
}

.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
  backdrop-filter: blur(12px);
}

.nav-btn:hover, .day-pills button:hover, .profile-toggle button:hover, .ghost-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(227,179,78,.55);
}

.nav-btn.active, .profile-toggle button.active, .day-pills button.active {
  background: rgba(227,179,78,.16);
  border-color: rgba(227,179,78,.72);
  color: var(--gold);
}

body:not([data-theme="dark"]) .nav-btn.active,
body:not([data-theme="dark"]) .profile-toggle button.active,
body:not([data-theme="dark"]) .day-pills button.active {
  background: #161616;
  border-color: #161616;
  color: #ffffff;
}

.micro-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--soft-bg);
  border-radius: 8px;
}

.micro-card span, .meta, label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
}

.micro-card p { color: var(--muted); line-height: 1.5; margin-bottom: 0; }

main {
  position: relative;
  padding: 30px;
  max-width: 1420px;
  width: 100%;
}

.hero {
  min-height: 150px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: end;
  padding: 24px 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--hero-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

body:not([data-theme="dark"]) .hero {
  border-color: #eeeeee;
  box-shadow: none;
}

h1 {
  margin: 0;
  max-width: 860px;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(30px, 4.6vw, 58px);
  line-height: .94;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy {
  max-width: 740px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
  margin: 10px 0 0;
}

.hero-panel {
  padding: 16px;
  border: 1px solid rgba(227,179,78,.38);
  background: var(--soft-bg);
  border-radius: 8px;
}

body:not([data-theme="dark"]) .hero-panel {
  background: #ffffff;
  border-top: 4px solid #d84a43;
  border-left-color: #eeeeee;
  border-right-color: #eeeeee;
  border-bottom-color: #eeeeee;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

.hero-panel span { color: var(--gold); font-weight: 800; }
.hero-panel strong { display: block; font-size: 24px; margin: 8px 0 4px; }
.hero-panel p { color: var(--muted); margin: 0; }

.control-strip {
  margin: 20px 0;
  display: grid;
  grid-template-columns: 170px 260px auto;
  gap: 14px;
  align-items: end;
}

.control-block {
  display: grid;
  gap: 8px;
}

select {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--coal);
  color: var(--ink);
  padding: 0 12px;
}

.day-pills, .profile-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.day-pills {
  grid-column: 1 / -1;
}

.day-pills button { padding: 0 12px; min-width: 62px; }
.profile-toggle button { padding: 0 14px; }

.view { display: none; animation: rise .28s ease both; }
.view.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.panel, .workout-card, .tool-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 10px 42px rgba(0,0,0,.24);
}

.panel { padding: 20px; }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

h2, h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-family: "Archivo Black", sans-serif;
  text-transform: uppercase;
  font-size: 34px;
}

h3 { font-size: 20px; }

.workout-card {
  overflow: hidden;
}

.card-top {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--soft-bg);
}

body:not([data-theme="dark"]) .card-top {
  background: #161616;
  color: #ffffff;
  border-bottom-color: #161616;
}

body:not([data-theme="dark"]) .card-top .meta,
body:not([data-theme="dark"]) .card-top h3 {
  color: #ffffff;
}

.person-badge {
  color: #11100e;
  background: var(--gold);
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}

body:not([data-theme="dark"]) .person-badge {
  background: #d84a43;
  color: #ffffff;
}

body:not([data-theme="dark"]) .person-badge.leah {
  background: #9b3b82;
  color: #ffffff;
}

.person-badge.leah { background: #f08b55; }

.exercise-list {
  display: grid;
}

.exercise {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(245,239,226,.08);
  align-items: start;
}

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

.code {
  color: var(--gold);
  font-weight: 900;
  font-size: 13px;
}

body:not([data-theme="dark"]) .code {
  color: #d84a43;
}

.exercise strong { display: block; margin-bottom: 4px; }

.prescription {
  color: var(--muted);
  font-size: 13px;
}

.check-btn {
  min-width: 38px;
  height: 38px;
  border-radius: 999px;
  color: var(--muted);
}

.check-btn.done {
  background: rgba(131,200,110,.18);
  border-color: rgba(131,200,110,.8);
  color: var(--green);
}

.note-box {
  margin: 16px 18px 18px;
  padding: 14px;
  border: 1px solid rgba(227,179,78,.24);
  background: rgba(227,179,78,.07);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
}

body:not([data-theme="dark"]) .note-box {
  background: #eef6fb;
  border-color: #1f6f8f;
  border-left: 4px solid #1f6f8f;
}

.finisher {
  border-color: rgba(255,92,46,.35);
  background: rgba(255,92,46,.08);
}

body:not([data-theme="dark"]) .finisher {
  background: #fde4e7;
  border-color: #f2b7bd;
  border-left-color: #d84a43;
}

.swap {
  border-color: rgba(240,139,85,.4);
  background: rgba(240,139,85,.08);
}

body:not([data-theme="dark"]) .swap {
  background: #fff0c8;
  border-color: #f5d27b;
  border-left-color: #f08a24;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  text-decoration: none;
  font-weight: 800;
}

.link-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selection-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 18px;
}

.summary-chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

body:not([data-theme="dark"]) .summary-chip {
  background: #f7f7f7;
  color: #333333;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  border-radius: 8px;
}

.stat strong { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: stretch;
}

.timeline-row .week-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: var(--gold);
}

.timeline-row .phase-copy {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  border-radius: 8px;
  padding: 14px;
}

.phase-copy p { margin: 5px 0 0; color: var(--muted); }

.warmup-card {
  margin-bottom: 18px;
}

.warmup-card .card-top {
  padding: 12px 16px;
}

.warmup-card .exercise-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.warmup-card .exercise {
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  padding: 9px 12px;
}

.warmup-card .exercise strong {
  font-size: 13px;
  margin-bottom: 2px;
}

.warmup-card .prescription {
  font-size: 11px;
}

.warmup-card .check-btn {
  display: none;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 12px 14px;
  background: #181510;
  border: 1px solid rgba(227,179,78,.55);
  color: var(--ink);
  border-radius: 8px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

.tracker-list {
  display: grid;
  gap: 12px;
}

.tracker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 42px rgba(0,0,0,.08);
}

.tracker-detail,
.tracker-empty {
  color: var(--muted);
  margin: 6px 0 0;
}

.tracker-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.video-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20;
}

.video-modal.open { display: block; }

.video-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(10px);
}

.video-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 28px));
  border: 1px solid rgba(227,179,78,.42);
  background: #11100e;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.video-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.video-dialog iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 6px;
  background: #000;
}

#videoExternal {
  margin-top: 12px;
  width: 100%;
}

.exercise-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.video-chip {
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(120,166,216,.55);
  background: rgba(120,166,216,.12);
  color: #b8d6f7;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .micro-card { margin-top: 0; }
  .hero, .control-strip, .grid-two { grid-template-columns: 1fr; }
  .tracker-row { grid-template-columns: 1fr; }
  .tracker-side { justify-content: flex-start; }
  .warmup-card .exercise-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  main, .rail { padding: 16px; }
  .theme-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    min-height: 36px;
    font-size: 11px;
  }
  .hero { padding: 18px; min-height: 0; }
  h1 { font-size: 30px; }
  .hero-copy { display: none; }
  .exercise { grid-template-columns: 34px minmax(0, 1fr); }
  .warmup-card .exercise-list { grid-template-columns: 1fr; }
  .warmup-card .exercise { grid-template-columns: 24px minmax(0, 1fr); }
  .check-btn { grid-column: 2; width: 100%; border-radius: 8px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .timeline-row { grid-template-columns: 1fr; }
}
