/* 나뭇잎 디지털 교과서 — 공통 스타일 */
:root {
  --ink: #18191b;
  --ink-2: #4f5258;
  --ink-3: #64676e;   /* 흐린 글자도 바탕·카드 위 4.5:1 이상 */
  --rule: #e2e3e6;
  --grid: rgba(24, 25, 27, .055);
  --paper: #f4f5f6;
  --paper-2: #ebecee;
  --card: #fbfbf8;
  --leaf: #74ab66;
  --forest: #35742a;
  --sprout: #b5d7ac;
  --warn: #a84a28;
  --warn-bg: #f7efe9;
  --night: #1c1e1b;
  --on-night: #f3f4ef;
  --top-bg: rgba(244, 245, 246, .82);
  --raised: #fff;
  --right-bg: #eef5eb;
  --hl: #fbe38a;
  --memo-bg: #fffdf3;
  --memo-rule: #e6c34a;
  --fig-bg: #fff;
  --on-accent: #fff;
  /* 화면 틀(메인, 목록, 상단바)의 표면. 카드 그림 칸은 캔버스가 --card(#fbfbf8)로 그리므로 --card는 그대로 둔다 */
  --surface: #fff;
  --line: rgba(24, 25, 27, .08);
  --line-strong: rgba(24, 25, 27, .15);
  /* 깊이: 오프셋과 흐림이 있는 겹 그림자. 검은 덧그림자(4px 4px 0)는 쓰지 않는다 */
  --lift: 0 1px 2px rgba(35, 35, 38, .05), 0 4px 14px -6px rgba(35, 35, 38, .12);
  --lift-hi: 0 1px 2px rgba(35, 35, 38, .05), 0 12px 32px -12px rgba(35, 35, 38, .22);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  /* 곡선: 들어오고 반응하는 것은 강한 ease-out, 화면 위에서 옮겨 가는 것은 ease-in-out */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);

  --pad: clamp(16px, 4vw, 56px);
  --max: 1240px;
  --f-kr: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  /* IBM Plex Mono에는 한글이 없다. 한글은 Pretendard로 그려 Windows의 굴림·빈 칸(□)을 막는다 */
  --f-mono: "IBM Plex Mono", "Pretendard Variable", Pretendard, ui-monospace, "SFMono-Regular", Menlo, monospace;
  --f-serif: "Newsreader", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--f-kr); line-height: 1.65;
  word-break: keep-all; overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ol, ul, dl, dd, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; }
canvas { display: block; }
/* 카드 캔버스는 칸 폭을 따른다. CSS 폭이 없으면 화면 크기가 width 속성(= 화면 크기 × 화소 배율)을 따라가
   배율이 1보다 큰 화면에서 그릴 때마다 커지며 칸 밖으로 넘친다(NM.fit의 되먹임). */
.card canvas { max-width: 100%; }
.card-fig canvas { width: 100%; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--leaf) 32%, transparent); }
:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
input, textarea { caret-color: var(--forest); }
html { scrollbar-color: color-mix(in srgb, var(--ink) 28%, transparent) transparent; }
a { text-underline-offset: .18em; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }   /* 화면 낭독기에만 읽히는 글 */
.mono { font-family: var(--f-mono); font-size: 12.5px; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.dim { color: var(--ink-3); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--pad); }

/* ───── 상단바 ───── */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 var(--pad);
  background: var(--top-bg);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-mark { width: 24px; height: 24px; color: var(--ink); flex: none; }
.brand small { font-family: var(--f-mono); font-weight: 400; font-size: 11px; color: var(--ink-3); letter-spacing: 0; }
.crumbs { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink-2); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs span[aria-hidden] { color: var(--ink-3); }
.top-right { margin-left: auto; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.top-right a { display: inline-block; padding: 7px 10px; border-radius: var(--r-sm); text-decoration: none; transition: background-color 150ms ease, color 150ms ease; }
@media (hover: hover) and (pointer: fine) { .top-right a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); } }

/* ───── 공통 요소 ───── */
.btn {
  display: inline-block; padding: 9px 16px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600; text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--forest); border-color: var(--forest); } }
.btn.sm { padding: 7px 14px; font-size: 13.5px; }
.chip {
  padding: 4px 11px; border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--card); font-family: var(--f-mono); font-size: 12px; color: var(--ink-2);
}
.chip { transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
.chip:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .chip:hover { border-color: var(--ink); color: var(--ink); } }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
input[type=range] { width: 100%; accent-color: var(--forest); margin: 6px 0; }
select { padding: 4px 8px; border: 1px solid var(--rule); background: var(--card); border-radius: var(--r-sm); font-size: 14px; }
.tag-pill { display: inline-block; font-family: var(--f-mono); font-size: 11px; padding: 1px 7px; border: 1px solid var(--rule); color: var(--ink-2); white-space: nowrap; }
.tag-pill.live { border-color: var(--forest); color: var(--forest); }

/* 메인(index.html) 서식은 css/home.css에 있다 */
.site-foot { padding: 32px 0 48px; display: grid; gap: 6px; }
.site-foot .foot-org { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding-top: 22px; margin-bottom: 4px; border-top: 1px solid var(--rule); }
.foot-home { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.foot-home .brand-mark { width: 22px; height: 22px; }
.foot-home b { font-size: 15px; }
.foot-home .mono, .foot-mail { font-size: 12.5px; color: var(--ink-3); }
.foot-home:hover .mono, .foot-mail:hover { color: var(--forest); }

/* ═════════ 주제 페이지 ═════════ */
.topic-hero { padding: clamp(36px, 6vw, 72px) 0 clamp(24px, 4vw, 40px); border-bottom: 1px solid var(--ink-3); }
.topic-hero .meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-bottom: 16px; }
.topic-hero h1 { font-size: clamp(32px, 4.6vw, 56px); font-weight: 800; line-height: 1.18; letter-spacing: -.04em; }
.topic-hero .lead { margin-top: 16px; max-width: 40em; color: var(--ink-2); font-size: clamp(15px, 1.25vw, 18px); }
.prereq { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13.5px; }
.prereq .mono { color: var(--ink-3); }
.prereq span.p { padding: 2px 9px; background: var(--paper-2); }
/* 누를 수 있는 선수 개념: 카드로 가는 링크(→)와 중학교 개념 설명 창 버튼(js/prereq.js) */
.prereq .p-card, .prereq .p-basic { padding: 1px 9px; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--rule); text-decoration: none; cursor: pointer; }
.prereq .p-card:hover, .prereq .p-basic:hover { border-color: var(--ink-3); }
.prereq .p-card::after { content: "→"; margin-left: 5px; color: var(--ink-3); }
.prereq .p-basic { border-style: dashed; }
.prereq .p-basic::after { content: "설명"; margin-left: 6px; font-family: var(--f-mono); font-size: 10.5px; color: var(--forest); }
dialog.basic-card { width: min(640px, calc(100vw - 32px)); max-height: min(80vh, 760px); padding: 0; color: var(--ink); background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-sm); box-shadow: var(--lift-hi); }
dialog.basic-card::backdrop { background: rgba(10, 10, 12, .45); }
.basic-card header { position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; gap: 12px; padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--rule); }
.basic-card header .mono { font-size: 11.5px; color: var(--forest); }
.basic-card h2 { font-size: 20px; letter-spacing: -.02em; }
.basic-x { margin-left: auto; font-size: 22px; line-height: 1; color: var(--ink-3); background: none; border: 0; cursor: pointer; }
.basic-x:hover { color: var(--ink); }
.basic-body { padding: 16px 20px 22px; font-size: 15.5px; line-height: 1.75; }
.basic-body p + p, .basic-body p + figure, .basic-body figure + p, .basic-body ul, .basic-body ol { margin-top: 10px; }
.basic-body figure { margin: 14px 0; text-align: center; }
.basic-body figure svg { max-width: 100%; height: auto; }
.basic-body figcaption { font-size: 13px; color: var(--ink-3); }
.basic-body .ex { margin-top: 12px; padding: 10px 14px; background: var(--paper-2); }

.topic-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: clamp(20px, 3vw, 44px); padding-top: 32px; }
.toc { position: sticky; top: 80px; align-self: start; font-size: 13.5px; }
.toc p { color: var(--ink-3); margin-bottom: 8px; }
.toc li a { display: grid; grid-template-columns: 46px 1fr; padding: 8px 0; border-top: 1px solid var(--rule); text-decoration: none; color: var(--ink-2); line-height: 1.4; }
.toc li a .mono { color: var(--ink-3); }
.toc li a.on { color: var(--ink); font-weight: 700; }
.toc li a.on .mono { color: var(--forest); }
.toc .progress { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--ink-3); color: var(--ink-3); }

/* ───── 개념 카드 ───── */
.card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--lift); overflow: clip; margin-bottom: clamp(28px, 4vw, 44px); }
.card.is-max { border-radius: 0; }
.card-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 14px 22px; border-bottom: 1px solid var(--rule);
}
.card-head .no { font-family: var(--f-mono); font-size: 13px; color: var(--forest); }
.card-head h2 { font-size: clamp(20px, 2.1vw, 26px); letter-spacing: -.03em; line-height: 1.3; }
.card-head .kind { margin-left: auto; font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); }
.card-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.card-fig { padding: 18px 22px 22px; border-right: 1px solid var(--rule); min-width: 0; overflow-x: auto; }
/* 그림 칸의 표·선택 상자·행렬 글자가 좁은 화면에서 카드 밖으로 밀어내지 않게 */
.card-fig select, .card-fig input:not([type="checkbox"]):not([type="radio"]) { max-width: 100%; }
.card-fig pre { max-width: 100%; overflow-x: auto; }
.katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.card-fig mark { overflow-wrap: anywhere; }
.ctl { margin-top: 10px; }
.ctl label.mono { display: block; }
.ctl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 12px; font-size: 13.5px; }
.toggles label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.toggles input { accent-color: var(--ink); margin: 0; }
.toggles i { width: 14px; height: 3px; background: var(--c); display: inline-block; }
.nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 8px; }
.nums.n4 { grid-template-columns: repeat(4, 1fr); }
.nums div { border-top: 1px solid var(--rule); padding-top: 7px; min-width: 0; }
.nums dt { color: var(--ink-3); font-size: 11px; font-family: var(--f-mono); }
.nums dd { font-family: var(--f-mono); font-size: 16px; color: var(--ink); }
.nums dd.bad, .bad { color: var(--warn); }
.nums dd.good { color: var(--forest); }
.legend { color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.dot.real { background: var(--ink); }
.dot.ghost { border: 1.5px dashed var(--forest); }
.line-key { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--c, var(--ink)); margin-left: 6px; vertical-align: middle; }
.line-key.dash { border-top-style: dashed; }
.fig-note { margin-top: 8px; font-size: 12px; color: var(--ink-3); }

.cv-wide { width: 100%; aspect-ratio: 16 / 9; }
.cv-sq { width: 100%; aspect-ratio: 1 / 1; }
.fig-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-content: start; }
.fig-2 > .ctl { grid-column: 1 / -1; }

.readout { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding-top: 12px; border-top: 1px solid var(--rule); }
.readout .mid { text-align: center; }
.swatch-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.swatch { width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); background: #888; }
.swatch-wrap .small { color: var(--ink-3); max-width: 9em; line-height: 1.35; font-family: var(--f-mono); }

.steps { padding: 8px 0; }
.steps li { position: relative; padding: 11px 22px 11px 84px; font-size: 14.5px; line-height: 1.65; border-bottom: 1px dotted var(--rule); }
.steps li:last-child { border-bottom: 0; }
.steps .tag { position: absolute; left: 22px; top: 14px; font-family: var(--f-mono); font-size: 11.5px; color: var(--forest); }
.steps li.warn { background: var(--warn-bg); }
.steps li.warn .tag { color: var(--warn); }
.steps em { font-style: normal; font-weight: 700; }
.formula { font-family: var(--f-serif); font-style: italic; font-size: 17px; background: var(--paper-2); padding: 1px 8px; white-space: nowrap; }

/* ───── 확인 문제 ───── */
.quiz { border-top: 1px solid var(--rule); padding: 16px 22px 20px; background: var(--raised); }
.quiz h3 { font-size: 15px; display: flex; gap: 10px; align-items: baseline; }
.quiz h3 .mono { color: var(--forest); font-weight: 400; }
.quiz .q { margin: 6px 0 12px; font-size: 15px; }
.quiz ol { display: grid; gap: 6px; }
.quiz button.opt {
  width: 100%; text-align: left; display: grid; grid-template-columns: 26px 1fr; gap: 8px;
  padding: 9px 12px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-sm); font-size: 14.5px;
}
.quiz button.opt { transition: transform 160ms var(--ease-out), border-color 150ms ease, background-color 150ms ease; }
.quiz button.opt:active { transform: scale(.99); }
@media (hover: hover) and (pointer: fine) { .quiz button.opt:hover { border-color: var(--ink-3); } }
.quiz button.opt .mono { color: var(--ink-3); padding-top: 2px; }
.quiz button.opt.right { border-color: var(--forest); background: var(--right-bg); }
.quiz button.opt.wrong { border-color: var(--warn); background: var(--warn-bg); }
.quiz .why { display: none; grid-column: 2; font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }
.quiz button.opt.right .why, .quiz button.opt.wrong .why { display: block; }
.quiz button.opt .why b { color: var(--ink); }

/* ───── 영상 블록 ───── */
.video-block { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(20px, 4vw, 56px); align-items: center; background: var(--night); color: var(--on-night); padding: clamp(24px, 4vw, 44px); margin-bottom: 44px; }
.video-block .mono { color: var(--sprout); }
.video-block h2 { font-size: clamp(22px, 2.6vw, 32px); letter-spacing: -.03em; margin: 10px 0 12px; line-height: 1.3; }
.video-block p { color: rgba(243,244,239,.72); max-width: 30em; }
.phone { position: relative; width: min(300px, 78vw); border: 1px solid rgba(255,255,255,.18); border-radius: var(--r-sm); overflow: hidden; background: #111; }
.phone canvas { width: 100%; height: auto; aspect-ratio: 9 / 16; cursor: pointer; }
.reel-play { position: absolute; left: 50%; top: 45%; translate: -50% -50%; width: 60px; height: 60px; border-radius: 50%; border: 0; background: rgba(243,244,239,.92); color: var(--night); display: none; place-items: center; }
.reel-play svg { width: 24px; height: 24px; margin-left: 3px; }
.phone.paused .reel-play { display: grid; }
.reel-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; background: #111; }
.reel-bar button { background: none; border: 0; color: rgba(243,244,239,.8); padding: 0; min-width: 5em; text-align: left; }
.reel-bar input { accent-color: var(--leaf); margin: 0; flex: 1; }
.reel-bar span { color: rgba(243,244,239,.6); }

/* ───── 다음 주제 ───── */
.next { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 56px; }
.next a, .next div { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; text-decoration: none; background: var(--card); box-shadow: var(--lift); }
.next div { border-style: dashed; border-color: var(--rule); color: var(--ink-3); background: none; box-shadow: none; }
.next a { transition: transform 160ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 150ms ease; }
.next a:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) { .next a:hover { border-color: var(--line-strong); box-shadow: var(--lift-hi); } }
.next .mono { color: var(--ink-3); display: block; }
.next b { font-size: 17px; }

/* ───── 반응형 ───── */
@media (max-width: 1000px) {
  .card-body { grid-template-columns: minmax(0, 1fr); }
  .card-fig { border-right: 0; border-bottom: 1px solid var(--rule); }
  .topic-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
  .toc ol { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; }
  .video-block { grid-template-columns: 1fr; justify-items: center; }
}
@media (max-width: 640px) {
  .crumbs { display: none; }
  .brand small { display: none; }
  .card-head, .card-fig { padding-left: 14px; padding-right: 14px; }
  .card-head .kind { margin-left: 0; width: 100%; }
  .steps li { padding: 11px 14px; }
  .steps .tag { position: static; display: block; margin-bottom: 1px; }
  .quiz { padding: 14px; }
  .ctl-row { grid-template-columns: 1fr; }
  .readout { grid-template-columns: 1fr 1fr; }
  .readout .mid { grid-column: 1 / -1; grid-row: 1; }
  .nums dd { font-size: 14px; }
  .nums.n4 { grid-template-columns: repeat(2, 1fr); }
  .next { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chip:active, .theme-btn:active, .next a:active, .tbox:active, .quiz button.opt:active, .scope-seg button:active { transform: none; }
}

/* ═════════ 목차 화면 (메인·과목) — js/home.js ═════════ */
/* 대단원을 신문 다단처럼 흘려 채운다(줄 맞춤 격자는 짧은 대단원 아래에 큰 빈칸이 생김) */
.chapters { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 0 28px; align-items: start; }   /* 단 나누기는 home.js(split)가 높이를 고르게 */
.chapter { margin-bottom: 24px; }
.course-head { position: sticky; top: 84px; align-self: start; }
@media (max-width: 1000px) { .course-head { position: static; } }
.course-head h2 a { text-decoration: none; }
.course-head h2 a:hover { color: var(--forest); }
.link { font-size: 14px; color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--rule); }
.link:hover { color: var(--ink); border-color: var(--ink); }
.chapter h3 { font-size: 14.5px; padding-bottom: 8px; border-bottom: 1px solid var(--line-strong); display: flex; gap: 8px; align-items: baseline; letter-spacing: -.01em; }
.chapter h3 .mono { color: var(--ink-2); }
.chapter ol > li > a, .chapter ol > li > div { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 14.5px; line-height: 1.4; }
.chapter ol > li > a:hover .t { text-decoration: underline; }
.chapter ol > li > a .mono { color: var(--ink-3); font-size: 11.5px; }
.chapter .cnt { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
/* 끝낸 절: 번호 자리에 그린 체크. 멈춘 절: 오른쪽 끝 초록 깃발(초록은 '지금 여기'에만) */
.chapter li[data-ids] > a { position: relative; }
.chapter li.done > a > .mono:first-child { color: transparent; }
.chapter li.done > a > .mono:first-child::before { content: ""; position: absolute; left: 4px; top: 12px; width: 5px; height: 10px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); rotate: 40deg; }
.chapter li.here > a .t { font-weight: 700; }
.chapter li.here > a::after { content: ""; position: absolute; left: -16px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--forest); box-shadow: 0 0 0 3px color-mix(in srgb, var(--forest) 22%, transparent); }
.chapter li.soon > div { color: var(--ink-3); }
.chapter .hits { display: none; padding: 2px 0 6px 40px; font-size: 13px; color: var(--ink-2); }
.searching .chapter .hits { display: block; }
.chapter .hits li::before { content: "· "; color: var(--ink-3); }

.course-hero { padding: clamp(36px, 6vw, 72px) 0 clamp(20px, 3vw, 32px); border-bottom: 1px solid var(--ink-3); }
.course-hero h1 { font-size: clamp(34px, 5vw, 60px); font-weight: 800; letter-spacing: -.04em; line-height: 1.15; margin: 6px 0 10px; }
/* 과목 목차(책 목차형): 왼쪽 과목 정보는 고정, 오른쪽에 대단원 → 절 → 카드 */
.cx { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: clamp(28px, 4vw, 56px); align-items: start; padding: clamp(32px, 5vw, 64px) 0 24px; }
.cx-side { position: sticky; top: 76px; }
.cx-pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: var(--r-sm); background: var(--right-bg); color: var(--forest); }
.cx-side h1 { font-size: clamp(32px, 4vw, 46px); font-weight: 800; letter-spacing: -.04em; line-height: 1.15; margin: 8px 0 10px; }
.cx-lead { color: var(--ink-2); font-size: 14px; line-height: 1.6; margin-bottom: 18px; }
.cx-prog { height: 6px; background: var(--paper-2); border-radius: var(--r-sm); overflow: hidden; }
.cx-prog i { display: block; height: 100%; background: var(--forest); border-radius: var(--r-sm); }
.cx-prog-t { color: var(--ink-3); margin: 6px 0 14px; }
.cx-go { display: block; background: var(--forest); color: var(--on-accent); border-radius: var(--r-sm); padding: 10px 14px; font-weight: 700; font-size: 14px; text-decoration: none; line-height: 1.4; }
.cx-go:hover { filter: brightness(1.08); }
.cx-all { color: var(--forest); font-weight: 600; }
.cx-info { display: grid; gap: 8px; margin: 18px 0 0; font-size: 13px; }
.cx-info div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.cx-info dt { color: var(--ink-3); }
.cx-info dd { margin: 0; }
.cx-path { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); display: grid; gap: 8px; }
.cx-path p { margin: 0; }
.cx-path .dim { display: block; font-size: 12px; margin-bottom: 1px; }
.cx-ch { margin-bottom: 40px; }
.cx-ch-head { display: flex; align-items: baseline; gap: 14px; border-bottom: 1px solid var(--ink-3); padding-bottom: 8px; }
.cx-no { font-size: 28px; font-weight: 800; color: var(--ink-2); min-width: 1.6em; line-height: 1; }
.cx-ch-head h2 { font-size: clamp(19px, 2vw, 23px); letter-spacing: -.025em; margin: 0; }
.cx-meta { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.cx-sec { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 2px 12px; padding: 13px 0; border-bottom: 1px solid var(--rule); }
.cx-n { color: var(--ink-3); font-size: 13px; padding-top: 2px; }
.cx-t b { font-size: 16px; letter-spacing: -.015em; }
.cx-t a { text-decoration: none; }
.cx-t a:hover { color: var(--forest); text-decoration: underline; }
.cx-code { display: block; font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.cx-badge { font-size: 12px; color: var(--ink-3); white-space: nowrap; padding-top: 3px; }
.cx-badge.ok { color: var(--forest); font-weight: 700; }
.cx-sec.soon .cx-t b { color: var(--ink-3); font-weight: 600; }
.cx-qs { grid-column: 2 / 4; display: grid; gap: 1px; margin-top: 6px; }
.cx-qs a { display: block; position: relative; padding: 3px 0 3px 15px; font-size: 14px; line-height: 1.5; color: var(--ink-2); text-decoration: none; }
.cx-qs a::before { content: ""; position: absolute; left: 2px; top: .8em; width: 5px; height: 5px; border-radius: 50%; border: 1px solid var(--ink-3); }
.cx-qs a:hover { color: var(--ink); text-decoration: underline; }
.cx-qs li.done a { color: var(--ink-3); }
.cx-qs li.done a::before { top: .45em; width: 4px; height: 8px; border: 0; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); border-radius: 0; rotate: 40deg; }
.cx-k { font-size: 11px; color: var(--forest); margin-right: 6px; }
@media (max-width: 860px) {
  .cx { grid-template-columns: 1fr; gap: 28px; }
  .cx-side { position: static; }
}
@media (max-width: 480px) {
  .cx-sec { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 2px 8px; }
  .cx-no { font-size: 22px; }
}
.chapter .cnt.dim { color: var(--ink-3); }

/* ───── 읽기 블록 (type: text) — 인터랙티브가 어울리지 않는 내용을 글·그림·사진·표로 ───── */
.c-items li.text .mono { color: var(--forest); }
.reading-body { padding: 20px 26px 24px; font-size: 15.5px; line-height: 1.8; }
.reading-body > * + * { margin-top: 12px; }
.reading-body .ask { font-size: 16.5px; font-weight: 600; line-height: 1.6; }
.reading-body h3 { font-size: 16px; margin-top: 24px; padding-top: 14px; border-top: 1px dotted var(--rule); }
.reading-body h3 .mono { color: var(--forest); font-size: 11.5px; font-weight: 400; margin-right: 8px; }
.reading-body h4 { font-size: 14.5px; margin-top: 16px; color: var(--ink); }
.reading-body h4 + p { margin-top: 4px; }
.reading-body em { font-style: normal; font-weight: 700; }
.reading-body ul.dots { padding-left: 1.2em; list-style: disc; }
.reading-body ul.dots li + li { margin-top: 4px; }
.reading-body figure { margin: 18px 0 6px; }
.reading-body figure img, .reading-body figure svg { display: block; width: 100%; height: auto; border: 1px solid var(--rule); background: var(--fig-bg); }
.reading-body figure.half { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reading-body figure.half figcaption { grid-column: 1 / -1; }
.reading-body figcaption { margin-top: 6px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.reading-body figcaption .src { display: block; font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.reading-body .tbl { overflow-x: auto; }
.reading-body table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.55; }
.reading-body th, .reading-body td { border-top: 1px solid var(--rule); padding: 7px 10px 7px 0; text-align: left; vertical-align: top; }
.reading-body thead th { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.reading-body tbody th { font-weight: 700; white-space: nowrap; }
.reading-body .judge { background: var(--warn-bg); padding: 12px 16px; font-size: 14.5px; line-height: 1.7; }
.reading-body .judge b:first-child { font-family: var(--f-mono); font-size: 11.5px; font-weight: 400; color: var(--warn); margin-right: 10px; }
@media (max-width: 640px) {
  .reading-body { padding: 16px 14px 18px; font-size: 15px; }
  .reading-body figure.half { grid-template-columns: 1fr; }
}
.reading-body figure.third { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.reading-body figure.third figcaption { grid-column: 1 / -1; }
.reading-body figure.third img { aspect-ratio: 1; object-fit: cover; }
@media (max-width: 640px) { .reading-body figure.third { grid-template-columns: 1fr 1fr; } }
.reading-body figure.narrow { max-width: 420px; }
.reading-body .src a { color: inherit; }

/* ───── 본문 카드 (STYLE.md 2·5절, data-kind="본문") — QURI css와 같은 클래스 이름. 색 띠 없음 ───── */
/* 본문 카드의 글 영역 규칙은 css/shared.css(두 사이트 같은 파일)로 옮겼다. 여기에는 사이트별 그림 색과 본문 밖에서도 쓰는 규칙만 둔다. */
:root { --fa: #35742a; --fb: #2f6db0; --fc: #8a5a08; --fd: #a84a28; }   /* 예제 상자 이름 등 글자로도 쓰므로 4.5:1 이상 */
[data-theme="dark"] { --fa: #8cc67a; --fb: #7fa6ea; --fc: #e0aa3e; --fd: #e8896b; }
.reading-body figure.q-fig { margin: 18px 0 8px; }
.reading-body figure.q-fig svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; border: 1px solid var(--rule); background: var(--card); font-family: var(--f-kr); }
[data-theme="dark"] .reading-body figure.q-fig svg:not(.no-invert) { filter: none; }
.reading-body figure.q-fig figcaption { max-width: 560px; margin: 6px auto 0; font-size: 13.5px; }

/* ───── 학습 도구: 메모, 형광펜, 확인 문제 기록 (js/notes.js) ───── */
.top-right a + a { margin-left: 2px; }
.card-head .nb-memo { margin-left: 10px; flex: none; padding: 2px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--card); font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-2); cursor: pointer; }
.card-head .nb-memo:hover { border-color: var(--ink); color: var(--ink); }
.card-head .nb-memo.has { border-color: var(--forest); color: var(--forest); }
.card-head .nb-memo.has::before { content: "● "; font-size: 8px; vertical-align: 2px; }
.nb-panel { border-top: 1px dashed var(--rule); padding: 12px 22px 14px; background: var(--memo-bg); }
.nb-panel label { display: block; color: var(--ink-3); font-size: 11.5px; margin-bottom: 6px; }
.nb-panel textarea { width: 100%; min-height: 68px; resize: vertical; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--raised); font: inherit; font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.nb-panel textarea:focus { outline: none; border-color: var(--ink); }
.nb-state { margin-top: 4px; font-size: 11px; color: var(--ink-3); }
.nb-state a { color: inherit; }
mark.hl { background: var(--hl); color: inherit; padding: 0 1px; border-radius: 1px; cursor: pointer; }
.nb-fab { position: fixed; z-index: 50; padding: 6px 12px; border: 0; border-radius: var(--r-sm); background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 600; box-shadow: 0 3px 12px rgba(0,0,0,.18); cursor: pointer; }
.nb-fab::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: var(--r-sm); background: var(--hl); vertical-align: -1px; }
.nb-fab.rm::before { background: none; border: 1px solid var(--paper); }
.quiz h3 .nb-prev { margin-left: auto; font-size: 11px; color: var(--ink-3); text-decoration: none; font-weight: 400; }
.quiz h3 .nb-prev.bad { color: var(--warn); }
.toc li a { position: relative; }
.toc li a.seen { padding-right: 16px; }
.toc li a.seen::before { content: ""; position: absolute; right: 4px; top: 12px; width: 4px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); rotate: 40deg; }   /* 본 카드: 그린 체크 */
.toc li a.noted::after { content: ""; position: absolute; right: 3px; top: 28px; width: 6px; height: 6px; border-radius: 50%; background: var(--memo-rule); }
/* 옆 목차의 기출 문항 상자: 절 끝까지 내려가지 않아도 보이게 */
.toc-px { display: grid; gap: 2px; margin-top: 14px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink); line-height: 1.35; }
.toc-px:hover { border-color: var(--forest); }
.toc-px .mono { font-size: 11px; color: var(--forest); }
.toc-px b { font-size: 14px; }
.toc-px .mono:last-child { color: var(--ink-3); font-size: 11.5px; }
body.toc-folded .toc .toc-px { display: none; }
@media (max-width: 1000px) { .toc-px { grid-template-columns: auto 1fr auto; align-items: baseline; gap: 12px; } }
.toc .toc-links { margin-top: 10px; }
.toc .toc-links a { color: var(--ink-2); }

/* 절: 카드 목록 접기(js/reader.js) — 접으면 본문이 넓어진다 */
.toc .toc-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.toc-fold { font: inherit; font-size: 11.5px; padding: 2px 8px; color: var(--ink-2); background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-sm); cursor: pointer; }
.toc-fold:hover { color: var(--ink); border-color: var(--ink-3); }
body.toc-folded .topic-layout { grid-template-columns: auto minmax(0, 1fr); }
body.toc-folded .toc ol, body.toc-folded .toc .progress, body.toc-folded .toc .toc-links { display: none; }
body.toc-folded .toc .toc-title { font-size: 0; }
body.toc-folded .toc .toc-fold { font-size: 12px; }

/* 카드 크게 보기: 화면 전체를 덮는다. 캠버스는 core.js fit()의 ResizeObserver가 다시 그린다 */
.card-max { flex: none; align-self: center; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; color: var(--ink-2); background: none; border: 1px solid var(--rule); border-radius: var(--r-sm); cursor: pointer; }
.card-head .kind + .card-max { margin-left: 0; }
.card-head h2 + .card-max { margin-left: auto; }
.card-max:hover { color: var(--ink); border-color: var(--ink-3); }
.card-max svg { width: 16px; height: 16px; }
.card.is-max { position: fixed; inset: 0; z-index: 60; margin: 0; overflow-y: auto; border: 0; }
.card.is-max .card-head { position: sticky; top: 0; z-index: 2; background: var(--card); }
.card.is-max .card-head, .card.is-max .card-body { max-width: 1520px; margin-inline: auto; }
body.has-max { overflow: hidden; }

/* KaTeX 수식(js/math.js): 기본 1.21em은 한글 본문 옆에서 커 보여 줄인다 */
.katex { font-size: 1.08em; }
/* \text{} 안 한글: KaTeX 글꼴에 한글이 없어 넓은 명조체로 대체되므로, 라틴은 KaTeX_Main을 두고 한글만 본문 글꼴로 */
.katex .text { font-family: KaTeX_Main, var(--f-kr); }

/* 카드 아래 연관 카드(빌드가 graph/concepts.txt로 고른다) */
.rel { display: grid; gap: 6px; margin: calc(10px - clamp(28px, 4vw, 44px)) 12px clamp(28px, 4vw, 44px); padding: 10px 16px 12px; background: var(--paper-2); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r) var(--r); font-size: 13.5px; }
.rel > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.rel > div > .mono { flex: none; width: 9.5em; font-size: 11.5px; color: var(--ink-3); }
.rel a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); line-height: 1.5; }
.rel a:hover { border-bottom-color: var(--ink); }
.rel a small { margin-right: 5px; font-size: 11px; color: var(--ink-3); }
@media (max-width: 640px) { .rel > div > .mono { width: 100%; } }
@media (max-width: 640px) {
  .nb-panel { padding: 12px 14px; }
  .card-head .nb-memo { margin-left: 0; }
}

/* ───── 내 노트 페이지 (notes.html) ───── */
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .btn.ghost:hover { background: var(--paper-2); border-color: var(--ink-3); color: var(--ink); } }
.btn.danger { color: var(--warn); border-color: var(--warn); }
button.btn { cursor: pointer; font-family: inherit; }
.nb-hero { padding: clamp(32px, 5vw, 60px) 0 20px; }
.nb-hero h1 { font-size: clamp(30px, 4vw, 48px); font-weight: 800; letter-spacing: -.04em; }
.nb-hero .lead { margin-top: 12px; max-width: 42em; color: var(--ink-2); }
.nb-stats { margin-top: 20px; max-width: 760px; }
.nb-stats dd small { font-size: 11px; color: var(--ink-3); }
.nb-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ink-3); position: sticky; top: 56px; background: var(--paper); z-index: 5; }
.nb-tabs a { padding: 10px 16px; text-decoration: none; color: var(--ink-2); font-weight: 600; border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px; border-radius: var(--r-sm) 2px 0 0; }
.nb-tabs a[aria-current="page"] { color: var(--ink); background: var(--paper); border-color: var(--ink-3); border-top: 3px solid var(--forest); }
.nb-view { padding: 8px 0 60px; max-width: 860px; }
.nb-sec { margin-top: 28px; font-size: 17px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.nb-sec .mono { color: var(--forest); font-size: 11.5px; font-weight: 400; }
.nb-sec a { text-decoration: none; }
.nb-sec a:hover { text-decoration: underline; }
.nb-item { margin-top: 10px; padding: 14px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.nb-title { font-weight: 700; text-decoration: none; }
a.nb-title:hover { text-decoration: underline; }
.nb-date { margin-left: 10px; font-size: 11px; color: var(--ink-3); }
.nb-note { margin-top: 8px; white-space: pre-wrap; font-size: 15px; line-height: 1.7; background: var(--memo-bg); padding: 8px 12px;  }
.nb-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; }
.nb-actions a { color: var(--forest); font-weight: 600; }
.nb-actions button, .nb-quotes button { border: 0; background: none; padding: 0; color: var(--ink-3); font-size: 13px; cursor: pointer; text-decoration: underline; }
.nb-actions button:hover, .nb-quotes button:hover { color: var(--warn); }
.nb-quotes { margin-top: 8px; display: grid; gap: 6px; }
.nb-quotes li { display: flex; gap: 10px; align-items: baseline; font-size: 14.5px; line-height: 1.6; }
.nb-quotes mark.hl { cursor: default; }
.nb-quotes button { text-decoration: none; font-size: 16px; }
.nb-wrong .nb-q { margin-top: 8px; font-size: 15px; font-weight: 600; line-height: 1.6; }
.nb-chosen { margin-top: 8px; display: grid; gap: 6px; }
.nb-chosen li { padding: 8px 12px; background: var(--warn-bg);  font-size: 14px; line-height: 1.6; }
.nb-chosen .mono { display: block; font-size: 11px; color: var(--warn); }
.nb-chosen b { display: block; }
.nb-chosen .why-t { color: var(--ink-2); font-size: 13.5px; }
.nb-wrong details { margin-top: 8px; font-size: 14px; }
.nb-wrong summary { cursor: pointer; color: var(--forest); font-weight: 600; }
.nb-wrong details p { margin-top: 6px; padding: 8px 12px; background: var(--right-bg);  line-height: 1.6; }
.nb-wrong.done { opacity: .6; }
.nb-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin-top: 16px; font-size: 14px; }
.nb-empty { margin-top: 24px; color: var(--ink-2); font-size: 15px; }
.nb-backup { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.nb-backup > div { padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.nb-backup h2 { font-size: 16px; }
.nb-backup p { margin: 6px 0 12px; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
@media (max-width: 760px) {
  .nb-backup { grid-template-columns: 1fr; }
  .nb-stats.nums.n4 { grid-template-columns: 1fr 1fr; }
  .nb-tabs a { padding: 9px 10px; font-size: 14px; }
  .nb-item { padding: 12px 14px; }
}

/* ───── 개념 지도 (graph.html) — 색은 --gv-* 변수, 라이트 테마에서 밝게 ───── */
.gv-body {
  --gv-bg: #1c1c1f; --gv-bg-2: #232327; --gv-panel: #222226; --gv-float: rgba(38,38,43,.92); --gv-pop: rgba(34,34,38,.97); --gv-line: #34343a;
  --gv-ink: #dcdce0; --gv-ink-strong: #ececf0; --gv-ink-max: #fff; --gv-ink-2: #b8b8c0; --gv-ink-3: #9a9aa3; --gv-ink-4: #7c7c85; --gv-accent-soft: #c4b5fd;
}
[data-theme="light"] .gv-body {
  --gv-bg: #f3f4ef; --gv-bg-2: #fbfbf8; --gv-panel: #fbfbf8; --gv-float: rgba(255,255,253,.94); --gv-pop: rgba(255,255,253,.98); --gv-line: #d6d8cf;
  --gv-ink: #2a2b27; --gv-ink-strong: #1c1d1a; --gv-ink-max: #111; --gv-ink-2: #4f514a; --gv-ink-3: #6c6e66; --gv-ink-4: #8a8c84; --gv-accent-soft: #6d4fd6;
}
.gv-body { overflow: hidden; background: var(--gv-bg); color: var(--gv-ink); }
.gv-body .top { background: var(--gv-bg); border-bottom-color: var(--gv-line); }
.gv-body .brand, .gv-body .brand-mark, .gv-body .crumbs, .gv-body .crumbs b, .gv-body .top-right { color: var(--gv-ink); }
.gv-body .crumbs span[aria-hidden], .gv-body .top-right a { color: var(--gv-ink-3); }
.gv-body .top-right a:hover { color: var(--gv-ink-max); }
.gv { position: relative; height: calc(100vh - 57px); height: calc(100dvh - 57px); display: flex; }
.gv-stage { position: relative; flex: 1; min-width: 0; background: radial-gradient(ellipse at 50% 45%, var(--gv-bg-2) 0%, var(--gv-bg) 70%); }
#gv-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#gv-canvas:active { cursor: grabbing; }
.gv-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.gv-top > * { pointer-events: auto; }
.gv-top input[type=search] { width: 260px; padding: 7px 12px; border: 1px solid var(--gv-line); background: var(--gv-float); color: var(--gv-ink-strong); border-radius: var(--r-sm); font-size: 14px; outline: none; }
.gv-top input[type=search]::placeholder { color: var(--gv-ink-4); }
.gv-top input[type=search]:focus { border-color: #a78bfa; }
.gv-btns { margin-left: auto; display: flex; gap: 6px; }
.gv-btns button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--gv-line); background: var(--gv-float); color: var(--gv-ink-2); border-radius: var(--r-sm); cursor: pointer; }
.gv-btns button:hover, .gv-btns button[aria-expanded="true"] { color: var(--gv-ink-max); border-color: #a78bfa; }
.gv-btns svg { width: 18px; height: 18px; }
.gv-top .gv-domain { margin-top: 0; width: 168px; flex: none; background: var(--gv-float); border-color: var(--gv-line); }
.gv-top .gv-domain button { padding: 7px 0; }
.gv-settings { position: absolute; top: 54px; right: 12px; width: 270px; max-height: calc(100% - 70px); overflow-y: auto; background: var(--gv-pop); border: 1px solid var(--gv-line); border-radius: var(--r-sm); padding: 6px 0; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 13px; }
.gv-settings details { border-bottom: 1px solid var(--gv-line); padding: 4px 14px 10px; }
.gv-settings details:last-child { border-bottom: 0; }
.gv-settings summary { cursor: pointer; padding: 8px 0 4px; color: var(--gv-ink-strong); font-weight: 600; list-style: none; }
.gv-settings summary::before { content: "›"; display: inline-block; width: 14px; color: var(--gv-ink-3); transition: transform .15s; }
.gv-settings details[open] summary::before { transform: rotate(90deg); }
.gv-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; color: var(--gv-ink-2); }
.gv-row.col { flex-direction: column; align-items: stretch; gap: 4px; }
.gv-row input[type=range] { width: 100%; accent-color: #a78bfa; }
.gv-row input[type=checkbox] { accent-color: #a78bfa; width: 16px; height: 16px; }
.gv-courses { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.gv-course-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--gv-line); border-radius: var(--r-sm); background: none; color: var(--gv-ink); font-size: 12px; cursor: pointer; }
.gv-course-chip i, .gv-groups i, .gv-chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.gv-course-chip[aria-pressed="false"] { opacity: .35; }
.gv-seg { display: flex; margin-top: 6px; border: 1px solid var(--gv-line); border-radius: var(--r-sm); overflow: hidden; }
.gv-seg button { flex: 1; padding: 5px 0; border: 0; background: none; color: var(--gv-ink-2); font-size: 12.5px; cursor: pointer; }
.gv-seg button[aria-pressed="true"] { background: #a78bfa; color: #16161a; font-weight: 600; }
.gv-groups { margin-top: 8px; display: grid; gap: 4px; color: var(--gv-ink-2); }
.gv-groups li { display: flex; gap: 8px; align-items: center; }
.gv-groups i.ring { background: none; border: 2px solid var(--gv-ink-max); width: 9px; height: 9px; }
.gv-reset { margin-top: 8px; padding: 5px 10px; border: 1px solid var(--gv-line); background: none; color: var(--gv-ink-2); border-radius: var(--r-sm); cursor: pointer; font-size: 12px; }
.gv-reset:hover { color: var(--gv-ink-max); border-color: #a78bfa; }
.gv-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 6px 14px; border-radius: var(--r-sm); background: var(--gv-float); color: var(--gv-ink-3); font-size: 12.5px; white-space: nowrap; transition: opacity .6s; pointer-events: none; }
.gv-hint.off { opacity: 0; }
.gv-panel { position: relative; width: 370px; flex: none; overflow-y: auto; border-left: 1px solid var(--gv-line); background: var(--gv-panel); padding: 18px 20px 30px; color: var(--gv-ink); }
.gv-close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--gv-ink-3); cursor: pointer; }
.gv-close:hover { color: var(--gv-ink-max); }
.gv-panel h2 { font-size: 22px; letter-spacing: -.03em; margin-top: 4px; padding-right: 24px; color: var(--gv-ink-strong); }
.gv-panel h3 { margin-top: 18px; font-size: 12.5px; color: var(--gv-ink-3); font-weight: 600; }
.gv-course { font-size: 11.5px; }
.gv-prog { margin-top: 6px; font-size: 13.5px; color: var(--gv-ink-2); }
.gv-prog b { color: var(--gv-ink-max); } .gv-prog .bad { color: #ff7b73; }
.gv-local { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 13px; color: var(--gv-ink-2); padding: 8px 10px; background: var(--gv-bg); border-radius: var(--r-sm); }
.gv-local input { accent-color: #a78bfa; vertical-align: middle; }
.gv-local input[type=range] { width: 70px; }
.gv-blocks { margin-top: 10px; display: grid; }
.gv-blocks li { display: grid; grid-template-columns: 34px 1fr; gap: 0 4px; font-size: 14px; line-height: 1.45; padding: 8px 0; border-top: 1px solid var(--gv-line); }
.gv-blocks .bd { grid-row: 1; font-size: 12px; }
.gv-blocks li > a { grid-column: 2; grid-row: 1; text-decoration: none; font-weight: 600; color: var(--gv-ink-strong); }
.gv-blocks li > a:hover { color: var(--gv-accent-soft); }
.gv-secs li { grid-template-columns: 1fr auto; }
.gv-secs li > a { grid-column: 1; }
.gv-secs li > .mono { grid-column: 2; grid-row: 1; color: var(--gv-ink-3); font-size: 12px; }
.gv-blocks li .mono { grid-column: 2; font-size: 11px; color: var(--gv-ink-4); }
.gv-blocks .ok { color: #8fd16f; } .gv-blocks .no { color: var(--gv-ink-4); } .gv-blocks .bad { color: #ff7b73; } .gv-blocks .memo { color: #e0b400; font-size: 9px; }
.gv-blocks .k { font-family: var(--f-mono); font-size: 11px; font-weight: 400; color: #a78bfa; margin-right: 5px; }
.gv-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.gv-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--gv-line); border-radius: var(--r-sm); background: var(--gv-bg); color: var(--gv-ink); font-size: 13px; cursor: pointer; }
.gv-chip:hover { border-color: #a78bfa; color: var(--gv-ink-max); }
.gv-none { margin-top: 6px; font-size: 12.5px; color: var(--gv-ink-4); }
.gv-path { margin-top: 18px; padding: 8px 14px; border: 1px solid #a78bfa; border-radius: var(--r-sm); background: none; color: var(--gv-accent-soft); font-weight: 600; font-size: 13.5px; cursor: pointer; }
.gv-path:hover { background: #a78bfa; color: #16161a; }
.gv-steps { margin-top: 10px; display: grid; gap: 4px; counter-reset: st; }
.gv-steps li { counter-increment: st; display: flex; gap: 8px; align-items: center; }
.gv-steps li::before { content: counter(st); font-family: var(--f-mono); font-size: 11px; color: var(--gv-ink-4); width: 18px; text-align: right; }
@media (max-width: 760px) {
  .gv-panel { position: absolute; left: 0; right: 0; bottom: 0; width: auto; max-height: 58%; border-left: 0; border-top: 1px solid var(--gv-line); box-shadow: 0 -8px 24px rgba(0,0,0,.4); z-index: 6; border-radius: var(--r-sm) 2px 0 0; }
  .gv-top input[type=search] { width: auto; flex: 1; min-width: 0; }
  .gv-btns { margin-left: 0; }
  .gv-settings { left: 12px; width: auto; }
  .gv-hint { font-size: 11.5px; white-space: normal; width: calc(100% - 40px); text-align: center; border-radius: var(--r-sm); }
}
.gv-groups i.sh { background: var(--gv-ink-2); border-radius: 0; }
.gv-groups i.sh.dot { border-radius: 50%; }
.gv-groups i.sh.sq { width: 8px; height: 8px; }
.gv-groups i.sh.tri { width: 0; height: 0; background: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--gv-ink-2); }
.gv-groups i.sh.course { border-radius: 50%; width: 12px; height: 12px; background: var(--gv-ink-2); box-shadow: 0 0 0 2px var(--gv-ink-max) inset; }
.gv-groups i.sh.hub { background: none; border: 2px solid var(--gv-ink-2); border-radius: 50%; width: 9px; height: 9px; }
.gv-chip i.hubdot { background: none; border: 2px solid; width: 9px; height: 9px; }
.gv-open { display: inline-block; margin-top: 12px; padding: 7px 14px; border-radius: var(--r-sm); background: #a78bfa; color: #16161a; font-weight: 700; font-size: 14px; text-decoration: none; }
.gv-open:hover { background: var(--gv-accent-soft); }

/* ───── 메인: 과목 체계도 ───── */
.tree { padding: 0; }
.tree-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 16px; margin-bottom: 18px; }
.tree-head h2 { font-size: clamp(20px, 2.2vw, 26px); font-weight: 800; letter-spacing: -.03em; margin: 0; }
/* 교과 색은 구역만 나타낸다(색인 탭, 카드 윗변, 점). 상태(본 것·멈춘 곳)는 색이 아니라 표시로 */
[data-track="phy"] { --tc: #4f7fd6; }
[data-track="chem"] { --tc: #8a5fd0; }
[data-track="bio"] { --tc: #d0702f; }
[data-track="earth"] { --tc: #9a7748; }
[data-track="common"] { --tc: var(--forest); }
[data-track="fusion"] { --tc: #c0587e; }
[data-track="math"] { --tc: #c98a12; }
/* 수학은 분야마다: 공통(황토) · 대수(남색) · 미적분(청록) · 기하(자주) · 확률과 통계(주홍) · 활용(올리브) */
[data-track="math"][data-mf="alg"] { --tc: #4f62d6; }
[data-track="math"][data-mf="calc"] { --tc: #1f8f78; }
[data-track="math"][data-mf="geo"] { --tc: #b0479b; }
[data-track="math"][data-mf="stat"] { --tc: #d2553a; }
[data-track="math"][data-mf="app"] { --tc: #7d8a2e; }
.tree-math > div { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: start; gap: 12px; }
.m-col { display: flex; flex-direction: column; gap: 8px; }
.m-col h3 { margin: 0; padding-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--tc); }
.tree-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 14px 0; }
.tree-col { position: relative; display: flex; flex-direction: column; gap: 10px; }
.tree-col::before { content: ""; position: absolute; left: 50%; top: -14px; bottom: -14px; width: 2px; background: var(--tc); opacity: .35; z-index: 0; }
.tree-col h3 { position: relative; margin: 0; padding: 4px 0; text-align: center; font-size: 15px; font-weight: 800; color: var(--ink); background: var(--paper); }
.tbox { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 2px; padding: 11px 13px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(35, 35, 38, .04); text-decoration: none; color: var(--ink); transition: transform 160ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 150ms ease; }
.tbox b { display: flex; align-items: center; gap: 7px; }
.tbox b::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--tc); }
.tbox:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) { .tbox:hover { border-color: var(--line-strong); box-shadow: var(--lift); } }
.tbox .lv { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-3); }

.tbox b { font-size: 15px; letter-spacing: -.02em; line-height: 1.35; }
.tbox .pg { font-size: 11.5px; color: var(--ink-2); }
.tbox.soon { background: transparent; border-style: dashed; border-color: var(--line-strong); box-shadow: none; }
.tbox.soon b::before { background: none; border: 1.5px solid var(--tc); }
.tree-head { align-items: center; justify-content: flex-start; }
.tree:not(.open) .tree-body, .tree:not(.open) .tree-note, .tree:not(.open) .scope-seg { display: none; }
/* 보기 범위: 기본(일반·진로선택) / 전체(융합선택·과학계열까지). 열 수는 여기서 정한다(인라인으로 두면 숨겨도 폭이 남음) */
.scope-seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); }
.scope-seg button { font: inherit; font-size: 13px; font-weight: 600; min-height: 32px; padding: 0 14px; background: transparent; border: 0; border-radius: calc(var(--r) - 3px); color: var(--ink-2); cursor: pointer; transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out); }
.scope-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.scope-seg button:active { transform: scale(.97); }
.tree-head .tree-note { flex: 1; min-width: 16em; margin: 0; color: var(--ink-2); }
body[data-scope="basic"] .mx [data-lv="고급"], body[data-scope="basic"] .mx [data-lv="실험"], body[data-scope="basic"] .mx [data-lv="융합"],
body[data-scope="basic"] section.course[data-adv], body[data-scope="basic"] .mx-row[data-adv], body[data-scope="basic"] .for-all, body[data-scope="all"] .for-basic { display: none; }
.sci-mx { --cols: 5; }
body[data-scope="basic"] .sci-mx { --cols: 4; }
body[data-scope="basic"] .sci-mx [data-tk="fusion"] { display: none; }   /* 교과 공통 열은 융합선택·과학계열 과목만 있다 */
/* 과학 표(열 = 교과): 열 제목은 교과 색, 행 이름은 선택 구분 */
.mx-h.mx-tk { color: var(--ink); border-bottom: 2px solid var(--tc); font-size: 14px; font-weight: 800; }
.mx-lb.mx-lv { flex-direction: column; align-items: flex-start; justify-content: center; color: var(--ink); border-left-color: var(--rule); font-size: 13px; line-height: 1.3; }
.mx-lb.mx-lv small { font-size: 11px; font-weight: 400; color: var(--ink-3); }
.tree:not(.open) { padding-bottom: 20px; }
.tree:not(.open) .tree-head { margin-bottom: 0; }
/* 선택 과목 표: 행 = 교과(과학)·영역(수학), 열 = 선택 구분(일반·진로·융합선택은 나란히, 과학계열은 오른쪽) */
.mx-arrow { text-align: center; margin: 10px 0 6px; }
.mx { display: grid; gap: 6px; }
.mx-row { display: grid; grid-template-columns: 86px repeat(var(--cols, 5), minmax(0, 1fr)); gap: 8px; align-items: stretch; }
.mx-head { align-items: end; }
.mx-h { font-size: 12.5px; font-weight: 700; color: var(--ink); padding: 0 2px 6px; border-bottom: 1px solid var(--line-strong); line-height: 1.3; }
.mx-h small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.mx-lb { display: flex; align-items: center; font-size: 14px; font-weight: 800; color: var(--ink); padding-left: 8px; }
.mx-cell { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mx-cell.empty { background: none; }
.mx .tbox { padding: 8px 10px 9px; }
.mx .tbox b { font-size: 14px; }
/* 수학 표: 행 = 선택 구분, 과목 상자는 같은 폭으로 옆으로 늘어놓는다 */
.mx .mx-row.mx-flowrow { grid-template-columns: 120px minmax(0, 1fr); }
.tree-sci .mx .mx-row.mx-flowrow { grid-template-columns: 86px minmax(0, 1fr); }   /* 과학의 공통 행: 아래 선택 과목 표의 행 이름 칸과 같은 폭 */
.mx-cell.mx-flow { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 220px)); gap: 8px; padding: 8px 0; }
body[data-domain="math"] .tree-sci, body[data-domain="sci"] .tree-mth,
body[data-domain="math"] .for-sci, body[data-domain="sci"] .for-math { display: none; }
@media (max-width: 860px) {
  .mx-head { display: none; }
  .mx-row { grid-template-columns: 1fr; gap: 6px; padding: 10px 0 14px; border-bottom: 1px solid var(--rule); }
  .mx-lb { padding: 2px 0 2px 8px; }
  .mx-cell { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 6px 8px; align-items: start; border: 0; padding: 0; }
  .mx-cell > .tbox { grid-column: 2; }
  .mx .mx-row.mx-flowrow { grid-template-columns: 1fr; }
  .mx-cell.mx-flow { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .mx-cell.mx-flow > .tbox { grid-column: auto; }
  .mx-cell.mx-flow::before { content: none; }
  .mx-cell.empty { display: none; }
  .mx-cell::before { content: attr(data-col); grid-column: 1; grid-row: 1 / span 4; font-size: 11.5px; color: var(--ink-3); padding-top: 9px; }
}
/* 학습률 막대: 상자 안쪽에 얇게(테두리가 아니라 내용의 일부) */
.lp { display: block; height: 4px; margin-top: 8px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.lp i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); border-radius: 999px; background: var(--ink-2); }   /* 진도는 교과 색이 아니라 잉크로 */
.course-head .learn { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 6px; max-width: 200px; margin-top: 8px; color: var(--ink-2); }
.course-head .learn .lp { flex-basis: 100%; margin-top: 0; }

body[data-domain="math"] #chips .chip { display: none; }
.tbox.soon b { color: var(--ink-2); }
.tbox.soon .pg { color: var(--ink-3); }
@media (max-width: 640px) {
  .tree-cols { grid-template-columns: repeat(2, 1fr); row-gap: 22px; }
  .tbox { padding: 8px 10px 11px; }
  .tbox b { font-size: 14px; }
}

/* 실험 카드: NMLab 기록 표 */
.lab-tbl { max-height: 190px; overflow: auto; margin: 8px 0; border: 1px solid var(--rule); background: var(--card); }
.lab-tbl table { width: 100%; border-collapse: collapse; font-family: var(--f-mono); font-size: 12px; }
.lab-tbl th { position: sticky; top: 0; background: var(--paper-2); color: var(--ink-2); font-weight: 500; text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--rule); }
.lab-tbl td { text-align: right; padding: 3px 8px; border-bottom: 1px solid var(--grid); }
.lab-tbl th:first-child, .lab-tbl td:first-child { text-align: left; color: var(--ink-3); width: 2.5em; }
.lab-tbl td.lab-empty { text-align: center; color: var(--ink-3); padding: 10px; }
.lab-del { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.lab-del:hover { color: var(--warn); }
.cv-plot { width: 100%; aspect-ratio: 16 / 10; margin-top: 6px; display: block; }
.lab-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.lab-btns .chip.go { background: var(--forest); border-color: var(--forest); color: var(--on-accent); }
.lab-btns .chip.go:hover { background: var(--ink); border-color: var(--ink); }
.verdict { margin-top: 8px; padding: 8px 10px; background: var(--paper-2); border-radius: var(--r-sm); }
.verdict.good {  color: var(--forest); }
.verdict.bad { }
#card-is1-new-unit .nu-pick .presets { margin: 4px 0; }
#card-is1-new-unit .nu-out { margin: 12px 0 4px; padding: 14px 16px; background: var(--paper-2);  }
#card-is1-new-unit .nu-unit { font-size: 26px; font-weight: 600; color: var(--ink); }
#card-is1-new-unit .nu-si { color: var(--ink-2); margin-top: 2px; }
#card-is1-new-unit .nu-name { margin-top: 8px; }
#card-is1-new-unit .nu-ex { color: var(--ink-2); }
.ext-tbl td b.good { color: var(--forest); } .ext-tbl td b.bad { color: var(--warn); }
.ext-tbl { max-height: none; }
.ext-tbl td { vertical-align: top; padding: 6px 8px; }
.ext-tbl td .dim { font-family: var(--f-kr); font-size: 11.5px; color: var(--ink-3); }
.ext-tbl th:first-child, .ext-tbl td:first-child { width: auto; color: var(--ink); text-align: left; }
.ext-tbl th:not(:first-child), .ext-tbl td:not(:first-child) { width: 4.2em; text-align: center; }
#card-is2-acid-plate .cls { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 10px; margin-top: 6px; }
#card-is2-acid-plate .cls .presets { margin: 2px 0; }
.verdict:empty { display: none; }

/* 증명 조립 (js/lib/proof.js NMProof): 위 = 쌓은 증명, 아래 = 남은 단계 */
.pf { margin: 8px 0 4px; }
.pf-built { counter-reset: pf; margin: 0 0 8px; padding: 0; list-style: none; min-height: 34px; border: 1px dashed var(--rule); background: var(--paper-2); }
.pf-built:empty::before { content: "아래에서 첫 단계를 고르세요"; display: block; padding: 8px 10px; font-size: 12.5px; color: var(--ink-3); }
.pf-built li { counter-increment: pf; position: relative; padding: 6px 10px 6px 34px; font-size: 13.5px; line-height: 1.55; border-bottom: 1px solid var(--rule); background: var(--card); }
.pf-built li::before { content: counter(pf); position: absolute; left: 10px; top: 6px; font-family: var(--f-mono); font-size: 11.5px; color: var(--forest); }
.pf-pool { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pf-pool li { padding: 7px 10px; font-size: 13.5px; line-height: 1.55; border: 1px solid var(--rule); background: var(--card); cursor: pointer; }
.pf-pool li:hover, .pf-pool li:focus-visible { border-color: var(--ink); outline: none; }
.pf-pool li.pf-no { border-color: var(--warn); }
.pf-why { display: none; }
.pf-pool li.pf-show .pf-why { display: block; margin-top: 4px; font-size: 12.5px; color: var(--warn); }
.pf-built .pf-why { display: none; }
.pf-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; font-size: 12.5px; }
.pf-bar .pf-reset { margin-left: auto; }
.pf-msg.good { color: var(--forest); font-weight: 600; }
.pf-msg.bad { color: var(--warn); }
.pf.pf-done .pf-built { border-style: solid; border-color: var(--forest); }

/* 반복 시행 (js/lib/sim.js NMSim) */
.sim-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.sim-btns .chip.go { background: var(--forest); border-color: var(--forest); color: var(--on-accent); }
.sim-btns .chip.go:hover { background: var(--ink); border-color: var(--ink); }

/* 오류 찾기 (NMPm.spot): 풀이 줄을 눌러 처음 틀린 곳을 찾는다 */
.spot { counter-reset: sp; margin: 8px 0 4px; padding: 0; list-style: none; border: 1px solid var(--rule); background: var(--card); }
.spot > li { counter-increment: sp; position: relative; padding: 7px 10px 7px 34px; font-size: 13.5px; line-height: 1.6; border-bottom: 1px solid var(--rule); cursor: pointer; }
.spot > li:last-child { border-bottom: 0; }
.spot > li::before { content: counter(sp); position: absolute; left: 11px; top: 7px; font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); }
.spot > li:hover, .spot > li:focus-visible { background: var(--paper-2); outline: none; }
.spot > li .why { display: none; }
.spot > li.sp-show .why { display: block; margin-top: 4px; font-size: 12.5px; }
.spot > li.sp-miss { background: var(--paper-2); }
.spot > li.sp-miss .why { color: var(--ink-2); }
.spot > li.sp-hit {  background: var(--warn-bg, var(--paper-2)); }
.spot > li.sp-hit .why { color: var(--warn); }
.spot[data-done] > li { cursor: default; }

/* 행렬 표 (고급 대수 NMLin.table) */
.lin-m { border-collapse: collapse; margin: 6px 0; font-family: var(--f-mono); font-size: 13.5px; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); }
.lin-m td { padding: 3px 10px; text-align: right; min-width: 2.6em; }
.lin-m td.bar { border-left: 1px dashed var(--ink3, var(--ink-3)); }
.lin-m tr.hi td { background: var(--paper-2); color: var(--forest); font-weight: 600; }

/* 예측 → 확인 카드: 정답을 열기 전에는 결과 칸을 흐리게 */
.predict-lock { opacity: .35; pointer-events: none; }

/* ═════════ 다크 모드 — <html data-theme="dark"> (head의 짧은 스크립트가 정하고 js/core.js가 버튼을 잇는다) ═════════ */
.theme-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; margin-left: 14px; padding: 0;
  vertical-align: middle; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: none; color: inherit;
}
.theme-btn { transition: transform 160ms var(--ease-out), border-color 150ms ease; }
.theme-btn:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) { .theme-btn:hover { border-color: var(--ink-3); } }
.theme-btn svg { width: 15px; height: 15px; }
.theme-btn .sun, [data-theme="dark"] .theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: block; }
.gv-body .theme-btn { border-color: var(--gv-line); }
/* 좁은 폰: 링크가 세 개인 절·과목 페이지는 상단바에 버튼까지 들어가지 않아 글자 로고를 숨기고 마크만 둔다 */
@media (max-width: 420px) {
  .top-right a + a, .theme-btn { margin-left: 10px; }
  body[data-sec] .brand, body[data-view="course"] .brand { font-size: 0; gap: 0; }
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ececee;
  --ink-2: #a5a8ae;
  --ink-3: #8d9097;
  --rule: #2e3034;
  --grid: rgba(230, 230, 226, .07);
  --paper: #0f1011;
  --paper-2: #1b1c1f;
  --card: #1f2023;
  --leaf: #86bf76;
  --forest: #8cc67a;
  --sprout: #9ccc8f;
  --warn: #e8896b;
  --warn-bg: #35241e;
  --night: #0e0f0e;
  --top-bg: rgba(15, 16, 17, .82);
  --raised: #222327;
  --right-bg: #213021;
  --hl: #6e5c16;
  --memo-bg: #25241d;
  --memo-rule: #a88d2c;
  --fig-bg: #e0dfdc;   /* 뒤집으면 카드 색(#1f2023)에 가깝다 */
  --on-accent: #17181a;
  --surface: #17181a;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .15);
  --lift: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px -8px rgba(0, 0, 0, .5);
  --lift-hi: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -12px rgba(0, 0, 0, .65);
}
[data-theme="dark"] [data-track="phy"] { --tc: #7fa6ea; }
[data-theme="dark"] [data-track="chem"] { --tc: #b08ee6; }
[data-theme="dark"] [data-track="bio"] { --tc: #e8955c; }
[data-theme="dark"] [data-track="earth"] { --tc: #c4a172; }
[data-theme="dark"] [data-track="fusion"] { --tc: #e083a6; }
[data-theme="dark"] [data-track="math"] { --tc: #e0aa3e; }
[data-theme="dark"] [data-track="math"][data-mf="alg"] { --tc: #8e9cf0; }
[data-theme="dark"] [data-track="math"][data-mf="calc"] { --tc: #5cc6ad; }
[data-theme="dark"] [data-track="math"][data-mf="geo"] { --tc: #df84cc; }
[data-theme="dark"] [data-track="math"][data-mf="stat"] { --tc: #ef8a6f; }
[data-theme="dark"] [data-track="math"][data-mf="app"] { --tc: #b6c45a; }

/* 카드 그림: 카드 스크립트는 밝은 종이 색으로 그리므로 밝기만 뒤집고 색상은 되돌린다.
   사진(img), 개념 지도(#gv-canvas), 영상(.video-block — 이미 어두운 화면으로 그린다)은 그대로. */
[data-theme="dark"] .card canvas:not(.no-invert, .no-invert *) { filter: invert(1) hue-rotate(180deg); }
[data-theme="dark"] .reading-body figure svg:not(.no-invert, .no-invert *) { filter: invert(.9) hue-rotate(180deg); }   /* 흰 바탕이 완전한 검정이 되지 않게 */

/* 블록 <style>에 적힌 밝은 배경 */
[data-theme="dark"] :is(#related-photo a, #card-is1-mutation .cod, #card-info-printer .pri, #card-info-graphrep .mc, #card-info-bracket .expr) { background: var(--raised); }
[data-theme="dark"] :is(#card-is1-halogen .grid3 button.yes, #card-is1-enzyme-fit .fit-grid td.y, #card-is2-ethics .eth-table .win, #card-is2-ethics select[data-v="1"]) { background: var(--right-bg); }
[data-theme="dark"] .card:is(#card-info-bst, #card-info-sort, #card-info-queens, #card-info-maze, #card-info-power, #card-info-space, #card-info-hanoi, #card-info-bnb, #card-info-dp-knapsack, #card-info-dp-memo, #card-info-unit-test, #card-info-fibtree, #card-info-printer, #card-info-treerep, #card-info-graphrep, #card-info-sq, #card-info-callstack, #card-info-bracket, #card-info-scope) :is(.ln.on, .l.on),
[data-theme="dark"] #card-is2-ethics select[data-v="2"] { background: rgba(140, 198, 122, .22); }
[data-theme="dark"] :is(#card-info-bigo-count pre.code .l.on, #card-info-git-merge pre.code .l.b, #text-info-dp-dc .lcs td.p, #card-resr-abstract .ab-s.miss, #card-bio-seq-tree .aln .sq i.d) { background: rgba(224, 160, 42, .26); }
[data-theme="dark"] #card-info-git-merge pre.code .l.a { background: rgba(127, 166, 234, .22); }
[data-theme="dark"] :is(#card-is2-ethics select[data-v="-1"], #card-resr-abstract .ab-s[aria-pressed="true"], #card-resr-abstract .ab-s.hit) { background: var(--warn-bg); }
[data-theme="dark"] #card-is2-ethics select[data-v="-2"] { background: #4a2c22; }

/* ───── 연습문제 (practice.html, 절 끝 버튼) ───── */
.px-go { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 14px; margin: 28px 0 8px; padding: 16px 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; }
.px-go:hover { border-color: var(--forest); }
.px-go .mono { color: var(--forest); }
.px-go b { font-size: 16px; }
.px-go .px-n { color: var(--ink-3); }
.px-go + .px-go { margin-top: 8px; }
.toc-px + .toc-px { margin-top: 8px; }
/* ───── 연습 시험 (bank.html, js/bank.js): AI 출제 연습 문항 ───── */
.px-text pre.code, .nb-exam-text pre.code { margin: 8px 0; padding: 10px 14px; background: var(--paper-2); border: 1px solid var(--rule); font: 14px/1.6 var(--f-mono); white-space: pre; overflow-x: auto; }
.px-text code, .px-opt code, .nb-exam-text code { font-family: var(--f-mono); font-size: .92em; }
.bk-ai { display: inline-block; margin-right: 6px; padding: 1px 8px; border: 1px solid var(--forest); border-radius: var(--r-sm); color: var(--forest); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.bk-range { padding: 22px 0 8px; border-bottom: 1px solid var(--rule); }
.bk-range h2 { font-size: 21px; letter-spacing: -.02em; }
.bk-range h2 .mono { font-size: 13px; font-weight: 400; margin-left: 6px; }
.bk-range > p { margin: 4px 0 12px; }
.bk-sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.bk-sheet { display: grid; gap: 3px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink); }
.bk-sheet:hover { border-color: var(--forest); }
.bk-sheet.rand { border-left-color: var(--ink-3); }
.bk-sheet .mono { font-size: 12px; }
.bk-sheet .ok { color: var(--forest); }
.bk-ch { margin: 14px 0 6px; font-size: 15px; }
.bk-secs { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.bk-secs li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 5px 0; border-bottom: 1px dashed var(--rule); font-size: 14.5px; }
.bk-item header .bk-no { font-weight: 700; font-size: 17px; min-width: 1.6em; }
.px-opt.sel { border-color: var(--ink); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--ink); }
.px-opt:disabled { cursor: default; }
.bk-sol { margin-top: 10px; padding: 10px 14px; background: var(--paper-2); border: 1px solid var(--rule); font-size: 14.5px; line-height: 1.75; max-width: 760px; }
.bk-sol > b { display: block; color: var(--forest); font-size: 13px; margin-bottom: 2px; }
.bk-sol p + p { margin-top: 4px; }
.bk-submit { display: flex; align-items: center; gap: 14px; padding: 8px 0 18px; }
.bk-score { margin: 0 0 18px; padding: 16px 20px; background: var(--card); border: 1px solid var(--forest); border-radius: var(--r); display: grid; gap: 4px; }
.bk-score > b { font-size: 26px; }
.bk-nav { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 30px; }
/* 난이도 표시와 고르기 */
.bk-lv { display: inline-block; padding: 0 7px; border: 1px solid var(--rule); border-radius: var(--r-sm); font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.bk-lv.lv-응용 { border-color: var(--leaf); color: var(--forest); }
.bk-lv.lv-심화 { border-color: var(--warn); color: var(--warn); }
.bk-lvrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 10px 0 4px; }
.bk-lvs { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.bk-lvs a { padding: 2px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); font-size: 13px; text-decoration: none; color: var(--ink); background: var(--card); }
.bk-lvs a:hover, .bk-lvs a[aria-current] { border-color: var(--forest); color: var(--forest); }
/* 서술형: 답안 칸, 힌트, 자기 채점 기준 */
.bk-free { display: grid; gap: 8px; max-width: 760px; margin-top: 8px; }
.bk-free textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; font: inherit; font-size: 15px; line-height: 1.7; color: var(--ink); background: var(--raised); border: 1px solid var(--rule); resize: vertical; }
.bk-free textarea:focus { outline: 2px solid var(--leaf); outline-offset: 1px; }
.bk-free .btn { justify-self: start; }
.bk-hint { margin: 8px 0 0; max-width: 760px; font-size: 14px; }
.bk-hint summary { cursor: pointer; color: var(--forest); font-weight: 600; font-size: 13.5px; }
.bk-hint p { margin: 4px 0 0 2px; color: var(--ink-2); }
.bk-rub { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--rule); display: grid; gap: 4px; }
.bk-rub > b { color: var(--forest); font-size: 13px; }
.bk-rub label { display: flex; align-items: baseline; gap: 8px; cursor: pointer; }
.bk-rub label span:nth-of-type(1) { flex: 1; }
.bk-rub input { accent-color: var(--forest); }
.bk-self b { font-size: 16px; color: var(--forest); }
.cx-bank { display: grid; gap: 2px; margin-top: 10px; padding: 10px 14px; border: 1px solid var(--forest); border-radius: var(--r-sm); color: var(--ink); text-decoration: none; line-height: 1.4; }
.cx-bank:hover { background: var(--paper-2); }
.cx-bank b { color: var(--forest); font-size: 14px; }
.cx-bank span { font-size: 12px; }
.px-head { padding: 32px 0 12px; display: grid; gap: 8px; }
.px-head h1 { font-size: clamp(26px, 4vw, 38px); letter-spacing: -.03em; line-height: 1.2; }
.px-head h1 em { font-style: normal; color: var(--forest); }
.px-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 18px; border-bottom: 1px solid var(--rule); }
.px-list { display: grid; gap: 18px; padding: 20px 0 40px; }
.px-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px 16px; scroll-margin-top: 72px; }
.px-item.bad { }
.px-item.ok { }
/* 텍스트로 옮겨 쓴 기출(practice.js textBody, notebook.js examText) */
.px-text { color: var(--ink); margin: 10px 0 14px; font-size: 15.5px; line-height: 1.8; max-width: 760px; }
.px-shared { margin-bottom: 12px; padding: 10px 14px; background: var(--paper-2); border: 1px solid var(--rule); }
.px-stem p + p, .px-shared p + p { margin-top: 6px; }
.px-text .box, .nb-exam-text .box { margin: 10px 0; padding: 10px 14px; border: 1px solid var(--ink-3); }
.px-text ol.gana, .nb-exam-text ol.gana { margin: 8px 0; padding: 10px 14px; list-style: none; border: 1px solid var(--ink-3); }
.px-text table, .nb-exam-text table { margin: 10px 0; border-collapse: collapse; font-size: 14px; }
.px-text td, .px-text th, .nb-exam-text td, .nb-exam-text th { padding: 4px 10px; border: 1px solid var(--rule); text-align: center; }
.px-figimg { margin: 12px 0; }
.px-figimg img { display: block; max-width: min(100%, 520px); height: auto; }
[data-theme="dark"] .px-figimg img { filter: invert(.88) hue-rotate(180deg); }
.px-opts.long { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.px-opts.long .px-opt { display: flex; align-items: baseline; gap: 8px; width: auto; height: auto; min-height: 40px; padding: 6px 12px; font-size: 15.5px; text-align: left; }
.px-opts.long .px-opt .n { flex: none; }
.px-opts.long .px-opt .c { min-width: 0; overflow-wrap: anywhere; }
.nb-exam-text { margin: 8px 0; font-size: 15px; line-height: 1.75; }
.nb-choices { margin-top: 6px; padding-left: 0; list-style: none; counter-reset: ch; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.nb-choices li { counter-increment: ch; }
.nb-choices li::before { content: counter(ch, decimal) ". "; color: var(--ink-3); font-size: 13px; }
@media (max-width: 640px) { .px-opts.long { grid-template-columns: 1fr; } }
.px-item header { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; margin-bottom: 10px; }
.px-prev { margin-left: auto; }
.px-prev.bad { color: var(--warn); }
.px-prev.ok { color: var(--forest); }
.px-fig { margin: 0 0 12px; background: #fff; border: 1px solid var(--rule); max-width: 760px; }
.px-fig img { display: block; width: 100%; height: auto; }
[data-theme="dark"] .px-fig img, [data-theme="dark"] .nb-exam { filter: invert(.88) hue-rotate(180deg); }
[data-theme="dark"] .px-fig { background: #1f2023; }
.px-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.px-opt { min-width: 52px; padding: 8px 14px; font-size: 18px; background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r-sm); color: var(--ink); }
.px-opt:hover { border-color: var(--ink); }
.px-opt.right { border-color: var(--forest); background: var(--right-bg); }
.px-opt.wrong { border-color: var(--warn); background: var(--warn-bg); }
.px-short { display: flex; gap: 8px; }
.px-short input { width: 140px; padding: 8px 12px; border: 1px solid var(--rule); background: var(--raised); color: var(--ink); border-radius: var(--r-sm); font-size: 16px; }
.px-result { margin-top: 10px; font-size: 14.5px; color: var(--ink-2); min-height: 1em; }
.px-empty { padding: 40px 0; color: var(--ink-3); }
.nb-exam { display: block; max-width: 560px; width: 100%; margin: 8px 0; border: 1px solid var(--rule); background: #fff; }
@media (max-width: 640px) {
  .px-go { grid-template-columns: 1fr; gap: 4px; }
  .px-item { padding: 12px; }
  .px-opt { min-width: 44px; padding: 7px 10px; }
}

/* ═════════ 카드: 그림은 화면에 고정, 글은 여섯 단계를 한 단계씩 펼친다 (js/reader.js) ═════════ */
@media (min-width: 1001px) {
  .card-body { align-items: start; }
  .card-fig { position: sticky; top: 64px; }
  .card.is-max .card-fig { top: 0; }
  .card-body > .steps-col { border-left: 1px solid var(--rule); margin-left: -1px; }
}
.steps-mode { display: flex; justify-content: flex-end; gap: 4px; padding: 8px 14px 0; }
.steps-mode button { font: inherit; font-size: 11.5px; padding: 2px 9px; color: var(--ink-3); background: none; border: 1px solid var(--rule); border-radius: var(--r-sm); cursor: pointer; }
.steps-mode button[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.step-tg { position: absolute; left: 22px; top: 12px; padding: 2px 0; font: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
.step-tg .tag { position: static; }
.steps-fold li:not(.open) { cursor: pointer; }
.steps-fold li:not(.open):hover { background: color-mix(in srgb, var(--forest) 5%, transparent); }
.steps-fold li:not(.open) .step-body { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-3); }
.steps-fold li:not(.open) .step-body .katex-display { display: inline; margin: 0; }
.step-arrow { display: none; position: absolute; right: 8px; top: 9px; width: 26px; height: 26px; padding: 6px; color: var(--ink-3); background: none; border: 0; border-radius: var(--r-sm); cursor: pointer; }
.step-arrow svg { display: block; width: 14px; height: 14px; transition: transform .15s; }
.step-arrow:hover { color: var(--forest); background: color-mix(in srgb, var(--forest) 8%, transparent); }
.steps-fold .step-arrow { display: block; }
.steps-fold li { padding-right: 40px; }
.steps-fold li:not(.open) .step-arrow svg { transform: rotate(-90deg); }
@media (max-width: 640px) { .step-tg { position: static; display: block; margin-bottom: 1px; } }
@media print { .steps-fold li .step-body { display: block !important; -webkit-line-clamp: none !important; color: inherit !important; } .step-arrow, .steps-mode { display: none !important; } }
/* ═════════ 이용권 잠금 (js/pass.js) — html[data-locked]이면 본문 대신 안내를 보인다 ═════════ */
html[data-locked] body[data-sec] .topic-layout, html[data-locked] body:not([data-sec]) main > :not(.lock) { display: none; }
.lock { max-width: 640px; margin: 8px 0 72px; padding: clamp(24px, 4vw, 36px); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--lift); }
body:not([data-sec]) .lock { margin-top: clamp(32px, 6vw, 72px); }
.lock-ic { display: grid; place-items: center; width: 46px; height: 46px; color: var(--forest); background: color-mix(in srgb, var(--forest) 11%, transparent); border-radius: 50%; }
.lock-ic svg { width: 24px; height: 24px; }
.lock h2 { margin-top: 16px; font-size: clamp(20px, 2.2vw, 24px); font-weight: 700; letter-spacing: -.03em; }
.lock > p { margin-top: 8px; font-size: 15px; line-height: 1.7; color: var(--ink-2); }
.lock-go { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.lock-go .btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 11px; font-weight: 700; }
.lock-go .btn:first-child { color: #fff; background: var(--forest); border-color: var(--forest); }
[data-theme="dark"] .lock-go .btn:first-child { color: #10200d; }
.lock .lock-more { margin-top: 16px; font-size: 13.5px; }
.lock .lock-more a { color: var(--ink-2); }
