@font-face { font-family: "Public Sans"; src: url(/fonts/public-sans-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url(/fonts/public-sans-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url(/fonts/public-sans-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url(/fonts/public-sans-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url(/fonts/public-sans-800.woff2) format("woff2"); font-weight: 800; font-display: swap; }
/* Noto Sans KR, cut down to the Hangul the interface uses. Rebuild it when lang/ko changes. */
@font-face { font-family: "Noto Sans KR UI"; src: url(/fonts/noto-sans-kr-subset.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+AC00-D7A3; }
@font-face { font-family: "Barlow Condensed"; src: url(/fonts/barlow-condensed-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url(/fonts/barlow-condensed-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url(/fonts/barlow-condensed-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #1E2B3A;
  --ink-deep: #0F1720;
  --ink-2: #4A596B;
  --ink-3: #5F6C7D;
  --rule: #D8DDE3;
  --rule-2: #C5CCD5;
  --wash: #F5F6F7;
  --wash-2: #EEF2F6;
  --paper: #FFFFFF;
  --e1: #F7EBB8;
  --e2: #F3D36B;
  --e3: #E8963F;
  --e4: #CF6B35;
  --e5: #9E3A26;
  --nil: #E4E7EB;
  --gain: #A9E0C0;
  --loss: #FFC3AE;
  --sans: "Public Sans", "Noto Sans KR UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --map-type: "Barlow Condensed", "Noto Sans KR UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--paper); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, dd, ol { margin: 0; padding: 0; }
ol { list-style: none; }
a { color: inherit; }
::selection { background: var(--e2); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- Top bar ------------------------------------------------------------- */
.bar { height: 56px; flex: none; background: var(--ink); color: #fff; display: flex; align-items: center; gap: 28px; padding: 0 24px; }
.bar :focus-visible { outline-color: #fff; }
.wordmark { font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 24px; letter-spacing: .04em; text-decoration: none; }
.wordmark em { font-style: normal; color: var(--e2); }
.bar__scope { font-size: 13px; color: #D5DCE4; min-width: 0; }
.bar__scope b { color: #fff; font-weight: 700; margin-right: 6px; }
.bar__nav { margin-left: auto; display: flex; gap: 4px; }
.bar__nav a { font-size: 13px; color: #D5DCE4; padding: 8px 12px; border-radius: 4px; text-decoration: none; }
.bar__nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.bar__nav a.on { color: #fff; background: rgba(255, 255, 255, .14); }
.lang { display: flex; border: 1px solid rgba(255, 255, 255, .28); border-radius: 4px; overflow: hidden; }
.lang a { min-width: 34px; height: 30px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #D5DCE4; text-decoration: none; }
.lang a:hover { color: #fff; }
.lang a.on { background: #fff; color: var(--ink); }

/* --- Atlas layout: list, map, rail ---------------------------------------- */
.atlas-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.atlas { flex: 1; min-height: 0; display: grid; grid-template-columns: 330px minmax(0, 1fr) 390px; }

.ranking { min-height: 0; display: flex; flex-direction: column; padding-top: 14px; border-right: 1px solid var(--rule); }
.ranking__head { font-family: var(--map-type); font-weight: 600; font-size: 13px; line-height: 1.25; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); padding: 0 20px 8px; }
.filters { display: flex; flex-direction: column; gap: 6px; padding: 0 20px 8px; }
.pills { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.pills__label { font-size: 12px; color: var(--ink-2); margin-right: 4px; }
.pill { font-size: 12px; line-height: 1; padding: 5px 7px; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; color: var(--ink); }
.pill:hover { border-color: var(--ink); }
.pill.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.atlas.is-changing .rows { opacity: .7; }
.rows { transition: opacity .15s; flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-auto-rows: minmax(19px, 1fr); }
.row { height: 100%; display: grid; grid-template-columns: 20px 28px minmax(0, 1fr) 58px 58px; align-items: center; gap: 6px; padding: 0 20px; font-size: 12px; text-decoration: none; }
.row:hover { background: var(--wash); }
.row:focus-visible { outline-offset: -2px; }
.row.on { background: var(--wash-2); box-shadow: inset 0 0 0 1px var(--ink); }
.row__rank { color: var(--ink-3); font-size: 11px; }
.row__name { white-space: nowrap; overflow: hidden; }
.row.on .row__name { font-weight: 700; }
.row__bar { height: 6px; background: var(--wash-2); }
.row__bar i { display: block; height: 100%; background: var(--ink); }
.row__value { text-align: right; font-weight: 600; }
.ranking__keys { flex: none; font-size: 11px; line-height: 1.4; color: var(--ink-3); padding: 5px 20px; border-top: 1px solid var(--rule); }
.ranking__keys a { text-underline-offset: 2px; }

.code { font-family: var(--map-type); font-weight: 700; font-size: 14px; letter-spacing: .05em; line-height: 15px; text-align: center; color: var(--ink); }
.code--0 { background: var(--nil); }
.code--1 { background: var(--e1); }
.code--2 { background: var(--e2); }
.code--3 { background: var(--e3); }
.code--4 { background: var(--e4); color: var(--ink-deep); }
.code--5 { background: var(--e5); color: #fff; }
.code--lg { font-size: 16px; line-height: 24px; padding: 0 8px; }
.thin-mark { display: inline-block; width: 10px; height: 10px; margin-left: 4px; vertical-align: -1px; background: repeating-linear-gradient(135deg, var(--ink) 0 1.5px, transparent 1.5px 4px); }

/* --- Map ------------------------------------------------------------------ */
.mapwrap { position: relative; min-height: 0; background: var(--wash); }
.map { position: absolute; inset: 0; background: var(--wash); font-family: var(--sans); }
.legend { position: absolute; z-index: 500; left: 16px; top: 16px; width: 226px; background: var(--paper); border: 1px solid var(--rule); padding: 10px 12px; }
.legend h2 { font-family: var(--map-type); font-weight: 600; font-size: 12px; line-height: 1.25; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.legend dl { display: grid; gap: 3px; }
.legend dl div { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center; font-size: 11px; }
.legend dt { height: 15px; }
.legend p { font-size: 11px; line-height: 1.4; color: var(--ink-2); margin-top: 8px; }
.hatch-key { border: 1px solid var(--ink); background: repeating-linear-gradient(135deg, var(--ink) 0 1px, transparent 1px 6px); }
.hatch-key--dense { background: repeating-linear-gradient(135deg, var(--ink) 0 1.5px, transparent 1.5px 3.5px); }
.map-failed { position: absolute; z-index: 600; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(320px, 80%); background: var(--paper); border: 1px solid var(--ink); padding: 12px 14px; font-size: 13px; line-height: 1.45; }
.map-failed a { display: inline-block; margin-top: 4px; font-weight: 600; text-underline-offset: 2px; }
.titleblock { position: absolute; z-index: 500; right: 16px; bottom: 16px; display: grid; grid-template-columns: auto auto; border: 1.5px solid var(--ink); background: var(--paper); font-family: var(--map-type); font-weight: 500; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.titleblock > * { padding: 4px 10px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.titleblock b { grid-column: 1 / 3; font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.titleblock svg { width: 12px; height: 16px; flex: none; }
.leaflet-container { font-family: var(--sans); }
.leaflet-tile-pane { filter: grayscale(1) contrast(.92) brightness(1.04); }
.leaflet-overlay-pane path { transition: fill .3s ease-out, fill-opacity .3s ease-out, stroke-opacity .3s ease-out; }
.leaflet-dots-pane, .map-code { transition: opacity .3s ease-out; }
.leaflet-control-attribution { font-size: 11px; background: rgba(255, 255, 255, .86) !important; }
.leaflet-popup-content-wrapper { border-radius: 0; border: 1px solid var(--ink); box-shadow: 0 6px 18px rgba(30, 43, 58, .22); }
.leaflet-popup-content { margin: 12px 14px; font-size: 12px; line-height: 1.4; color: var(--ink); }
.leaflet-popup-tip { box-shadow: none; border: 1px solid var(--ink); }
.listing-card { display: flex; flex-direction: column; gap: 6px; }
.listing-card h3 { font-size: 14px; line-height: 1.3; padding-right: 18px; }
.listing-card p { margin: 0; color: var(--ink-2); }
.listing-card dl { display: grid; gap: 2px; }
.listing-card dl div { display: flex; justify-content: space-between; gap: 12px; }
.listing-card dt { color: var(--ink-2); }
.listing-card dd { font-weight: 700; }
.listing-card a { color: var(--ink); font-weight: 600; text-underline-offset: 2px; }
.legend__zoom { color: var(--ink); font-weight: 600; }
.legend__touch { display: none; }
@media (pointer: coarse) { .legend .legend__touch { display: block; } }
/* Chips show the color the map actually has at county view: 72% over its grey ground. */
.legend dt.code--1 { background: color-mix(in srgb, var(--e1) 72%, #E9E9E7); }
.legend dt.code--2 { background: color-mix(in srgb, var(--e2) 72%, #E9E9E7); }
.legend dt.code--3 { background: color-mix(in srgb, var(--e3) 72%, #E9E9E7); }
.legend dt.code--4 { background: color-mix(in srgb, var(--e4) 72%, #E9E9E7); }
.legend dt.code--5 { color: var(--ink-deep); }
.legend dt.code--5 { background: color-mix(in srgb, var(--e5) 72%, #E9E9E7); }
.legend { overflow: hidden; transition: height .25s ease-out; }
:lang(ko) .ranking__head, :lang(ko) .legend h2, :lang(ko) .titleblock { letter-spacing: 0; }
.legend__dots { display: none; }
.mapwrap.is-close .legend__dots { display: block; animation: settle .25s ease-out; }
.mapwrap.is-close .legend > h2, .mapwrap.is-close .legend > dl { display: none; }
.mapwrap.is-close .legend .legend__dots p { display: flex; }
.legend__dots p { align-items: center; gap: 4px; margin: 0; }
.legend__dots .dot-none { margin-top: 6px; gap: 6px; }
.dot { width: 11px; height: 11px; flex: none; border-radius: 50%; border: 1px solid var(--ink); background: #fff; }
.dot--1 { background: var(--e1); }
.dot--2 { background: var(--e2); }
.dot--3 { background: var(--e3); }
.dot--4 { background: var(--e4); }
.dot--5 { background: var(--e5); }
.map-here, .map-status { position: absolute; z-index: 500; margin: 0; background: var(--paper); border: 1px solid var(--ink); font-size: 12px; font-weight: 600; padding: 7px 10px; }
.map-here { left: 258px; top: 16px; font-family: var(--map-type); font-size: 14px; letter-spacing: .04em; padding: 5px 10px; }
.map-status { left: 50%; bottom: 16px; transform: translateX(-50%); }
.rail.is-loading #district-head, .rail.is-loading #district-more, .rail.is-loading .result { opacity: .55; }
#district-head, #district-more, .result { transition: opacity .15s; }
.chartbox[hidden] { display: none; }
.leaflet-container a.leaflet-popup-close-button { width: 28px; height: 28px; }
.leaflet-container a.leaflet-popup-close-button span { display: none; }
.leaflet-container a.leaflet-popup-close-button::before, .leaflet-container a.leaflet-popup-close-button::after { content: ""; position: absolute; left: 8px; top: 13px; width: 12px; height: 1.5px; background: var(--ink); transform: rotate(45deg); }
.leaflet-container a.leaflet-popup-close-button::after { transform: rotate(-45deg); }
.whole-map { position: absolute; z-index: 500; right: 62px; top: 16px; height: 32px; padding: 0 12px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font: 600 12px var(--sans); cursor: pointer; }
.whole-map:hover { background: var(--paper); color: var(--ink); }
.mapwrap.is-close .legend p { display: none; }
.zoom-link { align-self: flex-start; padding: 0; border: 0; background: none; font: 600 12px var(--sans); color: var(--ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.leaflet-tooltip { font-family: var(--sans); font-size: 12px; border-radius: 0; border: 1px solid var(--ink); box-shadow: none; color: var(--ink); padding: 5px 8px; }
.leaflet-tooltip b { display: block; }
.map-code { font-family: var(--map-type); font-weight: 700; font-size: 14px; line-height: 1; white-space: nowrap; text-align: center; color: var(--ink-deep); pointer-events: none; }
.map-code.is-dark { color: #fff; }
.map-code.is-selected { background: var(--ink); box-shadow: 0 0 0 2px var(--ink); color: #fff; }
.map-code.is-hidden { visibility: hidden; }
.leaflet-control-zoom a { position: relative; border-radius: 0 !important; color: transparent !important; text-indent: -999px; }
.leaflet-control-zoom a::before, .leaflet-control-zoom-in::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 2px; margin: -1px 0 0 -6px; background: var(--ink); }
.leaflet-control-zoom-in::after { transform: rotate(90deg); }
.leaflet-control-scale-line { border: 1.5px solid var(--ink); border-top: 0; background: var(--paper); color: var(--ink); font-family: var(--map-type); font-weight: 600; font-size: 11px; letter-spacing: .06em; }
.leaflet-touch .leaflet-bar, .leaflet-bar { border-radius: 0; box-shadow: none; border: 1px solid var(--rule-2); }

/* --- Detail rail ------------------------------------------------------------ */
.rail { min-height: 0; overflow-y: auto; border-left: 1px solid var(--rule); padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.rail h2 { font-size: 14px; font-weight: 700; }
.head { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 16px; }
.head__title { display: flex; align-items: center; gap: 10px; }
.head__title h2 { font-family: var(--map-type); font-weight: 700; font-size: 30px; line-height: 1; }
.head__rank { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.notice { font-size: 12px; line-height: 1.45; padding: 8px 10px; background: var(--e1); }
.notice .thin-mark { margin: 0 6px 0 0; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--rule); }
.kpis div { padding: 8px 12px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.kpis div:nth-child(2n) { border-right: 0; }
.kpis div:nth-child(n + 3) { border-bottom: 0; }
.kpis dt { font-size: 11px; color: var(--ink-2); }
.kpis dd { font-size: 22px; font-weight: 800; line-height: 1.25; }
.kpis small { font-size: 11px; color: var(--ink-3); }
.basis { font-size: 11px; line-height: 1.4; color: var(--ink-3); }

.calc { display: flex; flex-direction: column; gap: 8px; }
.calc form { display: flex; flex-direction: column; gap: 8px; }
.seg { display: inline-flex; width: max-content; margin: 0; padding: 0; border: 1px solid var(--rule-2); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; font-size: 12px; padding: 5px 14px; }
.seg label:hover span { background: var(--wash); }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ink-2); min-width: 0; }
.field[hidden] { display: none; }
.input { display: flex; align-items: center; height: 34px; padding: 0 10px; gap: 4px; border: 1px solid var(--rule-2); background: var(--paper); }
.input:focus-within { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.input.is-bad { border-color: var(--e5); box-shadow: inset 0 0 0 1px var(--e5); }
.input i { font-style: normal; font-size: 13px; color: var(--ink-2); }
.input input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 0; background: none; font: 600 14px var(--sans); font-variant-numeric: tabular-nums; color: var(--ink); -moz-appearance: textfield; appearance: textfield; }
.input input::-webkit-outer-spin-button, .input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.more summary { font-size: 12px; cursor: pointer; color: var(--ink); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(-45deg); }
.more[open] summary::before { transform: rotate(45deg); }
.more .fields { margin-top: 8px; }
.hint { font-size: 11px; line-height: 1.45; color: var(--ink-3); }
.more .hint { margin-top: 6px; }

.result { background: var(--ink); color: #fff; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.result dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.result dt { font-size: 11px; color: #C9D2DC; }
.result dd { font-size: 22px; font-weight: 800; line-height: 1.2; }
.result dd.is-gain { color: var(--gain); }
.result dd.is-loss { color: var(--loss); }
.result__say { font-size: 13px; line-height: 1.4; font-weight: 600; }
.result__how { font-size: 11px; line-height: 1.4; color: #C9D2DC; }
.result.is-busy dd { opacity: .6; }

.chartbox { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--rule); }
#district-more { display: flex; flex-direction: column; gap: 14px; }
.chart { position: relative; height: 170px; }
.sizes { width: 100%; border-collapse: collapse; font-size: 12px; }
.sizes th, .sizes td { padding: 5px 0; text-align: right; font-weight: 500; border-bottom: 1px solid var(--rule); }
.sizes thead th { font-size: 11px; color: var(--ink-2); }
.sizes th:first-child { text-align: left; }
.sizes td:nth-child(2) { font-weight: 700; }
.sizes .is-thin td { color: var(--ink-2); font-style: italic; }
.source { padding-top: 12px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 6px; font-size: 11px; line-height: 1.5; color: var(--ink-2); }
.source a { text-underline-offset: 2px; }

/* --- Method (reading page) ---------------------------------------------------- */
@keyframes settle { from { opacity: 0; } }
.doc { animation: settle .22s ease-out; max-width: 72ch; margin: 0 auto; padding: 44px 24px 72px; font-size: 16px; line-height: 1.65; }
.doc h1 { font-family: var(--map-type); font-weight: 700; font-size: 44px; line-height: 1.05; margin-bottom: 14px; }
.doc h2 { font-size: 20px; line-height: 1.3; margin: 36px 0 8px; }
.doc p { margin-bottom: 12px; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.doc a { text-underline-offset: 2px; }
.doc code { font-size: 14px; background: var(--wash-2); padding: 1px 5px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 12px; }
.doc th, .doc td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }

/* --- Narrower screens --------------------------------------------------------- */
@media (max-width: 1280px) {
  .atlas { grid-template-columns: 300px minmax(0, 1fr) 350px; }
  .row { grid-template-columns: 20px 28px minmax(0, 1fr) 36px 54px; padding: 0 14px; }
  .ranking__head, .filters { padding-left: 14px; padding-right: 14px; }
  .bar__scope span { display: none; }
}
@media (max-width: 1040px) {
  /* Fingers, not pointers: every control is at least 44px tall. */
  .bar__nav a { display: grid; place-items: center; height: 44px; padding: 0 12px; }
  .lang a { min-width: 44px; height: 44px; }
  .pill { display: inline-flex; align-items: center; min-height: 44px; }
  .seg span { display: flex; align-items: center; min-height: 44px; padding: 0 18px; }
  .more summary, .zoom-link { min-height: 44px; }
  .input { height: 44px; }
  .sizes th, .sizes td { padding: 8px 0; }
  .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .whole-map { right: 66px; height: 44px; }
  .atlas-page { height: auto; overflow: visible; display: block; }
  .atlas { display: flex; flex-direction: column; }
  .ranking { order: 1; border-right: 0; border-bottom: 1px solid var(--rule); }
  .mapwrap { order: 2; }
  .map { position: relative; inset: auto; width: 100%; aspect-ratio: 1; max-height: 80vh; }
  .ranking__hint { display: none; }
  .rail { order: 3; border-left: 0; overflow: visible; }
  .rows { flex: none; height: 308px; grid-auto-rows: 44px; }
  .row { font-size: 14px; grid-template-columns: 26px 30px minmax(0, 1fr) 54px 70px; }
  .pill { padding: 8px 9px; }
  .legend, .titleblock { position: static; width: auto; }
  .legend { border-width: 1px 0 0; }
  .map-here { left: 8px; top: 8px; }
  .titleblock { margin: 0 12px 12px; }
}
@media (max-width: 560px) {
  .bar { gap: 12px; padding: 0 14px; }
  .bar__scope { display: none; }
  .fields { grid-template-columns: 1fr 1fr; }
  .doc h1 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
