:root {
  --ink: #172f33;
  --muted: #607176;
  --deep: #123f47;
  --deep-2: #0b3037;
  --sea: #2e747c;
  --foam: #edf4f1;
  --paper: #fbfaf4;
  --white: #fffef9;
  --line: #d6ddd8;
  --sand: #f1d27a;
  --sand-soft: #fff1bf;
  --red: #b74635;
  --green: #33735b;
  --shadow: 0 14px 40px rgba(20, 55, 60, .09);
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Source Sans 3', 'Avenir Next', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
}
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }
svg { display: block; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; background: var(--white); border: 2px solid var(--deep); border-radius: 6px; }
.skip-link:focus { top: 10px; }

.topbar {
  position: fixed;
  z-index: 30;
  inset: 0 0 auto 0;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px 0 26px;
  color: var(--white);
  background: var(--deep-2);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand svg { width: 39px; height: 39px; fill: none; stroke: var(--sand); stroke-width: 2.2; stroke-linejoin: round; }
.brand span { display: grid; line-height: 1.08; }
.brand strong { font-family: var(--serif); font-size: 25px; font-weight: 650; letter-spacing: -.01em; }
.brand small { margin-top: 3px; color: #b8caca; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.top-progress { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #d5e2df; }
.top-progress i { display: block; width: 120px; height: 5px; overflow: hidden; background: rgba(255,255,255,.15); border-radius: 10px; }
.top-progress b { display: block; width: 0; height: 100%; background: var(--sand); transition: width .4s ease; }
.mobile-menu { display: none; }

.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; padding-top: 76px; }
.sidebar {
  position: fixed;
  z-index: 20;
  top: 76px;
  bottom: 0;
  width: 248px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 26px 18px 22px;
  background: #f1f3ed;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 13px; min-height: 44px; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: #3b5054; font-size: 16px; font-weight: 600; }
.sidebar nav a:hover { background: rgba(18,63,71,.07); }
.sidebar nav a.active { color: var(--white); background: var(--deep); }
.nav-icon { width: 22px; text-align: center; font-family: Georgia, serif; font-size: 21px; font-weight: 400; }
.sidebar-note { padding: 16px; border-top: 1px solid var(--line); }
.sidebar-note span { display: inline-block; padding: 3px 8px; color: var(--deep); background: #dbe9e3; border-radius: 3px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-note p { margin: 9px 0 4px; font-size: 14px; line-height: 1.35; }
.sidebar-note small { color: var(--muted); font-size: 12px; }

main { grid-column: 2; min-width: 0; }
#app { width: min(1120px, calc(100% - 64px)); margin: 0 auto; padding: 54px 0 90px; }
.page-head { margin-bottom: 36px; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--sea); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.eyebrow::before { content: ''; width: 22px; height: 2px; background: var(--sand); }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; line-height: 1.08; color: var(--ink); }
h1 { max-width: 800px; margin: 12px 0 13px; font-size: clamp(42px, 5vw, 66px); letter-spacing: -.035em; }
h2 { margin: 0 0 14px; font-size: clamp(30px, 3.4vw, 43px); letter-spacing: -.025em; }
h3 { margin: 0 0 8px; font-size: 25px; }
.page-head > p { max-width: 720px; margin: 0; color: var(--muted); font-size: 19px; }

.hero { position: relative; min-height: 425px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; margin: -54px calc((100vw - 248px - min(1120px, calc(100vw - 248px - 64px))) / -2) 42px; padding: 72px max(32px, calc((100vw - 248px - min(1120px, calc(100vw - 248px - 64px))) / 2)); color: var(--white); background: var(--deep); }
.hero-copy { position: relative; z-index: 2; align-self: center; max-width: 650px; padding-right: 32px; }
.hero .eyebrow { color: #bcd7d2; }
.hero h1 { color: var(--white); }
.hero p { max-width: 610px; color: #d2e1de; font-size: 19px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 17px; border: 1px solid transparent; border-radius: 5px; color: var(--deep); background: var(--sand); text-decoration: none; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s; }
.button:hover { background: #f6dc90; transform: translateY(-1px); }
.button.secondary { color: var(--white); background: transparent; border-color: rgba(255,255,255,.35); }
.button.secondary:hover { background: rgba(255,255,255,.08); }
.button.ghost { color: var(--deep); background: transparent; border-color: var(--line); }
.button.ghost:hover { background: var(--foam); }
.hero-chart { position: relative; min-height: 290px; align-self: center; opacity: .96; }
.hero-chart svg { width: 100%; height: 100%; min-height: 320px; }

.stats-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 46px; border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow); }
.stat { padding: 22px 24px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat strong { display: block; font-family: var(--serif); font-size: 33px; line-height: 1; }
.stat span { color: var(--muted); font-size: 14px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 46px 0 18px; }
.section-title h2 { margin: 0; }
.section-title p { max-width: 500px; margin: 0; color: var(--muted); }

.chapter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.chapter-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 16px; padding: 22px; overflow: hidden; color: inherit; background: var(--white); border: 1px solid var(--line); border-radius: 7px; text-decoration: none; transition: border .15s, transform .15s, box-shadow .15s; }
.chapter-card:hover { transform: translateY(-2px); border-color: #9bb2af; box-shadow: var(--shadow); }
.chapter-no { display: grid; place-items: center; width: 40px; height: 40px; color: var(--deep); background: var(--foam); border-radius: 50%; font-family: var(--serif); font-size: 19px; }
.chapter-card.done .chapter-no { color: var(--white); background: var(--green); }
.chapter-card h3 { font-size: 22px; }
.chapter-card p { margin: 4px 0 10px; color: var(--muted); font-size: 15px; line-height: 1.4; }
.meta { color: var(--sea); font-size: 13px; font-weight: 700; }
.chapter-arrow { margin-top: 7px; color: var(--sea); font-size: 23px; }

.callout { display: grid; grid-template-columns: auto 1fr; gap: 17px; margin: 28px 0; padding: 20px 22px; background: var(--sand-soft); border-left: 4px solid #d5a82f; }
.callout.info { background: #e9f2f0; border-color: var(--sea); }
.callout.warn { background: #f8e7df; border-color: var(--red); }
.callout-icon { font-family: var(--serif); font-size: 25px; line-height: 1; }
.callout strong { display: block; margin-bottom: 3px; }
.callout p { margin: 0; color: #4e5e60; }

.learning-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 52px; align-items: start; }
.lesson article { max-width: 760px; }
.lesson-intro { color: var(--muted); font-size: 21px; }
.lesson-section { padding: 35px 0; border-top: 1px solid var(--line); }
.lesson-section h2 { font-size: 34px; }
.lesson-section p { margin: 10px 0; }
.lesson-section ul, .lesson-section ol { padding-left: 24px; }
.lesson-section li { margin: 8px 0; }
.memory { display: inline-block; margin: 12px 0; padding: 7px 11px; color: var(--deep); background: var(--sand-soft); border-radius: 4px; font-weight: 700; }
.lesson-aside { position: sticky; top: 104px; }
.toc { padding: 20px; background: #f1f3ed; border: 1px solid var(--line); border-radius: 6px; }
.toc strong { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.toc a { display: block; padding: 7px 0; color: var(--muted); border-bottom: 1px solid var(--line); text-decoration: none; font-size: 14px; line-height: 1.25; }
.toc a:last-child { border-bottom: 0; }
.toc a:hover { color: var(--deep); }
.completion { width: 100%; margin-top: 12px; }
.completion.done { color: var(--white); background: var(--green); }
.prev-next { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 42px; }
.prev-next a { padding: 17px; background: var(--white); border: 1px solid var(--line); border-radius: 5px; text-decoration: none; }
.prev-next a:last-child { text-align: right; }
.prev-next small { display: block; color: var(--muted); }

.diagram { margin: 24px 0; padding: 22px; background: #e8f1ed; border: 1px solid #cfddd8; border-radius: 6px; }
.diagram svg { width: 100%; max-height: 360px; }
.diagram figcaption { margin-top: 12px; color: var(--muted); font-size: 14px; text-align: center; }
.signal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0; }
.signal-card { min-height: 150px; padding: 16px; text-align: center; background: #102f36; border-radius: 5px; color: var(--white); }
.signal-card svg { width: 100%; height: 70px; margin-bottom: 8px; }
.signal-card strong { display: block; font-size: 14px; }
.signal-card small { color: #bfd1cf; }
.formula { margin: 20px 0; padding: 20px; font-family: var(--serif); font-size: 24px; text-align: center; background: var(--white); border: 1px solid var(--line); }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 28px; }
.chip { min-height: 37px; padding: 7px 13px; color: var(--deep); background: transparent; border: 1px solid #b9c8c5; border-radius: 30px; cursor: pointer; }
.chip:hover, .chip.active { color: var(--white); background: var(--deep); border-color: var(--deep); }
.quiz-shell { max-width: 820px; }
.quiz-progress { display: flex; align-items: center; gap: 13px; margin-bottom: 18px; color: var(--muted); font-size: 14px; }
.quiz-progress i { flex: 1; height: 6px; overflow: hidden; background: #dce3df; border-radius: 10px; }
.quiz-progress b { display: block; height: 100%; background: var(--sea); transition: width .25s; }
.question-card { padding: clamp(22px, 4vw, 38px); background: var(--white); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.question-card .category { color: var(--sea); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.question-card h2 { margin-top: 8px; font-size: clamp(28px, 4vw, 38px); }
.answers { display: grid; gap: 9px; margin-top: 25px; }
.answer { width: 100%; display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 11px; padding: 13px 15px; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.answer:hover:not(:disabled) { border-color: var(--sea); background: var(--foam); }
.answer i { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid #a7b7b4; border-radius: 50%; font-style: normal; font-size: 13px; }
.answer.correct { border-color: var(--green); background: #e5f1e9; }
.answer.wrong { border-color: var(--red); background: #f8e5df; }
.answer.selected { border-color: var(--sea); background: var(--foam); }
.answer.correct i { color: var(--white); background: var(--green); border-color: var(--green); }
.answer.wrong i { color: var(--white); background: var(--red); border-color: var(--red); }
.explanation { margin-top: 20px; padding: 17px; background: var(--foam); border-left: 3px solid var(--sea); }
.explanation p { margin: 4px 0 0; }
.quiz-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.result-card { max-width: 720px; padding: 38px; background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.result-score { font-family: var(--serif); font-size: 72px; color: var(--deep); line-height: 1; }
.result-breakdown { display: grid; gap: 8px; margin: 24px 0; }
.review-list { display: grid; gap: 9px; margin: 22px 0; }
.review-item { padding: 15px 17px; background: #f8e7df; border-left: 3px solid var(--red); }
.review-item strong { display: block; }
.review-item p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.breakdown-row { display: grid; grid-template-columns: 160px 1fr 45px; gap: 10px; align-items: center; font-size: 14px; }
.breakdown-row i { height: 6px; background: #dfe5e1; }
.breakdown-row b { display: block; height: 100%; background: var(--sea); }

.exam-intro { display: grid; grid-template-columns: 1fr .9fr; gap: 42px; align-items: center; padding: 36px; color: var(--white); background: var(--deep); border-radius: 7px; }
.exam-intro h2 { color: var(--white); }
.exam-intro p { color: #cadbd8; }
.exam-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: rgba(255,255,255,.15); }
.exam-facts div { padding: 18px; background: var(--deep); }
.exam-facts strong { display: block; font-family: var(--serif); font-size: 31px; color: var(--sand); }
.exam-facts small { color: #cadbd8; }
.timer { padding: 6px 10px; color: var(--deep); background: var(--sand-soft); border-radius: 4px; font-weight: 700; }

.knot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.knot-card { overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: 7px; }
.knot-visual { display: grid; place-items: center; min-height: 195px; padding: 22px; background: #e8f0eb; }
.knot-visual svg { width: 100%; height: 150px; }
.knot-body { padding: 22px; }
.knot-body p { color: var(--muted); }
.knot-body ol { padding-left: 20px; font-size: 15px; }
.video-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 18px; }
.video-card { overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: 6px; }
.video-frame { position: relative; aspect-ratio: 16/9; display: grid; place-items: center; color: var(--white); background: linear-gradient(135deg, #153e44, #2b7778); border: 0; width: 100%; cursor: pointer; }
.video-frame::before { content: ''; width: 58px; height: 42px; background: #d94b3b; border-radius: 10px; }
.video-frame::after { content: ''; position: absolute; border-left: 14px solid white; border-top: 9px solid transparent; border-bottom: 9px solid transparent; transform: translateX(2px); }
.video-frame iframe { width: 100%; height: 100%; border: 0; }
.video-card p { margin: 0; padding: 15px 17px; font-weight: 600; }

.checklist { display: grid; gap: 8px; }
.cost-table { width: 100%; margin: 18px 0 34px; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); }
.cost-table th, .cost-table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.cost-table th { color: var(--muted); background: #f1f3ed; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.cost-table td:last-child { font-weight: 700; white-space: nowrap; }
.check-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 15px 16px; background: var(--white); border: 1px solid var(--line); }
.check-item input { width: 19px; height: 19px; accent-color: var(--green); }
.check-item small { color: var(--muted); }
.steps { position: relative; display: grid; gap: 0; margin: 28px 0; }
.step { display: grid; grid-template-columns: 46px 1fr; gap: 17px; padding-bottom: 28px; }
.step-no { position: relative; z-index: 1; display: grid; place-items: center; width: 40px; height: 40px; color: var(--white); background: var(--deep); border-radius: 50%; font-family: var(--serif); }
.step:not(:last-child) .step-no::after { content: ''; position: absolute; top: 40px; bottom: -30px; width: 1px; background: #aebebb; }
.step h3 { font-size: 23px; }
.step p { margin: 4px 0; color: var(--muted); }

.source-list { display: grid; gap: 10px; }
.source-card { display: grid; grid-template-columns: 1fr auto; gap: 20px; padding: 19px 20px; background: var(--white); border: 1px solid var(--line); text-decoration: none; }
.source-card:hover { border-color: var(--sea); }
.source-card strong { display: block; }
.source-card p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.source-card span { color: var(--sea); font-weight: 700; }
.empty-state { padding: 40px; text-align: center; background: var(--white); border: 1px solid var(--line); }
.toast { position: fixed; z-index: 80; right: 24px; bottom: 24px; max-width: 340px; padding: 13px 17px; color: var(--white); background: var(--deep-2); border-radius: 5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.fine-print { color: var(--muted); font-size: 13px; }

@media (max-width: 1050px) {
  .hero { grid-template-columns: 1fr .7fr; }
  .learning-layout { grid-template-columns: 1fr; }
  .lesson-aside { position: static; order: -1; }
  .toc { display: none; }
}

@media (max-width: 780px) {
  body { font-size: 16px; }
  .topbar { height: 68px; padding: 0 16px; }
  .brand svg { width: 34px; height: 34px; }
  .brand strong { font-size: 22px; }
  .brand small { display: none; }
  .top-progress { display: none; }
  .mobile-menu { display: flex; align-items: center; gap: 4px; padding: 8px; color: var(--white); background: transparent; border: 0; }
  .mobile-menu span { width: 4px; height: 4px; background: var(--sand); border-radius: 50%; }
  .mobile-menu em { margin-left: 5px; font-style: normal; font-size: 14px; }
  .app-shell { display: block; padding-top: 68px; }
  .sidebar { top: 68px; width: min(320px, 86vw); transform: translateX(-105%); box-shadow: 14px 0 40px rgba(0,0,0,.15); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  main { width: 100%; }
  #app { width: min(100% - 32px, 700px); padding: 36px 0 65px; }
  .hero { min-height: auto; grid-template-columns: 1fr; margin: -36px -16px 28px; padding: 48px 24px 36px; }
  .hero-copy { padding: 0; }
  .hero-chart { min-height: 190px; margin-top: 20px; }
  .hero-chart svg { min-height: 220px; }
  h1 { font-size: 43px; }
  .stats-strip { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat:last-child { border-bottom: 0; }
  .chapter-grid, .knot-grid, .video-grid { grid-template-columns: 1fr; }
  .chapter-card { grid-template-columns: auto 1fr; }
  .chapter-arrow { display: none; }
  .section-title { align-items: start; flex-direction: column; }
  .signal-grid { grid-template-columns: 1fr 1fr; }
  .exam-intro { grid-template-columns: 1fr; padding: 26px; }
  .prev-next { grid-template-columns: 1fr; }
  .breakdown-row { grid-template-columns: 115px 1fr 38px; }
  .source-card { grid-template-columns: 1fr; gap: 5px; }
}

@media print {
  .topbar, .sidebar, .lesson-aside, .hero-actions, .button { display: none !important; }
  .app-shell { display: block; padding: 0; }
  main { width: 100%; }
  #app { width: 100%; padding: 0; }
  .lesson article { max-width: none; }
  body { background: white; font-size: 11pt; }
  .lesson-section { break-inside: avoid; }
}

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