/* ==========================================================================
   SensorBook — 이미지 센서 교과서 공통 스타일
   ========================================================================== */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --surface: #eef1f7;
  --surface-2: #e3e8f2;
  --border: #d6dce8;
  --text: #141a26;
  --text-dim: #566178;
  --text-faint: #8a93a8;
  --accent: #0a84c6;
  --accent-soft: rgba(10, 132, 198, 0.12);
  --accent-2: #7a4ce0;
  --accent-2-soft: rgba(122, 76, 224, 0.12);
  --ok: #1f9d55;
  --warn: #d98a00;
  --bad: #d64545;
  --red: #e0443e;
  --green: #2da44e;
  --blue: #2f6fe0;
  --grid: rgba(20, 26, 38, 0.08);
  --axis: rgba(20, 26, 38, 0.45);
  --canvas-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 20px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --maxw: 880px;
  --nav-h: 58px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17;
    --bg-elev: #121826;
    --surface: #171f30;
    --surface-2: #1e283c;
    --border: #273248;
    --text: #e6ebf5;
    --text-dim: #9aa6bf;
    --text-faint: #69748c;
    --accent: #38b6f5;
    --accent-soft: rgba(56, 182, 245, 0.14);
    --accent-2: #a585ff;
    --accent-2-soft: rgba(165, 133, 255, 0.14);
    --ok: #3fcf7f;
    --warn: #f5b93a;
    --bad: #ff6b6b;
    --red: #ff5f57;
    --green: #3fcf6f;
    --blue: #5b8cff;
    --grid: rgba(230, 235, 245, 0.08);
    --axis: rgba(230, 235, 245, 0.45);
    --canvas-bg: #0f1522;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-elev: #121826;
  --surface: #171f30;
  --surface-2: #1e283c;
  --border: #273248;
  --text: #e6ebf5;
  --text-dim: #9aa6bf;
  --text-faint: #69748c;
  --accent: #38b6f5;
  --accent-soft: rgba(56, 182, 245, 0.14);
  --accent-2: #a585ff;
  --accent-2-soft: rgba(165, 133, 255, 0.14);
  --ok: #3fcf7f;
  --warn: #f5b93a;
  --bad: #ff6b6b;
  --red: #ff5f57;
  --green: #3fcf6f;
  --blue: #5b8cff;
  --grid: rgba(230, 235, 245, 0.08);
  --axis: rgba(230, 235, 245, 0.45);
  --canvas-bg: #0f1522;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas, video { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--mono); font-size: 0.88em; background: var(--surface); padding: 0.1em 0.4em; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 48px 0; }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------------------------ Top bar */
.sb-topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.sb-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; font-size: 18px; white-space: nowrap; }
.sb-logo:hover { text-decoration: none; }
.sb-logo .mark { width: 28px; height: 28px; flex: none; }
.sb-logo small { font-weight: 500; color: var(--text-dim); font-size: 13px; }
.sb-topbar .spacer { flex: 1; }
.sb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
}
.sb-btn:hover { border-color: var(--accent); }
.sb-btn.icon { width: 36px; padding: 0; }
.sb-progress { position: absolute; left: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0; }

/* Drawer (chapter list) */
.sb-drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sb-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(340px, 88vw); z-index: 61;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  transform: translateX(-102%); transition: transform .25s ease;
  overflow-y: auto; padding: 20px 14px 40px;
}
body.drawer-open .sb-drawer { transform: none; }
body.drawer-open .sb-drawer-backdrop { opacity: 1; pointer-events: auto; }
.sb-drawer h4 { margin: 8px 10px 10px; font-size: 12px; letter-spacing: .12em; color: var(--text-faint); text-transform: uppercase; }
.sb-chlist { list-style: none; margin: 0; padding: 0; }
.sb-chlist a { display: flex; gap: 12px; align-items: baseline; padding: 9px 10px; border-radius: 10px; color: var(--text); line-height: 1.4; }
.sb-chlist a:hover { background: var(--surface); text-decoration: none; }
.sb-chlist a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sb-chlist .num { font-family: var(--mono); font-size: 12px; color: var(--text-faint); width: 22px; flex: none; }
.sb-chlist a.active .num { color: var(--accent); }

/* ------------------------------------------------------------------ Layout */
.sb-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 1180px) {
  .sb-layout { grid-template-columns: minmax(0, 1fr) 230px; }
}
.sb-toc { display: none; }
@media (min-width: 1180px) {
  .sb-toc { display: block; position: sticky; top: calc(var(--nav-h) + 28px); align-self: start; max-height: calc(100vh - var(--nav-h) - 56px); overflow-y: auto; padding-top: 48px; font-size: 13.5px; }
  .sb-toc h4 { margin: 0 0 10px; font-size: 11px; letter-spacing: .14em; color: var(--text-faint); }
  .sb-toc a { display: block; padding: 5px 0 5px 12px; border-left: 2px solid var(--border); color: var(--text-dim); line-height: 1.45; }
  .sb-toc a:hover { color: var(--text); text-decoration: none; }
  .sb-toc a.active { border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
}

main.chapter { max-width: var(--maxw); width: 100%; margin: 0 auto; padding: 40px 0 80px; min-width: 0; }
main.chapter > section { margin: 64px 0; }
main.chapter h2 { font-size: 28px; line-height: 1.35; letter-spacing: -0.02em; margin: 0 0 18px; padding-top: 8px; }
main.chapter h2 .h-num { font-family: var(--mono); color: var(--accent); font-size: 0.7em; margin-right: 10px; vertical-align: 0.12em; }
main.chapter h3 { font-size: 20px; margin: 36px 0 12px; letter-spacing: -0.01em; }
main.chapter p { margin: 0 0 16px; }
main.chapter ul, main.chapter ol { padding-left: 1.3em; margin: 0 0 16px; }
main.chapter li { margin: 4px 0; }
strong { font-weight: 700; }
.term { font-weight: 700; color: var(--accent); }
.en { color: var(--text-dim); font-size: 0.9em; }

/* Chapter hero */
.chapter-hero { padding: 24px 0 8px; }
.eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: .16em; color: var(--accent); font-weight: 600; text-transform: uppercase; }
.chapter-hero h1 { font-size: clamp(32px, 5.4vw, 46px); line-height: 1.2; letter-spacing: -0.03em; margin: 10px 0 16px; }
.lead { font-size: 19px; color: var(--text-dim); line-height: 1.7; }
.objectives { list-style: none; padding: 18px 20px !important; margin: 24px 0 0 !important; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 6px; }
.objectives::before { content: "이 장에서 배우는 것"; display: block; font-size: 12px; letter-spacing: .1em; color: var(--text-faint); font-weight: 700; margin-bottom: 4px; }
.objectives li { padding-left: 26px; position: relative; margin: 0 !important; }
.objectives li::before { content: ""; position: absolute; left: 4px; top: 0.62em; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); opacity: .85; }

/* ------------------------------------------------------------------ Figures */
figure { margin: 28px 0; }
figure.diagram { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
figure.diagram svg { display: block; width: 100%; height: auto; }
figcaption { font-size: 14px; color: var(--text-dim); margin-top: 12px; line-height: 1.6; }
figcaption b { color: var(--text); }
.fig-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* SVG helpers usable inside inline diagrams */
svg .t { fill: var(--text); font-family: var(--font); font-size: 13px; }
svg .t-dim { fill: var(--text-dim); font-family: var(--font); font-size: 12px; }
svg .t-mono { fill: var(--text-dim); font-family: var(--mono); font-size: 11px; }
svg .t-acc { fill: var(--accent); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .s-line { stroke: var(--text-dim); fill: none; stroke-width: 1.5; }
svg .s-axis { stroke: var(--axis); fill: none; stroke-width: 1.2; }
svg .s-acc { stroke: var(--accent); fill: none; stroke-width: 2; }
svg .f-surface { fill: var(--surface); stroke: var(--border); }
svg .f-elev { fill: var(--bg-elev); stroke: var(--border); }
svg .f-acc { fill: var(--accent); }
svg .f-acc-soft { fill: var(--accent-soft); stroke: var(--accent); }
svg .f-acc2-soft { fill: var(--accent-2-soft); stroke: var(--accent-2); }

/* ------------------------------------------------------------------ Simulator card */
.sim {
  margin: 32px 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.sim-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }
.sim-tag { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .12em; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 9px; line-height: 1.6; }
.sim-tag.three { color: var(--accent-2); border-color: var(--accent-2); }
.sim-head h3 { margin: 0 !important; font-size: 17px !important; flex: 1; min-width: 180px; }
.sim-body { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 820px) {
  .sim-body.side { grid-template-columns: minmax(0, 1fr) 280px; }
  .sim-body.side .sim-controls { border-top: 0; border-left: 1px solid var(--border); }
}
.sim-view { position: relative; background: var(--canvas-bg); min-height: 120px; }
.sim-view canvas { display: block; width: 100%; }
.sim-view.three { height: 440px; cursor: grab; touch-action: none; }
.sim-view.three:active { cursor: grabbing; }
.sim-view .hint { position: absolute; right: 10px; bottom: 8px; font-size: 12px; color: var(--text-faint); pointer-events: none; background: color-mix(in srgb, var(--canvas-bg) 70%, transparent); padding: 2px 8px; border-radius: 6px; }
.overlay-label { position: absolute; pointer-events: none; font-size: 12px; font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--bg-elev) 85%, transparent); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -50%); }
.sim-controls { padding: 16px 18px; border-top: 1px solid var(--border); display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-content: start; }
.sim-body.side .sim-controls { grid-template-columns: 1fr; }
.ctrl { display: grid; gap: 6px; font-size: 14px; }
.ctrl > span { display: flex; justify-content: space-between; gap: 8px; color: var(--text-dim); }
.ctrl output { font-family: var(--mono); color: var(--text); font-weight: 600; font-size: 13px; }
.ctrl select { font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.ctrl-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--text-dim); padding: 5px 11px; border-radius: 7px; cursor: pointer; }
.seg button.on, .seg button[aria-pressed="true"] { background: var(--bg-elev); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.btn { font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text-dim); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--surface-2) var(--fill, 50%)); }
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--surface-2); }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--accent); margin-top: -6.5px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--accent); }

.sim-readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--border); border-top: 1px solid var(--border); }
.stat { background: var(--bg-elev); padding: 12px 16px; display: grid; gap: 2px; }
.stat .k { font-size: 12px; color: var(--text-dim); }
.stat .v { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-left: 2px; }
.sim-note { padding: 12px 18px; font-size: 14px; color: var(--text-dim); border-top: 1px solid var(--border); background: var(--surface); line-height: 1.6; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-dim); padding: 10px 18px 0; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ------------------------------------------------------------------ Callouts & formula */
.callout { margin: 24px 0; padding: 16px 18px 16px 20px; border-radius: var(--radius-sm); background: var(--accent-soft); border-left: 4px solid var(--accent); font-size: 16px; }
.callout > strong:first-child { display: block; margin-bottom: 4px; }
.callout p:last-child { margin-bottom: 0; }
.callout.tip { background: color-mix(in srgb, var(--ok) 12%, transparent); border-left-color: var(--ok); }
.callout.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); border-left-color: var(--warn); }
.callout.deep { background: var(--accent-2-soft); border-left-color: var(--accent-2); }
.callout.deep > strong:first-child::before { content: "심화 · "; color: var(--accent-2); }

.formula { margin: 22px 0; padding: 14px 18px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow-x: auto; }
.formula .where { font-size: 14px; color: var(--text-dim); margin-top: 6px; }
.katex { font-size: 1.08em; }
.katex-display { margin: 0.4em 0 !important; overflow-x: auto; overflow-y: hidden; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 22px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface); font-weight: 700; font-size: 14px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Key points summary */
.keypoints { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.keypoints h2 { font-size: 22px !important; }
.keypoints ol { counter-reset: kp; list-style: none; padding: 0 !important; }
.keypoints li { counter-increment: kp; position: relative; padding-left: 38px; margin: 10px 0 !important; }
.keypoints li::before { content: counter(kp); position: absolute; left: 0; top: 0.1em; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 14px; display: grid; place-items: center; font-family: var(--mono); }

/* ------------------------------------------------------------------ Quiz */
.quiz { display: grid; gap: 16px; }
.quiz-q { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.quiz-q > p:first-child { font-weight: 700; margin-bottom: 12px; }
.quiz-q .opts { display: grid; gap: 8px; }
.quiz-q button.opt { text-align: left; font: inherit; font-size: 15px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; line-height: 1.5; }
.quiz-q button.opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-q button.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); font-weight: 600; }
.quiz-q button.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.quiz-q button.opt:disabled { cursor: default; }
.quiz-exp { display: none; margin-top: 12px; font-size: 15px; color: var(--text-dim); padding: 10px 14px; border-radius: 8px; background: var(--surface); }
.quiz-q.done .quiz-exp { display: block; }

/* ------------------------------------------------------------------ Prev / Next */
.sb-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: var(--maxw); margin: 0 auto; padding: 0 0 20px; }
.sb-pager a { display: block; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); color: var(--text); }
.sb-pager a:hover { border-color: var(--accent); text-decoration: none; }
.sb-pager small { display: block; color: var(--text-faint); font-size: 12px; }
.sb-pager .next { text-align: right; grid-column: 2; }
.sb-foot { border-top: 1px solid var(--border); color: var(--text-faint); font-size: 13px; padding: 28px 16px 40px; text-align: center; }

/* ------------------------------------------------------------------ Home page */
.home-hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--border); }
.home-hero .inner { max-width: 1180px; margin: 0 auto; padding: 72px 16px 64px; display: grid; gap: 40px; align-items: center; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .home-hero .inner { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.home-hero h1 { font-size: clamp(36px, 6.4vw, 62px); line-height: 1.12; letter-spacing: -0.035em; margin: 14px 0 20px; }
.home-hero h1 .grad { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-hero p { font-size: 19px; color: var(--text-dim); max-width: 560px; }
.home-hero .cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.home-hero .cta a { padding: 12px 20px; border-radius: 12px; font-weight: 700; }
.home-hero .cta a.primary { background: var(--accent); color: #fff; }
.home-hero .cta a.ghost { border: 1px solid var(--border); color: var(--text); background: var(--bg-elev); }
.home-hero .cta a:hover { text-decoration: none; filter: brightness(1.05); }
.hero-3d { height: 420px; border-radius: 20px; border: 1px solid var(--border); background: radial-gradient(ellipse at 50% 40%, var(--accent-soft), transparent 70%), var(--bg-elev); position: relative; overflow: hidden; box-shadow: var(--shadow); touch-action: none; }
.hero-3d .hint { position: absolute; left: 14px; bottom: 10px; font-size: 12px; color: var(--text-faint); }
.home-section { max-width: 1180px; margin: 0 auto; padding: 64px 16px; }
.home-section h2 { font-size: 30px; letter-spacing: -0.02em; margin: 0 0 8px; }
.home-section > p.sub { color: var(--text-dim); margin: 0 0 32px; }
.ch-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ch-card { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); transition: transform .15s, border-color .15s; min-height: 190px; }
.ch-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.ch-card .num { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .1em; }
.ch-card h3 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.ch-card p { margin: 0; color: var(--text-dim); font-size: 14.5px; line-height: 1.6; flex: 1; }
.ch-card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.ch-card .tags span { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface); color: var(--text-dim); }
.ch-card .tags span.sim { background: var(--accent-soft); color: var(--accent); }
.ch-card .tags span.d3 { background: var(--accent-2-soft); color: var(--accent-2); }
.flow { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); counter-reset: fl; }
.flow div { counter-increment: fl; padding: 16px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--border); font-size: 14.5px; color: var(--text-dim); position: relative; }
.flow div b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.flow div::before { content: counter(fl, decimal-leading-zero); font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 700; display: block; margin-bottom: 6px; }

/* Glossary */
.gl-search { width: 100%; font: inherit; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); margin-bottom: 20px; }
.gl-list { display: grid; gap: 10px; }
.gl-item { padding: 14px 18px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--border); }
.gl-item h4 { margin: 0 0 4px; font-size: 16px; }
.gl-item h4 .en { font-weight: 500; margin-left: 6px; }
.gl-item p { margin: 0 !important; font-size: 15px; color: var(--text-dim); }
.gl-item .ch { font-size: 12px; margin-top: 6px; display: inline-block; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  main.chapter { padding-top: 24px; }
  main.chapter h2 { font-size: 24px; }
  .sim-view.three { height: 340px; }
  .hero-3d { height: 320px; }
  .sb-logo small { display: none; }
  .sb-pager { grid-template-columns: 1fr; }
  .sb-pager .next { grid-column: 1; }
}
