:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --bg-card: #1c2740;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: #0ea5e9;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 12px;
  --maxw: 820px;
  --topbar-h: 48px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f1f5f9;
    --bg-soft: #ffffff;
    --bg-card: #ffffff;
    --line: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #0284c7;
    --accent-soft: #0ea5e9;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.01em; }
.home-link {
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px 8px;
  margin-left: -8px;
  border-radius: 8px;
}
.home-link[hidden] { display: none; }
.home-link:hover { background: var(--bg-soft); }
.install-btn {
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #07121f;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.install-btn[hidden] { display: none; }
.install-btn:hover { background: var(--accent-soft); }

/* ---------- Home / landing ---------- */
.home { padding: 24px 0 8px; }
.home-title { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: -0.01em; }
.home-lead { margin: 0 0 20px; color: var(--muted); }
.plan-grid { display: flex; flex-direction: column; gap: 12px; }
.plan-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.05s ease;
}
.plan-card:hover { border-color: var(--accent); }
.plan-card:active { transform: scale(0.995); }
.pc-top { display: flex; align-items: center; gap: 10px; }
.pc-title { font-size: 1.15rem; font-weight: 700; }
.pc-arrow { margin-left: auto; color: var(--muted); font-size: 1.3rem; line-height: 1; }
.pc-status {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
}
.status-active { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.status-maintenance { background: rgba(56, 189, 248, 0.14); color: var(--accent); }
.status-archived { background: rgba(148, 163, 184, 0.16); color: var(--muted); }
.pc-sub { color: var(--accent); font-size: 0.92rem; font-weight: 600; margin-top: 6px; }
.pc-meta { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.home-empty { color: var(--muted); }

/* ---------- Plan header block ---------- */
.plan-head-block { padding: 22px 0 4px; }
.plan-title {
  margin: 0 0 4px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 600;
}
.facts {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}
.facts span { white-space: nowrap; }
.facts span:not(:last-child)::after {
  content: "·";
  margin-left: 8px;
  color: var(--line);
}

.disclaimer {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9rem;
}
.disclaimer summary {
  cursor: pointer;
  color: var(--warn);
  font-weight: 600;
}
.disclaimer p { margin: 10px 0 2px; color: var(--text); }

/* ---------- Phase nav ---------- */
.phase-nav {
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
  display: flex;
  gap: 6px;
  margin: 0 -16px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  justify-content: center;
}
.phase-nav button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.phase-nav button:hover { color: var(--text); border-color: var(--accent); }
.phase-nav button.active {
  background: var(--accent);
  color: #07121f;
  border-color: var(--accent);
}

/* ---------- Main / phase panels ---------- */
#app { padding-top: 0; padding-bottom: 8px; }
.plan-main { padding: 16px 0 8px; }

.phase-panel { display: none; animation: fade 0.2s ease; }
.phase-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.phase-head h2 { margin: 4px 0 2px; font-size: 1.3rem; }
.phase-head .weeks { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.phase-head .goal { color: var(--text); margin: 10px 0 0; }
.phase-head .reference {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.section-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 26px 0 10px;
  font-weight: 700;
}

/* ---------- Info box (climbing rules) ---------- */
.infobox {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.infobox .row { margin: 0 0 8px; font-size: 0.92rem; }
.infobox .row:last-child { margin-bottom: 0; }
.infobox .k { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* ---------- Exercise cards ---------- */
.exercise {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.exercise > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.exercise > summary::-webkit-details-marker { display: none; }
.exercise .caret {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
  flex: 0 0 auto;
}
.exercise[open] .caret { transform: rotate(90deg); }
.exercise .ex-name { font-weight: 600; }
.exercise .tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  flex: 0 0 auto;
}
.exercise .body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 12px;
}
.exercise .dose {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
  padding: 8px 10px;
  border-radius: 8px;
  margin: 0 0 10px;
}
.exercise .meta { font-size: 0.85rem; color: var(--muted); margin: 0 0 8px; }
.exercise .desc { margin: 0 0 8px; }
.exercise .notes {
  font-size: 0.88rem;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--muted);
  margin: 8px 0 0;
}

/* ---------- Generic list cards ---------- */
.cardlist { list-style: none; padding: 0; margin: 0; }
.cardlist li {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.transition li { border-left: 3px solid var(--ok); }
.progression li { border-left: 3px solid var(--accent); }

.warn-banner {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  margin-top: 8px;
}

/* return ladder */
.ladder li { display: flex; gap: 12px; align-items: baseline; }
.ladder .when {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 80px;
}

/* ---------- Shared reference sections (below phases) ---------- */
.ref-section { margin-top: 18px; }
.ref-section > summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ref-section > summary::-webkit-details-marker { display: none; }
.ref-section > summary .caret { margin-left: auto; color: var(--muted); transition: transform 0.2s ease; }
.ref-section[open] > summary .caret { transform: rotate(90deg); }
.ref-section .ref-body { padding: 14px 4px 4px; }

.supp { border-left: 3px solid var(--ok); }
.supp.avoid { border-left-color: var(--danger); }
.supp .status {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 2px 8px; border-radius: 6px;
}
.supp .status.allowed { background: rgba(52,211,153,0.14); color: var(--ok); }
.supp .status.avoid { background: rgba(248,113,113,0.14); color: var(--danger); }
.supp .why { font-size: 0.88rem; color: var(--muted); margin: 8px 0 0; }

.warning-row {
  display: flex; flex-direction: column; gap: 4px;
  border-left: 3px solid var(--warn);
}
.warning-row .sig { font-weight: 600; }
.warning-row .act { font-size: 0.9rem; color: var(--muted); }

.evidence li { border-left: 3px solid var(--accent); }
.muted { color: var(--muted); }
small.muted { font-size: 0.85rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 32px;
  padding-top: 18px;
  padding-bottom: 40px;
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer code { color: var(--accent); }

@media (min-width: 640px) {
  h1 { font-size: 1.9rem; }
  .site-header { padding: 40px 0 24px; }
}
