/* 디자인 시스템: 토큰(:root) → 기본 요소 → 컴포넌트 → 지도. 자세한 규칙은 DESIGN.md.
   어두운 테마 값은 아래 두 곳(@media와 [data-theme="dark"])에 같은 목록이 있으니 함께 고칠 것 */
:root {
  /* 시안 A 「양피지 아틀라스」: 제목·본문은 세리프(Song Myung은 기존에 받던 글꼴, 나머지는 시스템 세리프), 작은 조작 글자는 산세리프(--font-ui) */
  --font-display: "Song Myung", "Nanum Myeongjo", "AppleMyungjo", "Noto Serif KR", "Batang", serif;
  --font-body: "Nanum Myeongjo", "Noto Serif KR", "Source Han Serif K", "AppleMyungjo", "Batang", "Georgia", serif;
  --font-ui: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --fs-xs:.75rem; --fs-sm:.875rem; --fs-md:1rem; --fs-lg:1.25rem; --fs-xl:2rem; --fs-2xl:var(--fs-xl);   /* 글자 5단계: 12·14·16·20·32px(기본). --fs-2xl은 이전 이름(xl과 같은 값) */
  --lh-body:1.55; --lh-dense:1.4;
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:24px;
  --r-sm:4px; --r-md:6px; --r-lg:10px; --r-pill:999px;
  --focus-w:2px; --focus-off:2px; --tap:32px;
  --shadow-c:#3b2a14;   /* 그림자 색(잉크 갈색). 그림자는 color-mix로 투명도를 준다 */
  --shadow-1:0 1px 2px color-mix(in srgb, var(--shadow-c) 22%, transparent);
  --shadow-2:0 6px 22px color-mix(in srgb, var(--shadow-c) 28%, transparent);
  --dur-fast:120ms;
  --surface-0:#ece2cb; --surface-1:#fbf6e9; --surface-2:#f3ead6; --surface-sunken:#e3d6ba;
  --ink:#2a1f14; --ink-muted:#5c4b37; --on-accent:#fffaf0;
  --line:#d8c9aa; --line-strong:#8c7655;
  --accent:#8a2f1c; --accent-hover:#6e2414; --accent-soft:#f1dcc8; --focus:#8a2f1c;
  --danger:#9c1f2e; --ok:#2f6a3c; --warn:#7f5200;
  --selected-bg:#f1dcc8; --selected-line:#8a2f1c;
  --sea:#c5d3d2; --sea-deep:#a9bcbd; --land:#f1e6c9; --coast:#6c7a76;
  --map-periph:#5c4b37; --map-exchange:#7d3a78; --map-river:#2a6390; --map-ridge:#7a5a22; --map-site:#9a4f17;
  /* 인쇄 지도 장식: 테두리 선(--frame), 눈금 칸의 밝은 칸(--frame-alt), 컴파스·장식(--ornament) */
  --frame:#3a2c1c; --frame-alt:#fbf6e9; --ornament:#8a2f1c;
  --terr-op:.55; --terr-op-unc:.28; --terr-op-sphere:.3;
  color-scheme:light;
  /* 이전 이름(호환) */
  --bg:var(--surface-0); --panel:var(--surface-1); --muted:var(--ink-muted);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --shadow-c:#000000;
  --surface-0:#0d141e; --surface-1:#141d29; --surface-2:#1b2634; --surface-sunken:#090f17;
  --ink:#ece3cc; --ink-muted:#b6aa8f; --on-accent:#1a1206;
  --line:#2a3646; --line-strong:#6a7a90;
  --accent:#e2b867; --accent-hover:#f0cd8a; --accent-soft:#3a3020; --focus:#f0cd8a;
  --danger:#f29a9a; --ok:#8fcf9f; --warn:#e8bf6a;
  --selected-bg:#332c1d; --selected-line:#e2b867;
  --sea:#10243a; --sea-deep:#0a1828; --land:#34332b; --coast:#8a9bb0;
  --map-periph:#b6aa8f; --map-exchange:#d79ad2; --map-river:#6bb8ec; --map-ridge:#d2b06e; --map-site:#e5a15a;
  --frame:#c9a75e; --frame-alt:#141d29; --ornament:#e2b867;
  --terr-op:.85; --terr-op-unc:.5; --terr-op-sphere:.55;
  color-scheme:dark;
  }
}
:root[data-theme="dark"] {
  --shadow-c:#000000;
  --surface-0:#0d141e; --surface-1:#141d29; --surface-2:#1b2634; --surface-sunken:#090f17;
  --ink:#ece3cc; --ink-muted:#b6aa8f; --on-accent:#1a1206;
  --line:#2a3646; --line-strong:#6a7a90;
  --accent:#e2b867; --accent-hover:#f0cd8a; --accent-soft:#3a3020; --focus:#f0cd8a;
  --danger:#f29a9a; --ok:#8fcf9f; --warn:#e8bf6a;
  --selected-bg:#332c1d; --selected-line:#e2b867;
  --sea:#10243a; --sea-deep:#0a1828; --land:#34332b; --coast:#8a9bb0;
  --map-periph:#b6aa8f; --map-exchange:#d79ad2; --map-river:#6bb8ec; --map-ridge:#d2b06e; --map-site:#e5a15a;
  --frame:#c9a75e; --frame-alt:#141d29; --ornament:#e2b867;
  --terr-op:.85; --terr-op-unc:.5; --terr-op-sphere:.55;
  color-scheme:dark;
}
@media (prefers-reduced-motion: reduce) { :root { --dur-fast:0ms; } * { transition: none !important; } }
* { box-sizing: border-box; }
html { font-size: 100%; --uf: 1; }
html[data-fs="lg"] { font-size: 112.5%; --uf: 1.125; }   /* 사용자 글씨 크기: 루트 글자 크기(rem 토큰이 따라감)와 지도 글자 배율 --uf */
html[data-fs="xl"] { font-size: 125%; --uf: 1.25; }
html, body { margin: 0; background: var(--surface-0); color: var(--ink); font-family: var(--font-body); font-size: var(--fs-md); line-height: var(--lh-body); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-off); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

/* 레이아웃 */
.wrap { max-width: 1100px; margin: 0 auto; padding: var(--sp-4); display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
header h1 { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-lg); margin: 0; text-wrap: balance; }
@media (min-width: 1000px) { header h1 { font-size: var(--fs-xl); } }
header p { margin: var(--sp-1) 0 0; color: var(--ink-muted); font-size: var(--fs-sm); }
.main { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .main { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } }
.stage { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) and (min-height: 980px) { .stage { position: sticky; top: var(--sp-2); } }
.searchbar { margin-top: 10px; }

/* 카드·패널 */
.controls, .panel { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3) 14px; display: grid; gap: 10px; }
.panel { padding: 14px; gap: 14px; }
.panel h2 { font-size: var(--fs-xs); letter-spacing: .04em; color: var(--ink-muted); margin: 0 0 6px; font-weight: 600; }

/* 입력 (한 규격) */
input[type=text], input[type=number], input[type=search], select, textarea { font: inherit; font-size: var(--fs-sm); min-height: var(--tap); padding: 4px var(--sp-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-1); color: var(--ink); max-width: 100%; }
input[type=number] { width: 7.5rem; }
input[type=search] { width: min(100%, 24rem); }
textarea { width: 100%; min-height: 6rem; margin: var(--sp-1) 0; }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }
input[type=checkbox] { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
label { font-size: var(--fs-sm); }

/* 버튼: 기본(보조) / 주 동작(#play) / 켜짐(aria-pressed) / 비활성 */
button { font: inherit; font-size: var(--fs-sm); font-weight: 500; min-height: var(--tap); border: 1px solid var(--line-strong); background: var(--surface-1); color: var(--ink); border-radius: var(--r-md); padding: 0 var(--sp-3); cursor: pointer; }
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button[aria-pressed="true"] { background: var(--selected-bg); border-color: var(--selected-line); font-weight: 600; }
button[aria-pressed="true"]::before { content: "✓ "; }
#play { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
#play:hover { background: var(--accent-hover); }
@media (pointer: coarse), (max-width: 520px) { :root { --tap: 44px; } }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.speed { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--ink-muted); }

/* 시간 컨트롤 */
.yearrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#yearLabel { font-family: var(--font-display); font-size: var(--fs-2xl); font-variant-numeric: tabular-nums; line-height: 1.2; }
.ganji { font-family: var(--font-body); font-size: var(--fs-md); color: var(--ink-muted); margin-left: var(--sp-2); }
#eraLabel { color: var(--accent); font-weight: 600; font-size: var(--fs-md); }
.row { display: flex; gap: 6px 10px; align-items: center; flex-wrap: wrap; font-size: var(--fs-sm); }
.row .grow { flex: 1 1 14rem; }
fieldset.tg { border: 1px solid var(--line); border-radius: var(--r-md); margin: 0; padding: 6px var(--sp-3) var(--sp-2); display: grid; gap: 6px; }
fieldset.tg legend { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-muted); padding: 0 var(--sp-1); }
.chk { display: flex; gap: var(--sp-2); align-items: flex-start; }
.chk input { margin-top: 3px; flex: none; }
.qres { list-style: none; margin: var(--sp-1) 0 var(--sp-2); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-md); max-width: 36rem; max-height: 70vh; overflow-y: auto; background: var(--surface-1); }
.qres li button { width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: 6px 10px; display: block; min-height: var(--tap); }
.qres li button.on, .qres li button:hover { background: var(--selected-bg); }
.qres li + li { border-top: 1px solid var(--line); }
.qres .k { color: var(--ink-muted); font-size: var(--fs-xs); margin-left: 6px; }
details.inline-more > summary { cursor: pointer; font-size: var(--fs-sm); color: var(--ink-muted); min-height: 28px; }

/* 지도 박스 */
.mapbox { position: relative; background: var(--sea); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.mapbox svg { touch-action: pan-y; }
svg { display: block; width: 100%; height: auto; }
.mapnote { margin: 0; padding: 6px var(--sp-3); background: var(--surface-1); border-top: 1px solid var(--line); color: var(--ink-muted); font-size: var(--fs-xs); line-height: var(--lh-dense); }
.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-2); }
.tabs [role=tab] { border-radius: var(--r-pill); }
.tabs [role=tab][aria-selected="true"] { background: var(--selected-bg); border-color: var(--selected-line); font-weight: 700; }
.tabs [role=tab][aria-selected="true"]::before { content: "✓ "; }
#moreTabs details > summary { display: none; }
#moreTabs details.more-off { display: none; }
#moreTabs details[open] { border-left: 0; padding-left: 0; }
#moreTabs + .legend, #moreTabs .legend + .legend { border-top: 0; }
#ctxTabs [role=tabpanel].ctx-off { display: none; }
#ctxTabs [role=tabpanel] > h2 { font-size: var(--fs-md); }
.mapview { position: relative; }
.mapview { --mini-h: 52px; }   /* 지도 바로 아래 재생 줄의 높이(지도 위에 겹치는 단추가 이 줄을 가리지 않게 띄우는 값) */
.mini-row { display: flex; align-items: center; gap: var(--sp-2); padding: 4px var(--sp-2); background: var(--surface-1); border-top: 1px solid var(--line); }
.slider-mini { flex: 1; min-width: 0; margin: 0; min-height: 36px; }
.mini-row button { min-height: 36px; min-width: 44px; padding: 0 var(--sp-2); }
@media (pointer: coarse) { .slider-mini, .mini-row button { min-height: 44px; } }
.embed .mini-row, .embed .yearpill { display: none; }
.yearpill { position: absolute; left: var(--sp-2); top: var(--sp-2); padding: 2px var(--sp-2); border-radius: var(--r-pill); background: var(--surface-1); border: 1px solid var(--line-strong); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-1); }
/* 한 열(휴대폰·좁은 화면): 아래로 읽어 내려가도 지도가 위에 남도록 고정. 해안선 고지는 따로 스크롤된다 */
@media (max-width: 1099px) and (min-height: 560px) {
  .stage, .mapbox { display: contents; }
  .mapview { position: sticky; top: 0; z-index: 5; background: var(--sea); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
  .mapview svg { max-height: 34vh; margin: 0 auto; }
  .slider-mini { flex: 1; min-width: 0; margin: 0; min-height: 44px; }
  .mini-row button { min-height: 44px; min-width: 44px; padding: 0 var(--sp-1); }
  html { scroll-padding-top: var(--mapfix, calc(34vh + 110px)); }
  .panel h2, .panel summary, .panel [id] { scroll-margin-top: var(--mapfix, calc(34vh + 110px)); }   /* 이동·포커스한 요소가 고정된 지도 밑에 가려지지 않게 */
  .mapnote { border: 1px solid var(--line); border-radius: var(--r-md); }
}
.zoomctl { position: absolute; right: var(--sp-2); top: var(--sp-2); display: grid; gap: var(--sp-1); }
.zoomctl button { width: 34px; height: 34px; min-height: 0; padding: 0; font-size: 1.1rem; line-height: 1; box-shadow: var(--shadow-1); }
@media (pointer: coarse), (max-width: 520px) { .zoomctl button { width: 44px; height: 44px; } }
#map:focus-visible { outline-offset: -3px; }

/* 목록·칩·링크 */
.states { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.states li { display: grid; grid-template-columns: 12px 1fr; gap: var(--sp-2); align-items: start; }
/* 합본처럼 나라가 100개 넘게 살아 있는 해에는 목록이 수천 노드·3만 px라서, 화면 밖 항목은 레이아웃을 건너뛴다(연도를 바꿀 때마다 약 절반 절감) */
.states li { content-visibility: auto; contain-intrinsic-size: auto 120px; padding-block: 4px; margin-block: -4px; }   /* 안쪽 여백은 포커스 윤곽선이 칸 경계에서 잘리지 않게 하려는 것(바깥 여백 -4px로 배치는 그대로) */
.dot { width: 12px; height: 12px; border-radius: 3px; margin-top: 4px; }
.dot.unc { background: transparent !important; border: 2px dashed; }
.sname { font-weight: 600; }
.smeta { color: var(--ink-muted); font-size: var(--fs-sm); line-height: var(--lh-dense); }
.smeta a, .events a { color: var(--accent); }
.events .src { display: block; color: var(--ink-muted); font-size: var(--fs-xs); }
.chip, .stype { display: inline-block; font-size: var(--fs-xs); line-height: 1.5; border: 1px solid var(--line-strong); border-radius: var(--r-pill); padding: 0 var(--sp-2); margin-left: var(--sp-1); color: var(--ink-muted); font-weight: 500; }
.chip.kind { color: var(--ink); }
.sband-wrap { padding: 0 8px; margin-top: -4px; }
.sband { display: block; width: 100%; height: 20px; }
.sband .era { fill: var(--surface-2); stroke: var(--surface-1); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sband .era.alt { fill: var(--line); }
.sband .era.on { fill: var(--accent-soft); stroke: var(--accent); }
.sband .tk { stroke: var(--ink-muted); stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; }
.sband .cmpk { stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; }
.sband-note { margin: 0 0 var(--sp-2); }
.tipbtn { min-height: 0; min-width: 0; padding: 0 var(--sp-1); margin-left: 2px; border: 0; background: none; color: var(--ink-muted); font-size: var(--fs-sm); line-height: 1.4; cursor: pointer; }
.tipbtn[aria-expanded="true"] { color: var(--accent); }
.tipbtn[aria-pressed]::before { content: none; }
.tiptext { display: block; margin: var(--sp-1) 0; padding: var(--sp-1) var(--sp-2); border-left: 2px solid var(--line-strong); font-size: var(--fs-xs); line-height: var(--lh-dense); color: var(--ink-muted); }
@media (pointer: coarse), (max-width: 520px) {
  .tipbtn, .events .y, .story .y, .y { position: relative; }
  .tipbtn { min-height: 32px; min-width: 32px; }
  .tipbtn::after, .y::after { content: ""; position: absolute; inset: -8px -6px; }   /* 눈에 보이는 크기는 그대로 두고 누를 수 있는 영역만 44px 안팎으로 넓힘 */
}
.tiptext[hidden] { display: none; }
.ext { font-size: .8em; margin-left: 1px; }
.events { margin: 0; padding-left: 18px; display: grid; gap: var(--sp-1); font-size: var(--fs-md); }
.events .y, .story .y, .y { background: none; border: 0; padding: 0; min-height: 0; font: inherit; color: var(--accent); font-variant-numeric: tabular-nums; margin-right: var(--sp-1); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.y:hover { text-decoration-style: solid; color: var(--accent-hover); }
.alt-sel { font-weight: 700; }
.bgline { margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-muted); }
.empty, #warDesc { color: var(--ink-muted); font-size: var(--fs-md); margin: 0; }
#warDesc { margin-top: var(--sp-2); font-size: var(--fs-sm); }
.note { color: var(--ink-muted); font-size: var(--fs-xs); line-height: 1.5; margin: 0; }
.story { border-top: 1px solid var(--line); padding-top: var(--sp-2); margin-top: var(--sp-2); font-size: var(--fs-md); }
.story:first-child { border: 0; margin: 0; padding: 0; }
.story ol { margin: 6px 0 var(--sp-1); padding-left: 18px; display: grid; gap: 3px; }
.story li:not(.cur) { color: var(--ink-muted); }
.story li.cur { font-weight: 600; }

/* 접이식(details) */
.legend { font-size: var(--fs-sm); color: var(--ink-muted); }
.legend summary { cursor: pointer; font-weight: 600; min-height: 28px; padding: var(--sp-1) 0; }
.legend[open] { border-left: 2px solid var(--line-strong); padding-left: var(--sp-3); }
.legend ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: var(--sp-1); }
.legend + .legend { border-top: 1px solid var(--line); }
.sw { display: inline-block; width: 26px; height: 12px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.sw.core { background: color-mix(in srgb, var(--accent) 55%, transparent); border: 1.6px solid var(--accent); }
.sw.sphere { background: color-mix(in srgb, var(--accent) 25%, transparent); border: 1.2px dotted var(--accent); }
.sw.zone { background: radial-gradient(closest-side, var(--accent), transparent); }
.sw.hatch { background: repeating-linear-gradient(45deg, var(--ink-muted) 0 2px, transparent 2px 6px); border: 1.4px dashed var(--ink-muted); }
.swl { vertical-align: middle; margin-right: 6px; }

/* 표·연표·띠 */
#eraSystems td, #eraSystems th { vertical-align: top; text-align: left; padding: var(--sp-1) var(--sp-2); border-bottom: 1px solid var(--line); font-size: var(--fs-xs); line-height: var(--lh-dense); }
#eraSystems th { background: var(--surface-2); font-weight: 600; }
#eraSystems table { border-collapse: collapse; width: 100%; margin-top: 6px; }
.tvscroll { overflow-x: auto; margin-top: 6px; }
#tableView svg, #structView svg { display: block; max-width: none; width: auto; height: auto; }
#tableView .bar, #structView .bar { cursor: pointer; }
.barinfo { min-height: 2.8em; margin: 0 0 var(--sp-1); }
#tableView .bar:hover, #structView .bar:hover { opacity: .75; }
.bar:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: 1px; }
#tableView text, #structView text { font-size: var(--fs-xs); fill: var(--ink); }
#tableView .gl, #structView .gl { stroke: var(--line); stroke-width: 1; }
#tableView .now, #structView .now { stroke: var(--accent); stroke-width: 1.5; }
#structView .th { font-weight: 700; fill: var(--accent); }

/* 지도 글자·선 */
.lbl { font-family: var(--font-body); font-weight: 600; paint-order: stroke; stroke: var(--land); stroke-width: calc(3px * var(--mf, 1) * var(--zk, 1)); fill: var(--ink); }
.cap { font-size: calc(12px * var(--mf, 1) * var(--zk, 1)); font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--land); stroke-width: calc(3px * var(--mf, 1) * var(--zk, 1)); }
.prov { font-size: calc(12px * var(--mf, 1) * var(--zk, 1)); font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--land); stroke-width: calc(3px * var(--mf, 1) * var(--zk, 1)); }
.city { font-size: calc(12px * var(--mf, 1) * var(--zk, 1)); font-weight: 400; fill: var(--ink); paint-order: stroke; stroke: var(--land); stroke-width: calc(3px * var(--mf, 1) * var(--zk, 1)); }
.city.alt { font-style: italic; }
.periph { font-size: calc(12px * var(--mf, 1) * var(--zk, 1)); font-style: italic; fill: var(--map-periph); paint-order: stroke; stroke: var(--land); stroke-width: calc(2.5px * var(--mf, 1) * var(--zk, 1)); }
.terr { fill-opacity: var(--terr-op); }
.terr.unc { fill-opacity: var(--terr-op-unc); }
.terr.sphere { fill-opacity: var(--terr-op-sphere); }
.terr.hatch { fill-opacity: 1; }

/* 나란히 보기(compare.html) 안에 끼운 화면(?embed=1): 머리말과 시간 조절은 바깥 화면이 맡는다 */
.embed header, .embed section.controls { display: none; }
.embed .wrap { padding: var(--sp-2); }

.chk[hidden] { display: none; }

.yearpill { max-width: calc(100% - 76px); white-space: normal; line-height: 1.3; border-radius: var(--r-lg); }   /* 합본의 긴 시대 이름이 화면 밖으로 넘치지 않게 */
.main, .stage, .mapbox, .mapview { min-width: 0; }   /* 가로로 긴 지도(합본)가 좁은 화면에서 칸을 밀어내지 않게 */
.mapview svg { max-width: 100%; }
#eraJump, #eraSet, .panel select { max-width: min(100%, 90vw); }   /* 합본의 긴 시대 이름이 칸을 넘치지 않게 */
.panel, .controls, fieldset.tg, #ctlMore > div { grid-template-columns: minmax(0, 1fr); }   /* 긴 안내 문구가 칸 폭을 키우지 않게 */
.panel > *, .panel details, .controls > * { min-width: 0; }
.row, span.row { max-width: 100%; min-width: 0; flex-wrap: wrap; }
#eraJump { width: 100%; }
.panel a, .smeta a, .src a { overflow-wrap: anywhere; }   /* 주소 그대로인 출처 이름이 칸을 넘치지 않게 */
.yearpill { pointer-events: none; }   /* 지도 조작(끌기·핀치)을 가리지 않게 */

/* 작은 축척 지도(세계 합본): 선 굵기를 화면 픽셀로 고정해 줌아웃에서도 경계가 보이고 확대해도 굵어지지 않게 함(engine.js mapTextScale이 .ns를 켬) */
#map.ns path, #map.ns line, #map.ns circle, #map.ns rect { vector-effect: non-scaling-stroke; }
#map.ns pattern line { vector-effect: none; }

/* 가로로 아주 긴 지도(세계 합본): 지도를 한 줄 전체 폭으로 */
@media (min-width: 1100px) {
  html.wide .wrap { max-width: min(1800px, 100%); }
  html.wide .main { grid-template-columns: minmax(0, 1fr); }
  html.wide .stage { position: static; }
}

/* 지구본(정사 투영) 보기: 합본에서만 전환 단추가 보이고, 켜면 평면 SVG(#map) 대신 캔버스(#gcv)와 글자 층(#gsvg)을 보인다 */
.globebox, #globeNote { display: none; }
.viewsw { position: absolute; z-index: 2; top: var(--sp-2); right: 52px; display: flex; gap: 0; box-shadow: var(--shadow-1); border-radius: var(--r-md); }
.viewsw[hidden] { display: none; }
.viewsw button { min-height: 34px; padding: 0 10px; border-radius: 0; font-weight: 600; }
.viewsw button:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.viewsw button:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; border-left: 0; }
.viewsw button[aria-pressed="true"]::before { content: none; }
@media (pointer: coarse), (max-width: 520px) { .viewsw { right: 56px; } .viewsw button { min-height: 44px; } }
html.globe #map { display: none; }
html.globe .globebox { display: block; position: relative; width: 100%; height: min(76vh, 780px); min-height: 300px; background: var(--surface-sunken); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
html.globe .globebox:active { cursor: grabbing; }
html.globe .mapnote[data-r] { display: none; }
html.globe #globeNote { display: block; }
#gcv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#gcv:focus-visible { outline-offset: -3px; }
#gsvg { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; pointer-events: none; overflow: hidden; }
#gsvg .lbl, #gsvg .cap, #gsvg .city { stroke-width: 3px; }
.gctl { position: absolute; left: var(--sp-2); bottom: calc(var(--sp-2) + var(--mini-h, 0px)); z-index: 4; max-width: calc(100% - 140px); }
.gctl[hidden] { display: none; }
.gctl select { max-width: 100%; }
.gctl select { min-height: 34px; box-shadow: var(--shadow-1); }
@media (pointer: coarse), (max-width: 520px) { .gctl select { min-height: 44px; } }
@media (max-width: 1099px) and (min-height: 560px) {
  html.globe .globebox { height: 42vh; min-height: 260px; }
}
html.globe .zoomctl { z-index: 3; }

/* 불러오는 중 · 건너뛰기 · 첫 화면 안내 */
.loading { margin: var(--sp-5); font-size: var(--fs-md); color: var(--ink-muted); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.loading-bar { flex: none; width: 56px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--line) 0 30%, var(--accent) 30% 60%, var(--line) 60%); background-size: 200% 100%; animation: loadbar 1.1s linear infinite; }
@keyframes loadbar { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .loading-bar { animation: none; } }
.skip { position: absolute; left: var(--sp-2); top: -100px; z-index: 50; background: var(--surface-1); }
.skip:focus { top: var(--sp-2); }
.welcome { background: var(--surface-1); border: 1px solid var(--selected-line); border-left-width: 4px; border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); display: grid; gap: var(--sp-2); }
.welcome h2 { margin: 0; font-size: var(--fs-md); }
.welcome ul { margin: 0; padding-left: 1.2em; display: grid; gap: var(--sp-1); font-size: var(--fs-sm); line-height: var(--lh-dense); }

/* 세계 합본(지구본 전환이 있는 지역)의 좁은 화면: 작은 지도 위를 덮던 확대·전환·지역 단추를 지도 아래 한 줄로 내림 */
@media (max-width: 1099px) and (min-height: 560px) {
  html.hasglobe .mapview { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-2); --mini-h: 0px; }
  html.hasglobe .mapview > svg, html.hasglobe .mapview > .globebox, html.hasglobe .mapview > .mini-row { flex: 0 0 100%; }
  html.hasglobe .mapview > svg { order: 1; }
  html.hasglobe .mapview > .globebox { order: 1; }
  html.hasglobe .viewsw, html.hasglobe .zoomctl, html.hasglobe .gctl { position: static; box-shadow: none; max-width: none; }
  html.hasglobe .viewsw { order: 2; } html.hasglobe .gctl { order: 3; } html.hasglobe .zoomctl { order: 4; }
  html.hasglobe .gctl { flex: 1 1 0; min-width: 0; padding: 2px 0 2px var(--sp-2); }
  html.hasglobe .gctl select { width: 100%; box-shadow: none; }
  html.hasglobe .zoomctl { display: flex; margin-left: auto; padding: 2px var(--sp-2) 2px 0; }
  html.hasglobe .viewsw { padding: 2px 0 2px var(--sp-2); }
  html.hasglobe .mapview > .mini-row { order: 5; }
  html.hasglobe .yearpill { max-width: calc(100% - 16px); }
}

/* 합본처럼 나라가 수백 곳인 해: 목록이 페이지를 6만 px까지 늘리지 않게 칸 안에서 스크롤 */
html.wide .states { max-height: min(70vh, 640px); overflow-y: auto; overscroll-behavior: contain; padding-right: var(--sp-2); border-block: 1px solid var(--line); }
html.wide .states:focus-visible { outline-offset: 0; }

/* 확대한 평면 지도: 끌어서 이동할 수 있음을 손 모양으로 알림 */
#map.pan { cursor: grab; }
#map.pan:active { cursor: grabbing; }
/* 늦게 불러오는 글 층이 남은 동안의 작은 알림(합본): 자리를 차지하지 않아 화면이 밀리지 않는다 */
.loading.late { position: fixed; right: var(--sp-3); bottom: var(--sp-3); margin: 0; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-pill); box-shadow: var(--shadow-1); z-index: 50; cursor: default; }

/* 긴 설명 가독성: 시대 이름 참고(지역별 목록)·출처 줄(칩이 많으면 접음) */
.eralist { margin: var(--sp-1) 0; padding: 0; list-style: none; display: grid; gap: var(--sp-2); max-width: 72ch; }
.eralist li { line-height: var(--lh-body); }
.eralist .rg { color: var(--accent); margin-right: var(--sp-1); }
.eramore, .srcmore { margin-top: var(--sp-1); }
.eramore > summary, .srcmore > summary { cursor: pointer; color: var(--accent); font-size: var(--fs-sm); min-height: 28px; display: list-item; }
.eramore[open] > summary, .srcmore[open] > summary { margin-bottom: var(--sp-1); }
.srcl { display: inline-block; max-width: 72ch; line-height: 1.9; margin-top: var(--sp-1); }
.srcl .stype { margin-left: 0; margin-right: var(--sp-1); }
/* 넓은 칸(합본 한 줄 배치·데스크톱)에서 설명 문단이 한 줄에 150자씩 늘어지지 않게 읽기 좋은 폭으로 제한 */
.panel p, .panel .smeta, .panel .note { max-width: 75ch; }

/* 지도 아래 텍스트 전체: 한 줄 길이·줄 간격·위계·긴 목록 접기 */
.panel .states, .panel .events, .panel .story, .panel .legend ul, .panel .legend p, .structlist, #altList, #histList, #relList, #exchList, #siteList, #warDesc, .tiptext, .listmore, #adminList { max-width: 75ch; }
.panel li, .panel p, .smeta, .note, .events, .tiptext { overflow-wrap: break-word; }
.note, .legend p, .legend li, .events li, .story, #altList, #histList { line-height: 1.6; }
.smeta { line-height: 1.5; }
.legend ul, .events { gap: var(--sp-2); }
.structlist { gap: var(--sp-3) !important; }
.states { gap: var(--sp-3); }
/* 나라 항목: 이름(굵게) > 기간·수도 > 국호 변천 > 설명(본문 색) > 출처(작고 흐리게) */
.smeta .sl { display: block; margin-top: 2px; }
.smeta .asof { font-size: var(--fs-xs); }
.smeta .snote { color: var(--ink); margin-top: var(--sp-1); line-height: 1.6; }
.smeta .srcl { font-size: var(--fs-xs); margin-top: var(--sp-1); }
.listmore { margin-top: var(--sp-2); }
.listmore > summary { cursor: pointer; color: var(--accent); font-size: var(--fs-sm); min-height: 28px; display: list-item; }
.listmore[open] > summary { margin-bottom: var(--sp-2); }
/* 합본의 행정구역 이름 목록처럼 아주 긴 한 덩어리는 칸 안에서 스크롤(키보드로 초점을 줄 수 있음) */
#adminList { max-height: 14em; overflow-y: auto; }

/* 넓은 화면(합본 한 줄 배치): 패널을 2열로. 왼쪽 나라 목록(스크롤·고정), 오른쪽 해석·사건. 좁으면 기존 한 열(display: contents) */
.pcols, .pcol { display: contents; }
@media (min-width: 1280px) {
  html.wide .pcols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
  html.wide .pcol { display: grid; gap: 14px; min-width: 0; align-content: start; }
  html.wide .pcol-a { position: sticky; top: var(--sp-2); }
  html.wide .states { max-height: calc(100vh - 150px); min-height: 320px; }
  html.wide .panel .states, html.wide .panel .events, html.wide .panel .story, html.wide #altList, html.wide #histList, html.wide .listmore { max-width: none; }
  html.wide .panel .pcol p, html.wide .panel .pcol .smeta, html.wide .panel .pcol .note { max-width: 80ch; }
}
html.wide .states { max-height: min(78vh, 900px); }

/* 사건 목록: 연도·분류 칩 줄 / 본문 / 출처·배경 줄을 항목마다 같은 구조로 */
.events li { display: grid; gap: 2px; padding-bottom: var(--sp-2); border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.evmeta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }
.evmeta .chip { margin-left: 0; }
.evmeta .y { margin-right: 0; font-weight: 600; }
.evtext { line-height: 1.6; }
.events .src, .events .bgline { margin-top: var(--sp-1); }
/* 체크박스 + 라벨 + 작은 부연(둘째 줄) 정렬 */
.chk > span { min-width: 0; }
.chkdesc { display: block; color: var(--ink-muted); font-size: var(--fs-xs); line-height: 1.5; margin-top: 2px; font-weight: 400; }
.evbig { flex: 1 1 100%; margin-top: var(--sp-1); }
.evbig input { margin-top: 4px; }
/* 칩은 짧은 라벨만(긴 서술은 본문). 넘치면 줄바꿈 */
.chip, .stype { max-width: 100%; white-space: normal; vertical-align: baseline; }
.smeta .srcl, .srcl { display: block; margin-top: var(--sp-1); }
br:has(+ .srcl) { display: none; }
/* 항목 구분선·여백 일정하게 */
.states { gap: 0; }
.states li { padding-block: var(--sp-2); margin-block: 0; }
.states li + li { border-top: 1px solid var(--line); }
.eralab { display: block; font-weight: 600; color: var(--ink-muted); font-size: var(--fs-sm); margin-bottom: 2px; }
.eramore { margin-top: var(--sp-2); }
.mapnote { max-width: 80ch; }
@media (min-width: 1280px) {
  html.wide #ctlMore > div { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
  html.wide #ctlMore > div > .row, html.wide #ctlMore > div > span.row { grid-column: 1 / -1; }
}

/* 찾기 결과 선택 강조: 목록 항목·지도 윤곽선·이름표 */
.picked { outline: 3px solid var(--accent); outline-offset: 2px; background: var(--accent-soft); border-radius: var(--r-sm); animation: pickfade 6s ease-out forwards; }
@keyframes pickfade { 0%, 70% { background: var(--accent-soft); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .picked { animation: none; } }
.pickring { animation: pickpulse 1s ease-in-out 4; pointer-events: none; }
@keyframes pickpulse { 50% { stroke-opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pickring { animation: none; } }
.lbl[data-pick] { fill: var(--accent); stroke-width: calc(5px * var(--mf, 1) * var(--zk, 1)); }
.noarea { color: var(--ink); font-style: italic; }
@media (max-width: 1099px) and (min-height: 560px) { .states li, .events li, .story { scroll-margin-top: var(--mapfix, calc(34vh + 110px)); } }

/* 찾기 결과: 묶음 머리글·계통 들여쓰기·두 줄 항목 */
.qres ul { list-style: none; margin: 0; padding: 0; }
.qgh { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--ink-muted); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .03em; padding: 4px 10px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.qgroup:first-child .qgh { border-top: 0; }
.qres .qgroup > ul > li + li { border-top: 1px solid var(--line); }
.qi { display: flex; align-items: stretch; }
.qi .qopt { flex: 1 1 auto; min-width: 0; }
.qopt .qt { display: block; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qopt .qm { display: block; color: var(--ink-muted); font-size: var(--fs-xs); margin-top: 2px; }
.qopt .qm .chip { margin-left: 0; margin-right: 4px; }
.qi.d1 .qopt { padding-left: 24px; } .qi.d2 .qopt { padding-left: 38px; } .qi.d3 .qopt { padding-left: 52px; } .qi.d4 .qopt { padding-left: 66px; }
.qmoreo { color: var(--accent); font-size: var(--fs-sm); }
.qres li button.qadd { flex: none; width: 44px; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: none; color: var(--accent); font-size: 1.1rem; cursor: pointer; }
.qres li button.qadd[aria-pressed="true"] { background: var(--accent-soft); font-weight: 700; }

/* 항목 비교: 아래 고정 줄(칩) + 비교 보기(dialog) */
#cmpTray { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); background: var(--surface-1); border-top: 2px solid var(--accent); box-shadow: 0 -2px 8px color-mix(in srgb, var(--shadow-c) 20%, transparent); font-size: var(--fs-sm); }
#cmpTray[hidden] { display: none; }
body.cmp-on { padding-bottom: 76px; }
.cchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); padding: 0 0 0 var(--sp-2); background: var(--surface-2); }
.cchip i, #cmpDlg h3 i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--ink-muted); }
.cchip button { min-height: 32px; min-width: 32px; border: 0; background: none; border-radius: var(--r-pill); font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--ink); }
.cmpchk { display: inline-flex; gap: 6px; align-items: center; }
#cmpDlg { width: min(1200px, 96vw); max-height: 92vh; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface-1); color: var(--ink); padding: var(--sp-3) var(--sp-4); overflow: auto; }
#cmpDlg::backdrop { background: color-mix(in srgb, var(--shadow-c) 55%, transparent); }
.cmphead { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.cmphead h2 { margin: 0; font-size: var(--fs-lg); }
.cmpyr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0; }
.cmpyr input[type=range] { flex: 1 1 220px; min-width: 0; }
.ctracks { display: grid; gap: 4px; margin: var(--sp-2) 0 var(--sp-3); }
.ctr { display: grid; grid-template-columns: minmax(80px, 160px) 1fr; gap: var(--sp-2); align-items: center; font-size: var(--fs-xs); }
.ctn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctb { position: relative; height: 16px; background: var(--surface-2); border-radius: 3px; }
.ctb i { position: absolute; top: 0; bottom: 0; }
.cbar { border-radius: 3px; opacity: .9; }
.ccom { background: transparent; border-inline: 2px solid var(--ink); }
.cnow { width: 2px; background: var(--accent); }
.cgrid { display: grid; grid-template-columns: repeat(var(--n), minmax(220px, 1fr)); gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-2); }
.ccard { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); min-width: 0; display: grid; gap: var(--sp-2); align-content: start; }
.ccard h3 { margin: 0; font-size: var(--fs-md); display: flex; gap: 6px; align-items: center; }
.cmini { width: 100%; height: auto; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: var(--r-sm); }
.ccard dl { margin: 0; display: grid; gap: 2px; font-size: var(--fs-sm); }
.ccard dt { font-size: var(--fs-xs); color: var(--ink-muted); font-weight: 600; margin-top: var(--sp-1); }
.ccard dd { margin: 0; overflow-wrap: break-word; }
.cev { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 4px; }
.cmprm { justify-self: start; }
@media (max-width: 520px) { #cmpDlg { width: 100vw; max-height: 100vh; border-radius: 0; padding: var(--sp-3); } .cgrid { grid-template-columns: repeat(var(--n), 80vw); } }

/* ---- 지도 위 「레이어」 플로팅 패널 ---- */
.layerctl { display: flex; flex-direction: row-reverse; align-items: flex-start; gap: var(--sp-1); position: absolute; z-index: 4; right: var(--sp-2); top: calc(var(--sp-2) + 3 * 34px + 3 * var(--sp-1) + var(--sp-1)); }
.layerctl > #layerBtn, .layerctl > #mapInfoBtn { min-height: 34px; padding: 0 10px; font-size: var(--fs-xs); font-weight: 600; box-shadow: var(--shadow-1); }
.layerctl > #layerBtn[aria-expanded="true"], .layerctl > #mapInfoBtn[aria-expanded="true"] { background: var(--selected-bg, var(--surface-2)); border-color: var(--selected-line); }
.layerpanel { position: absolute; right: calc(100% + var(--sp-1)); top: 0; width: 15rem; max-height: 60vh; overflow-y: auto; background: var(--surface-1); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-2, var(--shadow-1)); padding: var(--sp-2); font-size: var(--fs-xs); }
.layerpanel[hidden], .lprow[hidden] { display: none; }
.layerpanel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.lphead { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-1); font-size: var(--fs-xs); }
.lpclose { min-height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); }
.lprow { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; }
.lprow .chk { flex: 1 1 0; min-width: 0; font-size: var(--fs-xs); min-height: 32px; align-items: center; }
.lprow .chk span { font-size: var(--fs-xs); line-height: 1.3; }
.lprow .tipbtn { flex: 0 0 auto; font-size: var(--fs-xs); border: 1px solid var(--line-strong); border-radius: 50%; width: 22px; height: 22px; min-width: 22px; min-height: 22px; padding: 0; margin: 0; }
.lprow .tiptext { flex: 1 1 100%; margin: 2px 0 var(--sp-1); }
@media (pointer: coarse), (max-width: 520px) { .layerctl > #layerBtn, .layerctl > #mapInfoBtn { min-height: 44px; min-width: 44px; } .layerctl { top: calc(var(--sp-2) + 3 * 44px + 3 * var(--sp-1) + var(--sp-1)); } .lprow .chk { min-height: 44px; } }
@media (pointer: coarse) { .lprow .tipbtn::after { inset: -11px; } }
@media (max-width: 700px) {
  .layerpanel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 60vh; border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 30; padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 16px color-mix(in srgb, var(--shadow-c) 25%, transparent); }
  body.cmp-on .layerpanel { bottom: var(--cmp-h, 56px); }
}
@media (max-width: 1099px) and (min-height: 560px) {
  html.hasglobe .layerpanel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 60vh; border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 30; padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 16px color-mix(in srgb, var(--shadow-c) 25%, transparent); }
  html.hasglobe body.cmp-on .layerpanel { bottom: var(--cmp-h, 56px); }
}
.embed .layerctl { display: none; }
@media (max-width: 1099px) and (min-height: 560px) { html.hasglobe .layerctl { position: static; order: 4; padding: 2px 0; } html.hasglobe .zoomctl { margin-left: 0; } }

/* ---- 지도 위 연도 막대(재생·이동) ---- */
.yearbar { position: absolute; z-index: 4; left: 0; right: 0; margin-inline: auto; width: max-content; bottom: calc(var(--sp-2) + var(--mini-h, 0px)); display: flex; align-items: center; gap: 2px; padding: 3px; max-width: calc(100% - 16px); background: color-mix(in srgb, var(--surface-1) 85%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); border: 1px solid var(--line-strong); border-radius: var(--r-pill); box-shadow: var(--shadow-1); transition: opacity .15s; }
.yearbar > button { min-height: 34px; min-width: 34px; padding: 0 10px; font-size: var(--fs-xs); border-radius: var(--r-pill); white-space: nowrap; }
.yearbar > button[aria-pressed="true"]::before { content: none; }
.yearbar .byear { padding: 0 var(--sp-2); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mapview.dragging .yearbar { opacity: .3; }
.yearbar:focus-within { opacity: 1; }
.yearmore { position: absolute; z-index: 5; bottom: calc(var(--sp-2) + var(--mini-h, 0px) + 50px); right: var(--sp-2); width: 19rem; max-width: 90vw; max-height: 50vh; overflow-y: auto; display: grid; gap: var(--sp-2); background: var(--surface-1); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-1); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); transform: none; }
.yearmore[hidden] { display: none; }
.yearmore .row, .yearmore .btns, .yearmore .speed { font-size: var(--fs-xs); }
.yearmore input[type=number] { width: 9rem; }
.yearmore .tipbtn { justify-self: start; font-size: var(--fs-xs); }
.embed .yearbar { display: none; }
@media (pointer: coarse), (max-width: 520px) { .yearbar > button { min-height: 44px; min-width: 44px; padding: 0 var(--sp-2); } .yearmore .btns button, .yearmore .row button { min-height: 44px; } }
@media (max-width: 520px) { .yearbar .bl { display: none; } .yearbar > button { padding: 0 4px; } .yearbar .byear { padding: 0 4px; } }
@media (max-width: 1099px) and (min-height: 560px) {
  .yearmore { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: 60vh; border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 30; padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 16px color-mix(in srgb, var(--shadow-c) 25%, transparent); }
  body.cmp-on .yearmore { bottom: var(--cmp-h, 56px); }
  html.hasglobe .yearbar { position: relative; margin: 0; width: auto; left: auto; right: auto; bottom: auto; order: 4; flex: 0 0 100%; justify-content: center; max-width: none; border-radius: 0; border-width: 1px 0 0; background: var(--surface-1); box-shadow: none; }
}

/* ---- 넓은 화면(≥1100px): 지도는 왼쪽에 붙박이, 나라·사건·해석 패널만 오른쪽에서 스크롤 ---- */
@media (min-width: 1100px) and (min-height: 560px) {
  :root { --mapw: 58%; }
  html[data-split="map"] { --mapw: 66%; } html[data-split="panel"] { --mapw: 45%; }
  .main, html.wide .main { grid-template-columns: var(--mapw) minmax(0, 1fr); align-items: start; }
  .stage, html.wide .stage { position: sticky; top: var(--sp-2); align-self: start; max-height: calc(100vh - 2 * var(--sp-2)); overflow-y: auto; overscroll-behavior: contain; }
  body.cmp-on .stage { max-height: calc(100vh - var(--cmp-h, 56px) - 2 * var(--sp-2)); }
  .mapview { --mini-h: 0px; }
  .mapview svg { max-height: calc(100vh - 250px); margin: 0 auto; }
  .mini-row, .sband-note { display: none; }
  html.wide { --mapw: 62%; } html.wide[data-split="map"] { --mapw: 70%; } html.wide[data-split="panel"] { --mapw: 48%; }
  html.hasglobe .gctl { bottom: calc(var(--sp-2) + 48px); }   /* 가운데 아래 연도 막대와 겹치지 않게 「지역 보기」 select를 한 단 위로 */
  html.wide .pcols { display: contents; }
  html.wide .pcol { display: contents; }
  html.wide .pcol-a { position: static; }
  html.wide .states { max-height: min(70vh, 640px); min-height: 0; }
}

.layerctl > #mapInfoBtn { min-width: 34px; padding: 0; }
@media (min-width: 1100px) { .mapinfo { width: 22rem; } }
.mapinfo .mapnote { border: 0; padding: var(--sp-1) 0; background: none; max-width: none; }
.mapinfo .mapnote + .mapnote { border-top: 1px solid var(--line); }
html.globe .mapinfo #globeNote { display: block; }

/* ---- 큰 화면: 폭 제한을 풀고 지도가 화면 높이를 채우게 ---- */
@media (min-width: 1100px) and (min-height: 560px) {
  .wrap, html.wide .wrap { max-width: none; }
  .main, html.wide .main { grid-template-columns: minmax(0, 1fr) clamp(28rem, 38vw, 46rem); }
  html.wide .main { grid-template-columns: minmax(0, 1fr) clamp(28rem, 34vw, 40rem); }   /* 가로로 긴 합본 지도는 폭이 곧 크기라 패널은 읽기 폭(약 60자)까지만 */
  html[data-split="map"] .main, html.wide[data-split="map"] .main { grid-template-columns: minmax(0, 1fr) clamp(26rem, 30vw, 38rem); }
  html[data-split="panel"] .main, html.wide[data-split="panel"] .main { grid-template-columns: minmax(0, 1fr) clamp(32rem, 50vw, 70rem); }
  .mapview svg { max-height: calc(100vh - var(--ctlh, 250px)); }
  html.globe .globebox { height: calc(100vh - var(--ctlh, 250px)); }
  #eraNote { max-height: 4.6rem; overflow-y: auto; overscroll-behavior: contain; }   /* 합본의 긴 시대 이름 참고가 붙박이 지도 칸을 키우지 않게(안에서 스크롤) */
}

/* ---- 큰 화면 분할: 제목 줄 압축, 연도 막대는 지도 아래 줄, 연도 머리말은 오른쪽 열 맨 위 ---- */
.introcl { display: none; }
@media (min-width: 1100px) and (min-height: 560px) {
  header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-5); }
  header h1 { margin: 0; font-size: var(--fs-lg); }
  header > p[data-r=intro] { display: none; }
  .introcl { display: block; }
  .searchbar { flex: 1 1 22rem; max-width: 40rem; position: relative; margin-top: 0; }
  .searchbar .qres { position: absolute; left: 0; top: 100%; z-index: 40; width: min(36rem, 100%); margin: 2px 0 0; }
  .yearhead { display: grid; gap: var(--sp-1); }
  .yearhead:empty { display: none; }
  .yearhead .yearrow { font-size: var(--fs-md); }
  #eraNote { max-height: 9rem; }
  .yearbar { position: static; margin: 6px auto; width: max-content; max-width: 100%; }
  .yearmore { bottom: calc(var(--sp-2) + 56px); }
}

/* ======== 지도 전체 화면(map-first) 배치: html[data-layout="full"], 768px 이상·높이 560px 이상 ========
   지도가 화면 전체를 덮는 배경이고 제목·찾기·막대·슬라이더(도크)·패널이 그 위에 뜬다. 「화면 배치」에서 분할로 되돌릴 수 있다. */
#panelToggle { display: none; }
@media (min-width: 768px) and (min-height: 560px) {
  html[data-layout="full"]:not(.embed) {
    --pwp: min(92vw, 420px); --pw: 0px; --dockb: 0px; --pwt: 0px;
  }
  html[data-layout="full"][data-panel="open"]:not(.embed) { --pwt: var(--pwp); }
  html[data-layout="full"]:not(.embed) body.cmp-on { --dockb: var(--cmp-h, 56px); }
  html[data-layout="full"]:not(.embed), html[data-layout="full"]:not(.embed) body { height: 100%; overflow: hidden; }
  html[data-layout="full"]:not(.embed) .wrap { max-width: none; padding: 0; display: block; }
  html[data-layout="full"]:not(.embed) .main, html[data-layout="full"]:not(.embed) .stage, html[data-layout="full"]:not(.embed) .mapbox { display: contents; }
  html[data-layout="full"]:not(.embed) header { position: fixed; top: var(--sp-2); left: var(--sp-2); z-index: 20; display: flex; flex-wrap: nowrap; align-items: center; gap: var(--sp-3); max-width: calc(100vw - var(--pw) - 210px); padding: 4px var(--sp-3); background: color-mix(in srgb, var(--surface-1) 90%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
  html[data-layout="full"]:not(.embed) header h1 { font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 0 auto; max-width: 18rem; }
  html[data-layout="full"]:not(.embed) header > p[data-r=intro] { display: none; }
  html[data-layout="full"]:not(.embed) .introcl { display: block; }
  html[data-layout="full"]:not(.embed) .searchbar { flex: 0 1 22rem; min-width: 12rem; margin: 0; position: relative; }
  html[data-layout="full"]:not(.embed) .searchbar .row { flex-wrap: nowrap; }
  html[data-layout="full"]:not(.embed) .searchbar input { min-width: 0; width: 100%; }
  html[data-layout="full"]:not(.embed) .searchbar .qres { position: absolute; left: 0; top: calc(100% + 4px); z-index: 40; width: min(36rem, 90vw); margin: 0; max-height: 70vh; }
  html[data-layout="full"]:not(.embed) .mapview { position: fixed; left: 0; top: 0; right: var(--pw); bottom: 0; z-index: 0; display: block; background: var(--sea); border: 0; border-radius: 0; box-shadow: none; overflow: hidden; }
  html[data-layout="full"]:not(.embed) .mapview svg { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - var(--ctlh, 120px) - var(--dockb)); max-height: none; margin: 0; }
  html[data-layout="full"]:not(.embed).globe .globebox { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - var(--ctlh, 120px) - var(--dockb)); min-height: 0; }
  html[data-layout="full"]:not(.embed) .mini-row, html[data-layout="full"]:not(.embed) .sband-note { display: none; }
  html[data-layout="full"]:not(.embed) .yearpill { top: 58px; }
  /* 지구본 합본에서 좁은 화면용으로 지도 아래 줄에 내렸던 단추들을 다시 지도 위에 띄운다 */
  html[data-layout="full"]:not(.embed).hasglobe .viewsw { position: absolute; top: var(--sp-2); right: 52px; padding: 0; order: 0; box-shadow: var(--shadow-1); }
  html[data-layout="full"]:not(.embed).hasglobe .zoomctl { position: absolute; right: var(--sp-2); top: var(--sp-2); display: grid; margin: 0; padding: 0; box-shadow: none; }
  html[data-layout="full"]:not(.embed).hasglobe .gctl { position: absolute; left: var(--sp-2); bottom: calc(var(--dockb) + var(--dockh, 90px) + 56px); flex: none; padding: 0; max-width: calc(100% - 140px); order: 0; }
  html[data-layout="full"]:not(.embed).hasglobe .layerctl { position: absolute; order: 0; padding: 0; }
  html[data-layout="full"]:not(.embed) .yearbar, html[data-layout="full"]:not(.embed).hasglobe .yearbar { position: absolute; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100% - 16px); bottom: calc(var(--dockb) + var(--dockh, 90px) + 6px); order: 0; flex: none; border-width: 1px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--surface-1) 88%, transparent); box-shadow: var(--shadow-1); }
  html[data-layout="full"]:not(.embed) .yearmore { bottom: calc(var(--dockb) + var(--dockh, 90px) + 60px); }
  html[data-layout="full"]:not(.embed) .gctl { bottom: calc(var(--dockb) + var(--dockh, 90px) + 56px); }
  html[data-layout="full"]:not(.embed) .controls { position: fixed; left: 0; right: var(--pw); bottom: var(--dockb); z-index: 12; margin: 0; padding: 4px var(--sp-4) 6px; gap: 2px; border-radius: 0; border-width: 1px 0 0; background: color-mix(in srgb, var(--surface-1) 90%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  html[data-layout="full"]:not(.embed) .panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--pwp); z-index: 15; overflow-y: auto; overscroll-behavior: contain; border-radius: 0; border-width: 0 0 0 1px; box-shadow: -4px 0 16px color-mix(in srgb, var(--shadow-c) 18%, transparent); transition: transform .2s, visibility 0s; }
  html[data-layout="full"][data-panel="closed"]:not(.embed) .panel { transform: translateX(100%); visibility: hidden; transition: transform .2s, visibility 0s .2s; }
  html[data-layout="full"]:not(.embed) #panelToggle { display: block; position: fixed; top: 50%; right: var(--pwt); transform: translateY(-50%); z-index: 16; width: 28px; height: 64px; padding: 0; border-radius: var(--r-lg) 0 0 var(--r-lg); font-size: 1.3rem; line-height: 1; box-shadow: var(--shadow-1); background: var(--surface-1); }
  html[data-layout="full"]:not(.embed) .welcome { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); width: min(40rem, 92vw); z-index: 50; box-shadow: var(--shadow-1); }
  html[data-layout="full"]:not(.embed) .panel #states, html[data-layout="full"]:not(.embed) .panel .states { max-height: min(60vh, 560px); }
}
@media (min-width: 1100px) and (min-height: 560px) {
  html[data-layout="full"]:not(.embed) { --pwp: clamp(400px, 24vw, 460px); }
  html[data-layout="full"][data-panel="open"]:not(.embed) { --pw: var(--pwp); }
}

/* ---- 연도 비교: 커튼(분할선) ---- */
#curtain { position: absolute; z-index: 3; width: 0; pointer-events: none; }
#curtain[hidden] { display: none; }
#curtain .cw-line { position: absolute; left: -1.5px; top: 0; bottom: 0; width: 3px; background: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--surface-1) 70%, transparent); }
#curtain .cw-hit { position: absolute; left: -14px; width: 28px; top: 0; bottom: 0; pointer-events: auto; cursor: ew-resize; touch-action: none; }
#curtain .cw-handle { position: absolute; left: -22px; top: calc(50% - 22px); width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%; pointer-events: auto; cursor: ew-resize; touch-action: none; font-size: .65rem; letter-spacing: -1px; border: 2px solid var(--accent); background: var(--surface-1); box-shadow: var(--shadow-1); }
#curtain .cw-a, #curtain .cw-b { position: absolute; top: calc(50% - 16px); pointer-events: auto; padding: 3px var(--sp-2); background: color-mix(in srgb, var(--surface-1) 90%, transparent); border: 1px solid var(--line-strong); border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-1); display: flex; align-items: center; gap: var(--sp-1); }
#curtain .cw-a { right: 30px; pointer-events: none; }
#curtain .cw-b { left: 30px; }
#curtain .cw-b input { width: 6.5rem; min-height: 28px; font-size: var(--fs-xs); }
#curtain .cw-b button { min-height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); }
@media (pointer: coarse), (max-width: 520px) { #curtain .cw-b input, #curtain .cw-b button { min-height: 40px; } #curtain .cw-b input { width: 3.6rem; padding: 0 6px; } #curtain .cw-b button { padding: 0 6px; } }
@media (max-width: 520px) { #curtain .cw-a, #curtain .cw-b { top: 44px; } #curtain .cw-a { right: 8px; } #curtain .cw-b { left: 8px; padding: 2px 6px; } }
.embed #curtain { display: none; }

/* 찾기로 고른 나라 중심 패널 */
.focuscard { border: 1px solid var(--accent); border-radius: var(--r-md, 10px); background: color-mix(in srgb, var(--accent) 6%, var(--surface-1)); padding: var(--sp-3); margin-bottom: var(--sp-3); }
.focuscard[hidden], .focusaux[hidden] { display: none; }
.focuscard .fhead { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.focuscard h2 { margin: 0; font-size: var(--fs-lg, 1.1rem); display: flex; align-items: center; gap: var(--sp-2); }
.focuscard .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid; flex: none; }
.focuscard .fdl { margin: var(--sp-2) 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px var(--sp-3); font-size: var(--fs-sm); }
.focuscard .fdl dt { color: var(--ink-muted); font-weight: 600; }
.focuscard .fdl dd { margin: 0; }
.focuscard .fnb { cursor: pointer; min-height: 28px; }
.focuscard .fclear { min-height: 36px; white-space: nowrap; }
.focuscard .cev { margin: 0; padding-left: 1.1em; }
.focusaux { margin-bottom: var(--sp-3); }
.focusaux .fauxbody { display: grid; gap: var(--sp-3); margin-top: var(--sp-2); }
@media (max-width: 520px) { .focuscard .fdl { grid-template-columns: 1fr; } }
html[data-focus] #yearrow .eraside { display: none; }
.focuscard .fh3 { margin: var(--sp-3) 0 var(--sp-1); font-size: var(--fs-sm); color: var(--ink-muted); }
.focuscard ol.ftl, .focuscard ol.cev { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 4px; font-size: var(--fs-sm); }
.focuscard li.fnow { background: color-mix(in srgb, var(--accent) 14%, transparent); border-left: 3px solid var(--accent); padding-left: 6px; border-radius: 4px; }
.focuscard .fmore { margin-top: var(--sp-1); font-size: var(--fs-sm); }
.focuscard .fmore > ol { margin-top: var(--sp-1); }

/* 볼 만한 해: 단추 연도 표시·더 보기 시트 */
#jumpRow .scn .jy { font-size: var(--fs-xs); color: var(--ink-muted); margin-right: 2px; }
#jumpRow .scmore { font-weight: 600; }
.scenesheet { position: fixed; z-index: 31; left: 50%; top: 10vh; transform: translateX(-50%); width: min(36rem, 94vw); max-height: 78vh; overflow-y: auto; display: grid; gap: var(--sp-2); background: var(--surface-1); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: var(--sp-3) var(--sp-4); align-content: start; }
.scenesheet[hidden] { display: none; }
.scenesheet .lphead { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.scenesheet .tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.scenesheet .sclist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); font-size: var(--fs-sm); }
.scenesheet .sclist li { padding: 4px 6px; border-radius: 6px; }
.scenesheet .sclist li.scnear { background: color-mix(in srgb, var(--accent) 12%, transparent); border-left: 3px solid var(--accent); }
.scenesheet .scmemo { font-style: italic; }
@media (max-width: 700px) { .scenesheet { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: auto; max-height: 70vh; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); } }
@media (pointer: coarse) { .scenesheet .sclist .y, .scenesheet .tabs button, #jumpRow .scn, #jumpRow .scmore { min-height: 44px; } }

/* 사건 목록 위 줄기 사건 토글 */
.evk { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-2); }
.evk[hidden] { display: none; }
.evk .seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-pill); overflow: hidden; }
.evk .seg button { border: 0; border-radius: 0; min-height: 32px; padding: 0 var(--sp-3); background: var(--surface-1); font-size: var(--fs-sm); }
.evk .seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent, #fff); font-weight: 600; }
@media (pointer: coarse) { .evk .seg button { min-height: 44px; } }

/* 전선 단계 단추: 전쟁별 그룹 */
#warBtns .wargrp { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; width: 100%; margin-bottom: var(--sp-2); }
#warBtns .wargrp[hidden] { display: none; }
#warBtns .wgt { flex: 1 1 100%; font-size: var(--fs-sm); color: var(--ink-muted); }
.warall { font-size: var(--fs-sm); margin: 0 0 var(--sp-2); }

/* 장기 구조 띠: 막대 위에 얹힌 라벨은 면 색 판을 깔아 4.5:1 이상(막대 색·투명도는 그대로) */
#structView .lblbg { fill: var(--surface-1); fill-opacity: .96; stroke: var(--line-strong); stroke-width: .5; pointer-events: none; }

/* ======== 시안 A 「양피지 아틀라스」(밝은 테마) · 「밤 항해도」(어두운 테마) ========
   색은 모두 위 토큰을 쓰고 이 절은 모양만 바꾼다. 인쇄 지도 요소: 지도 가장자리 눈금 테두리(.mapview::after), 컴파스(.mapview::before, 장식),
   연도 슬라이더를 축척 막대 모양으로, 카드·팝오버는 이중 괘선. 엔진 동작·마크업은 그대로다. */
html, body { background: radial-gradient(ellipse 120% 80% at 50% 0%, var(--surface-1), var(--surface-0) 70%) fixed var(--surface-0); }
/* 작은 조작 글자는 산세리프(12px 세리프는 획이 가늘어 읽기 어렵다) */
button, input, select, textarea, .chip, .stype, .yearpill, .mapnote, .qgh, .tiptext, .chkdesc, .lprow, .lphead, .evkcnt, .qopt .qm, .smeta .srcl, .events .src { font-family: var(--font-ui); }
.events .y, .story .y, .y { font-family: inherit; }

/* 제목: 지도 표제처럼 자간을 둔 세리프, 오른쪽으로 가는 괘선 */
header h1 { font-family: var(--font-display); color: var(--ink); }
.searchbar label { white-space: nowrap; }
.panel h2:not(.focuscard *) { padding-bottom: 3px; border-bottom: 1px solid color-mix(in srgb, var(--line-strong) 60%, transparent); font-family: var(--font-display); font-weight: 400; font-size: var(--fs-sm); letter-spacing: .08em; color: var(--accent); }
#ctxTabs [role=tabpanel] > h2 { font-size: var(--fs-md); }
.focuscard h2, .welcome h2, .cmphead h2 { font-family: var(--font-display); font-weight: 400; }
#yearLabel { font-family: var(--font-display); color: var(--ink); letter-spacing: .02em; }
#eraLabel { color: var(--accent); }
.yearhead { padding-bottom: var(--sp-2); border-bottom: 3px double var(--line-strong); }

/* 카드: 바깥 괘선 + 안쪽 가는 괘선(이중 괘선) */
.controls, .panel { border-color: var(--line-strong); border-radius: var(--r-sm); box-shadow: inset 0 0 0 3px var(--surface-1), inset 0 0 0 4px var(--line); }
button { border-radius: var(--r-sm); }
button:hover { background: color-mix(in srgb, var(--accent) 7%, var(--surface-1)); }
#play:hover { background: var(--accent-hover); }
button[aria-pressed="true"] { background: var(--selected-bg); }
input[type=text], input[type=number], input[type=search], select, textarea { border-radius: var(--r-sm); }
.tabs [role=tab] { border-radius: var(--r-sm); }
.chip, .stype { border-color: color-mix(in srgb, var(--line-strong) 80%, var(--surface-1)); }

/* 팝오버·시트·찾기 결과·첫 방문 안내: 종이 카드에 이중 괘선 */
.layerpanel, .yearmore, .scenesheet, .qres, #cmpDlg { border: 3px double var(--line-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-2); }
.qgh { font-family: var(--font-display); font-weight: 400; letter-spacing: .06em; color: var(--accent); }
.lphead b { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-sm); letter-spacing: .04em; }
.welcome { border: 3px double var(--frame); border-radius: var(--r-sm); background: radial-gradient(ellipse at 50% 0%, var(--surface-1), var(--surface-2)) var(--surface-1); box-shadow: var(--shadow-2), inset 0 0 0 4px var(--surface-1), inset 0 0 0 5px var(--line); padding: var(--sp-4) var(--sp-5); }
.welcome h2 { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-lg); color: var(--ink); text-align: center; }
.welcome h2::before, .welcome h2::after { content: ""; flex: 1 1 1rem; min-width: 1rem; height: 5px; border-block: 1px solid var(--ornament); }
.welcome ul { font-size: var(--fs-md); line-height: var(--lh-body); }
.welcome li::marker { color: var(--ornament); }
.welcome .btns { justify-content: center; }
#welcomeClose { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
#welcomeClose:hover { background: var(--accent-hover); }

/* 전쟁 상자(전선 단계): 삽입 지도처럼 이중 괘선 상자 */
#warBox { border: 3px double var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); padding: var(--sp-3); }
#warBox h2 { margin-top: 0; }

/* 목록: 지도책 색인처럼 점선 구분 */
.states li + li, .events li { border-color: color-mix(in srgb, var(--line-strong) 55%, transparent); border-style: dotted; }
.events li:last-child { border-bottom: 0; }
.story { border-top-style: dotted; border-color: var(--line-strong); }

/* 연도 슬라이더: 지도의 축척 막대(어두운·밝은 칸 번갈아) 모양. 키보드·포커스는 기본 range 그대로 */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border: 1px solid var(--frame); background: var(--line-strong); border-color: var(--line-strong); }
input[type=range]::-moz-range-track { height: 6px; border: 1px solid var(--frame); background: var(--line-strong); border-color: var(--line-strong); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface-1); box-shadow: 0 0 0 1px var(--frame), var(--shadow-1); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface-1); box-shadow: 0 0 0 1px var(--frame), var(--shadow-1); }
@media (pointer: coarse) { input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9px; } input[type=range]::-moz-range-thumb { width: 20px; height: 20px; } }
.sband .era { stroke: var(--surface-0); }
.sband .era.on { fill: color-mix(in srgb, var(--accent) 30%, var(--surface-1)); stroke: var(--accent); }

/* 지도: 바다는 가장자리로 갈수록 조금 짙은 청회색 */
.mapbox, .mapview { background: radial-gradient(ellipse 75% 70% at 50% 45%, var(--sea) 55%, var(--sea-deep)) var(--sea); }
.lbl { font-family: var(--font-display); font-weight: 400; letter-spacing: .05em; }
.cap, .prov, .city, .periph { font-family: var(--font-body); }
.yearpill { border-radius: var(--r-sm); border-color: var(--frame); font-family: var(--font-display); font-weight: 400; background: var(--surface-1); }
.zoomctl button, .viewsw button, .layerctl > #layerBtn, .layerctl > #mapInfoBtn { border-color: var(--frame); }
/* 연도 막대: 둥근 알약 대신 이중 괘선 띠 */
.yearbar { border-radius: var(--r-sm); border-color: var(--frame); box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3px var(--line-strong), var(--shadow-1); }
.yearbar > button { border-radius: var(--r-sm); }
.yearbar .byear { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-sm); }

/* 지도 가장자리 장식(좁은 화면·분할 화면): 지도 안쪽에 가는 테두리 선. 초점 링은 그대로 위에 그린다 */
#map { outline: 1px solid color-mix(in srgb, var(--frame) 70%, transparent); outline-offset: -5px; }
#map:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: -3px; }
@media (max-width: 1099px) and (min-height: 560px) {
  .mapview { background: radial-gradient(ellipse 75% 70% at 50% 45%, var(--sea) 55%, var(--sea-deep)) var(--sea); border-color: var(--frame); border-radius: var(--r-sm); }
  .mini-row { border-top: 3px double var(--line-strong); }
}

/* 지도 전체 화면 배치(768px 이상, 기본): 인쇄 지도 테두리(눈금 칸)·컴파스·표제 상자 */
@media (min-width: 768px) and (min-height: 560px) {
  html[data-layout="full"]:not(.embed) #map { outline: 0; }
  html[data-layout="full"]:not(.embed) #map:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: -12px; }
  html[data-layout="full"]:not(.embed) .mapview { background: radial-gradient(ellipse 70% 70% at 50% 42%, var(--sea) 55%, var(--sea-deep)) var(--sea); }
  /* 이중 괘선 테두리(바깥 1px, 안쪽 1px). 눈금 칸 무늬는 지저분해 뺐다 */
  html[data-layout="full"]:not(.embed) .mapview::after {
    content: ""; position: absolute; z-index: 1; left: 0; top: 0; right: 0; bottom: calc(var(--ctlh, 120px) + var(--dockb, 0px)); pointer-events: none;
    border: 1px solid var(--frame);
    background:
      linear-gradient(var(--frame), var(--frame)) 0 5px / 100% 1px no-repeat,
      linear-gradient(var(--frame), var(--frame)) 0 calc(100% - 5px) / 100% 1px no-repeat,
      linear-gradient(var(--frame), var(--frame)) 5px 0 / 1px 100% no-repeat,
      linear-gradient(var(--frame), var(--frame)) calc(100% - 5px) 0 / 1px 100% no-repeat;
  }
  /* 컴파스(장식, 북쪽 표시). 모양은 마스크(검정은 알파 값일 뿐), 색은 --ornament */
  html[data-layout="full"]:not(.embed) .mapview::before {
    content: ""; position: absolute; z-index: 1; right: 22px; bottom: calc(var(--ctlh, 120px) + var(--dockb, 0px) + 18px); width: 60px; height: 71px; pointer-events: none; opacity: .62;
    background: var(--ornament);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 118'%3E%3Cpath d='M43 15V2l14 13V2' fill='none' stroke='%23000' stroke-width='2.6' stroke-linejoin='round'/%3E%3Cg transform='translate(0 18)'%3E%3Ccircle cx='50' cy='50' r='33' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3Ccircle cx='50' cy='50' r='29' fill='none' stroke='%23000' stroke-width='.8'/%3E%3Cg fill='%23000' fill-opacity='.55' transform='rotate(45 50 50)'%3E%3Cpath d='M50 22L54 46L78 50L54 54L50 78L46 54L22 50L46 46Z'/%3E%3C/g%3E%3Cpath d='M50 4L50 50L45 45Z M96 50L50 50L55 45Z M50 96L50 50L55 55Z M4 50L50 50L45 55Z' fill='%23000'/%3E%3Cpath d='M50 4L50 50L55 45Z M96 50L50 50L55 55Z M50 96L50 50L45 55Z M4 50L50 50L45 45Z' fill='%23000' fill-opacity='.35'/%3E%3Ccircle cx='50' cy='50' r='2.6' fill='%23000'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 118'%3E%3Cpath d='M43 15V2l14 13V2' fill='none' stroke='%23000' stroke-width='2.6' stroke-linejoin='round'/%3E%3Cg transform='translate(0 18)'%3E%3Ccircle cx='50' cy='50' r='33' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3Ccircle cx='50' cy='50' r='29' fill='none' stroke='%23000' stroke-width='.8'/%3E%3Cg fill='%23000' fill-opacity='.55' transform='rotate(45 50 50)'%3E%3Cpath d='M50 22L54 46L78 50L54 54L50 78L46 54L22 50L46 46Z'/%3E%3C/g%3E%3Cpath d='M50 4L50 50L45 45Z M96 50L50 50L55 45Z M50 96L50 50L55 55Z M4 50L50 50L45 55Z' fill='%23000'/%3E%3Cpath d='M50 4L50 50L55 45Z M96 50L50 50L55 55Z M50 96L50 50L45 55Z M4 50L50 50L45 45Z' fill='%23000' fill-opacity='.35'/%3E%3Ccircle cx='50' cy='50' r='2.6' fill='%23000'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  }
  html[data-layout="full"]:not(.embed).globe .mapview::before { display: none; }
  /* 표제 상자(카르투슈): 이중 괘선 */
  html[data-layout="full"]:not(.embed) header { top: 12px; left: 12px; border-radius: var(--r-sm); border-color: var(--frame); background: color-mix(in srgb, var(--surface-1) 94%, transparent); box-shadow: inset 0 0 0 2px var(--surface-1), inset 0 0 0 3px var(--line-strong), var(--shadow-2); padding: 6px var(--sp-3); }
  html[data-layout="full"]:not(.embed) header h1 { line-height: 1.3; max-width: 20rem; }
  html[data-layout="full"]:not(.embed) .yearpill { top: 66px; left: 12px; }
  html[data-layout="full"]:not(.embed) .zoomctl, html[data-layout="full"]:not(.embed).hasglobe .zoomctl { top: 12px; right: 12px; }
  html[data-layout="full"]:not(.embed).hasglobe .viewsw { top: 12px; right: 56px; }
  html[data-layout="full"]:not(.embed) .layerctl, html[data-layout="full"]:not(.embed).hasglobe .layerctl { right: 12px; top: calc(12px + 3 * 34px + 4 * var(--sp-1)); }
  html[data-layout="full"]:not(.embed) .gctl, html[data-layout="full"]:not(.embed).hasglobe .gctl { left: 12px; }
  html[data-layout="full"]:not(.embed) .yearbar, html[data-layout="full"]:not(.embed).hasglobe .yearbar { border-radius: var(--r-sm); background: color-mix(in srgb, var(--surface-1) 94%, transparent); box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3px var(--line-strong), var(--shadow-2); bottom: calc(var(--dockb) + var(--dockh, 90px) + 12px); }
  html[data-layout="full"]:not(.embed) .controls { border-top: 3px double var(--line-strong); box-shadow: none; background: color-mix(in srgb, var(--surface-1) 94%, transparent); }
  html[data-layout="full"]:not(.embed) .panel { border-radius: 0; border-width: 0 0 0 4px; border-style: double; border-color: var(--line-strong); box-shadow: var(--shadow-2); background: radial-gradient(ellipse 140% 60% at 100% 0%, var(--surface-1), var(--surface-2)) var(--surface-1); }
  html[data-layout="full"]:not(.embed) #panelToggle { border-color: var(--frame); border-radius: var(--r-sm) 0 0 var(--r-sm); }
  html[data-layout="full"]:not(.embed) .welcome { top: 76px; }
}
@media (min-width: 768px) and (max-width: 899px) and (min-height: 560px) { html[data-layout="full"]:not(.embed) .mapview::before { display: none; } }
@media (min-width: 768px) and (min-height: 560px) and (pointer: coarse) { html[data-layout="full"]:not(.embed) .layerctl, html[data-layout="full"]:not(.embed).hasglobe .layerctl { top: calc(12px + 3 * 44px + 4 * var(--sp-1)); } }
@media (max-width: 520px) { .welcome { padding: var(--sp-2) var(--sp-3); gap: var(--sp-1); } .welcome h2 { font-size: var(--fs-md); } .welcome h2::before, .welcome h2::after { display: none; } .welcome ul { font-size: var(--fs-sm); line-height: var(--lh-dense); gap: 2px; } }
