/* Open Map Tools: calm reference-publication styling per DESIGN.md. One background, one accent, hairline rules. */
:root {
  color-scheme: light dark;
  --bg: #fdfdfc; --text: #141414; --text-muted: #505357; --rule: #d6d7d9;
  --accent: #1f3fa6; --accent-hover: #162f80; --on-accent: #ffffff;
  --field-border: #767a80; --error: #a31d1d; --ok: #1d6b34; --focus: var(--accent);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1b1d; --text: #ececea; --text-muted: #a9acb0; --rule: #3a3c40;
    --accent: #9fb2ff; --accent-hover: #c2cdff; --on-accent: #101226;
    --field-border: #8a8e94; --error: #ff9b94; --ok: #7fd49a;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1b1d; --text: #ececea; --text-muted: #a9acb0; --rule: #3a3c40;
  --accent: #9fb2ff; --accent-hover: #c2cdff; --on-accent: #101226;
  --field-border: #8a8e94; --error: #ff9b94; --ok: #7fd49a;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; background: var(--bg); color: var(--text); font: 400 1.125rem/1.6 var(--font); overflow-wrap: break-word; }
@media (max-width: 359px) { body { font-size: 1.0625rem; } }
img, video, svg, iframe, canvas { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 600px) { .wrap { padding: 0 24px; } }
.skip { position: absolute; left: -999px; top: 0; background: var(--bg); color: var(--text); padding: 12px 16px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* header */
.site-header { border-bottom: 1px solid var(--rule); }
.header-in { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; padding-top: 8px; padding-bottom: 8px; }
.wordmark { font-size: 1.25rem; line-height: 1; letter-spacing: -0.01em; font-weight: 650; color: var(--text); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.wordmark:hover { color: var(--text); }
.nav { display: flex; flex-wrap: wrap; gap: 0 20px; margin-left: auto; order: 3; width: 100%; }
@media (min-width: 600px) { .nav { order: 0; width: auto; } }
.nav a { min-height: 44px; display: inline-flex; align-items: center; font-size: 1rem; }
.nav a[aria-current="page"] { text-decoration-thickness: 2px; text-underline-offset: 0.3em; font-weight: 600; }
.theme-toggle:hover { border-color: var(--rule); }
main:focus { outline: none; }
h1, h2, h3, [id] { scroll-margin-top: 16px; }
.theme-toggle { min-height: 44px; padding: 0 12px; font: 600 1rem/1.2 var(--font); color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 2px; cursor: pointer; margin-left: auto; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
@media (min-width: 600px) { .theme-toggle { margin-left: 0; } }

/* type */
h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.15; font-weight: 700; margin-top: 8px; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 1.625rem; line-height: 1.25; font-weight: 650; margin: 2.5rem 0 .75rem; text-wrap: balance; }
@media (min-width: 700px) { h2 { margin-top: 3rem; } }
h3 { font-size: 1.25rem; line-height: 1.3; font-weight: 650; margin: 1.75rem 0 .5rem; }
p, ul, ol, dl { margin: 0 0 1rem; }
p, li { text-wrap: pretty; }
.small, small, figcaption, .crumbs, .meta { font-size: .9375rem; line-height: 1.5; }
.muted, figcaption, .crumbs, .meta, .unit { color: var(--text-muted); }
.lede { font-size: 1.1875rem; max-width: 68ch; margin-top: 12px; }
h1 + .meta, h1 + .summary, h1 + p { margin-top: 12px; }
main { padding-top: 16px; padding-bottom: 64px; }
@media (min-width: 700px) { main { padding-top: 24px; } }
figure { margin: 1.5rem 0; max-width: min(100%, 68ch); width: fit-content; }
figure img { display: block; border-radius: 2px; }
figcaption { margin-top: 8px; }
.crumbs { margin: 0; }
.crumbs a { color: var(--accent); }
.prose, .readable { max-width: 68ch; }
main .wrap > p, main .wrap > ul:not(.list-plain), main .wrap > ol { max-width: 68ch; }
.summary { font-size: 1.1875rem; max-width: 68ch; }
.updated { margin: 12px 0 0; }
code, .mono { font-family: var(--font-mono); font-size: .9em; }
.note { border-left: 2px solid var(--rule); padding-left: 12px; max-width: 68ch; }
.note strong:first-child { font-weight: 600; }
.toc { max-width: 68ch; margin: 1rem 0; }
.toc ol { margin: 0; padding-left: 1.25rem; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* tool panel and forms */
.tool-panel { border: 1px solid var(--rule); border-top: 2px solid var(--text); border-radius: 2px; padding: 12px; margin-top: 16px; }
@media (min-width: 600px) { .tool-panel { padding: 24px; margin-top: 24px; } }
.grid2 { display: grid; gap: 16px; }
@media (min-width: 700px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid2.pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (min-width: 600px) { .grid2.pair { gap: 16px; } }
.field { display: block; margin-bottom: 16px; }
.field > label, label.lbl { display: block; font: 600 1rem/1.3 var(--font); margin-bottom: 4px; }
.hint { display: block; font-size: .9375rem; color: var(--text-muted); margin-top: 4px; }
input[type=text], input[type=file], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; font: 400 1.125rem/1.4 var(--font); color: var(--text);
  background: var(--bg); border: 1px solid var(--field-border); border-radius: 2px; font-variant-numeric: tabular-nums lining-nums;
}
input[type=text]:hover, select:hover, textarea:hover { border-color: var(--text); }
select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
textarea { font-family: var(--font-mono); font-size: 1rem; min-height: 120px; }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 12px 20px; font: 600 1rem/1.2 var(--font);
  background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: 2px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--field-border); }
.btn.secondary:hover { background: transparent; color: var(--text); border-color: var(--text); }
.btn[disabled], .btn[aria-disabled=true] { opacity: .6; cursor: not-allowed; }
.btn[aria-disabled=true]:hover { border-color: var(--field-border); }
.res-note { margin: 16px 0 0; }
.tool-meta { margin: 12px 0 0; }
.scroll-cue { margin: 0 0 4px; }
@media (min-width: 700px) { .scroll-cue { display: none; } }
.btn-link { background: none; border: 0; padding: 0; min-height: 44px; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 0; }
.error { margin: 16px 0 0; }
.err-label { color: var(--error); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.status { min-height: 1.5em; margin: 8px 0 0; font-size: .9375rem; color: var(--text-muted); }
.results { max-width: 28rem; display: grid; gap: 0; margin: 24px 0 0; border-top: 1px solid var(--rule); }
.res-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.res-row dt { margin: 0; font-weight: 600; }
.res-row dd { margin: 0; text-align: right; }
.res-num { font-size: 2rem; letter-spacing: -0.01em; line-height: 1.1; font-weight: 650; font-variant-numeric: tabular-nums lining-nums; }
.res-num.text { font-size: 1.5rem; overflow-wrap: anywhere; }
.unit { font-size: 1rem; }

/* tables */
.table-wrap { overflow-x: auto; max-width: 100%; margin: 0 0 1.5rem; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; font-variant-numeric: tabular-nums lining-nums; }
caption { text-align: left; font-size: .9375rem; color: var(--text-muted); padding-bottom: 8px; caption-side: top; }
th, td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { border-bottom: 2px solid var(--text); font-weight: 600; }
.num, th.num { text-align: right; padding-right: 0; padding-left: 12px; }
@media (max-width: 599px) { table { font-size: .9375rem; } th, td { padding-right: 12px; } .num, th.num { padding-left: 16px; } }
.table-wrap:focus-visible { outline-offset: 0; }

/* map */
.map { width: 100%; aspect-ratio: 4 / 3; margin-top: 16px; border: 1px solid var(--rule); background: var(--bg); }
@media (min-width: 700px) { .map { aspect-ratio: 16 / 9; } }
.map[data-no-tiles] { background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px); background-size: 40px 40px; }
.leaflet-container { font-family: var(--font); background: var(--bg); }
.leaflet-tile-pane, .leaflet-tile { opacity: 1; filter: none; }
.leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
.jump { margin: 16px 0 0; }
.jump a { display: inline-flex; align-items: center; min-height: 44px; margin-right: 16px; }
.map-attr { margin: 8px 0 0; }
.list-plain { list-style: none; padding: 0; margin: 0 0 1rem; }
.list-plain li { border-bottom: 1px solid var(--rule); padding: 8px 0; }
.dir li { padding: 12px 0; }
.dir a { font-weight: 600; font-size: 1.125rem; }
.dir p { margin: 0; color: var(--text-muted); }
@media (min-width: 700px) {
  .dir li { display: grid; grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); column-gap: 32px; align-items: baseline; padding: 14px 0; }
}

/* ad slots (render empty) */
.ad-slot { margin: 0; }
.ad-slot:not(:empty) { margin-block: 48px; padding: 12px; border: 1px dashed var(--rule); }
.ad-slot:not(:empty)::before { content: attr(data-label); display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }

/* footer */
.site-footer { border-top: 1px solid var(--rule); padding-top: 32px; margin-top: 16px; padding-bottom: 32px; }
.footer-in { display: grid; gap: 24px; }
.footer-in { grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.footer-in > :nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 700px) { .footer-in { grid-template-columns: 1fr 1fr 1.4fr; } .footer-in > :nth-child(3) { grid-column: auto; } }
.foot-h { font-size: 1rem; margin-top: 0; margin: 0 0 8px; font-weight: 650; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li a { display: inline-flex; min-height: 32px; align-items: center; font-size: 1rem; }
@media (max-width: 699px) { .site-footer li a { min-height: 44px; } }
.copy { margin-top: 24px; color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print {
  :root, :root[data-theme] { --bg: #fff; --text: #000; --text-muted: #000; --rule: #999; --accent: #000; }
  .site-header, .site-footer, .theme-toggle, .map, form .actions, .ad-slot { display: none !important; }
  a { color: #000; }
}
