:root {
  --bg:           #f7f8fb;
  --bg-elev:      #ffffff;
  --bg-card:      #ffffff;
  --bg-card-2:    #f1f3f8;
  --border:       #dde2ed;
  --border-soft:  #e9edf5;
  --text:         #1a2138;
  --text-dim:     #4d566f;
  --text-muted:   #76809a;
  --accent:       #0e8a82;
  --accent-2:     #4561d6;
  --accent-soft:  rgba(14, 138, 130, 0.08);
  --warn:         #b46b00;
  --warn-soft:    rgba(180, 107, 0, 0.08);
  --danger:       #c83838;
  --code-bg:      #f1f3f8;
  --code-text:    #1a2138;
  --shadow:       0 2px 12px rgba(20,30,60,0.08);
  --radius:       10px;
  --maxw:         1180px;
  --maxw-prose:   860px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Segoe UI", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  /* 한글 줄바꿈: 단어 중간 자르지 않기 */
  word-break: keep-all;
  overflow-wrap: break-word;
}
/* NOTE: html/body에 overflow-x:hidden 두면 position:sticky가 깨짐.
   가로 스크롤은 툴팁의 안전한 default 좌표(-9999px)와 max-width 제어로 방지. */
/* 코드는 정확한 정렬을 위해 단어 단위 wrapping 해제 */
pre, pre code, .mono { word-break: normal; overflow-wrap: normal; white-space: pre; }
/* 인라인 코드는 너무 긴 문자열만 끊도록 */
:not(pre) > code { word-break: break-word; overflow-wrap: anywhere; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
code, pre, .mono { font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, Menlo, monospace; }
pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border-soft);
}
code:not(pre code) {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}

/* ==================== TOP BAR ==================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247,248,251,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 14px; }
.brand-name { font-weight: 700; letter-spacing: 2px; font-size: 14px; }
.brand-sub { color: var(--text-muted); font-size: 12px; letter-spacing: 0.2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: white; }
.btn-ghost { background: transparent; }

/* ==================== HERO ==================== */
.hero {
  max-width: var(--maxw); margin: 0 auto;
  padding: 80px 24px 60px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.hero-eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 3px;
  margin-bottom: 16px;
  font-weight: 600;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.15;
  font-weight: 800;
  margin-bottom: 18px;
  letter-spacing: -0.02em;
}
.hero h1 .hl { color: var(--accent); }
.hero-lead {
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  color: var(--text-dim);
  margin-bottom: 32px;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-meta b { color: var(--text-dim); font-weight: 600; }

/* ==================== LAYOUT (sidebar + content) ==================== */
.layout-wrap {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
}
.main-wrap { flex: 1; min-width: 0; }

/* ==================== SIDEBAR ==================== */
.sidebar {
  position: sticky;
  top: 57px;
  align-self: flex-start;
  flex-shrink: 0;
  width: 248px;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  padding: 24px 0 32px;
  border-right: 1px solid var(--border-soft);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.sidebar-group { margin-bottom: 12px; }
.sidebar-chapter {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
  font-weight: 700;
  padding: 10px 16px 6px;
  text-transform: uppercase;
}
.sidebar-link {
  display: flex;
  align-items: baseline;
  padding: 6px 16px 6px 18px;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  font-size: 13px;
  line-height: 1.45;
}
.sidebar-link:hover { color: var(--text); background: var(--bg-card); }
.sidebar-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.sidebar-num {
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 10px;
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, Menlo, monospace;
  font-size: 11px;
  flex-shrink: 0;
  min-width: 18px;
}
.sidebar-link.active .sidebar-num { color: var(--accent); }
.sidebar-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
@media (max-width: 900px) {
  .layout-wrap { flex-direction: column; }
  .sidebar {
    position: static;
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 0 16px;
    display: none;
  }
  .sidebar.open { display: block; }
  .sidebar-toggle { display: inline-flex; align-items: center; gap: 6px; }
}

/* ==================== MAIN LAYOUT ==================== */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
section.chapter {
  padding: 60px 0 80px;
  border-bottom: 1px solid var(--border-soft);
}
.chap-head { margin-bottom: 36px; }
.chap-eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 600;
  margin-bottom: 8px;
}
.chap-title {
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 10px;
}
.chap-lead {
  color: var(--text-dim);
  font-size: 1.02rem;
}
/* 영문 합성어가 가운데서 끊기지 않도록: 필요한 곳에 .nowrap 적용 */
.nowrap { white-space: nowrap; }

/* ==================== SLIDE BLOCK ==================== */
.slide {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 28px;
  position: relative;
  transition: border-color 0.15s ease;
}
.slide:hover { border-color: var(--border); }
.slide-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.slide-tag .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.slide h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.slide-sub {
  color: var(--text-dim);
  font-size: 0.98rem;
  margin-bottom: 24px;
}
.slide p { margin-bottom: 14px; color: var(--text-dim); }
.slide p strong, .slide li strong { color: var(--text); font-weight: 600; }

/* ==================== TERM TOOLTIP (hover 설명) ==================== */
.term {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  transition: color 0.12s ease, border-bottom-color 0.12s ease;
}
.term:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}
/* 툴팁: position:fixed + JS 동적 위치 계산 — 어떤 위치/스크롤에서도 잘리지 않음 */
.term::after {
  content: attr(data-tip);
  position: fixed;
  top: var(--tip-y, -9999px);
  left: var(--tip-x, -9999px);          /* hidden 상태에서 음수 영역 침범 방지 */
  transform: var(--tip-tx, none);        /* 기본 transform 없음 → 화면 밖에 안전하게 위치 */
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  width: max-content;
  max-width: 340px;
  white-space: normal;
  line-height: 1.6;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0s linear 0.12s;
  z-index: 9999;  /* topbar(50)보다 훨씬 위 */
  box-shadow: 0 6px 20px rgba(20,30,60,0.18);
}
.term:hover::after,
.term.term-active::after {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.12s ease, visibility 0s;
}




/* ==================== GRID ==================== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 820px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}

.feature {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* hover lift 효과: transform 사용 금지 (.term 툴팁이 fixed인데 transform 부모를
   기준 컨테이너로 삼아 좌표가 어긋나는 CSS spec 이슈). box-shadow로 동등한 시각 효과 구현. */
.feature:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(20,30,60,0.10);
}
.feature-num {
  display: inline-flex;
  width: 24px; height: 24px;
  background: var(--accent);
  color: var(--bg);
  align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}
.feature h4 {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.feature p { font-size: 0.9rem; color: var(--text-dim); margin: 0; }

/* ==================== TABS ==================== */
.tabs { margin: 16px 0; }
.tab-buttons {
  display: flex; gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  transition: all 0.15s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }


/* ==================== EXPANDABLE ==================== */
.expand {
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin: 14px 0;
  overflow: hidden;
}
.expand-summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.94rem;
  display: flex; justify-content: space-between; align-items: center;
  user-select: none;
  list-style: none;
}
.expand-summary::-webkit-details-marker { display: none; }
.expand-summary::after {
  content: "+";
  color: var(--accent);
  font-size: 18px;
  font-weight: 400;
  transition: transform 0.2s ease;
}
.expand[open] .expand-summary::after { content: "−"; }
.expand-body {
  padding: 0 18px 16px;
  color: var(--text-dim);
  font-size: 0.94rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}
.expand-body p { margin-bottom: 10px; }
.expand-body ul { padding-left: 18px; }
.expand-body li { color: var(--text-dim); margin-bottom: 6px; }

/* ==================== TABLES ==================== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 12px 0;
}
.tbl th, .tbl td {
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}
.tbl th {
  background: var(--bg-card-2);
  font-weight: 700;
  color: var(--text);
  font-size: 0.85rem;
  letter-spacing: 0.3px;
}
.tbl td { color: var(--text-dim); }

/* Compare table — RDF vs LPG 비교 표 (매트릭스 카드와 동일한 컬러 시스템) */
.tbl.tbl-compare td {
  background: var(--bg-card);
}
.tbl.tbl-compare th:nth-child(1) {
  background: rgba(69, 97, 214, 0.10);
  color: var(--accent-2);
  font-weight: 700;
  border-top: 3px solid var(--accent-2);
}
.tbl.tbl-compare td:nth-child(1) {
  background: var(--bg-card);
  font-weight: 700;
  color: var(--text);
}
.tbl.tbl-compare th:nth-child(2) {
  background: rgba(200, 56, 56, 0.10);
  color: var(--danger);
  border-top: 3px solid var(--danger);
}
.tbl.tbl-compare th:nth-child(3) {
  background: var(--accent-soft);
  color: var(--accent);
  border-top: 3px solid var(--accent);
}
.tbl.tbl-compare tbody tr:hover td:nth-child(2) {
  background: rgba(200, 56, 56, 0.05);
}
.tbl.tbl-compare tbody tr:hover td:nth-child(3) {
  background: rgba(14, 138, 130, 0.05);
}

/* ==================== LISTS ==================== */
.checklist { list-style: none; padding: 0; }
.checklist li {
  padding: 8px 0 8px 28px;
  position: relative;
  color: var(--text-dim);
  font-size: 0.93rem;
  cursor: pointer;
  transition: color 0.15s ease;
}
.checklist li::before {
  content: "";
  position: absolute;
  left: 0; top: 12px;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
}
.checklist li.done::before {
  background: var(--accent);
  border-color: var(--accent);
}
.checklist li.done::after {
  content: "✓";
  position: absolute;
  left: 3px; top: 8px;
  color: var(--bg);
  font-size: 12px;
  font-weight: 700;
}
.checklist li.done { color: var(--text-muted); text-decoration: line-through; }

/* ==================== TRIPLE / GRAPH VISUALS ==================== */
.triple-viz {
  display: flex; align-items: center; justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 28px 18px;
  margin: 16px 0;
}
.triple-node {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.triple-arrow {
  display: flex; flex-direction: column; align-items: center;
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.85rem;
}
.triple-arrow .arrow-line {
  display: flex; align-items: center;
  font-size: 1.5rem;
  color: var(--accent-2);
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, Menlo, monospace;
}
/* SPO 역할 칩 */
.triple-role-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
  text-transform: none;
}
.triple-node {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  text-align: center;
}
.triple-node .triple-val {
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, Menlo, monospace;
  font-size: 0.95rem;
}
.triple-node.triple-role-s {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.triple-node.triple-role-s .triple-role-tag {
  color: #fff;
  background: var(--accent);
}
.triple-node.triple-role-o {
  border-color: #6a4ed1;
  box-shadow: 0 0 0 4px rgba(106, 78, 209, 0.10);
}
.triple-node.triple-role-o .triple-role-tag {
  color: #fff;
  background: #6a4ed1;
}
.triple-arrow .triple-role-p {
  color: #fff;
  background: var(--accent-2);
}


/* ==================== STEP FLOW ==================== */
.steps {
  display: flex; gap: 0;
  margin: 18px 0;
  flex-wrap: wrap;
}
.step {
  flex: 1; min-width: 140px;
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  padding: 16px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}
.step:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -10px; top: 50%;
  transform: translateY(-50%);
  background: var(--bg);
  color: var(--accent);
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  z-index: 1;
}
.step:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.step:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.step:not(:last-child) { border-right: none; }
.step.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
/* active step의 right 라인은 인접한 다음 step의 left border가 담당.
   다음 step의 left를 accent 색으로 바꾸면 1px green 한 줄로 active 박스가 자연스럽게 닫힘 */
.step.active + .step { border-left-color: var(--accent); }
.step:hover { background: var(--bg-card); }
.step-num {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}
.step-name { font-weight: 700; font-size: 0.92rem; margin-bottom: 4px; }
.step-desc { color: var(--text-muted); font-size: 0.82rem; line-height: 1.4; }
.step-detail {
  background: var(--bg-card-2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 18px;
  margin-top: 10px;
  font-size: 0.93rem;
  color: var(--text-dim);
}
.step-detail p { margin: 0; color: var(--text-dim); }




/* ==================== FOOTER ==================== */
footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 40px 24px 60px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  border-top: 1px solid var(--border-soft);
}
footer p { color: var(--text-muted); }

/* ==================== UTILITY ==================== */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .row-2 { grid-template-columns: 1fr; } }
.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.spacer-sm { height: 12px; }
.spacer-md { height: 24px; }
.spacer-lg { height: 40px; }
.center { text-align: center; }
.kbd {
  display: inline-block;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, Menlo, monospace;
  color: var(--text);
}
hr.soft { border: none; border-top: 1px solid var(--border-soft); margin: 24px 0; }

/* ==================== GLOSSARY (용어사전) ==================== */
.glossary-meta {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  color: var(--text-muted);
  font-size: 13px;
}
.glossary-meta .count-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.glossary-search {
  flex: 1 1 220px; min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.glossary-search:focus { border-color: var(--accent); }
.glossary-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.glossary-group {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}
.glossary-group:first-child { margin-top: 0; border-top: none; padding-top: 0; }
.glossary-group .group-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}
.glossary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.glossary-item .g-term {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.glossary-item .g-def {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}
.glossary-item .g-jump {
  align-self: flex-start;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.glossary-item .g-jump:hover { color: var(--accent-2); text-decoration: underline; }
.glossary-item.is-hidden { display: none; }
.glossary-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 20px 0;
  font-size: 14px;
}
/* term이 글로서리에서 점프되어 왔을 때 잠깐 강조 */
.term.term-flash {
  background: var(--accent-soft);
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
  transition: background 0.25s ease;
}

/* ==================== FAB (글로서리 플로팅 버튼) ==================== */
.fab-glossary {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(14,138,130,0.35), 0 2px 6px rgba(20,30,60,0.18);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.fab-glossary:hover { background: #0a716b; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(14,138,130,0.45), 0 2px 8px rgba(20,30,60,0.22); }
.fab-glossary:active { transform: translateY(0); }
.fab-glossary .fab-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  font-size: 14px;
}
.fab-glossary.is-open { background: var(--accent-2); box-shadow: 0 8px 24px rgba(69,97,214,0.35), 0 2px 6px rgba(20,30,60,0.18); }
.fab-glossary.is-open:hover { background: #3650c1; }
@media (max-width: 720px) {
  .fab-glossary { right: 14px; bottom: 14px; padding: 10px 14px; font-size: 12px; }
}

/* ==================== GLOSSARY SEARCH 강화 (카운트 + 하이라이트) ==================== */
.glossary-search-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.2px;
  min-height: 14px;
}
.glossary-search-count:empty { margin-top: 0; }
mark.g-hl {
  background: rgba(255, 213, 79, 0.55);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* ==================== GLOSSARY DRAWER (우측 슬라이드 패널) ==================== */
.glossary-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(20,30,60,0.12);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 100;
  display: flex; flex-direction: column;
  visibility: hidden;
}
.glossary-drawer.is-open { transform: translateX(0); visibility: visible; }
.glossary-drawer-header {
  flex: 0 0 auto;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elev);
}
.glossary-drawer-title-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.glossary-drawer-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.glossary-drawer-title .drawer-count {
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
}
.glossary-drawer-close {
  background: none; border: none;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.glossary-drawer-close:hover { background: var(--bg-card-2); color: var(--text); }
.glossary-drawer-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.glossary-drawer-search:focus { border-color: var(--accent); }
.glossary-drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 18px 24px;
}
.glossary-drawer-body .glossary-list {
  display: flex; flex-direction: column; gap: 10px;
}
.glossary-drawer-body .glossary-group {
  border-top-color: var(--border-soft);
  padding-top: 12px;
  margin-top: 4px;
  font-size: 12px;
}
.glossary-drawer-body .glossary-group .group-letter { width: 22px; height: 22px; font-size: 11px; }
.glossary-drawer-body .glossary-item { padding: 10px 12px; }
.glossary-drawer-body .glossary-item .g-term { font-size: 13.5px; }
.glossary-drawer-body .glossary-item .g-def { font-size: 12.5px; }
.glossary-drawer-hint {
  flex: 0 0 auto;
  padding: 8px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-card-2);
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.3px;
}
@media (max-width: 600px) {
  .glossary-drawer { width: 100vw; border-left: none; }
}

/* ==================== PRINT ==================== */
@media print {
  .topbar, .sidebar, .topbar-actions, .fab-glossary, .glossary-drawer { display: none; }
  .layout-wrap, .main-wrap { display: block; }
  body { background: white; color: black; }
  .slide { page-break-inside: avoid; border: 1px solid #ccc; }
  .glossary-item { page-break-inside: avoid; }
}

/* ==================== PAGE MODE (각 슬라이드 = 1 페이지) ==================== */
html.page-mode, html.page-mode body { scroll-behavior: auto; }
body.page-mode .hero { display: none; }
body.page-mode section.chapter { display: none; }
body.page-mode section.chapter.has-active { display: block; padding: 36px 0 60px; border-bottom: none; }
body.page-mode section.chapter.has-active > .chap-head { display: block; margin-bottom: 24px; }
body.page-mode section.chapter > article.slide { display: none; }
body.page-mode section.chapter > article.slide.is-active {
  display: block;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 0;
  box-shadow: none;
}
/* slide-bare: iframe·d11 등 — 회색 페이지 배경 그대로 */
body.page-mode section.chapter > article.slide.slide-bare.is-active {
  background: transparent;
}
body.page-mode main { padding-bottom: 96px; }

.page-nav { display: none; }
body.page-mode .page-nav {
  display: flex;
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  align-items: center;
  gap: 14px;
  box-shadow: 0 6px 22px rgba(20,30,60,0.14);
  z-index: 60;
  font-family: inherit;
}
.page-nav .pnav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  font-weight: 600;
}
.page-nav .pnav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-nav .pnav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-nav .pnav-indicator {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 36px;
  text-align: center;
}
.page-nav .pnav-indicator b { color: var(--accent); font-size: 14px; font-weight: 700; }
.page-nav .pnav-title {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-left: 1px solid var(--border-soft);
  padding-left: 12px;
  margin-left: -2px;
}
@media (max-width: 640px) {
  .page-nav .pnav-title { display: none; }
  body.page-mode .page-nav { padding: 6px 10px; gap: 8px; }
}

@media print {
  body.page-mode section.chapter,
  body.page-mode section.chapter > .chap-head,
  body.page-mode section.chapter > article.slide,
  body.page-mode .hero { display: block !important; }
  body.page-mode .page-nav { display: none !important; }
}
