:root {
  --navy: #081938;
  --blue: #173f86;
  --blue-bright: #2f6de1;
  --purple: #553b91;
  --purple-dark: #302369;
  --gold: #e1b83f;
  --gold-light: #f5dc7a;
  --ink: #172033;
  --muted: #657088;
  --paper: #f7f8fc;
  --white: #ffffff;
  --line: #dfe4ef;
  --success: #1d8a6b;
  --warning: #b46918;
  --shadow: 0 22px 55px rgba(8, 25, 56, 0.18);
  --sidebar: 318px;
  --topbar: 78px;
  --radius: 20px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

[hidden] { display: none !important; }

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 82% 16%, rgba(225,184,63,.24), transparent 22%),
    linear-gradient(135deg, #123c80 0%, #273f87 48%, #5a3b8f 100%);
}

.auth-panel {
  width: min(520px, 100%);
  padding: 42px;
  border: 1px solid rgba(255,255,255,.25);
  border-top: 5px solid var(--gold);
  border-radius: 24px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 32px 90px rgba(8,25,56,.38);
}

.auth-logo { display: block; width: min(315px, 82%); height: auto; margin: 0 0 24px; }

.auth-panel h1 { margin: 5px 0 14px; color: var(--navy); font-family: Georgia, serif; font-size: 38px; line-height: 1.05; }
.auth-panel > p:not(.eyebrow):not(.auth-help) { color: var(--muted); }
.auth-form { display: grid; gap: 9px; margin-top: 26px; }
.auth-form label { color: var(--navy); font-size: 12px; font-weight: 800; }
.auth-form input { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid #ccd4e3; border-radius: 11px; background: white; }
.auth-form .button { margin-top: 4px; }
.auth-message { min-height: 22px; margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.auth-help { margin: 25px 0 0; padding-top: 18px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.auth-help a { color: var(--blue); }
.auth-legal { display: flex; gap: 16px; margin-top: 8px; font-size: 11px; }
.auth-legal a { color: var(--blue); }
.text-button.preview-button { display: block; margin: 4px auto 0; color: var(--blue); }
.access-message h2 { margin: 24px 0 8px; color: var(--navy); font-family: Georgia, serif; }
.access-message p { color: var(--muted); }
.access-message .button { margin-top: 10px; }

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(225, 184, 63, 0.55);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: var(--topbar) minmax(calc(100vh - var(--topbar)), auto);
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px 0 24px;
  color: white;
  border-bottom: 3px solid var(--gold);
  background: linear-gradient(105deg, #133c80 0%, #233d82 42%, #593a8e 100%);
  box-shadow: 0 10px 28px rgba(8, 25, 56, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  padding: 0;
  color: white;
  background: transparent;
  border: 0;
}

.brand img {
  display: block;
  width: 250px;
  height: 62px;
  border-radius: 7px;
  object-fit: cover;
  object-position: left center;
}

.topbar-actions { display: flex; align-items: center; gap: 18px; }
.save-state { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.75); font-size: 12px; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: #87d7ba; box-shadow: 0 0 0 4px rgba(135,215,186,.14); }
.save-state[data-state="saving"] .save-dot { background: var(--gold); box-shadow: 0 0 0 4px rgba(225,184,63,.15); }
.save-state[data-state="error"] .save-dot { background: #ff9d8a; box-shadow: 0 0 0 4px rgba(255,157,138,.15); }
.save-state[data-state="local"] .save-dot { background: #d6dceb; box-shadow: 0 0 0 4px rgba(214,220,235,.12); }
.account-state { max-width: 190px; overflow: hidden; color: rgba(255,255,255,.62); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sign-out { color: rgba(255,255,255,.72); }

.mobile-menu { display: none; color: white; background: transparent; border: 0; font-size: 24px; }

.sidebar {
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  overflow: auto;
  padding: 32px 25px 24px;
  color: white;
  background:
    radial-gradient(circle at 12% 10%, rgba(47, 109, 225, .45), transparent 30%),
    linear-gradient(168deg, var(--navy) 0%, #112b62 55%, #2d2364 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.sidebar-intro h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 28px; line-height: 1.08; }
.sidebar-intro p:last-child { margin: 14px 0 0; color: rgba(255,255,255,.7); font-size: 13px; line-height: 1.6; }

.overall-progress { margin: 26px 0 25px; padding: 17px; border: 1px solid rgba(255,255,255,.13); border-radius: 16px; background: rgba(255,255,255,.07); }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.progress-copy strong { color: var(--gold-light); }
.progress-track { height: 7px; margin: 10px 0 9px; overflow: hidden; border-radius: 20px; background: rgba(255,255,255,.13); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), #fff0a6); transition: width .45s ease; }
.overall-progress p { margin: 0; color: rgba(255,255,255,.63); font-size: 11px; }

.trail-nav { display: grid; gap: 7px; }
.trail-nav-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 10px;
  color: rgba(255,255,255,.72);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
}
.trail-nav-button:hover:not(:disabled), .trail-nav-button.active { color: white; border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.09); }
.trail-nav-button:disabled { cursor: not-allowed; opacity: .52; }
.trail-nav-number { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--navy); background: var(--gold); font-size: 10px; font-weight: 900; }
.trail-nav-button.locked .trail-nav-number { color: rgba(255,255,255,.65); background: rgba(255,255,255,.12); }
.trail-nav-title { display: block; font-size: 12px; font-weight: 750; }
.trail-nav-kicker { display: block; margin-top: 2px; color: rgba(255,255,255,.48); font-size: 10px; }
.trail-nav-status { font-size: 13px; }

.sidebar-footer { margin-top: 25px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer p { margin: 7px 0 0; color: rgba(255,255,255,.45); font-size: 10px; }
.sidebar-legal { display: flex; gap: 13px; margin-top: 10px; font-size: 10px; }
.sidebar-legal a { color: rgba(255,255,255,.56); }
.text-button { padding: 0; color: rgba(255,255,255,.65); border: 0; background: transparent; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }

main { min-width: 0; overflow: hidden; }

.map-view {
  min-height: calc(100vh - var(--topbar));
  background:
    radial-gradient(circle at 82% 14%, rgba(225,184,63,.12), transparent 20%),
    linear-gradient(180deg, #f8f9fd 0%, #eef1f9 100%);
}

.map-hero { max-width: 1180px; margin: 0 auto; padding: 56px 52px 22px; }
.map-hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(290px, .85fr); gap: 50px; align-items: end; }
.map-hero h2 { margin: 0; max-width: 780px; color: var(--navy); font-family: Georgia, "Times New Roman", serif; font-size: clamp(40px, 5vw, 70px); line-height: .98; letter-spacing: -.035em; }
.map-hero h2 em { color: var(--purple); font-style: normal; }
.map-hero p.lead { max-width: 720px; margin: 22px 0 0; color: #4b5871; font-size: 18px; line-height: 1.65; }
.hero-card { padding: 24px; border: 1px solid rgba(23,63,134,.12); border-radius: var(--radius); background: rgba(255,255,255,.76); box-shadow: 0 16px 44px rgba(8,25,56,.08); backdrop-filter: blur(12px); }
.hero-card h3 { margin: 0 0 8px; color: var(--navy); font-size: 17px; }
.hero-card p { margin: 0 0 17px; color: var(--muted); font-size: 13px; }

.map-canvas {
  position: relative;
  max-width: 1180px;
  height: 610px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 34px 34px 0 0;
  background:
    radial-gradient(circle at 82% 20%, rgba(255,228,132,.45), transparent 17%),
    linear-gradient(155deg, #173f86 0%, #2f438e 42%, #623b8e 100%);
  box-shadow: var(--shadow);
}

.map-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .28;
  background-image: radial-gradient(rgba(255,255,255,.58) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.sun { position: absolute; right: 12%; top: 8%; width: 88px; height: 88px; border-radius: 50%; background: radial-gradient(circle, #fff3b4 0%, #e8bd43 50%, rgba(232,189,67,0) 72%); }
.ridge, .ridge::before, .ridge::after { position: absolute; content: ""; bottom: -2px; border-radius: 55% 45% 0 0 / 80% 90% 0 0; transform-origin: bottom; }
.ridge.one { left: -6%; width: 54%; height: 56%; background: linear-gradient(150deg, #17366f, #101f52); transform: rotate(2deg); }
.ridge.two { right: -8%; width: 62%; height: 46%; background: linear-gradient(150deg, #3f337d, #231a5a); transform: rotate(-2deg); }
.ridge.three { left: 26%; width: 58%; height: 35%; background: linear-gradient(150deg, #214781, #283274); opacity: .96; }

.map-node { position: absolute; z-index: 3; width: 190px; padding: 0; color: white; text-align: left; border: 0; background: transparent; transform: translate(-50%, -50%); }
.map-node:nth-of-type(1) { left: 12%; top: 69%; }
.map-node:nth-of-type(2) { left: 29%; top: 43%; }
.map-node:nth-of-type(3) { left: 48%; top: 62%; }
.map-node:nth-of-type(4) { left: 64%; top: 34%; }
.map-node:nth-of-type(5) { left: 79%; top: 56%; }
.map-node:nth-of-type(6) { left: 91%; top: 25%; }
.node-marker { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 9px; color: var(--navy); border: 4px solid rgba(255,255,255,.72); border-radius: 50%; background: var(--gold); box-shadow: 0 9px 25px rgba(8,25,56,.35); font-weight: 900; transition: transform .2s ease, box-shadow .2s ease; }
.map-node:hover:not(:disabled) .node-marker { transform: translateY(-4px) scale(1.04); box-shadow: 0 14px 32px rgba(8,25,56,.48); }
.map-node.locked { cursor: not-allowed; opacity: .64; }
.map-node.locked .node-marker { color: rgba(255,255,255,.7); border-color: rgba(255,255,255,.28); background: rgba(8,25,56,.7); }
.node-title { display: block; font-weight: 850; font-size: 14px; text-shadow: 0 2px 6px rgba(8,25,56,.5); }
.node-copy { display: block; margin-top: 3px; color: rgba(255,255,255,.7); font-size: 11px; line-height: 1.35; }
.node-lock { display: inline-block; margin-top: 5px; padding: 2px 7px; border: 1px solid rgba(255,255,255,.22); border-radius: 99px; color: rgba(255,255,255,.7); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }

.map-legend { position: absolute; left: 28px; bottom: 25px; z-index: 5; display: flex; gap: 18px; color: rgba(255,255,255,.64); font-size: 10px; }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.legend-dot.locked { background: rgba(255,255,255,.3); }

.trail-view { min-height: calc(100vh - var(--topbar)); background: linear-gradient(180deg, #eef1f8 0%, #fbfbfd 280px); }
.trail-hero { padding: 46px max(40px, calc((100vw - var(--sidebar) - 1080px) / 2)); color: white; background: linear-gradient(110deg, #123c80 0%, #273f87 48%, #5a3b8f 100%); border-bottom: 4px solid var(--gold); }
.trail-hero-inner { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: end; }
.trail-hero h2 { margin: 3px 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4vw, 54px); line-height: 1; }
.trail-hero p { max-width: 720px; margin: 0; color: rgba(255,255,255,.74); font-size: 15px; }
.evidence-pill { padding: 11px 16px; border: 1px solid rgba(255,255,255,.24); border-radius: 99px; background: rgba(255,255,255,.1); font-size: 12px; white-space: nowrap; }
.evidence-pill strong { color: var(--gold-light); }

.stepper-wrap { max-width: 1080px; margin: -1px auto 0; padding: 0 26px; }
.stepper { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: white; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 18px 18px; box-shadow: 0 10px 28px rgba(8,25,56,.07); overflow: hidden; }
.step-button { position: relative; min-height: 75px; padding: 14px 11px; color: var(--muted); border: 0; border-right: 1px solid var(--line); background: white; text-align: left; }
.step-button:last-child { border-right: 0; }
.step-button:hover { background: #f8f9fd; }
.step-button.active { color: var(--navy); background: #f3f5fb; }
.step-button.complete::after { content: "✓"; position: absolute; top: 12px; right: 10px; color: var(--success); font-weight: 900; }
.step-number { display: block; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.step-title { display: block; margin-top: 4px; font-size: 11px; font-weight: 800; line-height: 1.3; }

.lesson { max-width: 1080px; margin: 0 auto; padding: 40px 26px 90px; }
.lesson-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 30px; align-items: start; }
.lesson-main { display: grid; gap: 22px; }
.lesson-aside { position: sticky; top: calc(var(--topbar) + 22px); display: grid; gap: 16px; }

.card { padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 14px 34px rgba(8,25,56,.06); }
.card h3 { margin: 0 0 10px; color: var(--navy); font-family: Georgia, "Times New Roman", serif; font-size: 27px; line-height: 1.12; }
.card h4 { margin: 0 0 8px; color: var(--navy); font-size: 15px; }
.card p { color: #4d5970; }
.card p:last-child { margin-bottom: 0; }
.card-gold { border-color: rgba(225,184,63,.6); background: linear-gradient(145deg, #fffdf6, #fffaf0); }
.card-purple { color: white; border: 0; background: linear-gradient(145deg, #172f6c, #553b91); }
.card-purple h3, .card-purple h4 { color: white; }
.card-purple p { color: rgba(255,255,255,.78); }

.lesson-heading { margin-bottom: 6px; }
.lesson-heading .kicker { color: var(--purple); font-size: 11px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.lesson-heading h3 { margin: 7px 0 9px; color: var(--navy); font-family: Georgia, "Times New Roman", serif; font-size: 36px; line-height: 1.08; }
.lesson-heading p { max-width: 760px; margin: 0; color: var(--muted); font-size: 15px; }

.video-card { padding: 0; overflow: hidden; }
.video-frame { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; padding: 34px; color: white; text-align: center; background: radial-gradient(circle at 70% 22%, rgba(225,184,63,.28), transparent 28%), linear-gradient(135deg, #123b7c, #563a8d); }
.video-frame::before { content: ""; position: absolute; inset: 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 16px; }
.video-avatar { position: relative; z-index: 1; display: grid; place-items: center; width: 74px; height: 74px; margin: 0 auto 13px; border: 2px solid var(--gold); border-radius: 50%; background: rgba(8,25,56,.44); font-family: Georgia, serif; font-size: 24px; }
.video-frame h4 { position: relative; z-index: 1; margin: 0; color: white; font-size: 18px; }
.video-frame p { position: relative; z-index: 1; max-width: 430px; margin: 7px auto 0; color: rgba(255,255,255,.7); font-size: 12px; }
.video-actions { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 16px 18px; background: white; }
.video-actions span { color: var(--muted); font-size: 11px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 11px; font-size: 13px; font-weight: 800; text-decoration: none; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button-primary { color: var(--navy); background: var(--gold); box-shadow: 0 8px 22px rgba(225,184,63,.24); }
.button-primary:hover { background: #edc64c; }
.button-secondary { color: var(--blue); border-color: rgba(23,63,134,.24); background: white; }
.button-ghost { color: white; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.08); }
.button-small { min-height: 36px; padding: 0 13px; font-size: 11px; }
.button-danger { color: #8b2f36; border-color: #e7c4c7; background: #fff6f6; }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.choice-card { min-height: 112px; padding: 17px; text-align: left; border: 1px solid var(--line); border-radius: 15px; background: #fafbfe; }
.choice-card:hover { border-color: rgba(47,109,225,.4); background: #f5f7fd; }
.choice-card.selected { border-color: var(--gold); background: #fffaf0; box-shadow: 0 0 0 3px rgba(225,184,63,.13); }
.choice-icon { display: block; margin-bottom: 9px; font-size: 22px; }
.choice-title { display: block; color: var(--navy); font-size: 13px; font-weight: 850; }
.choice-copy { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.field { display: grid; gap: 7px; }
.field + .field { margin-top: 17px; }
.field label { color: var(--navy); font-size: 12px; font-weight: 800; }
.field-hint { color: var(--muted); font-size: 11px; line-height: 1.5; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 12px 13px;
  color: var(--ink);
  border: 1px solid #ccd4e3;
  border-radius: 11px;
  background: white;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field textarea.tall { min-height: 168px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue-bright); }

.episode-stack { display: grid; gap: 15px; }
.episode-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcfe; }
.episode-card.complete { border-color: rgba(29,138,107,.42); background: #f6fcfa; }
.episode-card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.episode-number { color: var(--purple); font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.episode-state { padding: 3px 8px; border-radius: 99px; color: var(--muted); background: #edf0f6; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.episode-card.complete .episode-state { color: var(--success); background: rgba(29,138,107,.1); }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }

.example-box { padding: 18px; border-left: 4px solid var(--gold); border-radius: 0 13px 13px 0; background: #fffaf0; }
.example-box strong { display: block; margin-bottom: 5px; color: var(--navy); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.example-box p { margin: 0; color: #5a5360; font-size: 12px; line-height: 1.58; }

.checklist { display: grid; gap: 11px; }
.check-item { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfe; }
.check-item input { width: 18px; height: 18px; accent-color: var(--success); }
.check-item span { color: #4d5970; font-size: 12px; }

.completion-card { padding: 25px; text-align: center; border: 1px solid rgba(225,184,63,.55); border-radius: var(--radius); background: radial-gradient(circle at 50% 0%, rgba(225,184,63,.25), transparent 40%), linear-gradient(145deg, #fffdf7, #f8f7ff); }
.completion-medallion { display: grid; place-items: center; width: 82px; height: 82px; margin: 0 auto 15px; color: white; border: 5px solid #f0d576; border-radius: 50%; background: linear-gradient(145deg, var(--blue), var(--purple)); box-shadow: 0 12px 28px rgba(8,25,56,.2); font-size: 30px; }
.completion-card h3 { font-size: 30px; }

.lesson-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-top: 4px; }
.validation-message { display: none; margin: 0; padding: 12px 14px; color: #834820; border: 1px solid #efcfab; border-radius: 11px; background: #fff8ef; font-size: 12px; }
.validation-message.visible { display: block; }

.aside-card { padding: 19px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 12px 30px rgba(8,25,56,.05); }
.aside-card h4 { margin: 0 0 9px; color: var(--navy); font-size: 13px; }
.aside-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.58; }
.aside-stat { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line); }
.aside-stat span { color: var(--muted); font-size: 10px; }
.aside-stat strong { color: var(--purple); font-size: 17px; }

.road-mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.road-mini { padding: 9px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fafbfe; font-size: 10px; }

.dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 30px 90px rgba(8,25,56,.34); }
.dialog-wide { width: min(980px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(8,25,56,.7); backdrop-filter: blur(5px); }
.dialog-shell { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 25px; padding: 24px 27px 18px; color: white; background: linear-gradient(110deg, #123c80, #593a8e); border-bottom: 3px solid var(--gold); }
.dialog-header h2 { margin: 0; font-family: Georgia, serif; font-size: 30px; }
.icon-button { width: 37px; height: 37px; color: white; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; background: rgba(255,255,255,.08); font-size: 23px; line-height: 1; }
.dialog-body { padding: 27px; overflow: auto; }
.dialog-body p { color: #46536b; line-height: 1.7; }
.dialog-footer { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 17px 27px; border-top: 1px solid var(--line); background: #fafbfe; }
.dialog-note { margin-right: auto; color: var(--muted); font-size: 11px; }

.script-copy { white-space: pre-wrap; font-size: 15px; }
.script-direction { padding: 13px 15px; border-radius: 12px; color: #6c5a24; background: #fff8e1; font-size: 11px; }

.market-file { display: grid; gap: 18px; }
.market-file-header { padding: 25px; color: white; border-radius: 18px; background: linear-gradient(130deg, #123c80, #563a8d); }
.market-file-header h3 { margin: 4px 0 8px; font-family: Georgia, serif; font-size: 32px; }
.market-file-header p { margin: 0; color: rgba(255,255,255,.72); }
.market-section { padding: 20px; border: 1px solid var(--line); border-radius: 15px; }
.market-section h4 { margin: 0 0 11px; color: var(--navy); }
.market-section p, .market-section li { color: #536078; font-size: 12px; line-height: 1.6; }
.market-section ul { margin: 0; padding-left: 19px; }
.empty-state { padding: 17px; color: var(--muted); border: 1px dashed #cbd3e2; border-radius: 12px; background: #fafbfe; font-size: 12px; }
.status-chip { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 99px; color: var(--purple); background: #eee9fa; font-size: 10px; font-weight: 850; }

/* Full-course interactive work surfaces */
.story-card, .instruction-card, .completion-standard { position: relative; overflow: hidden; padding: 24px; border-radius: 18px; }
.story-card { color: white; background: radial-gradient(circle at 88% 10%, rgba(225,184,63,.28), transparent 31%), linear-gradient(128deg, #123c80 0%, #263d82 48%, #593a8e 100%); box-shadow: 0 18px 44px rgba(8,25,56,.14); }
.story-card::after { content: ""; position: absolute; inset: 9px; pointer-events: none; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; }
.story-card h4, .instruction-card h4 { position: relative; z-index: 1; margin: 7px 0 9px; font-family: Georgia, "Times New Roman", serif; font-size: 22px; line-height: 1.18; }
.story-card p { position: relative; z-index: 1; margin: 0; color: rgba(255,255,255,.84); line-height: 1.68; }
.story-label, .instruction-label { position: relative; z-index: 1; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .13em; }
.instruction-card { border: 1px solid rgba(86,58,141,.18); background: linear-gradient(145deg, #fbfaff, #f5f2fc); }
.instruction-card h4 { color: var(--purple); }
.instruction-card > p { margin: 0; color: #4d5970; line-height: 1.66; }
.good-example { margin-top: 17px; padding: 16px 17px; border-left: 4px solid var(--gold); border-radius: 0 12px 12px 0; background: white; }
.good-example strong { color: var(--navy); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.good-example p { margin: 5px 0 0; color: #59657a; font-size: 12px; line-height: 1.6; }
.completion-standard { border: 1px solid rgba(29,138,107,.25); background: linear-gradient(145deg, #f4fcf9, #fbfffd); }
.completion-standard > strong { color: var(--success); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.completion-standard ul { display: grid; gap: 9px; margin: 14px 0 0; padding: 0; list-style: none; }
.completion-standard li { position: relative; padding-left: 25px; color: #526078; font-size: 12px; line-height: 1.5; }
.completion-standard li::before { content: "✓"; position: absolute; left: 0; top: -1px; display: grid; place-items: center; width: 17px; height: 17px; color: white; border-radius: 50%; background: var(--success); font-size: 10px; font-weight: 900; }

.scorecard-stack, .capsule-stack, .route-stack, .message-stack, .hypothesis-stack, .week-stack, .evidence-stack, .decision-stack { display: grid; gap: 18px; }
.road-scorecard, .proof-capsule, .route-card, .message-card, .hypothesis-card, .week-card, .evidence-row, .decision-card { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 12px 32px rgba(8,25,56,.045); }
.road-scorecard:nth-child(even), .proof-capsule:nth-child(even), .route-card:nth-child(even), .message-card:nth-child(even), .hypothesis-card:nth-child(even), .week-card:nth-child(even), .evidence-row:nth-child(even), .decision-card:nth-child(even) { background: #fbfaff; }
.road-scorecard-head { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 22px; align-items: start; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.road-scorecard-head > div > span, .capsule-head > span, .route-index, .message-card > span, .hypothesis-card > span, .week-card > span, .evidence-row > span, .decision-card > span { color: var(--purple); font-size: 10px; font-weight: 900; letter-spacing: .11em; }
.road-scorecard-head h3 { margin: 5px 0; color: var(--navy); font-family: Georgia, "Times New Roman", serif; font-size: 22px; }
.road-scorecard-head p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.score-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.score-grid .field + .field, .road-scorecard-head .field + .field { margin-top: 0; }
.capsule-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 17px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.capsule-head strong { color: var(--muted); font-size: 10px; }
.route-index { display: block; margin-bottom: 15px; }
.message-card > span, .hypothesis-card > span, .week-card > span, .evidence-row > span, .decision-card > span { display: block; margin-bottom: 17px; }
.message-card .field:last-child, .hypothesis-card .field:last-child, .week-card .field:last-child, .evidence-row .field:last-child, .decision-card .field:last-child { margin-bottom: 0; }

@media (max-width: 820px) {
  .road-scorecard-head, .score-grid { grid-template-columns: 1fr; }
  .road-scorecard-head { gap: 12px; }
}

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 330px; padding: 13px 17px; color: white; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; background: #0e2451; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  :root { --sidebar: 280px; }
  .brand-product, .brand-divider, .save-state { display: none; }
  .map-node { width: 160px; }
  .map-node:nth-of-type(6) { left: 88%; }
  .lesson-grid { grid-template-columns: minmax(0, 1fr) 270px; }
}

@media (max-width: 820px) {
  :root { --topbar: 68px; }
  .app-shell { display: block; }
  .topbar { height: var(--topbar); padding: 0 15px; }
  .mobile-menu { display: block; }
  .account-state, .sign-out { display: none; }
  .brand { margin-right: auto; margin-left: 10px; }
  .brand img { width: 136px; height: 44px; }
  .sidebar { position: fixed; z-index: 45; top: var(--topbar); left: 0; width: min(330px, 88vw); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 18px 0 40px rgba(8,25,56,.32); }
  .sidebar.open { transform: translateX(0); }
  .map-hero { padding: 42px 22px 20px; }
  .map-hero-grid { grid-template-columns: 1fr; gap: 23px; }
  .map-canvas { margin: 0 15px; height: 720px; border-radius: 28px; }
  .map-node:nth-of-type(1) { left: 20%; top: 82%; }
  .map-node:nth-of-type(2) { left: 68%; top: 70%; }
  .map-node:nth-of-type(3) { left: 31%; top: 55%; }
  .map-node:nth-of-type(4) { left: 72%; top: 43%; }
  .map-node:nth-of-type(5) { left: 28%; top: 28%; }
  .map-node:nth-of-type(6) { left: 72%; top: 15%; }
  .trail-hero { padding: 35px 22px; }
  .trail-hero-inner { grid-template-columns: 1fr; }
  .stepper-wrap { overflow-x: auto; padding: 0; }
  .stepper { min-width: 680px; border-radius: 0; }
  .lesson { padding: 32px 18px 70px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .lesson-aside { position: static; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .auth-gate { padding: 14px; }
  .auth-panel { padding: 29px 23px; }
  .auth-panel h1 { font-size: 31px; }
  .topbar-actions .button { padding: 0 10px; }
  .map-hero h2 { font-size: 42px; }
  .map-canvas { height: 790px; }
  .map-node { width: 135px; }
  .node-copy { display: none; }
  .choice-grid, .lesson-aside { grid-template-columns: 1fr; }
  .card { padding: 21px; }
  .lesson-heading h3 { font-size: 30px; }
  .lesson-actions { align-items: stretch; flex-direction: column-reverse; }
  .lesson-actions .button { width: 100%; }
  .dialog-footer { flex-wrap: wrap; }
  .dialog-footer .button { flex: 1 1 160px; }
  .dialog-note { flex: 1 0 100%; }
}

@media print {
  body * { visibility: hidden !important; }
  #market-file-dialog, #market-file-dialog * { visibility: visible !important; }
  #market-file-dialog { position: absolute; inset: 0; width: 100%; max-height: none; display: block; border: 0; }
  #market-file-dialog .dialog-header, #market-file-dialog .dialog-footer { display: none; }
  #market-file-dialog .dialog-body { overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
