/* ============ tokens ============ */
:root {
  --ink: #0b111a;
  --ink-soft: #101a26;
  --panel: #f2f5f8;
  --card: #ffffff;
  --stage-1: #0d1725;
  --stage-2: #050a11;
  --text: #16222f;
  --muted: #5d7183;
  --faint: #8b9dac;
  --line: rgba(20, 40, 60, 0.14);
  --line-soft: rgba(20, 40, 60, 0.08);
  --accent: #c9761a;
  --accent-ink: #8a4f0c;
  --accent-soft: rgba(201, 118, 26, 0.12);
  --cyan: #1a7f8c;
  --ok: #227f5b;
  --bad: #b1482f;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --panel: #0e151f;
    --card: #131d29;
    --text: #e8eef5;
    --muted: #94a8b9;
    --faint: #6d8092;
    --line: rgba(160, 190, 215, 0.16);
    --line-soft: rgba(160, 190, 215, 0.09);
    --accent: #f0ac48;
    --accent-ink: #ffcf8a;
    --accent-soft: rgba(240, 172, 72, 0.14);
    --cyan: #5fd0dd;
    --ok: #5ec49a;
    --bad: #e8836a;
    --bg: #080d14;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg, #eef2f6);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

p, h1, h2, h3, ul, dl, dd, dt { margin: 0; }
button { font: inherit; color: inherit; }

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 20px 40px;
}

/* ============ top bar ============ */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--line);
}
.brand-mark svg { width: 26px; height: 26px; }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 2px;
}

h1 {
  font-size: clamp(19px, 1.55vw + 12px, 27px);
  line-height: 1.22;
  letter-spacing: -0.015em;
  font-weight: 700;
  text-wrap: balance;
}

.topbar-note {
  font-size: 12.5px;
  color: var(--faint);
  letter-spacing: 0.04em;
  padding-bottom: 4px;
}

/* ============ chapter nav ============ */
.chapters {
  display: flex;
  gap: 6px;
  margin: 16px 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.chapters::-webkit-scrollbar { display: none; }

.chapter {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .18s, background .18s, border-color .18s;
  white-space: nowrap;
}
.chapter .num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.chapter .label { font-size: 13.5px; font-weight: 500; }
.chapter:hover { color: var(--text); border-color: var(--faint); }
.chapter.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #14100a;
}
.chapter.is-active .num { color: rgba(20, 16, 10, 0.6); }
.chapter:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ============ layout ============ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(340px, 0.82fr);
  gap: 22px;
  align-items: start;
}

/* ============ stage ============ */
.stage {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 52% 18%, #1b2b3d 0%, #0d1725 45%, #05090f 100%);
  border: 1px solid var(--line);
  aspect-ratio: 16 / 11;
  min-height: 340px;
  isolation: isolate;
  box-shadow: 0 22px 50px -30px rgba(0, 0, 0, 0.6);
}

@media (min-width: 981px) {
  .stage { position: sticky; top: 18px; }
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
#scene.is-dragging { cursor: grabbing; }

.hotspots { position: absolute; inset: 0; pointer-events: none; }

.hotspot {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .2s;
}
.hotspot .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #ffd08a;
  box-shadow: 0 0 0 4px rgba(255, 208, 138, 0.18), 0 0 12px rgba(255, 208, 138, 0.55);
  flex: 0 0 auto;
}
.hotspot .txt {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: #dbe7f2;
  background: rgba(8, 14, 22, 0.72);
  border: 1px solid rgba(180, 205, 225, 0.22);
  border-radius: 999px;
  padding: 2px 8px;
  backdrop-filter: blur(4px);
}
.hotspot:hover .txt, .hotspot.is-active .txt {
  border-color: rgba(255, 208, 138, 0.75);
  color: #fff3dd;
}
.hotspot.is-active .dot { background: #fff; }

.stage-hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(to top, rgba(4, 8, 13, 0.85), rgba(4, 8, 13, 0));
  flex-wrap: wrap;
}

.hud-group { display: flex; gap: 7px; flex-wrap: wrap; }

.chip {
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(190, 212, 232, 0.24);
  background: rgba(10, 18, 28, 0.6);
  color: #c3d4e2;
  cursor: pointer;
  transition: background .16s, border-color .16s, color .16s;
}
.chip:hover { border-color: rgba(220, 235, 248, 0.6); color: #f2f8fd; }
.chip.is-on {
  border-color: rgba(255, 208, 138, 0.7);
  color: #ffe3b8;
  background: rgba(255, 190, 100, 0.12);
}
.chip:focus-visible { outline: 2px solid #ffd08a; outline-offset: 2px; }

.hint {
  font-size: 11.5px;
  color: rgba(198, 214, 228, 0.66);
  letter-spacing: 0.04em;
}

.stage-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  padding: 24px;
  color: #cfdcea;
  background: rgba(5, 10, 16, 0.92);
  font-size: 14px;
}
.stage-fallback[hidden] { display: none; }

/* ============ panel ============ */
.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px;
}

.pane { display: block; }
.pane[hidden] { display: none; }

.pane-head { margin-bottom: 20px; }

.kicker {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.pane-head h2 {
  font-size: clamp(20px, 1.1vw + 14px, 25px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  font-weight: 700;
  margin-bottom: 10px;
  text-wrap: balance;
}

.lede {
  font-size: 14px;
  line-height: 1.72;
  color: var(--muted);
  max-width: 46ch;
}

/* part list */
.part-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 7px;
  margin-bottom: 20px;
}

.part-btn {
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  line-height: 1.3;
  transition: border-color .16s, background .16s, transform .16s;
  min-height: 44px;
}
.part-btn .pn { display: block; font-size: 13.5px; font-weight: 600; }
.part-btn .pe {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--faint);
  text-transform: uppercase;
  margin-top: 2px;
}
.part-btn:hover { border-color: var(--accent); }
.part-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.part-btn.is-active .pe { color: var(--accent); }
.part-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.part-detail {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.part-en {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--faint);
  text-transform: uppercase;
}
.part-detail h3, .phase-detail h3 {
  font-size: 19px;
  margin: 4px 0 8px;
  letter-spacing: -0.01em;
}
.part-body, .phase-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.75;
}

.part-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin-top: 14px;
  font-size: 12.5px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
.part-meta dt { color: var(--faint); letter-spacing: 0.04em; }
.part-meta dd { color: var(--text); }

/* airfoil */
.airfoil-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #081019;
}
#airfoil { display: block; width: 100%; height: 168px; }
.airfoil-caption {
  font-size: 12px;
  color: #a9c0d3;
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(160, 190, 215, 0.12);
  margin: 0;
}

/* sliders */
.sliders { display: grid; gap: 12px; margin: 18px 0 16px; }
.slider { display: block; }
.slider-top {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.slider-top output { font-family: var(--mono); color: var(--text); font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 2px; background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

/* gauges */
.gauges, .surfaces {
  list-style: none;
  display: grid;
  gap: 9px;
  padding: 0;
  margin: 0 0 14px;
}
.gauges li, .surfaces li {
  display: grid;
  grid-template-columns: 84px 1fr 62px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.g-key, .s-key { color: var(--muted); }
.g-bar, .s-bar {
  position: relative;
  height: 7px;
  border-radius: 4px;
  background: var(--line-soft);
  overflow: hidden;
}
.g-bar i, .s-bar i {
  position: absolute;
  inset: 0 auto 0 50%;
  width: 0;
  border-radius: 4px;
  background: var(--cyan);
  transition: width .25s ease, left .25s ease, background .25s;
}
.s-bar i { background: var(--accent); }
.g-val, .s-val {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  text-align: right;
}

.note {
  font-size: 13px;
  color: var(--text);
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  padding: 9px 12px;
  border-radius: 0 8px 8px 0;
  line-height: 1.6;
}
.note.is-warn {
  background: rgba(200, 60, 40, 0.12);
  border-color: #d9603f;
  color: var(--text);
}

.formula {
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 12px;
  line-height: 1.7;
  font-family: var(--mono);
}

/* yoke */
.yoke-wrap {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.yoke {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 50%, rgba(120, 160, 195, 0.1), transparent 70%),
    var(--card);
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.yoke.is-dragging { cursor: grabbing; }
.yoke-ring {
  position: absolute;
  left: 50%; top: 50%;
  width: 96px; height: 96px;
  margin: -48px 0 0 -48px;
  border-radius: 50%;
  border: 1px dashed var(--line);
}
.yoke-cross {
  position: absolute;
  background: var(--line-soft);
}
.yoke-cross.h { left: 20px; right: 20px; top: 50%; height: 1px; }
.yoke-cross.v { top: 20px; bottom: 20px; left: 50%; width: 1px; }
.yoke-dot {
  position: absolute;
  left: 50%; top: 50%;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  transition: transform .08s linear;
}
.yoke-lbl {
  position: absolute;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--faint);
}
.yoke-lbl.top { top: 6px; left: 50%; transform: translateX(-50%); }
.yoke-lbl.bottom { bottom: 6px; left: 50%; transform: translateX(-50%); }
.yoke-lbl.left { left: 8px; top: 50%; transform: translateY(-50%); }
.yoke-lbl.right { right: 8px; top: 50%; transform: translateY(-50%); }

.rudder-pedals { font-size: 12px; }
.rp-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--faint);
  margin-bottom: 8px;
}
.rp-row { display: flex; align-items: center; gap: 8px; }
.pedal {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.pedal:hover { border-color: var(--accent); color: var(--accent); }
.pedal:active { background: var(--accent-soft); }
.rp-track {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line-soft);
}
.rp-track i {
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .18s ease;
}

.ghost-btn {
  margin-top: 4px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  min-height: 40px;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.facts { margin-top: 18px; display: grid; gap: 10px; }
.facts div {
  display: grid;
  gap: 2px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}
.facts dt { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.facts dd { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* timeline */
.timeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: 20px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 4%; right: 4%;
  top: 21px;
  height: 1px;
  background: var(--line);
}
.tl-step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--faint);
}
.tl-step .dotmk {
  width: 11px; height: 11px;
  margin-top: 16px;
  border-radius: 50%;
  background: var(--panel);
  border: 1.5px solid var(--faint);
  transition: background .16s, border-color .16s, transform .16s;
}
.tl-step .tl-name {
  font-size: 10.5px;
  line-height: 1.25;
  text-align: center;
  letter-spacing: 0.02em;
}
.tl-step:hover { color: var(--text); }
.tl-step.is-active { color: var(--text); }
.tl-step.is-active .dotmk {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.25);
}
.tl-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.phase-detail { border-top: 1px solid var(--line); padding-top: 16px; }
.phase-en {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--faint);
  text-transform: uppercase;
}
.phase-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.phase-meta div { display: grid; gap: 2px; }
.phase-meta dt {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--faint);
  font-family: var(--mono);
}
.phase-meta dd { font-size: 12.5px; }

/* quiz */
.quiz { display: grid; gap: 18px; }
.q-item { border-top: 1px solid var(--line); padding-top: 14px; }
.q-item:first-child { border-top: 0; padding-top: 0; }
.q-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 10px;
}
.q-title span { color: var(--faint); font-family: var(--mono); font-size: 11px; margin-right: 6px; }
.q-opts { display: grid; gap: 7px; }
.q-opt {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
  min-height: 44px;
  transition: border-color .16s, background .16s;
}
.q-opt:hover:not(:disabled) { border-color: var(--accent); }
.q-opt:disabled { cursor: default; }
.q-opt.is-right { border-color: var(--ok); background: rgba(34, 127, 91, 0.1); }
.q-opt.is-wrong { border-color: var(--bad); background: rgba(177, 72, 47, 0.1); }
.q-explain {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
  margin-top: 9px;
  padding-left: 11px;
  border-left: 2px solid var(--line);
}

.quiz-result { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.score {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.score-note { font-size: 13px; color: var(--muted); margin: 6px 0 14px; }

/* footer */
.footnote {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--faint);
}
.footnote-mark { font-family: var(--mono); letter-spacing: 0.16em; }

/* ============ responsive ============ */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stage { aspect-ratio: 16 / 11; max-height: 62vh; }
}

@media (max-width: 720px) {
  .app { padding: 16px 14px 32px; }
  .topbar { gap: 10px; }
  .topbar-note { display: none; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .brand-mark svg { width: 22px; height: 22px; }
  .chapters { margin: 14px -14px 16px; padding: 0 14px 4px; }
  .panel { padding: 20px 18px; border-radius: 16px; }
  .stage { border-radius: 16px; aspect-ratio: 4 / 3.4; min-height: 300px; }
  .yoke-wrap { grid-template-columns: 1fr; justify-items: center; }
  .yoke { width: 100%; max-width: 200px; height: 172px; }
  .rudder-pedals { width: 100%; max-width: 240px; }
  .timeline { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 14px; }
  .timeline::before { display: none; }
  .tl-step .dotmk { display: none; }
  .tl-step {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 4px;
    background: var(--card);
  }
  .tl-step.is-active { border-color: var(--accent); background: var(--accent-soft); }
  .tl-name { font-size: 11px; }
  .gauges li, .surfaces li { grid-template-columns: 76px 1fr 58px; gap: 8px; }
  .hint { display: none; }
  .hotspot .txt { font-size: 10.5px; padding: 2px 6px; }
}

@media (max-width: 420px) {
  .part-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { aspect-ratio: 1 / 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
