/* Copyright (c) 2026 geniuskey and GPUBook contributors.
   SPDX-License-Identifier: MIT — see ../LICENSE-MIT. */
/* ==========================================================================
   GPUBook — GPU 칩 설계 교과서 공통 스타일 (DeviceBook v2 키트에서 이식)
   ========================================================================== */
@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: #2b8a3e;
  --accent-soft: rgba(43, 138, 62, 0.10);
  --accent-2: #1c6fc9;
  --accent-2-soft: rgba(28, 111, 201, 0.10);
  --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;
  --on-accent: #ffffff;
  --electron: #2563eb;
  --hole: #dc3b3b;
  --band-c: #2563eb;
  --band-v: #dc3b3b;
  --fermi: #1c6fc9;
  --compute: #2b8a3e;
  --tensor: #7048e8;
  --ctrl: #d9480f;
  --sram: #0c8599;
  --dram: #1c6fc9;
  --data: #e67700;
  --link: #ae3ec9;
  --volt: #c99400;
  --heat: #e03131;
  --clock: #495057;
  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: #69db7c;
    --accent-soft: rgba(105, 219, 124, 0.14);
    --accent-2: #74b9ff;
    --accent-2-soft: rgba(116, 185, 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);
    --on-accent: #0b2412;
  --electron: #6ea8ff;
  --hole: #ff7a7a;
  --band-c: #6ea8ff;
  --band-v: #ff7a7a;
  --fermi: #74b9ff;
  --compute: #69db7c;
  --tensor: #b197fc;
  --ctrl: #ff922b;
  --sram: #3bc9db;
  --dram: #74b9ff;
  --data: #ffa94d;
  --link: #e599f7;
  --volt: #ffd43b;
  --heat: #ff6b6b;
  --clock: #adb5bd;
    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: #69db7c;
  --accent-soft: rgba(105, 219, 124, 0.14);
  --accent-2: #74b9ff;
  --accent-2-soft: rgba(116, 185, 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);
  --on-accent: #0b2412;
  --electron: #6ea8ff;
  --hole: #ff7a7a;
  --band-c: #6ea8ff;
  --band-v: #ff7a7a;
  --fermi: #74b9ff;
  --compute: #69db7c;
  --tensor: #b197fc;
  --ctrl: #ff922b;
  --sram: #3bc9db;
  --dram: #74b9ff;
  --data: #ffa94d;
  --link: #e599f7;
  --volt: #ffd43b;
  --heat: #ff6b6b;
  --clock: #adb5bd;
    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, drawer, pager, footer: shared/css/book-ui.css (@euiyun/book) */

/* ------------------------------------------------------------------ Layout */
.gp-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 1180px) {
  .gp-layout { grid-template-columns: minmax(0, 1fr) 230px; }
}
.gp-toc { display: none; }
@media (min-width: 1180px) {
  .gp-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; }
  .gp-toc h4 { margin: 0 0 10px; font-size: 11px; letter-spacing: .14em; color: var(--text-faint); }
  .gp-toc a { display: block; padding: 5px 0 5px 12px; border-left: 2px solid var(--border); color: var(--text-dim); line-height: 1.45; }
  .gp-toc a:hover { color: var(--text); text-decoration: none; }
  .gp-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에 style="flex:<viewBox 폭> 1 <viewBox 폭>px" */
.fig-panels { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-start; }
figure.diagram .fig-panels > svg { min-width: 0; }

/* SVG helpers usable inside inline diagrams (:not(html *) — <use>로 복제된 도형에도 적용) */
svg .t, .t:not(html *) { fill: var(--text); font-family: var(--font); font-size: 13px; }
svg .t-dim, .t-dim:not(html *) { fill: var(--text-dim); font-family: var(--font); font-size: 12px; }
svg .t-mono, .t-mono:not(html *) { fill: var(--text-dim); font-family: var(--mono); font-size: 11px; }
svg .t-acc, .t-acc:not(html *) { fill: var(--accent); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .s-line, .s-line:not(html *) { stroke: var(--text-dim); fill: none; stroke-width: 1.5; }
svg .s-axis, .s-axis:not(html *) { stroke: var(--axis); fill: none; stroke-width: 1.2; }
svg .s-acc, .s-acc:not(html *) { stroke: var(--accent); fill: none; stroke-width: 2; }
svg .f-surface, .f-surface:not(html *) { fill: var(--surface); stroke: var(--border); }
svg .f-elev, .f-elev:not(html *) { fill: var(--bg-elev); stroke: var(--border); }
svg .f-acc, .f-acc:not(html *) { fill: var(--accent); }
svg .f-acc-soft, .f-acc-soft:not(html *) { fill: var(--accent-soft); stroke: var(--accent); }
svg .f-acc2-soft, .f-acc2-soft:not(html *) { 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: minmax(0, 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: var(--on-accent); 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 ul:last-child, .callout ol: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; }
/* Leave room for tall fraction glyphs, especially Korean text, inside the scroll area. */
.katex-display { margin: 0.4em 0 !important; padding: 0.5em 0; 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 */

/* ------------------------------------------------------------------ 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: var(--on-accent); }
.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; }
}

/* ------------------------------------------------------------------ GPUBook extras */
svg .s-acc2, .s-acc2:not(html *) { stroke: var(--accent-2); fill: none; stroke-width: 2; }
svg .f-acc2, .f-acc2:not(html *) { fill: var(--accent-2); }
svg .f-ok-soft, .f-ok-soft:not(html *) { fill: color-mix(in srgb, var(--ok) 16%, transparent); stroke: var(--ok); }
svg .f-warn-soft, .f-warn-soft:not(html *) { fill: color-mix(in srgb, var(--warn) 18%, transparent); stroke: var(--warn); }
svg .f-bad-soft, .f-bad-soft:not(html *) { fill: color-mix(in srgb, var(--bad) 14%, transparent); stroke: var(--bad); }
.bits { font-family: var(--mono); letter-spacing: .08em; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
/* 스크롤 컨테이너 안의 KaTeX 숨김 MathML(absolute)이 페이지 가로 스크롤을 만들지 않도록 */
.table-wrap, .formula, .sim, figure, .callout, .quiz-q { position: relative; }
/* keep-all에서 '·'로 이어진 긴 토큰이 좁은 화면을 넘지 않도록 */
main.chapter p, main.chapter li, figcaption, .callout, .quiz-exp { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ GPUBook extras: 밴드 다이어그램·캐리어 (v2)
   밴드 끝 Ec·Ev, 페르미 준위 EF(점선), 진성 준위 Ei(점점선), 준페르미 준위 EFn·EFp, 진공 준위 E0.
   캐리어·이온은 <use href="#gp-e" x y/>(전자), #gp-h(정공), #gp-don(이온화 도너 ⊕), #gp-acc(이온화 억셉터 ⊖), #gp-e-sm/#gp-h-sm(작은 점). */
svg .s-ec, .s-ec:not(html *) { stroke: var(--band-c); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
svg .s-ev, .s-ev:not(html *) { stroke: var(--band-v); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
svg .s-ef, .s-ef:not(html *) { stroke: var(--fermi); fill: none; stroke-width: 1.8; stroke-dasharray: 7 4; }
svg .s-efn, .s-efn:not(html *) { stroke: var(--electron); fill: none; stroke-width: 1.7; stroke-dasharray: 7 4; }
svg .s-efp, .s-efp:not(html *) { stroke: var(--hole); fill: none; stroke-width: 1.7; stroke-dasharray: 7 4; }
svg .s-ei, .s-ei:not(html *) { stroke: var(--text-faint); fill: none; stroke-width: 1.2; stroke-dasharray: 2 3; }
svg .s-vac, .s-vac:not(html *) { stroke: var(--text-dim); fill: none; stroke-width: 1.2; stroke-dasharray: 1.5 3.5; stroke-linecap: round; }
svg .f-cb, .f-cb:not(html *) { fill: color-mix(in srgb, var(--band-c) 9%, transparent); stroke: none; }
svg .f-vb, .f-vb:not(html *) { fill: color-mix(in srgb, var(--band-v) 9%, transparent); stroke: none; }
svg .f-dep, .f-dep:not(html *) { fill: color-mix(in srgb, var(--accent) 7%, transparent); stroke: none; }
svg .t-ec, .t-ec:not(html *) { fill: var(--band-c); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-ev, .t-ev:not(html *) { fill: var(--band-v); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-ef, .t-ef:not(html *) { fill: var(--fermi); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-ei, .t-ei:not(html *) { fill: var(--text-faint); font-family: var(--font); font-size: 12px; font-weight: 600; }
svg .t-el, .t-el:not(html *) { fill: var(--electron); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-ho, .t-ho:not(html *) { fill: var(--hole); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .q-e, .q-e:not(html *) { fill: url(#gp-qe); stroke: color-mix(in srgb, var(--electron) 70%, #000); stroke-width: 0.6; }
svg .q-h, .q-h:not(html *) { fill: var(--bg-elev); stroke: var(--hole); stroke-width: 1.6; }
svg .q-don, .q-don:not(html *) { fill: color-mix(in srgb, var(--hole) 9%, var(--bg-elev)); stroke: var(--hole); stroke-width: 1.2; }
svg .q-acc, .q-acc:not(html *) { fill: color-mix(in srgb, var(--electron) 9%, var(--bg-elev)); stroke: var(--electron); stroke-width: 1.2; }
svg .q-sign, .q-sign:not(html *) { fill: none; stroke-width: 1.6; stroke-linecap: round; }
svg .q-sign-d, .q-sign-d:not(html *) { stroke: var(--hole); } svg .q-sign-a, .q-sign-a:not(html *) { stroke: var(--electron); }
svg .q-plus, .q-plus:not(html *) { fill: var(--hole); }
/* 예전 그림용(호환): 새 그림은 #gp-e·#gp-h 기호와 .m-* 재질을 쓴다 */
svg .f-e, .f-e:not(html *) { fill: var(--electron); } svg .f-h, .f-h:not(html *) { fill: var(--bg-elev); stroke: var(--hole); stroke-width: 1.6; }
svg .f-n, .f-n:not(html *) { fill: color-mix(in srgb, var(--electron) 14%, transparent); } svg .f-p, .f-p:not(html *) { fill: color-mix(in srgb, var(--hole) 13%, transparent); }
svg .f-ox, .f-ox:not(html *) { fill: var(--m-ox); } svg .f-metal, .f-metal:not(html *) { fill: var(--m-metal); } svg .f-si, .f-si:not(html *) { fill: var(--m-si); }
svg .lbl-e, .lbl-e:not(html *) { fill: var(--electron); font-family: var(--font); font-size: 14px; font-weight: 700; }
svg .lbl-h, .lbl-h:not(html *) { fill: var(--hole); font-family: var(--font); font-size: 14px; font-weight: 700; }
svg .s-dash, .s-dash:not(html *) { stroke: var(--text-faint); fill: none; stroke-width: 1.2; stroke-dasharray: 4 3; }
svg .beam, .beam:not(html *) { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; }
svg .lbl, .lbl:not(html *) { fill: var(--text); font-family: var(--font); font-size: 14px; }
svg .lbl-dim, .lbl-dim:not(html *) { fill: var(--text-dim); font-family: var(--font); font-size: 13px; }
svg .lbl-b, .lbl-b:not(html *) { fill: var(--text); font-family: var(--font); font-size: 15px; font-weight: 700; }
svg .lbl-acc, .lbl-acc:not(html *) { fill: var(--accent); font-family: var(--font); font-size: 14px; font-weight: 700; }
svg .lbl-acc2, .lbl-acc2:not(html *) { fill: var(--accent-2); font-family: var(--font); font-size: 14px; font-weight: 700; }
svg .ink, .ink:not(html *) { stroke: var(--text); stroke-width: .8; fill: none; opacity: .45; }

/* 범례 */
.mat-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-dim); padding: 10px 18px; border-top: 1px solid var(--border); }
.mat-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.mat-legend i { width: 13px; height: 13px; border-radius: 3.5px; display: inline-block; border: 1px solid rgba(0,0,0,.18); flex: none; }
.mat-legend .sub { font-size: .8em; }

/* 단계 목록 (단면 쌓기) */
.steps-list { list-style: none; margin: 0; padding: 0 !important; display: grid; gap: 4px; max-height: 250px; overflow-y: auto; font-size: 13.5px; counter-reset: st; }
.steps-list li { counter-increment: st; display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; line-height: 1.35; margin: 0 !important; }
.steps-list li::before { content: counter(st, decimal-leading-zero); font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex: none; }
.steps-list li .k { font-family: var(--mono); font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--bg-elev); color: var(--accent-2); flex: none; }
.steps-list li .d { flex: 1; min-width: 0; }
.steps-list li .x { border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 15px; padding: 0 2px; }
.steps-list li .x:hover { color: var(--bad); }
.steps-list li.cur { border-color: var(--accent); background: var(--accent-soft); }
.steps-list li.future { opacity: .45; }
.step-desc { font-size: 13.5px; color: var(--text-dim); line-height: 1.6; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-height: 5.2em; }
.step-desc b { color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.ok-t { color: var(--ok); } .bad-t { color: var(--bad); } .warn-t { color: var(--warn); }

/* Search in the center of the book menu */

/* Shareable simulator anchor links */
.sim-link { margin-left: auto; flex: 0 0 auto; font: 12px var(--mono); color: var(--text-faint); }
.sim-link:hover, .sim-link:focus-visible { color: var(--accent); text-decoration: none; }
.sim { scroll-margin-top: 1rem; }

/* ==========================================================================
   Figure & simulator kit (v2) — MemoryBook·ProcessBook과 같은 키트
   - 재질 그라데이션: js/common.js가 #gp-m-*(위→아래), #gp-mc-*(원기둥)를 문서에 넣는다.
   - 사용: <rect class="m-si">, <rect class="mc-cu">, 화살표 <path class="arr" d="…">, 캐리어 <use href="#gp-e" x="…" y="…"/>
   ========================================================================== */
:root {
  --m-si-1: #aab3c1; --m-si-2: #8f99aa; --m-si-e: #6d788b;
  --m-nm-1: #d3def6; --m-nm-2: #bdcdef; --m-nm-e: #8ea4d6;
  --m-n-1: #b5c8f1; --m-n-2: #9ab1e7; --m-n-e: #6d8bd0;
  --m-np-1: #86a8ed; --m-np-2: #6589dc; --m-np-e: #3f66b8;
  --m-pm-1: #f6dfdb; --m-pm-2: #edc8c2; --m-pm-e: #cf9a93;
  --m-p-1: #f1c3bd; --m-p-2: #e5a79f; --m-p-e: #c27b72;
  --m-pp-1: #ee9f93; --m-pp-2: #de7c6f; --m-pp-e: #b8574b;
  --m-ox-1: #ddedf9; --m-ox-2: #bcd8f0; --m-ox-e: #8db8de;
  --m-nit-1: #f1c97c; --m-nit-2: #e2b05a; --m-nit-e: #b98a36;
  --m-poly-1: #d6826d; --m-poly-2: #c0604a; --m-poly-e: #964434;
  --m-pr-1: #e29fc3; --m-pr-2: #cf7aa6; --m-pr-e: #a65884;
  --m-w-1: #7c8593; --m-w-2: #58606e; --m-w-e: #3e4550;
  --m-cu-1: #e19a5f; --m-cu-2: #cc7a3a; --m-cu-e: #9c5a26;
  --m-al-1: #d3d9e0; --m-al-2: #b7bec8; --m-al-e: #8d96a3;
  --m-tin-1: #ddbd4f; --m-tin-2: #c9a227; --m-tin-e: #977818;
  --m-hk-1: #93d3b4; --m-hk-2: #6fbf9a; --m-hk-e: #47977a;
  --m-sil-1: #8d7eae; --m-sil-2: #6f5f93; --m-sil-e: #514471;
  --m-epi-1: #dccaa5; --m-epi-2: #c9b48a; --m-epi-e: #9f8a61;
  --m-ge-1: #c2bbcd; --m-ge-2: #a79fb6; --m-ge-e: #7d7490;
  --m-gaas-1: #a6d8d1; --m-gaas-2: #85c5bc; --m-gaas-e: #529990;
  --m-algaas-1: #d6efeb; --m-algaas-2: #bce2dc; --m-algaas-e: #84b8b0;
  --m-ingaas-1: #dcb7e0; --m-ingaas-2: #c899cd; --m-ingaas-e: #98669e;
  --m-inp-1: #d0c9ec; --m-inp-2: #b5acdf; --m-inp-e: #8479bb;
  --m-gan-1: #b6d2a6; --m-gan-2: #9bc089; --m-gan-e: #6b955a;
  --m-algan-1: #e2edcf; --m-algan-2: #cee0b4; --m-algan-e: #98b27a;
  --m-sic-1: #cfc58f; --m-sic-2: #b8ae70; --m-sic-e: #857c40;
  --m-metal-1: #cfd5de; --m-metal-2: #acb5c2; --m-metal-e: #7d8796;
  --m-au-1: #f4d781; --m-au-2: #e3bd4e; --m-au-e: #b08a24;
  --m-die-1: #b6bfcc; --m-die-2: #99a3b3; --m-die-e: #747f92;
  --m-sol-1: #e8ebef; --m-sol-2: #c4cad3; --m-sol-e: #8f98a7;
  --m-mold-1: #5f6673; --m-mold-2: #444a55; --m-mold-e: #2f343d;
  --m-pcb-1: #66a27b; --m-pcb-2: #3f7a55; --m-pcb-e: #2b5a3d;
  --m-glass-1: #f0f8fd; --m-glass-2: #d2e9f7; --m-glass-e: #9cc6e2;
  --m-dram-1: #a9c7ee; --m-dram-2: #85ade4; --m-dram-e: #4f7fc0;
  --m-interp-1: #c9cfd8; --m-interp-2: #b0b8c4; --m-interp-e: #828c9b;
  --m-sub-1: #9fc49b; --m-sub-2: #7ba877; --m-sub-e: #4f7c4b;
  --m-lid-1: #e8b48a; --m-lid-2: #d69666; --m-lid-e: #a86b3e;
  --m-tim-1: #e9e2f3; --m-tim-2: #d4c9e6; --m-tim-e: #a597bf;
  --m-hatch: rgba(20, 26, 38, 0.16); --m-hatch-bg: transparent;
  --m-shadow: rgba(16, 24, 40, 0.16);
  --three-bg-1: #ffffff; --three-bg-2: #eef2f8;
  --junction: #e8b100;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --m-si-1: #7d8696; --m-si-2: #687183; --m-si-e: #9aa4b6;
    --m-nm-1: #7283a9; --m-nm-2: #5f729c; --m-nm-e: #94a4c6;
    --m-n-1: #657bab; --m-n-2: #50679d; --m-n-e: #8a9ec9;
    --m-np-1: #4c6eb3; --m-np-2: #3256a9; --m-np-e: #7695d3;
    --m-pm-1: #a67f78; --m-pm-2: #996a63; --m-pm-e: #c2a09a;
    --m-p-1: #aa7069; --m-p-2: #9a5c54; --m-p-e: #c8948d;
    --m-pp-1: #af6054; --m-pp-2: #a74538; --m-pp-e: #cf887d;
    --m-ox-1: #6f8faa; --m-ox-2: #5c7c98; --m-ox-e: #8fb1cc;
    --m-nit-1: #bb944a; --m-nit-2: #a3803c; --m-nit-e: #d9b064;
    --m-poly-1: #a85744; --m-poly-2: #924836; --m-poly-e: #cc7a66;
    --m-pr-1: #ab5f88; --m-pr-2: #964f76; --m-pr-e: #cf86ad;
    --m-w-1: #5c6472; --m-w-2: #4a515d; --m-w-e: #8790a0;
    --m-cu-1: #b96d36; --m-cu-2: #a25d2b; --m-cu-e: #d98f55;
    --m-al-1: #9aa2ae; --m-al-2: #848c98; --m-al-e: #bcc4cf;
    --m-tin-1: #a88a26; --m-tin-2: #92761c; --m-tin-e: #cdab44;
    --m-hk-1: #5a9f80; --m-hk-2: #4a8a6d; --m-hk-e: #7cc2a1;
    --m-sil-1: #66588a; --m-sil-2: #554976; --m-sil-e: #8a7bb0;
    --m-epi-1: #a8966f; --m-epi-2: #93825f; --m-epi-e: #c6b48c;
    --m-ge-1: #817a8c; --m-ge-2: #6d657c; --m-ge-e: #a59faf;
    --m-gaas-1: #689a93; --m-gaas-2: #4f8f86; --m-gaas-e: #8fbcb6;
    --m-algaas-1: #7aa09a; --m-algaas-2: #679089; --m-algaas-e: #9cbeb8;
    --m-ingaas-1: #96719a; --m-ingaas-2: #88598d; --m-ingaas-e: #b796bb;
    --m-inp-1: #7c73a2; --m-inp-2: #685f92; --m-inp-e: #9f96c0;
    --m-gan-1: #7a966a; --m-gan-2: #658a53; --m-gan-e: #a0b991;
    --m-algan-1: #91a176; --m-algan-2: #7e9064; --m-algan-e: #b1bf99;
    --m-sic-1: #9c925c; --m-sic-2: #8e8446; --m-sic-e: #bfb686;
    --m-metal-1: #808792; --m-metal-2: #69727f; --m-metal-e: #a2a9b3;
    --m-au-1: #b99c46; --m-au-2: #b58f20; --m-au-e: #d9be71;
    --m-die-1: #6a7384; --m-die-2: #576070; --m-die-e: #8e98aa;
    --m-sol-1: #a6adb8; --m-sol-2: #8d95a1; --m-sol-e: #c3cad4;
    --m-mold-1: #454b56; --m-mold-2: #373c45; --m-mold-e: #616875;
    --m-pcb-1: #3f6f52; --m-pcb-2: #315a42; --m-pcb-e: #5c9273;
    --m-glass-1: #2f4a5e; --m-glass-2: #253d4f; --m-glass-e: #557d9a;
  --m-dram-1: #35557f; --m-dram-2: #2b4669; --m-dram-e: #6b93c9;
  --m-interp-1: #5d6573; --m-interp-2: #4c5361; --m-interp-e: #8c95a5;
  --m-sub-1: #3f6440; --m-sub-2: #335234; --m-sub-e: #6f9a6d;
  --m-lid-1: #a8714a; --m-lid-2: #8e5d3b; --m-lid-e: #d39a6d;
  --m-tim-1: #4d4560; --m-tim-2: #3f3850; --m-tim-e: #7e739a;
    --m-hatch: rgba(230, 235, 245, 0.13); --m-hatch-bg: transparent;
    --m-shadow: rgba(0, 0, 0, 0.45);
    --three-bg-1: #162033; --three-bg-2: #0d131f;
    --junction: #ffd24a;
  }
}
:root[data-theme="dark"] {
  --m-si-1: #7d8696; --m-si-2: #687183; --m-si-e: #9aa4b6;
  --m-nm-1: #7283a9; --m-nm-2: #5f729c; --m-nm-e: #94a4c6;
  --m-n-1: #657bab; --m-n-2: #50679d; --m-n-e: #8a9ec9;
  --m-np-1: #4c6eb3; --m-np-2: #3256a9; --m-np-e: #7695d3;
  --m-pm-1: #a67f78; --m-pm-2: #996a63; --m-pm-e: #c2a09a;
  --m-p-1: #aa7069; --m-p-2: #9a5c54; --m-p-e: #c8948d;
  --m-pp-1: #af6054; --m-pp-2: #a74538; --m-pp-e: #cf887d;
  --m-ox-1: #6f8faa; --m-ox-2: #5c7c98; --m-ox-e: #8fb1cc;
  --m-nit-1: #bb944a; --m-nit-2: #a3803c; --m-nit-e: #d9b064;
  --m-poly-1: #a85744; --m-poly-2: #924836; --m-poly-e: #cc7a66;
  --m-pr-1: #ab5f88; --m-pr-2: #964f76; --m-pr-e: #cf86ad;
  --m-w-1: #5c6472; --m-w-2: #4a515d; --m-w-e: #8790a0;
  --m-cu-1: #b96d36; --m-cu-2: #a25d2b; --m-cu-e: #d98f55;
  --m-al-1: #9aa2ae; --m-al-2: #848c98; --m-al-e: #bcc4cf;
  --m-tin-1: #a88a26; --m-tin-2: #92761c; --m-tin-e: #cdab44;
  --m-hk-1: #5a9f80; --m-hk-2: #4a8a6d; --m-hk-e: #7cc2a1;
  --m-sil-1: #66588a; --m-sil-2: #554976; --m-sil-e: #8a7bb0;
  --m-epi-1: #a8966f; --m-epi-2: #93825f; --m-epi-e: #c6b48c;
  --m-ge-1: #817a8c; --m-ge-2: #6d657c; --m-ge-e: #a59faf;
  --m-gaas-1: #689a93; --m-gaas-2: #4f8f86; --m-gaas-e: #8fbcb6;
  --m-algaas-1: #7aa09a; --m-algaas-2: #679089; --m-algaas-e: #9cbeb8;
  --m-ingaas-1: #96719a; --m-ingaas-2: #88598d; --m-ingaas-e: #b796bb;
  --m-inp-1: #7c73a2; --m-inp-2: #685f92; --m-inp-e: #9f96c0;
  --m-gan-1: #7a966a; --m-gan-2: #658a53; --m-gan-e: #a0b991;
  --m-algan-1: #91a176; --m-algan-2: #7e9064; --m-algan-e: #b1bf99;
  --m-sic-1: #9c925c; --m-sic-2: #8e8446; --m-sic-e: #bfb686;
  --m-metal-1: #808792; --m-metal-2: #69727f; --m-metal-e: #a2a9b3;
  --m-au-1: #b99c46; --m-au-2: #b58f20; --m-au-e: #d9be71;
  --m-die-1: #6a7384; --m-die-2: #576070; --m-die-e: #8e98aa;
  --m-sol-1: #a6adb8; --m-sol-2: #8d95a1; --m-sol-e: #c3cad4;
  --m-mold-1: #454b56; --m-mold-2: #373c45; --m-mold-e: #616875;
  --m-pcb-1: #3f6f52; --m-pcb-2: #315a42; --m-pcb-e: #5c9273;
  --m-glass-1: #2f4a5e; --m-glass-2: #253d4f; --m-glass-e: #557d9a;
  --m-dram-1: #35557f; --m-dram-2: #2b4669; --m-dram-e: #6b93c9;
  --m-interp-1: #5d6573; --m-interp-2: #4c5361; --m-interp-e: #8c95a5;
  --m-sub-1: #3f6440; --m-sub-2: #335234; --m-sub-e: #6f9a6d;
  --m-lid-1: #a8714a; --m-lid-2: #8e5d3b; --m-lid-e: #d39a6d;
  --m-tim-1: #4d4560; --m-tim-2: #3f3850; --m-tim-e: #7e739a;
  --m-hatch: rgba(230, 235, 245, 0.13); --m-hatch-bg: transparent;
  --m-shadow: rgba(0, 0, 0, 0.45);
  --three-bg-1: #162033; --three-bg-2: #0d131f;
  --junction: #ffd24a;
}
/* 단색이 필요할 때: var(--m-si) 등 */
:root { --m-si: var(--m-si-2); --m-nm: var(--m-nm-2); --m-n: var(--m-n-2); --m-np: var(--m-np-2); --m-pm: var(--m-pm-2); --m-p: var(--m-p-2); --m-pp: var(--m-pp-2); --m-ox: var(--m-ox-2); --m-nit: var(--m-nit-2); --m-poly: var(--m-poly-2); --m-pr: var(--m-pr-2); --m-w: var(--m-w-2); --m-cu: var(--m-cu-2); --m-al: var(--m-al-2); --m-tin: var(--m-tin-2); --m-hk: var(--m-hk-2); --m-sil: var(--m-sil-2); --m-epi: var(--m-epi-2); --m-ge: var(--m-ge-2); --m-gaas: var(--m-gaas-2); --m-algaas: var(--m-algaas-2); --m-ingaas: var(--m-ingaas-2); --m-inp: var(--m-inp-2); --m-gan: var(--m-gan-2); --m-algan: var(--m-algan-2); --m-sic: var(--m-sic-2); --m-metal: var(--m-metal-2); --m-au: var(--m-au-2); --m-die: var(--m-die-2); --m-sol: var(--m-sol-2); --m-mold: var(--m-mold-2); --m-pcb: var(--m-pcb-2); --m-glass: var(--m-glass-2); --m-dram: var(--m-dram-2); --m-interp: var(--m-interp-2); --m-sub: var(--m-sub-2); --m-lid: var(--m-lid-2); --m-tim: var(--m-tim-2); }

/* materials: vertical shading (.m-*) and cylinder shading (.mc-*). .m-sin = .m-nit
   si 실리콘 · nm/n/np = n⁻/n/n⁺ · pm/p/pp = p⁻/p/p⁺ · ox SiO₂ · nit Si₃N₄ · poly · pr · w · cu · al · tin · hk(HfO₂) · sil(NiSi) · epi(SiGe)
   ge · gaas · algaas · ingaas · inp · gan · algan · sic · metal(일반 접촉 금속) · au · die · sol · mold · pcb · glass */
svg .m-si, .m-si:not(html *) { fill: url(#gp-m-si); stroke: var(--m-si-e); } svg .mc-si, .mc-si:not(html *) { fill: url(#gp-mc-si); stroke: var(--m-si-e); }
svg .m-nm, .m-nm:not(html *) { fill: url(#gp-m-nm); stroke: var(--m-nm-e); } svg .mc-nm, .mc-nm:not(html *) { fill: url(#gp-mc-nm); stroke: var(--m-nm-e); }
svg .m-n, .m-n:not(html *) { fill: url(#gp-m-n); stroke: var(--m-n-e); } svg .mc-n, .mc-n:not(html *) { fill: url(#gp-mc-n); stroke: var(--m-n-e); }
svg .m-np, .m-np:not(html *) { fill: url(#gp-m-np); stroke: var(--m-np-e); } svg .mc-np, .mc-np:not(html *) { fill: url(#gp-mc-np); stroke: var(--m-np-e); }
svg .m-pm, .m-pm:not(html *) { fill: url(#gp-m-pm); stroke: var(--m-pm-e); } svg .mc-pm, .mc-pm:not(html *) { fill: url(#gp-mc-pm); stroke: var(--m-pm-e); }
svg .m-p, .m-p:not(html *) { fill: url(#gp-m-p); stroke: var(--m-p-e); } svg .mc-p, .mc-p:not(html *) { fill: url(#gp-mc-p); stroke: var(--m-p-e); }
svg .m-pp, .m-pp:not(html *) { fill: url(#gp-m-pp); stroke: var(--m-pp-e); } svg .mc-pp, .mc-pp:not(html *) { fill: url(#gp-mc-pp); stroke: var(--m-pp-e); }
svg .m-ox, .m-ox:not(html *) { fill: url(#gp-m-ox); stroke: var(--m-ox-e); } svg .mc-ox, .mc-ox:not(html *) { fill: url(#gp-mc-ox); stroke: var(--m-ox-e); }
svg .m-nit, .m-nit:not(html *) { fill: url(#gp-m-nit); stroke: var(--m-nit-e); } svg .mc-nit, .mc-nit:not(html *) { fill: url(#gp-mc-nit); stroke: var(--m-nit-e); }
svg .m-poly, .m-poly:not(html *) { fill: url(#gp-m-poly); stroke: var(--m-poly-e); } svg .mc-poly, .mc-poly:not(html *) { fill: url(#gp-mc-poly); stroke: var(--m-poly-e); }
svg .m-pr, .m-pr:not(html *) { fill: url(#gp-m-pr); stroke: var(--m-pr-e); } svg .mc-pr, .mc-pr:not(html *) { fill: url(#gp-mc-pr); stroke: var(--m-pr-e); }
svg .m-w, .m-w:not(html *) { fill: url(#gp-m-w); stroke: var(--m-w-e); } svg .mc-w, .mc-w:not(html *) { fill: url(#gp-mc-w); stroke: var(--m-w-e); }
svg .m-cu, .m-cu:not(html *) { fill: url(#gp-m-cu); stroke: var(--m-cu-e); } svg .mc-cu, .mc-cu:not(html *) { fill: url(#gp-mc-cu); stroke: var(--m-cu-e); }
svg .m-al, .m-al:not(html *) { fill: url(#gp-m-al); stroke: var(--m-al-e); } svg .mc-al, .mc-al:not(html *) { fill: url(#gp-mc-al); stroke: var(--m-al-e); }
svg .m-tin, .m-tin:not(html *) { fill: url(#gp-m-tin); stroke: var(--m-tin-e); } svg .mc-tin, .mc-tin:not(html *) { fill: url(#gp-mc-tin); stroke: var(--m-tin-e); }
svg .m-hk, .m-hk:not(html *) { fill: url(#gp-m-hk); stroke: var(--m-hk-e); } svg .mc-hk, .mc-hk:not(html *) { fill: url(#gp-mc-hk); stroke: var(--m-hk-e); }
svg .m-sil, .m-sil:not(html *) { fill: url(#gp-m-sil); stroke: var(--m-sil-e); } svg .mc-sil, .mc-sil:not(html *) { fill: url(#gp-mc-sil); stroke: var(--m-sil-e); }
svg .m-epi, .m-epi:not(html *) { fill: url(#gp-m-epi); stroke: var(--m-epi-e); } svg .mc-epi, .mc-epi:not(html *) { fill: url(#gp-mc-epi); stroke: var(--m-epi-e); }
svg .m-ge, .m-ge:not(html *) { fill: url(#gp-m-ge); stroke: var(--m-ge-e); } svg .mc-ge, .mc-ge:not(html *) { fill: url(#gp-mc-ge); stroke: var(--m-ge-e); }
svg .m-gaas, .m-gaas:not(html *) { fill: url(#gp-m-gaas); stroke: var(--m-gaas-e); } svg .mc-gaas, .mc-gaas:not(html *) { fill: url(#gp-mc-gaas); stroke: var(--m-gaas-e); }
svg .m-algaas, .m-algaas:not(html *) { fill: url(#gp-m-algaas); stroke: var(--m-algaas-e); } svg .mc-algaas, .mc-algaas:not(html *) { fill: url(#gp-mc-algaas); stroke: var(--m-algaas-e); }
svg .m-ingaas, .m-ingaas:not(html *) { fill: url(#gp-m-ingaas); stroke: var(--m-ingaas-e); } svg .mc-ingaas, .mc-ingaas:not(html *) { fill: url(#gp-mc-ingaas); stroke: var(--m-ingaas-e); }
svg .m-inp, .m-inp:not(html *) { fill: url(#gp-m-inp); stroke: var(--m-inp-e); } svg .mc-inp, .mc-inp:not(html *) { fill: url(#gp-mc-inp); stroke: var(--m-inp-e); }
svg .m-gan, .m-gan:not(html *) { fill: url(#gp-m-gan); stroke: var(--m-gan-e); } svg .mc-gan, .mc-gan:not(html *) { fill: url(#gp-mc-gan); stroke: var(--m-gan-e); }
svg .m-algan, .m-algan:not(html *) { fill: url(#gp-m-algan); stroke: var(--m-algan-e); } svg .mc-algan, .mc-algan:not(html *) { fill: url(#gp-mc-algan); stroke: var(--m-algan-e); }
svg .m-sic, .m-sic:not(html *) { fill: url(#gp-m-sic); stroke: var(--m-sic-e); } svg .mc-sic, .mc-sic:not(html *) { fill: url(#gp-mc-sic); stroke: var(--m-sic-e); }
svg .m-metal, .m-metal:not(html *) { fill: url(#gp-m-metal); stroke: var(--m-metal-e); } svg .mc-metal, .mc-metal:not(html *) { fill: url(#gp-mc-metal); stroke: var(--m-metal-e); }
svg .m-au, .m-au:not(html *) { fill: url(#gp-m-au); stroke: var(--m-au-e); } svg .mc-au, .mc-au:not(html *) { fill: url(#gp-mc-au); stroke: var(--m-au-e); }
svg .m-die, .m-die:not(html *) { fill: url(#gp-m-die); stroke: var(--m-die-e); } svg .mc-die, .mc-die:not(html *) { fill: url(#gp-mc-die); stroke: var(--m-die-e); }
svg .m-sol, .m-sol:not(html *) { fill: url(#gp-m-sol); stroke: var(--m-sol-e); } svg .mc-sol, .mc-sol:not(html *) { fill: url(#gp-mc-sol); stroke: var(--m-sol-e); }
svg .m-mold, .m-mold:not(html *) { fill: url(#gp-m-mold); stroke: var(--m-mold-e); } svg .mc-mold, .mc-mold:not(html *) { fill: url(#gp-mc-mold); stroke: var(--m-mold-e); }
svg .m-pcb, .m-pcb:not(html *) { fill: url(#gp-m-pcb); stroke: var(--m-pcb-e); } svg .mc-pcb, .mc-pcb:not(html *) { fill: url(#gp-mc-pcb); stroke: var(--m-pcb-e); }
svg .m-glass, .m-glass:not(html *) { fill: url(#gp-m-glass); stroke: var(--m-glass-e); } svg .mc-glass, .mc-glass:not(html *) { fill: url(#gp-mc-glass); stroke: var(--m-glass-e); }
svg .m-dram, .m-dram:not(html *) { fill: url(#gp-m-dram); stroke: var(--m-dram-e); } svg .mc-dram, .mc-dram:not(html *) { fill: url(#gp-mc-dram); stroke: var(--m-dram-e); }
svg .m-interp, .m-interp:not(html *) { fill: url(#gp-m-interp); stroke: var(--m-interp-e); } svg .mc-interp, .mc-interp:not(html *) { fill: url(#gp-mc-interp); stroke: var(--m-interp-e); }
svg .m-sub, .m-sub:not(html *) { fill: url(#gp-m-sub); stroke: var(--m-sub-e); } svg .mc-sub, .mc-sub:not(html *) { fill: url(#gp-mc-sub); stroke: var(--m-sub-e); }
svg .m-lid, .m-lid:not(html *) { fill: url(#gp-m-lid); stroke: var(--m-lid-e); } svg .mc-lid, .mc-lid:not(html *) { fill: url(#gp-mc-lid); stroke: var(--m-lid-e); }
svg .m-tim, .m-tim:not(html *) { fill: url(#gp-m-tim); stroke: var(--m-tim-e); } svg .mc-tim, .mc-tim:not(html *) { fill: url(#gp-mc-tim); stroke: var(--m-tim-e); }
svg .m-sin, .m-sin:not(html *) { fill: url(#gp-m-nit); stroke: var(--m-nit-e); } svg .mc-sin, .mc-sin:not(html *) { fill: url(#gp-mc-nit); stroke: var(--m-nit-e); }
svg .p-hatch, .p-hatch:not(html *) { fill: url(#gp-hatch); stroke: none; }
svg .p-dots, .p-dots:not(html *) { fill: url(#gp-dots); stroke: none; }
svg .p-grid, .p-grid:not(html *) { fill: url(#gp-grid); stroke: none; }
svg .junc, .junc:not(html *) { stroke: var(--junction); stroke-width: 1.6; stroke-dasharray: 5 3; fill: none; }

/* lines, arrows, leaders */
svg .arr, .arr:not(html *) { stroke: var(--text-dim); stroke-width: 1.5; fill: none; marker-end: url(#gp-ah); stroke-linecap: round; }
svg .arr-t, .arr-t:not(html *) { stroke: var(--text); stroke-width: 1.6; fill: none; marker-end: url(#gp-ah-t); stroke-linecap: round; }
svg .arr-a, .arr-a:not(html *) { stroke: var(--accent); stroke-width: 2; fill: none; marker-end: url(#gp-ah-a); stroke-linecap: round; }
svg .arr-a2, .arr-a2:not(html *) { stroke: var(--accent-2); stroke-width: 2; fill: none; marker-end: url(#gp-ah-a2); stroke-linecap: round; }
svg .arr-ok, .arr-ok:not(html *) { stroke: var(--ok); stroke-width: 2; fill: none; marker-end: url(#gp-ah-ok); stroke-linecap: round; }
svg .arr-warn, .arr-warn:not(html *) { stroke: var(--warn); stroke-width: 2; fill: none; marker-end: url(#gp-ah-warn); stroke-linecap: round; }
svg .arr-bad, .arr-bad:not(html *) { stroke: var(--bad); stroke-width: 2; fill: none; marker-end: url(#gp-ah-bad); stroke-linecap: round; }
svg .arr-blue, .arr-blue:not(html *) { stroke: var(--blue); stroke-width: 2; fill: none; marker-end: url(#gp-ah-blue); stroke-linecap: round; }
svg .arr-red, .arr-red:not(html *) { stroke: var(--red); stroke-width: 2; fill: none; marker-end: url(#gp-ah-red); stroke-linecap: round; }
svg .arr-e, .arr-e:not(html *) { stroke: var(--electron); stroke-width: 2; fill: none; marker-end: url(#gp-ah-e); stroke-linecap: round; }
svg .arr-h, .arr-h:not(html *) { stroke: var(--hole); stroke-width: 2; fill: none; marker-end: url(#gp-ah-h); stroke-linecap: round; }
svg .arr-ef, .arr-ef:not(html *) { stroke: var(--fermi); stroke-width: 2; fill: none; marker-end: url(#gp-ah-ef); stroke-linecap: round; }
svg .arr2, .arr2:not(html *) { marker-start: url(#gp-ah); }
svg .lead, .lead:not(html *) { stroke: var(--text-faint); stroke-width: 1; fill: none; marker-end: url(#gp-dot); }
svg .lead-a, .lead-a:not(html *) { stroke: var(--accent); stroke-width: 1; fill: none; marker-end: url(#gp-dot-a); }
svg .dimline, .dimline:not(html *) { stroke: var(--text-dim); stroke-width: 1; fill: none; marker-start: url(#gp-ah); marker-end: url(#gp-ah); }
svg .ext, .ext:not(html *) { stroke: var(--text-faint); stroke-width: 0.8; stroke-dasharray: 2 2; fill: none; }
svg .dash, .dash:not(html *) { stroke-dasharray: 5 4; }
svg .wire2, .wire2:not(html *) { stroke: var(--text); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .node, .node:not(html *) { fill: var(--text); }
svg .node-o, .node-o:not(html *) { fill: var(--bg-elev); stroke: var(--text); stroke-width: 1.6; }

/* blocks */
svg .card, .card:not(html *) { fill: var(--bg-elev); stroke: var(--border); filter: url(#gp-sh); }
svg .chip, .chip:not(html *) { fill: var(--surface); stroke: var(--border); }
svg .chip-a, .chip-a:not(html *) { fill: var(--accent-soft); stroke: var(--accent); }
svg .chip-a2, .chip-a2:not(html *) { fill: var(--accent-2-soft); stroke: var(--accent-2); }
svg .f-ok, .f-ok:not(html *) { fill: var(--ok); } svg .f-warn, .f-warn:not(html *) { fill: var(--warn); } svg .f-bad, .f-bad:not(html *) { fill: var(--bad); }
svg .s-ok, .s-ok:not(html *) { stroke: var(--ok); fill: none; stroke-width: 2; } svg .s-warn, .s-warn:not(html *) { stroke: var(--warn); fill: none; stroke-width: 2; } svg .s-bad, .s-bad:not(html *) { stroke: var(--bad); fill: none; stroke-width: 2; }
svg .s-faint, .s-faint:not(html *) { stroke: var(--text-faint); fill: none; stroke-width: 1; }
svg .glow, .glow:not(html *) { filter: url(#gp-glow); }

/* text */
svg .t-b, .t-b:not(html *) { font-weight: 700; }
svg .t-sb, .t-sb:not(html *) { font-weight: 600; }
svg .t-xs, .t-xs:not(html *) { font-size: 10.5px; }
svg .t-sm, .t-sm:not(html *) { font-size: 11.5px; }
svg .t-lg, .t-lg:not(html *) { font-size: 15px; }
svg .t-xl, .t-xl:not(html *) { font-size: 17px; font-weight: 700; }
svg .t-c, .t-c:not(html *) { text-anchor: middle; }
svg .t-e, .t-e:not(html *) { text-anchor: end; }
svg .t-acc2, .t-acc2:not(html *) { fill: var(--accent-2); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-ok, .t-ok:not(html *) { fill: var(--ok); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-warn, .t-warn:not(html *) { fill: var(--warn); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-bad, .t-bad:not(html *) { fill: var(--bad); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .t-faint, .t-faint:not(html *) { fill: var(--text-faint); font-family: var(--font); font-size: 11.5px; }
svg .t-inv, .t-inv:not(html *) { fill: #fff; }
svg .t-halo, .t-halo:not(html *) { paint-order: stroke; stroke: var(--bg-elev); stroke-width: 3.5px; stroke-linejoin: round; }
svg .sub, .sub:not(html *) { font-size: 0.74em; }
/* size modifiers win over color classes that carry their own font-size (.t-acc2, .t-faint, .t-dim…) */
svg .t-xs.t-xs, .t-xs.t-xs:not(html *) { font-size: 10.5px; } svg .t-sm.t-sm, .t-sm.t-sm:not(html *) { font-size: 11.5px; } svg .t-lg.t-lg, .t-lg.t-lg:not(html *) { font-size: 15px; } svg .t-xl.t-xl, .t-xl.t-xl:not(html *) { font-size: 17px; }

/* simulator controls: label text stays one inline run (첨자 유지) */
.ctrl > span { align-items: baseline; }
.ctrl-l { min-width: 0; }
.check-l { min-width: 0; }
.check-l sub, .check-l sup { line-height: 0; }
.ctrl-l sub, .ctrl-l sup, .stat .k sub, .stat .k sup { line-height: 0; }
.stat .v { line-height: 1.35; }
.btn:focus-visible, .seg button:focus-visible, .opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn.primary:hover { filter: brightness(1.06); }
.btn[disabled] { opacity: .5; cursor: default; }
.sim-view canvas { touch-action: pan-y; }

/* canvas tooltip (GP.tip) */
.gp-tip { position: absolute; z-index: 5; pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s; background: color-mix(in srgb, var(--bg-elev) 96%, transparent); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow); max-width: 260px; }
.gp-tip.on { opacity: 1; transform: none; }
.gp-tip b { color: var(--text); }
.gp-tip .k { color: var(--text-dim); }
.gp-tip .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.gp-tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.2); }

/* 3D view: soft studio backdrop + label leaders */
.sim-view.three, .hero-3d { background: radial-gradient(120% 95% at 50% 30%, var(--three-bg-1) 0%, var(--three-bg-2) 100%); }
.hero-3d { background: radial-gradient(ellipse at 50% 40%, var(--accent-soft), transparent 70%), radial-gradient(120% 95% at 50% 30%, var(--three-bg-1) 0%, var(--three-bg-2) 100%); }
.gp-3d-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gp-3d-leaders path { stroke: var(--text-dim); stroke-width: 1; fill: none; opacity: .75; }
.gp-3d-leaders circle { fill: var(--text-dim); stroke: var(--bg-elev); stroke-width: 1; }
.overlay-label { box-shadow: 0 1px 2px rgba(16, 24, 40, .08); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); line-height: 1.45; }

/* figure zoom */
figure.diagram svg.zoomable { cursor: zoom-in; }
.fig-zoom { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border-radius: 8px; border: 1px solid var(--border); background: color-mix(in srgb, var(--bg-elev) 90%, transparent); color: var(--text-dim); cursor: pointer; opacity: 0; transition: opacity .15s, color .15s, border-color .15s; }
/* figure.diagram svg(폭 100 %)나 페이지별 svg 규칙이 단추 아이콘까지 키우지 않게 */
figure.diagram .fig-zoom svg { width: 15px; height: 15px; min-width: 0; }
figure.diagram:hover .fig-zoom, .fig-zoom:focus-visible { opacity: 1; }
.fig-zoom:hover { color: var(--accent); border-color: var(--accent); }
@media (hover: none) { .fig-zoom { opacity: .9; } }
.gp-lightbox { width: min(1240px, 96vw); max-width: none; max-height: 94vh; padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elev); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .35); overflow: hidden; }
.gp-lightbox[open] { display: flex; flex-direction: column; }
.gp-lightbox::backdrop { background: rgba(8, 12, 20, .62); backdrop-filter: blur(2px); }
.gp-lightbox .lb-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.gp-lightbox .lb-title { flex: 1; font-weight: 700; font-size: 15px; }
.gp-lightbox .lb-close { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font-size: 15px; cursor: pointer; }
.gp-lightbox .lb-close:hover { border-color: var(--accent); color: var(--accent); }
.gp-lightbox .lb-body { overflow: auto; padding: 18px 20px 20px; -webkit-overflow-scrolling: touch; }
.gp-lightbox .lb-fig svg { display: block; width: 100%; height: auto; }
.gp-lightbox .lb-fig .fig-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.gp-lightbox .lb-cap { margin: 14px 0 0; font-size: 14.5px; color: var(--text-dim); line-height: 1.65; max-width: 900px; }
.gp-lightbox .lb-cap b { color: var(--text); }
@media (max-width: 760px) {
  .gp-lightbox { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; border: 0; }
  .gp-lightbox .lb-body { padding: 12px; }
  .gp-lightbox .lb-fig svg { min-width: 680px; }
  .gp-lightbox .lb-fig .fig-row { grid-template-columns: 1fr; }
  .gp-lightbox .lb-fig .fig-row svg { min-width: 0; }
  .gp-lightbox .lb-fig .fig-panels { min-width: 520px; }
  .gp-lightbox .lb-fig .fig-panels > svg { min-width: 0; flex-basis: 100% !important; }
}
html.gp-lb-open { overflow: hidden; }

/* 넓은 단일 그림: 좁은 화면에서 가로로 밀어 보기(common.js figureZoom이 .fig-scroll로 감싼다) */
.fig-scroll { position: relative; min-width: 0; }
@media (max-width: 640px) {
  .fig-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; overscroll-behavior-x: contain; }
  figure.diagram .fig-scroll > svg { min-width: var(--fig-mw, 0); }
  .fig-scroll.can-scroll:not(.at-end) { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
  .fig-scroll.can-scroll:not(.at-start):not(.at-end) { -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 10%, #000 82%, transparent); }
  .fig-scroll.can-scroll.at-end:not(.at-start) { -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%); mask-image: linear-gradient(90deg, transparent, #000 14%); }
  .fig-scroll.can-scroll + figcaption::before { content: "↔ 그림을 옆으로 밀어 보세요 · "; color: var(--text-faint); font-size: 12.5px; }
}

/* 읽음표가 홀수 개이면 좁은 화면 2열에서 마지막 칸이 비지 않게 한 줄을 다 쓴다 */
@media (max-width: 560px) {
  .sim-readout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sim-readout > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* GPU 칩 색 코드: 면 .k-*(옅은 면+테두리), 선 .ks-*, 글자 .kt-*, 범례 <span class="m-key compute">, 캔버스 GP.palette().compute */
svg .k-compute, .k-compute:not(html *) { fill: color-mix(in srgb, var(--compute) 16%, var(--bg-elev)); stroke: var(--compute); } svg .kf-compute, .kf-compute:not(html *) { fill: var(--compute); } svg .ks-compute, .ks-compute:not(html *) { stroke: var(--compute); fill: none; stroke-width: 2.2; } svg .kt-compute, .kt-compute:not(html *) { fill: var(--compute); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-tensor, .k-tensor:not(html *) { fill: color-mix(in srgb, var(--tensor) 16%, var(--bg-elev)); stroke: var(--tensor); } svg .kf-tensor, .kf-tensor:not(html *) { fill: var(--tensor); } svg .ks-tensor, .ks-tensor:not(html *) { stroke: var(--tensor); fill: none; stroke-width: 2.2; } svg .kt-tensor, .kt-tensor:not(html *) { fill: var(--tensor); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-ctrl, .k-ctrl:not(html *) { fill: color-mix(in srgb, var(--ctrl) 16%, var(--bg-elev)); stroke: var(--ctrl); } svg .kf-ctrl, .kf-ctrl:not(html *) { fill: var(--ctrl); } svg .ks-ctrl, .ks-ctrl:not(html *) { stroke: var(--ctrl); fill: none; stroke-width: 2.2; } svg .kt-ctrl, .kt-ctrl:not(html *) { fill: var(--ctrl); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-sram, .k-sram:not(html *) { fill: color-mix(in srgb, var(--sram) 16%, var(--bg-elev)); stroke: var(--sram); } svg .kf-sram, .kf-sram:not(html *) { fill: var(--sram); } svg .ks-sram, .ks-sram:not(html *) { stroke: var(--sram); fill: none; stroke-width: 2.2; } svg .kt-sram, .kt-sram:not(html *) { fill: var(--sram); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-dram, .k-dram:not(html *) { fill: color-mix(in srgb, var(--dram) 16%, var(--bg-elev)); stroke: var(--dram); } svg .kf-dram, .kf-dram:not(html *) { fill: var(--dram); } svg .ks-dram, .ks-dram:not(html *) { stroke: var(--dram); fill: none; stroke-width: 2.2; } svg .kt-dram, .kt-dram:not(html *) { fill: var(--dram); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-data, .k-data:not(html *) { fill: color-mix(in srgb, var(--data) 16%, var(--bg-elev)); stroke: var(--data); } svg .kf-data, .kf-data:not(html *) { fill: var(--data); } svg .ks-data, .ks-data:not(html *) { stroke: var(--data); fill: none; stroke-width: 2.2; } svg .kt-data, .kt-data:not(html *) { fill: var(--data); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-link, .k-link:not(html *) { fill: color-mix(in srgb, var(--link) 16%, var(--bg-elev)); stroke: var(--link); } svg .kf-link, .kf-link:not(html *) { fill: var(--link); } svg .ks-link, .ks-link:not(html *) { stroke: var(--link); fill: none; stroke-width: 2.2; } svg .kt-link, .kt-link:not(html *) { fill: var(--link); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-volt, .k-volt:not(html *) { fill: color-mix(in srgb, var(--volt) 16%, var(--bg-elev)); stroke: var(--volt); } svg .kf-volt, .kf-volt:not(html *) { fill: var(--volt); } svg .ks-volt, .ks-volt:not(html *) { stroke: var(--volt); fill: none; stroke-width: 2.2; } svg .kt-volt, .kt-volt:not(html *) { fill: var(--volt); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-heat, .k-heat:not(html *) { fill: color-mix(in srgb, var(--heat) 16%, var(--bg-elev)); stroke: var(--heat); } svg .kf-heat, .kf-heat:not(html *) { fill: var(--heat); } svg .ks-heat, .ks-heat:not(html *) { stroke: var(--heat); fill: none; stroke-width: 2.2; } svg .kt-heat, .kt-heat:not(html *) { fill: var(--heat); font-family: var(--font); font-size: 13px; font-weight: 700; }
svg .k-clock, .k-clock:not(html *) { fill: color-mix(in srgb, var(--clock) 16%, var(--bg-elev)); stroke: var(--clock); } svg .kf-clock, .kf-clock:not(html *) { fill: var(--clock); } svg .ks-clock, .ks-clock:not(html *) { stroke: var(--clock); fill: none; stroke-width: 2.2; } svg .kt-clock, .kt-clock:not(html *) { fill: var(--clock); font-family: var(--font); font-size: 13px; font-weight: 700; }
.m-key { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); margin-right: 12px; }
.m-key::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--m, var(--accent)); }
.m-key.compute { --m: var(--compute); } .m-key.tensor { --m: var(--tensor); } .m-key.ctrl { --m: var(--ctrl); } .m-key.sram { --m: var(--sram); } .m-key.dram { --m: var(--dram); } .m-key.data { --m: var(--data); } .m-key.link { --m: var(--link); } .m-key.volt { --m: var(--volt); } .m-key.heat { --m: var(--heat); } .m-key.clock { --m: var(--clock); }
.callout.fab { background: var(--surface); border-left-color: var(--accent-2); }
.callout.fab > strong:first-child::before { content: "GX-1 노트 · "; color: var(--accent-2); font-family: var(--mono); font-size: 13px; letter-spacing: .04em; }
