:root {
  --ink: #10213b;
  --muted: #66758b;
  --paper: #f5f2ea;
  --white: #fff;
  --cyan: #42d7d1;
  --cyan-dark: #12a9a5;
  --orange: #ff6b3d;
  --yellow: #f4c84a;
  --line: rgba(16, 33, 59, .14);
  --shadow: 0 24px 70px rgba(17, 36, 61, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  line-height: 1.7;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
canvas { max-width: 100%; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 242, 234, .9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 13px; letter-spacing: .14em; font-weight: 700; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--ink);
  background: var(--cyan);
  border-radius: 50%;
  font-size: 26px;
  font-weight: 900;
}
.topnav { display: flex; gap: 38px; font-size: 14px; font-weight: 700; }
.topnav a { position: relative; }
.topnav a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: -6px; height: 2px; background: var(--orange); transition: .25s; }
.topnav a:hover::after { right: 0; }
.progress-pill {
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  padding: 8px 14px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  color: var(--ink);
  font-size: 12px;
}
.progress-pill strong { color: var(--orange); }

.hero {
  min-height: calc(100vh - 72px);
  padding: 72px clamp(24px, 6vw, 100px);
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  align-items: center;
  gap: 6vw;
  overflow: hidden;
}
.eyebrow { margin: 0 0 18px; color: var(--orange); font-size: 11px; font-weight: 900; letter-spacing: .22em; }
.hero h1, h2 { margin: 0; line-height: 1.15; letter-spacing: -.045em; }
.hero h1 { font-size: clamp(46px, 6vw, 86px); }
.hero h1 em { color: var(--orange); font-style: normal; }
.hero-lead { max-width: 590px; margin: 30px 0; color: var(--muted); font-size: 16px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.button {
  min-height: 50px;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  border: 0;
  border-radius: 4px;
  font-weight: 800;
  cursor: pointer;
}
.button.primary { color: white; background: var(--orange); box-shadow: 0 10px 25px rgba(255, 107, 61, .22); }
.button.primary:hover { background: #ea542a; transform: translateY(-1px); }
.button.ghost { border: 1px solid var(--line); background: transparent; }
.hero-stats { display: flex; gap: 40px; margin-top: 48px; }
.hero-stats div { display: grid; }
.hero-stats strong { font: 800 25px/1.2 Georgia, serif; }
.hero-stats span { color: var(--muted); font-size: 11px; }
.hero-visual { position: relative; }
.scope-card {
  position: relative;
  z-index: 2;
  padding: 24px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  color: white;
  background: var(--ink);
  box-shadow: 0 30px 90px rgba(16,33,59,.25);
  transform: rotate(1.5deg);
}
.scope-head { display: flex; justify-content: space-between; color: #b5c3d5; font: 700 11px/1 monospace; letter-spacing: .14em; }
.scope-head i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.scope-card canvas { width: 100%; display: block; }
.scope-readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 4px; background: rgba(255,255,255,.12); }
.scope-readout div { padding: 12px 15px; display: grid; background: var(--ink); }
.scope-readout span { color: #8fa2ba; font-size: 10px; }
.scope-readout b { font-family: monospace; color: var(--cyan); }
.orbit { position: absolute; border: 1px solid var(--orange); border-radius: 50%; opacity: .45; }
.orbit-a { width: 180px; height: 180px; right: -80px; top: -80px; }
.orbit-b { width: 52px; height: 52px; left: -28px; bottom: -24px; background: var(--yellow); border: 0; }

.section { padding: 110px clamp(24px, 7vw, 112px); }
.section-heading { display: grid; grid-template-columns: 1fr minmax(280px, 480px); gap: 50px; align-items: end; margin-bottom: 52px; }
.section-heading h2, .concept-copy h2, .practice-intro h2 { font-size: clamp(38px, 4.6vw, 64px); }
.section-heading > p { margin: 0; color: var(--muted); }
.pathway { background: white; }
.chapter-tabs { display: flex; gap: 8px; margin-bottom: 28px; overflow-x: auto; }
.chapter-tab, .lab-tab {
  padding: 12px 17px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 700;
}
.chapter-tab span { margin-right: 9px; font-family: Georgia, serif; }
.chapter-tab.active { color: white; border-color: var(--ink); background: var(--ink); }
.lesson-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.lesson-card {
  position: relative;
  min-height: 270px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: #faf9f5;
  cursor: pointer;
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.lesson-card:hover { transform: translateY(-5px); border-color: var(--cyan-dark); box-shadow: var(--shadow); }
.lesson-card.complete::after { content: "✓"; position: absolute; right: 22px; top: 20px; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); background: var(--cyan); font-weight: 900; }
.lesson-number { color: var(--orange); font: 700 13px/1 Georgia, serif; }
.lesson-card h3 { margin: 35px 0 12px; font-size: 23px; line-height: 1.4; }
.lesson-card p { margin: 0; color: var(--muted); font-size: 13px; }
.lesson-meta { margin-top: auto; padding-top: 22px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; border-top: 1px solid var(--line); }
.lesson-arrow { color: var(--orange); font-size: 18px; }

.concept-section { display: grid; grid-template-columns: .8fr 1.2fr; gap: 7vw; align-items: center; }
.concept-copy > p:not(.eyebrow) { color: var(--muted); }
.concept-list { margin: 42px 0 0; padding: 0; list-style: none; }
.concept-list li { padding: 18px 0; display: flex; gap: 20px; align-items: center; border-bottom: 1px solid var(--line); cursor: pointer; opacity: .48; }
.concept-list li.active { opacity: 1; }
.concept-list li > span { font: 700 13px/1 Georgia, serif; color: var(--orange); }
.concept-list li div { display: grid; }
.concept-list small { color: var(--muted); }
.concept-stage { padding: 25px; border-radius: 8px; color: white; background: var(--ink); box-shadow: var(--shadow); }
.concept-stage canvas { width: 100%; display: block; }
.stage-controls { display: flex; gap: 20px; align-items: center; }
.stage-controls button { width: 42px; height: 42px; border: 0; border-radius: 50%; color: var(--ink); background: var(--cyan); cursor: pointer; font-weight: 900; }
.stage-controls label { flex: 1; display: grid; grid-template-columns: auto 1fr 45px; align-items: center; gap: 12px; color: #a9b7ca; font-size: 12px; }
input[type="range"] { accent-color: var(--cyan); }

.lab-section { background: var(--ink); }
.section-heading.light h2 { color: white; }
.section-heading.light > p { color: #aab7c9; }
.lab-shell { overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; background: #132945; box-shadow: 0 35px 90px rgba(0,0,0,.2); }
.lab-tabs { display: flex; padding: 0 20px; border-bottom: 1px solid rgba(255,255,255,.1); overflow-x: auto; }
.lab-tab { padding: 18px 22px; border: 0; border-bottom: 3px solid transparent; color: #95a7bd; }
.lab-tab.active { color: white; border-bottom-color: var(--cyan); }
.lab-body { display: grid; grid-template-columns: 280px 1fr; min-height: 560px; }
.lab-controls { padding: 28px; border-right: 1px solid rgba(255,255,255,.1); color: white; }
.control-block { margin-bottom: 28px; }
.control-block label { display: flex; justify-content: space-between; color: #b7c4d4; font-size: 12px; }
.control-block output { color: var(--cyan); font-family: monospace; }
.control-block input { width: 100%; margin-top: 10px; }
.lab-note { padding: 14px; border-left: 3px solid var(--yellow); color: #c4cfdd; background: rgba(255,255,255,.05); font-size: 12px; }
.lab-display { padding: 25px; display: flex; flex-direction: column; min-width: 0; }
.lab-display canvas { width: 100%; min-height: 320px; flex: 1; }
.lab-results { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.result-tile { padding: 12px; display: grid; border: 1px solid rgba(255,255,255,.1); border-radius: 4px; }
.result-tile span { color: #8ea0b7; font-size: 10px; }
.result-tile b { color: var(--cyan); font-family: monospace; font-size: 17px; }

.practice-section { display: grid; grid-template-columns: .8fr 1.2fr; gap: 7vw; align-items: center; }
.practice-intro > p:not(.eyebrow) { color: var(--muted); }
.score-ring {
  width: 118px;
  height: 118px;
  margin-top: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--cyan) 0deg, #dcded9 0);
  position: relative;
}
.score-ring::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--paper); }
.score-ring div { position: relative; z-index: 1; }
.score-ring strong { font: 700 35px/1 Georgia, serif; }
.quiz-card { padding: clamp(25px, 4vw, 52px); border: 1px solid var(--line); background: white; box-shadow: var(--shadow); }
.quiz-top { display: flex; justify-content: space-between; color: var(--orange); font: 800 11px/1 monospace; letter-spacing: .12em; }
.difficulty { padding: 5px 9px; color: var(--ink); background: #e4f8f6; }
.quiz-card h3 { margin: 35px 0 28px; font-size: clamp(20px, 2vw, 28px); line-height: 1.6; }
.quiz-options { display: grid; gap: 10px; }
.quiz-option { padding: 15px 18px; display: flex; gap: 13px; align-items: center; border: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.quiz-option:hover, .quiz-option.selected { border-color: var(--cyan-dark); background: #effaf9; }
.quiz-option.correct { border-color: #2db27d; background: #eaf8f1; }
.quiz-option.wrong { border-color: var(--orange); background: #fff0eb; }
.quiz-option span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); font-weight: 800; }
.quiz-feedback { margin-top: 18px; padding: 15px; border-left: 3px solid var(--cyan-dark); background: #effaf9; font-size: 13px; }
.quiz-next { margin-top: 22px; }
.quiz-next:disabled { opacity: .38; cursor: not-allowed; }

.formula-section { background: white; }
.formula-search { padding: 11px 15px; display: flex; gap: 10px; border: 1px solid var(--line); background: #faf9f5; }
.formula-search input { width: 100%; border: 0; outline: 0; background: transparent; }
.formula-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.formula-card { padding: 22px; border: 1px solid var(--line); }
.formula-card small { color: var(--orange); font-weight: 800; }
.formula-card strong { margin: 15px 0 9px; display: block; font: 700 22px/1.3 Georgia, "Yu Mincho", serif; }
.formula-card p { margin: 0; color: var(--muted); font-size: 12px; }

.lesson-dialog { width: min(850px, calc(100% - 28px)); max-height: 88vh; padding: 0; border: 0; color: var(--ink); background: var(--paper); box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.lesson-dialog::backdrop { background: rgba(8,20,36,.72); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; z-index: 2; top: 18px; float: right; margin: 18px 18px 0 0; width: 40px; height: 40px; border: 0; border-radius: 50%; color: white; background: var(--ink); cursor: pointer; }
.lesson-content-head { padding: 60px 60px 35px; color: white; background: var(--ink); }
.lesson-content-head span { color: var(--cyan); font: 800 11px/1 monospace; letter-spacing: .15em; }
.lesson-content-head h2 { margin-top: 18px; font-size: 40px; }
.lesson-content-body { padding: 45px 60px 60px; }
.lesson-content-body h3 { margin-top: 32px; font-size: 22px; }
.lesson-content-body .analogy { padding: 18px; border-left: 4px solid var(--yellow); background: white; }
.lesson-content-body .formula-focus { padding: 22px; color: white; background: #17304f; font: 700 24px/1.5 Georgia, "Yu Mincho", serif; text-align: center; }
.lesson-check { width: 100%; margin-top: 35px; }

footer { padding: 40px clamp(24px, 6vw, 100px); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #a9b7c8; background: #09182b; font-size: 12px; }
footer .brand { color: white; }
footer button { border: 0; color: #a9b7c8; background: transparent; cursor: pointer; text-decoration: underline; }

@media (max-width: 920px) {
  .topnav { display: none; }
  .hero, .concept-section, .practice-section { grid-template-columns: 1fr; }
  .hero { padding-top: 45px; }
  .hero-visual { margin-top: 20px; }
  .lesson-grid, .formula-grid { grid-template-columns: repeat(2, 1fr); }
  .lab-body { grid-template-columns: 1fr; }
  .lab-controls { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.1); }
  .control-block { margin: 0; }
}

@media (max-width: 600px) {
  .topbar { height: 62px; }
  .progress-pill span { display: none; }
  .hero { min-height: auto; padding: 55px 20px 75px; }
  .hero h1 { font-size: 45px; }
  .hero-stats { gap: 22px; }
  .scope-card { padding: 14px; }
  .section { padding: 75px 20px; }
  .section-heading { grid-template-columns: 1fr; gap: 20px; }
  .lesson-grid, .formula-grid { grid-template-columns: 1fr; }
  .lesson-card { min-height: 230px; }
  .lab-controls { grid-template-columns: 1fr; }
  .lab-results { grid-template-columns: repeat(2, 1fr); }
  .lesson-content-head, .lesson-content-body { padding-left: 25px; padding-right: 25px; }
  footer { flex-direction: column; text-align: center; }
}

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