/* ── 기본 ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #1a56db;
  --blue-lt: #e8f0fe;
  --gray-1:  #f8f9fa;
  --gray-2:  #e9ecef;
  --gray-3:  #adb5bd;
  --gray-4:  #495057;
  --text:    #212529;
  --sidebar-w: 260px;
  --topbar-h:  52px;
  --radius:    6px;
  font-size: 15px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: #fff;
  line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 상단 바 ────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: #fff;
  border-bottom: 1px solid var(--gray-2);
  z-index: 100;
}

#menu-btn {
  font-size: 20px; background: none; border: none;
  cursor: pointer; padding: 4px 8px; color: var(--gray-4);
  display: none;
}

#hub-link {
  display: inline-flex; align-items: center; gap: 3px;
  font-weight: 600; font-size: 12px; color: var(--gray-4);
  white-space: nowrap; text-decoration: none;
  border: 1px solid var(--gray-2); border-radius: 14px;
  padding: 3px 10px; background: var(--gray-1);
}
#hub-link::before { content: '←'; font-size: 11px; }
#hub-link:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-lt); }
#logo {
  font-weight: 700; font-size: 16px; color: var(--blue);
  white-space: nowrap; text-decoration: none;
}

#search-box {
  flex: 1; display: flex; max-width: 480px;
  border: 1px solid var(--gray-2); border-radius: var(--radius);
  overflow: hidden;
}
#search-input {
  flex: 1; border: none; outline: none;
  padding: 6px 10px; font-size: 14px;
}
#search-btn {
  border: none; background: var(--gray-1); padding: 0 12px;
  cursor: pointer; font-size: 15px;
}
#search-btn:hover { background: var(--gray-2); }

#auth-area { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.btn-outline {
  border: 1px solid var(--blue); color: var(--blue); background: none;
  padding: 5px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn-outline:hover { background: var(--blue-lt); }
.btn-ghost {
  border: 1px solid var(--gray-2); background: none; color: var(--gray-4);
  cursor: pointer; font-size: 13px; padding: 5px 10px; border-radius: 20px;
}
.btn-ghost:hover { border-color: var(--gray-3); color: var(--text); }

#user-info:not([hidden]) { display: flex; align-items: center; gap: 6px; }
#user-name { display: flex; align-items: center; }

/* ── 레이아웃 ────────────────────────────────────── */
#layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ── 사이드바 ────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
  overflow-y: auto; overflow-x: hidden;
  background: var(--gray-1);
  border-right: 1px solid var(--gray-2);
  transition: transform 0.2s;
}

#sidebar-inner { padding: 10px 0; }

/* TOC 모드 헤더 (뒤로가기 + 문서코드) */
#toc-nav-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-2);
  background: var(--gray-1);
}
#toc-nav-header[hidden] { display: none; }
#toc-back-btn {
  flex-shrink: 0; background: none;
  border: 1px solid var(--gray-3); border-radius: 4px;
  cursor: pointer; font-size: 12px; padding: 3px 8px;
  color: var(--gray-4); white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
#toc-back-btn:hover { background: var(--gray-2); color: var(--text); }
#toc-doc-badge {
  font-size: 11px; color: var(--blue); font-weight: 600;
  background: var(--blue-lt); border-radius: 3px;
  padding: 2px 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

#series-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--gray-2);
  margin-bottom: 4px;
}
.series-tab {
  font-size: 12px; padding: 3px 8px;
  border: 1px solid var(--gray-3); border-radius: 12px;
  background: none; cursor: pointer; color: var(--gray-4);
  transition: background 0.15s, color 0.15s;
}
.series-tab:hover { background: var(--gray-2); color: var(--text); }
.series-tab.active {
  background: var(--blue); border-color: var(--blue); color: #fff;
}

#doc-list { list-style: none; }
#doc-list li a {
  display: block; padding: 7px 14px;
  font-size: 13px; color: var(--gray-4);
  border-left: 3px solid transparent;
  text-decoration: none; line-height: 1.35;
}
#doc-list li a:hover { background: var(--gray-2); color: var(--text); }
#doc-list li a.active {
  color: var(--blue); border-left-color: var(--blue);
  background: var(--blue-lt); font-weight: 600;
}
.doc-code-sm {
  font-size: 10px; color: var(--blue);
  background: var(--blue-lt); border-radius: 3px;
  padding: 1px 4px; display: inline-block; margin-bottom: 3px;
}
.doc-title-sm {
  display: block; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* TOC 링크 */
.toc-link { display: flex !important; gap: 6px; align-items: baseline; }
.toc-link.level-1 { font-weight: 600; color: var(--text) !important; padding: 7px 14px !important; }
.toc-link.level-2 { padding-left: 22px !important; font-size: 12px; }
.toc-link.level-3 { padding-left: 32px !important; font-size: 11px; color: var(--gray-3) !important; }
.sec-num-sm { white-space: nowrap; font-size: 11px; color: var(--gray-3); flex-shrink: 0; }

/* ── 메인 콘텐츠 ─────────────────────────────────── */
#content {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  padding: 28px 32px;
  max-width: 860px;
}

/* ── 홈 페이지 ───────────────────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-top: 20px;
}
.doc-card {
  border: 1px solid var(--gray-2); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
  text-decoration: none; color: inherit;
  display: block; transition: box-shadow 0.15s;
}
.doc-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); text-decoration: none; }
.doc-card-code { font-size: 11px; color: var(--gray-3); margin-bottom: 4px; }
.doc-card-title { font-size: 13px; font-weight: 600; line-height: 1.4; }

/* ── 문서 뷰 ─────────────────────────────────────── */
.doc-header { margin-bottom: 0; padding-bottom: 16px; border-bottom: 2px solid var(--gray-2); }
.doc-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.pdf-view-btn {
  display: inline-flex; align-items: center; gap: 4px;
  margin-bottom: 10px; padding: 4px 10px;
  font-size: 13px; font-weight: 500; color: var(--blue);
  border: 1px solid var(--blue); border-radius: 4px;
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.pdf-view-btn::before { content: '📄'; font-size: 13px; }
.pdf-view-btn:hover { background: var(--blue); color: #fff; }
.doc-header-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.doc-code { font-size: 12px; color: var(--gray-3); }

/* 즐겨찾기 버튼 */
.fav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--gray-3); padding: 0 2px; line-height: 1;
  transition: color 0.15s;
}
.fav-btn:hover { color: #f5a623; }
.fav-btn.fav-active { color: #f5a623; }

/* 즐겨찾기 페이지 */
.favs-heading { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.fav-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.fav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border: 1px solid var(--gray-2); border-radius: 6px;
  background: #fff;
}
.fav-item-link { flex: 1; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fav-item-link:hover .fav-item-main { color: var(--blue); }
.fav-item-meta { font-size: 10px; color: var(--gray-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-item-main { font-size: 13px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-remove-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--gray-3); font-size: 12px; padding: 3px 5px; border-radius: 4px; margin-left: 4px;
}
.fav-remove-btn:hover { background: var(--gray-1); color: var(--text); }
/* 그룹 헤더 */
.fav-group-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 2px 5px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--gray-2); margin-bottom: 5px;
}
.fav-group-arrow {
  font-size: 20px; color: var(--gray-4);
  transition: transform 0.15s; display: inline-block; line-height: 1;
}
.fav-group-name { font-size: 12px; font-weight: 700; color: var(--gray-4); text-transform: uppercase; letter-spacing: 0.05em; }
.fav-group-badge {
  font-size: 11px; background: var(--gray-1); border-radius: 10px;
  padding: 1px 7px; color: var(--gray-4); font-weight: 600;
}
.fav-group-header.collapsed .fav-group-arrow { transform: rotate(-90deg); }
.fav-group-header.collapsed + .fav-list { display: none; }
.fav-sec-num { font-weight: 700; color: var(--blue); }

/* topbar 즐겨찾기 링크 */
#graph-btn, #favs-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--gray-4); text-decoration: none; white-space: nowrap;
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--gray-2); background: #fff;
}
#graph-btn:hover { border-color: var(--blue); color: var(--blue); }
#favs-btn:hover { border-color: #f5a623; color: #f5a623; }

/* ── 그래프 페이지 ─────────────────────────────────────────────────────────── */
body.graph-mode #content {
  max-width: none;
  padding: 0;
}
#graph-page {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 1px);
}
#graph-header {
  display: flex; align-items: baseline; gap: 12px; flex-shrink: 0;
  padding: 10px 16px 8px; border-bottom: 1px solid var(--gray-2);
  background: #fff;
}
#graph-title { font-size: 15px; font-weight: 700; color: var(--gray-5); }
#graph-desc  { font-size: 11px; color: var(--gray-3); }
#graph-container {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* 시리즈 필터 바 */
.gc-series-bar {
  flex-shrink: 0; display: flex; align-items: center;
  padding: 7px 14px;
  background: #fff; border-bottom: 1px solid var(--gray-2);
}
.gc-series {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px; flex: 1 1 0;
}

/* 옵션 바 */
.gc-opts-bar {
  flex-shrink: 0; display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 16px; padding: 6px 14px;
  background: #f8fafc; border-bottom: 1px solid var(--gray-2);
}
.gc-label {
  font-size: 11px; font-weight: 600; color: var(--gray-3); margin-right: 2px; white-space: nowrap;
}
.gc-series-btn {
  padding: 2px 8px; border-radius: 10px; border: 1.5px solid var(--sc,#94a3b8);
  font-size: 11px; cursor: pointer; background: #fff; color: var(--sc,#94a3b8);
  transition: opacity 0.15s, background 0.15s;
}
.gc-series-btn:not(.active) { opacity: 0.28; background: #f8fafc; }
.gc-all-btn {
  padding: 2px 9px; border-radius: 10px; border: 1px solid var(--gray-2);
  font-size: 11px; cursor: pointer; background: #f1f5f9; color: var(--gray-4);
  margin-left: 4px;
}
.gc-all-btn:hover { background: var(--gray-1); }
.gc-options {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
}
.gc-opt-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--gray-4); white-space: nowrap; cursor: default;
}
.gc-select {
  font-size: 11px; border: 1px solid var(--gray-2); border-radius: 6px;
  padding: 2px 4px; color: var(--gray-5); background: #fff; cursor: pointer;
}
.gc-range { width: 70px; cursor: pointer; accent-color: var(--blue); }

/* 2D / 3D 모드 토글 */
.gc-mode-group {
  display: flex; border: 1px solid var(--gray-2); border-radius: 6px; overflow: hidden;
}
.gc-mode-btn {
  padding: 3px 10px; border: none; background: #fff; font-size: 11px;
  font-weight: 600; cursor: pointer; color: var(--gray-3); transition: background 0.15s, color 0.15s;
}
.gc-mode-btn:first-child { border-right: 1px solid var(--gray-2); }
.gc-mode-btn.active { background: var(--blue); color: #fff; }

/* 사이트 공통 푸터 */
#site-footer {
  margin-left: var(--sidebar-w);
  border-top: 1px solid var(--gray-2);
  padding: 16px 20px;
  font-size: 12px;
  color: var(--gray-4);
  background: var(--gray-1);
}
.site-footer-wrap {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center;
}
.site-footer-links { display: inline-flex; gap: 4px; align-items: center; }
.site-footer-sep { color: var(--gray-3); }
#site-footer a { color: var(--gray-4); text-decoration: none; }
#site-footer a:hover { text-decoration: underline; }

/* 관리자 페이지 */
#admin-page { padding: 24px; }
.admin-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.admin-sub { font-size: 13px; color: var(--gray-4); margin-bottom: 16px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { background: var(--gray-1); font-weight: 600; padding: 10px 18px; text-align: left; border-bottom: 2px solid var(--gray-2); white-space: nowrap; }
.admin-table td { padding: 9px 18px; border-bottom: 1px solid var(--gray-2); vertical-align: middle; white-space: nowrap; }
.admin-table tr:hover td { background: var(--gray-1); }
.admin-role { font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.admin-role-admin { background: #fee2e2; color: #b91c1c; }
.admin-role-user { background: var(--gray-1); color: var(--gray-4); }
.admin-token { font-size: 11px; background: var(--gray-1); padding: 2px 6px; border-radius: 4px; font-family: monospace; }
.admin-limit-val { font-size: 13px; min-width: 36px; display: inline-block; }
.admin-limit-val strong { color: #1d4ed8; }
.admin-limit-btn { font-size: 11px; padding: 3px 10px; border: 1px solid var(--gray-2); background: #fff; color: var(--gray-5); border-radius: 4px; cursor: pointer; margin-left: 8px; }
.admin-limit-btn:hover { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.admin-limit-btn:disabled { opacity: .4; cursor: default; }
.admin-limit-reset-btn { font-size: 11px; padding: 3px 10px; border: 1px solid var(--gray-2); background: #fff; color: var(--gray-3); border-radius: 4px; cursor: pointer; margin-left: 4px; }
.admin-limit-reset-btn:hover { border-color: #fca5a5; background: #fff5f5; color: #dc2626; }
.admin-limit-reset-btn:disabled { opacity: .4; cursor: default; }
.admin-revoke-btn { font-size: 12px; padding: 3px 10px; border: 1px solid #fca5a5; background: #fff; color: #dc2626; border-radius: 4px; cursor: pointer; }
.admin-revoke-btn:hover { background: #fee2e2; }
.admin-revoke-btn:disabled { opacity: .5; cursor: default; }

/* MCP 패널 */
#mcp-panel {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.35);
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding-top: 52px; padding-right: 12px;
}
#mcp-panel-inner {
  background: #fff; border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: 340px; overflow: hidden;
}
.mcp-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--gray-2);
}
.mcp-panel-header button {
  background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-4);
}
.mcp-panel-section { padding: 12px 16px; border-bottom: 1px solid var(--gray-2); }
.mcp-panel-label { font-size: 11px; font-weight: 600; color: var(--gray-4); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.mcp-token-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.mcp-token-row code {
  flex: 1; font-size: 11px; background: var(--gray-1);
  border: 1px solid var(--gray-2); border-radius: 4px;
  padding: 5px 8px; word-break: break-all; font-family: monospace; line-height: 1.4;
}
.mcp-token-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mcp-no-token { font-size: 12px; color: var(--gray-4); margin-bottom: 10px; }
.mcp-panel-actions {
  display: flex; gap: 8px; padding: 10px 16px; justify-content: flex-end;
  border-top: 1px solid var(--gray-2);
}
/* 패널 공용 버튼 */
.mcp-btn {
  padding: 5px 12px; font-size: 12px; border-radius: 5px;
  cursor: pointer; border: 1px solid transparent; font-family: inherit;
  transition: background .15s, border-color .15s;
}
.mcp-btn-primary {
  background: var(--blue); color: #fff; border-color: var(--blue);
}
.mcp-btn-primary:hover { background: #1648c0; border-color: #1648c0; }
.mcp-btn-ghost {
  background: #fff; color: var(--gray-4); border-color: var(--gray-2);
}
.mcp-btn-ghost:hover { background: var(--gray-1); border-color: var(--gray-3); color: var(--text); }
.mcp-btn-danger {
  background: #fff; color: #dc2626; border-color: #fca5a5;
}
.mcp-btn-danger:hover { background: #fef2f2; border-color: #dc2626; }

/* 그래프 캔버스 */
.gc-canvas {
  flex: 1; position: relative; overflow: hidden; background: #f8fafc;
}
.gc-canvas svg { display: block; width: 100%; height: 100%; }

/* 툴팁 */
.graph-tip {
  position: absolute; pointer-events: none; z-index: 50;
  background: #1e293b; color: #f1f5f9; border-radius: 8px;
  padding: 8px 12px; font-size: 12px; line-height: 1.5;
  max-width: 240px; opacity: 0; transition: opacity 0.1s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.gt-code { font-size: 11px; color: #94a3b8; margin-bottom: 2px; }
.gt-title { font-weight: 600; color: #f1f5f9; margin-bottom: 4px; }
.gt-meta  { font-size: 11px; color: #94a3b8; }
.gt-meta b { color: #60a5fa; }

/* 범례 */
.graph-legend {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.93); border: 1px solid var(--gray-2);
  border-radius: 20px; padding: 6px 14px;
  display: flex; flex-direction: row; flex-wrap: wrap;
  gap: 4px 14px; font-size: 11px;
  max-width: 90%; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.gl-row { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.gl-dot  { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.gl-label { color: var(--gray-4); }

/* 섹션 헤딩 즐겨찾기 버튼 */
.sec-heading { display: flex; align-items: baseline; gap: 6px; }
.sec-fav-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--gray-3); padding: 0; line-height: 1;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.sec-block:hover .sec-fav-btn { opacity: 0.7; }
.sec-fav-btn:hover { opacity: 1 !important; color: #f5a623; }
.sec-fav-btn.fav-active { opacity: 1; color: #f5a623; }

/* 사이드바 가이드 링크 */
#guide-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 4px;
  border-bottom: 1px solid var(--gray-2);
  margin-bottom: 4px;
}
.sidebar-guide-link {
  display: block;
  font-size: 12px;
  color: var(--gray-3);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 5px;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-guide-link:hover { background: var(--gray-2); color: var(--text); }

/* 홈 기출참조 버튼 */
.sidebar-exam-divider { height: 1px; background: var(--gray-2); margin: 4px 12px; }
.sidebar-exam-item a { font-weight: 600; }
.doc-group-header {
  padding: 8px 14px 4px;
  cursor: default; pointer-events: none;
  border-top: 1px solid var(--gray-2); margin-top: 4px;
}
.doc-group-header .doc-code-sm { opacity: 0.6; }
.doc-group-header .doc-title-sm { font-weight: 700; color: var(--gray-4); font-size: 11px; }
.doc-card-header {
  cursor: default; pointer-events: none;
  background: var(--gray-1); opacity: 0.7;
  grid-column: 1 / -1;
  border-style: dashed;
}
.exam-page-btn-wrap { text-align: center; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--gray-2); }
.exam-page-btn {
  display: inline-block; padding: 10px 22px; border-radius: 8px;
  background: var(--primary, #1a56d6); color: #fff; font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.exam-page-btn:hover { background: #1444b0; }

/* 기출문제 참조 페이지 */
.exam-page { max-width: 960px; }
.exam-page-top { margin-bottom: 16px; }
.exam-page-top h2 { font-size: 18px; margin: 0 0 4px; }
.exam-page-desc { color: var(--gray-3); font-size: 13px; margin: 0; }
.exam-filter {
  width: 100%; max-width: 400px; padding: 7px 12px; margin-bottom: 14px;
  border: 1px solid var(--gray-2); border-radius: 6px; font-size: 13px;
}
.exam-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.exam-table th {
  background: var(--gray-1, #f5f5f5); text-align: left;
  padding: 7px 10px; border-bottom: 2px solid var(--gray-2); font-size: 12px; color: var(--gray-4);
}
.exam-table td { padding: 7px 10px; border-bottom: 1px solid var(--gray-2); vertical-align: top; }
.exam-tr:hover td { background: #f8fbff; }
.exam-code-link { font-weight: 600; color: var(--primary, #1a56d6); text-decoration: none; font-size: 12px; }
.exam-code-link:hover { text-decoration: underline; }
.exam-clause-link { font-weight: 700; color: var(--primary, #1a56d6); text-decoration: none; }
.exam-clause-link:hover { text-decoration: underline; }
.exam-rounds { color: #555; font-size: 12px; }
.exam-topic-row { margin-bottom: 3px; font-size: 13px; }
.exam-topic-round { font-size: 11px; font-weight: 600; color: #888; margin-right: 5px; }

/* 기출문제 배지 */
.exam-badge {
  flex-shrink: 0; display: inline-block;
  font-size: 11px; font-weight: 500; line-height: 1;
  padding: 2px 7px; border-radius: 10px;
  background: #e8f4fd; color: #1a6fa8;
  cursor: pointer; white-space: nowrap;
  border: 1px solid #b3d7f5;
  transition: background 0.15s;
}
.exam-badge:hover { background: #cce4f7; }
.exam-badge--frequent { background: #fff3e0; color: #c45000; border-color: #f5c58a; }
.exam-badge--frequent:hover { background: #ffe0b2; }

/* 기출 팝업 */
.exam-popup {
  position: fixed; z-index: 1200;
  background: #fff; border: 1px solid #d0d0d0;
  border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 14px 16px; min-width: 220px; max-width: 320px;
  font-size: 13px;
}
.exam-popup-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.exam-popup-title { font-weight: 700; color: #333; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.exam-popup-close { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--gray-3); padding: 0; line-height: 1; }
.exam-popup-close:hover { color: #333; }
.exam-popup-item { padding: 5px 0; border-top: 1px solid #f0f0f0; }
.exam-popup-item:first-of-type { border-top: none; }
.exam-popup-exam { font-weight: 600; color: #1a6fa8; }
.exam-popup-topic { color: #555; font-size: 12px; }

/* 식 즐겨찾기 버튼 */
.eq-meta { display: flex; align-items: center; gap: 2px; }
.eq-fav-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--gray-3); padding: 0 2px; line-height: 1;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.para-eq:hover .eq-fav-btn { opacity: 0.7; }
.eq-fav-btn:hover { opacity: 1 !important; color: #f5a623; }
.eq-fav-btn.fav-active { opacity: 1; color: #f5a623; }

/* 표/그림 즐겨찾기 버튼 */
.para-table { position: relative; margin: 10px 0; scroll-margin-top: calc(var(--topbar-h) + 12px); }
.para-img { position: relative; scroll-margin-top: calc(var(--topbar-h) + 12px); }
.tbl-fav-btn {
  position: absolute; top: 4px; right: 4px;
  background: rgba(255,255,255,0.85); border: 1px solid var(--gray-2);
  border-radius: 4px; cursor: pointer;
  font-size: 14px; color: var(--gray-3); padding: 2px 5px; line-height: 1;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.para-table:hover .tbl-fav-btn,
.para-img:hover .tbl-fav-btn { opacity: 0.7; }
.tbl-fav-btn:hover { opacity: 1 !important; color: #f5a623; }
.tbl-fav-btn.fav-active { opacity: 1; color: #f5a623; }

/* 섹션 인쇄 선택 버튼 */
.sec-print-btn {
  flex-shrink: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px; background: none; border: none; border-radius: 4px;
  color: #b0b8c4;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.sec-block:hover .sec-print-btn { opacity: 1; }
.sec-print-btn:hover { color: var(--blue); }
.sec-print-btn.print-active { opacity: 1 !important; color: var(--blue); }

/* 인쇄 선택 액션 바 */
#print-action-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; gap: 10px;
  background: #1e293b; color: #fff; padding: 10px 20px;
  font-size: 14px; box-shadow: 0 -2px 8px rgba(0,0,0,0.25);
}
#print-count-label { flex: 1; font-weight: 600; }
#print-pdf-btn {
  background: var(--blue); color: #fff; border: none; border-radius: 6px;
  padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
#print-pdf-btn:hover { background: #1a56d6; }
#print-clear-btn {
  background: none; color: #94a3b8; border: 1px solid #475569;
  border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
#print-clear-btn:hover { color: #fff; border-color: #94a3b8; }

/* 사용자 아바타 */
#user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--gray-2);
  cursor: pointer; display: block;
}
#user-avatar-fallback {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* 탭 (본문 / 신구대비표) */
.doc-tabs {
  display: flex; gap: 0; margin-top: 14px;
  border-bottom: 2px solid var(--gray-2);
}
.doc-tab {
  padding: 7px 18px; border: none; background: none;
  font-size: 14px; cursor: pointer; color: var(--gray-4);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.doc-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* 섹션 블록 */
.sec-block { margin-top: 28px; scroll-margin-top: calc(var(--topbar-h) + 12px); }
.sec-block.level-1 { margin-top: 40px; }

.sec-heading {
  scroll-margin-top: calc(var(--topbar-h) + 12px);
  font-weight: 700; line-height: 1.4;
}
h2.sec-heading { font-size: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--gray-2); margin-bottom: 12px; }
h3.sec-heading { font-size: 15px; margin-bottom: 8px; color: var(--text); }
h4.sec-heading { font-size: 14px; margin-bottom: 6px; color: var(--gray-4); }

.para { margin-bottom: 8px; font-size: 14px; line-height: 1.85; padding-left: 1.2em; }
.para.ind-1 { padding-left: 2.4em; }
.para.ind-2 { padding-left: 3.6em; }
.para.ind-3 { padding-left: 4.8em; }
.para.ind-4 { padding-left: 6.0em; }
.para-eq { padding: 6px 0 6px 1.2em; }
.para-eq-def { padding: 4px 0 4px 1.2em; }
.eq-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; width: 100%; }
.eq-body { text-align: center; }
.eq-num { white-space: nowrap; font-size: 0.92em; color: #333; padding-right: 4px; align-self: center; }
.para-table { margin: 10px 0; }
.contributor-heading { font-weight: 700; font-size: 1em; margin: 1.4em 0 0.3em; padding-bottom: 4px; border-bottom: 2px solid var(--gray-2); }
.para-table table { border-collapse: collapse; font-size: 13px; width: 100%; }
.para-table th, .para-table td {
  border: 1px solid var(--gray-2); padding: 6px 10px; text-align: left;
}
.para-table th { background: var(--gray-1); font-weight: 600; }
.tbl-caption {
  caption-side: top; text-align: left;
  font-size: 13px; font-weight: 700; padding: 0 0 4px;
  color: var(--text);
}
.fig-caption {
  text-align: center; font-size: 13px; font-weight: 700;
  color: var(--text); margin: 6px 0 0; padding: 0;
}

/* 홈 시리즈 */
.series-summary {
  font-weight: 700; font-size: 15px; cursor: pointer; padding: 4px 0;
}
.series-summary .cnt {
  font-weight: 400; font-size: 12px; color: var(--gray-3); margin-left: 4px;
}

/* ── 검색 결과 ───────────────────────────────────── */
.search-header { margin-bottom: 20px; }
.search-header h2 { font-size: 18px; }
.search-header p { color: var(--gray-3); font-size: 13px; margin-top: 4px; }

.search-tabs {
  display: flex; gap: 0; margin-bottom: 16px;
  border-bottom: 2px solid var(--gray-2);
}
.search-tab {
  padding: 7px 16px; font-size: 13px; cursor: pointer;
  border: none; background: none; color: var(--gray-4);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.search-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

.result-item {
  padding: 12px 0; border-bottom: 1px solid var(--gray-2);
}
.result-item:last-child { border-bottom: none; }
.result-doc { font-size: 11px; color: var(--gray-3); margin-bottom: 2px; }
.result-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.result-title a { color: var(--text); }
.result-title a:hover { color: var(--blue); text-decoration: none; }
.result-text { font-size: 13px; color: var(--gray-4); line-height: 1.6; }
.result-text em { color: var(--blue); font-style: normal; font-weight: 600; }

/* ── 드롭다운 섹션 (용어/기호의 정의) ─────────────────── */
.sec-collapsible { border: none; }
.sec-collapsible-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sec-collapsible-summary::-webkit-details-marker { display: none; }
.sec-collapsible-summary::before {
  content: '▶';
  font-size: 0.7em;
  color: var(--blue);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.sec-collapsible[open] > .sec-collapsible-summary::before {
  transform: rotate(90deg);
}
.sec-collapsible-summary .sec-heading {
  margin: 0;
  display: inline;
}

/* ── 용어 목록 ───────────────────────────────────── */
.terms-list { margin: 4px 0 16px; padding: 0; list-style: none; }
.term-item {
  display: grid;
  grid-template-columns: minmax(100px, 200px) 1fr;
  gap: 4px 16px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-2);
}
.term-item:last-child { border-bottom: none; }
.term-name {
  font-size: 14px; font-weight: 600; color: var(--blue);
  line-height: 1.5;
}
.term-en { font-weight: 400; color: var(--gray-3); font-size: 12px; display: block; }
.term-def { font-size: 13px; color: var(--gray-4); line-height: 1.65; margin: 0; }
.term-figure { margin-top: 8px; }
.term-figure img { max-width: 100%; height: auto; display: block; }
.terms-subsec-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.terms-subsec-item { font-size: 12px; color: var(--gray-4); background: var(--gray-1); border: 1px solid var(--gray-2); border-radius: 4px; padding: 2px 8px; }

/* ── 기호 목록 ───────────────────────────────────── */
.symbols-list { margin: 4px 0 16px; padding: 0; list-style: none; }
.symbol-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 16px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-2);
}
.symbol-item:last-child { border-bottom: none; }
.symbol-notation {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.symbol-def { font-size: 13px; color: var(--gray-4); line-height: 1.6; margin: 0; }

/* ── 신구대비표 ──────────────────────────────────── */
.changes-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 16px; }
.changes-table th {
  background: var(--gray-1); border: 1px solid var(--gray-2);
  padding: 8px 10px; font-weight: 600; white-space: nowrap;
}
.changes-table td {
  border: 1px solid var(--gray-2); padding: 8px 10px;
  vertical-align: top; line-height: 1.6;
}
.changes-table tr:hover td { background: var(--blue-lt); }

/* ── 북마크 버튼 ─────────────────────────────────── */
.bookmark-btn {
  float: right; font-size: 16px; background: none; border: none;
  cursor: pointer; color: var(--gray-3); padding: 0 4px;
  transition: color 0.15s;
}
.bookmark-btn:hover, .bookmark-btn.active { color: #f59e0b; }

/* ── 참조 팝업 ───────────────────────────────────── */
.kds-ref {
  color: var(--blue); cursor: pointer; text-decoration: underline;
  text-decoration-style: dotted; text-underline-offset: 2px;
}
.kds-ref:hover { text-decoration-style: solid; }

.tbl-ref, .fig-ref, .eq-ref {
  color: var(--blue); cursor: pointer; text-decoration: underline;
  text-decoration-style: dotted; text-underline-offset: 2px;
}
.tbl-ref:hover, .fig-ref:hover, .eq-ref:hover { text-decoration-style: solid; }

/* 윗첨자 */
.para sup { font-size: 0.75em; vertical-align: super; line-height: 0; }
.para-table th sup,
.para-table td sup { font-size: 0.7em; vertical-align: super; line-height: 1; }

#ref-popup {
  position: absolute; z-index: 200;
  background: #fff; border: 1px solid var(--gray-2);
  border-radius: var(--radius); box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  width: 380px; max-width: calc(100vw - 16px); max-height: min(75vh, 560px); overflow-y: auto;
}
#ref-popup-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 12px 8px; border-bottom: 1px solid var(--gray-2);
  position: sticky; top: 0; background: #fff; gap: 8px; z-index: 1;
}
#ref-popup-header-left { min-width: 0; flex: 1; }
#ref-popup-label { font-size: 11px; color: var(--gray-3); margin-bottom: 2px; }
#ref-popup-title { font-size: 13px; font-weight: 600; line-height: 1.4; }
#ref-popup-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#ref-popup-open {
  font-size: 12px; padding: 3px 10px;
  border: 1px solid var(--blue); border-radius: var(--radius);
  color: var(--blue); background: none; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
#ref-popup-open:hover { background: var(--blue-lt); text-decoration: none; }
#ref-popup-close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--gray-3); padding: 0 2px; line-height: 1;
}
#ref-popup-close:hover { color: var(--text); }
#ref-popup-body { padding: 10px 12px; font-size: 13px; line-height: 1.75; }
#ref-popup-body .para { margin-bottom: 6px; }
#ref-popup-body .para-eq { text-align: center; padding: 6px 0; }

/* 팝업 배경 오버레이 */
#ref-popup-overlay {
  position: fixed; inset: 0; z-index: 199;
  display: none;
}

/* ── 표 팝업 모달 ────────────────────────────────── */
/* 공지사항 모달 */
#notice-modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.35); display: none;
}
#notice-modal {
  position: fixed; z-index: 301;
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 6px 32px rgba(0,0,0,0.22);
  width: min(92vw, 560px); max-height: 80vh;
  display: flex; flex-direction: column;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}
#notice-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--gray-2);
}
#notice-modal-title { font-size: 14px; font-weight: 700; line-height: 1.4; flex: 1; }
#notice-modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--gray-3); padding: 0 2px; line-height: 1; flex-shrink: 0;
}
#notice-modal-close:hover { color: var(--text); }
#notice-modal-body { padding: 14px 16px; overflow-y: auto; font-size: 13.5px; line-height: 1.6; flex: 1; }
#notice-modal-footer {
  padding: 10px 16px; border-top: 1px solid var(--gray-2); text-align: right;
}
#notice-modal-ok {
  background: var(--blue); color: #fff; border: none; border-radius: 4px;
  padding: 6px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
}
#notice-modal-ok:hover { opacity: 0.88; }
.notice-item { display: flex; gap: 10px; margin-bottom: 12px; }
.notice-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.notice-item strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.notice-item p { margin: 0; color: var(--gray-3); font-size: 13px; }
.notice-divider { border: none; border-top: 1px solid var(--gray-2); margin: 14px 0; }
.notice-series-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; color: var(--text); }
.notice-series-item { display: flex; align-items: baseline; gap: 6px; margin: 6px 0; font-size: 13px; }
.notice-series-name { font-weight: 600; color: var(--text); }
.notice-series-count { color: var(--gray-3); font-size: 12px; }
.notice-series-badge { background: #e8f0fe; color: var(--blue); font-size: 11px; font-weight: 700; border-radius: 3px; padding: 1px 5px; }
@media (prefers-color-scheme: dark) {
  #notice-modal { background: var(--bg); }
  #notice-modal-header, #notice-modal-footer { border-color: var(--gray-2); }
  .notice-series-badge { background: #1a3a6a; }
}

#tbl-modal-overlay {
  position: fixed; inset: 0; z-index: 198;
  background: rgba(0,0,0,0.25); display: none;
}
#tbl-modal {
  position: fixed; z-index: 199;
  background: #fff; border: 1px solid var(--gray-2);
  border-radius: var(--radius); box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  width: min(92vw, 820px); max-height: 80vh;
  overflow: auto;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
#tbl-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; gap: 8px;
  border-bottom: 1px solid var(--gray-2);
  position: sticky; top: 0; background: #fff;
}
#tbl-modal-title { font-size: 13px; font-weight: 600; flex: 1; }
#tbl-modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--gray-3); padding: 0 4px; line-height: 1;
}
#tbl-modal-close:hover { color: var(--text); }
#tbl-modal-body { padding: 12px 14px; }
#tbl-modal-body .para-table { margin: 0; padding-left: 0; }
#tbl-modal-body .para-table table { width: auto; min-width: 100%; }
#tbl-modal-body .para-table-subtitle { font-size: 13px; font-weight: 600; margin: 12px 0 4px; }

/* 동일 번호 서브표 그룹 */
.table-group { margin: 10px 0; }
.table-group .para-table { margin: 0 0 4px; }
.para-table-subtitle { font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--text); }

/* ── 로딩 / 빈 상태 ──────────────────────────────── */
.loading { color: var(--gray-3); font-size: 14px; padding: 40px 0; text-align: center; }
.empty { color: var(--gray-3); font-size: 14px; padding: 24px 0; }

/* ── 모바일 ──────────────────────────────────────── */
/* ── 기출문제 테이블 모바일: 카드형 ── */
@media (max-width: 767px) {
  .exam-table thead { display: none; }
  .exam-table, .exam-table tbody, .exam-tr, .exam-table td { display: block; width: 100%; }
  .exam-tr { border: 1px solid var(--gray-2); border-radius: 8px; margin-bottom: 10px; padding: 10px 12px; }
  .exam-tr:hover td { background: none; }
  .exam-table td { padding: 2px 0; border-bottom: none; }
  /* 기준번호 + 조문: 한 줄 */
  .exam-table td:nth-child(1),
  .exam-table td:nth-child(2) { display: inline; }
  .exam-table td:nth-child(2)::before { content: ' § '; color: var(--gray-3); font-size: 11px; }
  /* 회차: 작게 */
  .exam-table td:nth-child(3) { font-size: 11px; color: #777; margin-top: 4px; }
  /* 내용: 풀 너비, 위쪽 여백 */
  .exam-table td:nth-child(4) { margin-top: 6px; border-top: 1px solid var(--gray-2); padding-top: 6px; }
  .exam-topic-row { font-size: 13px; line-height: 1.55; }
}

@media (max-width: 767px) {
  /* 2행 topbar: 행1=☰·뷰어·★·로그인, 행2=검색 */
  :root { --topbar-h: 96px; }

  #topbar {
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 12px 8px;
    gap: 0 8px;
  }

  #menu-btn { display: block; }

  /* 슬래시·사용자이름 숨김 */
  #nav-sep { display: none; }
  #user-name { display: none; }
  /* 즐겨찾기: ★ 아이콘만 표시 */
  .nav-label { display: none; }

  /* 버튼 크기 축소 */
  .btn-outline { padding: 5px 10px; font-size: 12px; }
  .btn-ghost   { padding: 5px 8px;  font-size: 12px; }
  #favs-btn    { padding: 4px 8px;  font-size: 16px; }

  /* 검색박스: 두 번째 행으로 이동 */
  #search-box {
    order: 10;
    flex: 0 0 100%;
    max-width: none;
    margin-top: 6px;
  }

  #sidebar {
    transform: translateX(-100%);
    z-index: 90;
    width: min(var(--sidebar-w), 80vw);
  }
  #sidebar.open { transform: translateX(0); }

  #content { margin-left: 0; padding: 16px; }
  #site-footer { margin-left: 0; }
  #content.sidebar-open { opacity: 0.4; pointer-events: none; }

  .home-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .home-grid { grid-template-columns: 1fr; }
  /* 극소형 화면: 로그아웃 텍스트 → 아이콘 */
  #logout-btn { font-size: 0; padding: 5px 10px; }
  #logout-btn::after { content: '↩'; font-size: 16px; }
}

/* ── 그림 (이미지) ───────────────────────────────── */
.para-img {
  margin: 12px 0;
  text-align: center;
}
/* figure는 block — inline-block이면 자식 img의 % 폭과 순환 참조가 되어 이미지가 사라짐 */
.para-img figure {
  display: block;
  max-width: 100%;
}
.doc-img {
  max-width: 70%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ── 용어 하이라이팅 & 팝업 ─────────────────────────── */
.term-ref {
  color: #0f7a4f;
  cursor: pointer;
  border-bottom: 1px dotted #0f7a4f;
  text-underline-offset: 2px;
}
.term-ref:hover { border-bottom-style: solid; background: #f0faf5; }

.term-popup {
  position: absolute;
  z-index: 201;
  background: #fff;
  border: 1px solid #c3e6d8;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  width: 340px;
  max-width: calc(100vw - 16px);
  padding: 0;
  font-size: 13px;
}
.term-popup.hidden { display: none; }
.term-popup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: #f0faf5;
  border-bottom: 1px solid #c3e6d8; border-radius: var(--radius) var(--radius) 0 0;
}
.term-popup-source { font-size: 11px; color: #0f7a4f; font-weight: 500; }
.term-popup-close {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: #6b7280; padding: 0 2px; line-height: 1;
}
.term-popup-close:hover { color: var(--text); }
.term-popup-word {
  padding: 8px 12px 4px; font-weight: 700; font-size: 14px; color: var(--text);
}
.term-popup-def {
  padding: 0 12px 10px; color: #374151; line-height: 1.6;
}


@media (max-width: 767px) {
  /* 그래프 범례: 모바일 숨김 (시리즈 버튼에 색상 표시됨) */
  .graph-legend { display: none !important; }

  /* 시리즈 필터: 가로 스크롤 한 줄 (세로 공간 절약) */
  .gc-series {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    min-width: 0;
  }
  .gc-series::-webkit-scrollbar { display: none; }

  /* 슬라이더: 터치 조작 위해 조금 더 넓게 */
  .gc-range { width: 88px; }
}

@media print {
  .exam-badge, .exam-popup { display: none !important; }
}

/* ── 내진성능평가 뷰어 추가 스타일 ──────────────────────────────────────────── */

/* 섹션 지연 마감(lazy finalize) — 브라우저 기본 scroll anchoring 을 끄고
   app.js 가 위쪽 섹션 높이 변화를 직접 보정한다 (Safari 미지원 대응, 이중 보정 방지) */
#tab-body { overflow-anchor: none; }

/* 조문 박스 (1×N 단일 컬럼 표) — 시설물안전법 해설서에만 나타난다.
   해설 블록(.haeseol-block)이 이미 음영이라 조문까지 음영이면 가시성이 떨어진다.
   음영·테두리를 없애고 본문 단락(.para)과 같은 글꼴·행간으로 맞춘다.
   직계 선택자로 한정 — 조문 셀 안에 중첩된 진짜 표의 괘선은 그대로 둔다. */
.jomun-wrap > table { font-size: 14px; }
.jomun-wrap > table > tbody > tr > td {
  background: none; border: none; padding: 0;
}
.jomun-wrap > table > tbody > tr > td > .cell-p {
  line-height: 1.85; margin-bottom: 8px;
}
.jomun-wrap > table > tbody > tr > td > .cell-p:last-child { margin-bottom: 0; }
/* 항목 기호가 없는 줄은 본문과 같은 들여쓰기 */
.jomun-wrap > table > tbody > tr > td > .cell-p:not([class*="cell-li"]) { padding-left: 1.2em; }

/* 조문 박스의 항목 계층은 본문과 기호 체계가 다르다.
     조문 박스:  가.  →  1)  →  ①        (이 문서 고유)
     본문/해설:  1.   →  (1) →  ①
   buildCellHtml 의 cell-liN 은 본문 기준으로 배정되어 '가.'(li1) 가 '1)'(li0) 보다
   깊어지는 역전이 생긴다. 클래스 배정은 다른 문서와 공유하므로 건드리지 않고,
   .jomun-wrap 안에서만 깊이를 다시 매핑한다.
   각 단계는 (앞 단계 위치 + 기호 폭) 만큼 들여쓰고, 음수 text-indent 만큼
   padding-left 로 보정해 첫 줄이 셀 밖으로 나가지 않게 한다. */
.jomun-wrap > table > tbody > tr > td > .cell-li1 {   /* 가. — 1단계, 본문과 같은 줄머리 */
  padding-left: 2.8em; text-indent: -1.6em;
}
.jomun-wrap > table > tbody > tr > td > .cell-li0 {   /* 1)  — 2단계 */
  padding-left: 4.3em; text-indent: -1.4em;
}
.jomun-wrap > table > tbody > tr > td > .cell-li2 {   /* ①  — 3단계 */
  padding-left: 5.7em; text-indent: -1.4em;
}
.jomun-wrap > table > tbody > tr > td > .cell-li3 {   /* ㉠  — 4단계 */
  padding-left: 7.1em; text-indent: -1.4em;
}

/* 그림 크기 및 중앙정렬 */
.doc-fig-img { max-width: 70%; height: auto; display: block; margin: 0 auto; }

/* 셀 단락 계층 */
.cell-p { margin: 0 0 0.35em; line-height: 1.55; }
.cell-p:last-child { margin-bottom: 0; }
/* 헤더행 대각선 분할 셀 */
.para-table th.diag-th { padding: 0; }
.diag-cell {
  position: relative; min-height: 4em; min-width: 6.5em; height: 100%;
  background: linear-gradient(to bottom left,
    transparent calc(50% - 0.5px),
    var(--gray-3) calc(50% - 0.5px),
    var(--gray-3) calc(50% + 0.5px),
    transparent calc(50% + 0.5px));
}
.diag-tr { position: absolute; top: 3px; right: 6px; }
.diag-bl { position: absolute; bottom: 3px; left: 6px; }

/* 편집자 주 (원본 표기와 다르게 교정한 곳에 근거를 남김) */
.editor-note {
  font-size: 12px;
  color: var(--gray-4);
  background: #fffbea;
  border-left: 3px solid #f0c000;
  border-radius: 0 3px 3px 0;
  padding: 5px 10px;
  margin: 4px 0 8px;
}
.editor-note::before {
  content: '편집자 주 ';
  font-weight: 700;
  color: #a07800;
}

/* 그림 자리표시자 (원본이 빈 칸이거나 도면 캡처 대기) */
.fig-placeholder {
  border: 1px dashed var(--gray-3);
  border-radius: 4px;
  background: var(--gray-1);
  color: var(--gray-4);
  font-size: 13px;
  text-align: center;
  padding: 40px 16px;
  margin: 0 auto;
  max-width: 70%;
}

/* 좌우 병렬 이미지 행 */
.img-row {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 12px; flex-wrap: wrap;
}
.img-row img { max-width: 46%; height: auto; }
/* 3장 이상인 행은 46%로는 한 줄에 못 들어가 2+1 로 접힌다 (원본은 한 줄) */
.img-row:has(img:nth-child(3)) img { max-width: calc((100% - 24px) / 3); }
.img-row:has(img:nth-child(4)) img { max-width: calc((100% - 36px) / 4); }

/* 해설 블록: 좌측 세로바 + 옅은 음영 */
.haeseol-block {
  border-left: 4px solid var(--gray-3);
  background: #f8f9fb;
  padding: 10px 16px 12px;
  margin: 14px 0;
  border-radius: 0 6px 6px 0;
}
.haeseol-label {
  font-weight: 700; font-size: 13px; color: var(--gray-4);
  margin-bottom: 6px;
}
.haeseol-block .para { margin-left: 0; }

/* 용어의 정의: 용어명 스타일 */
.cell-term {
  font-weight: 700; color: var(--blue);
  margin-top: 1.1em !important; margin-bottom: 0.15em !important;
}
.cell-term-en { font-weight: 400; color: var(--gray-3); font-size: 0.92em; margin-left: 2px; }
/* 조문박스 내 수식 줄: 가운데 정렬 + 식번호 우측 */
.cell-eq-row { display: flex; align-items: center; margin: 0.5em 0 !important; }
.cell-eq-body { flex: 1; text-align: center; }
.cell-eq-num { flex: 0 0 auto; padding-left: 8px; font-size: 0.92em; }
.cell-li0 { padding-left: 1.4em; text-indent: -1.4em; }
.cell-li1 { padding-left: 3.0em; text-indent: -1.7em; }
.cell-li2 { padding-left: 4.4em; text-indent: -1.4em; }
.cell-li3 { padding-left: 5.8em; text-indent: -1.4em; }

/* 헤드행 중앙정렬 */
.para-table th { text-align: center; }
