* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); color: var(--ink); padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: .5rem; top: .5rem; }

.layout { flex: 1; display: flex; min-height: 0; position: relative; }
.panel {
  width: var(--panel-w); flex: none; overflow-y: auto; background: var(--panel);
  border-right: 1px solid var(--line); padding: .75rem 1rem 2rem;
}
.panel[hidden] { display: none; }
.panel h2 { font: 500 .72rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin: 1.3rem 0 .45rem; padding-top: .45rem; border-top: 2px solid var(--ink); }
.status { font-size: .85rem; color: var(--muted); margin: 0; }

.layer-list, .item-list { list-style: none; padding: 0; margin: 0; }
/* Hold space for the layer rows while the list loads, so the panel doesn't jump. */
.layer-list:empty { min-height: calc(var(--rows, 3) * 118px); }
.layer { background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: .55rem .65rem; margin-bottom: .45rem; }
.layer-row { display: flex; align-items: flex-start; gap: .55rem; }
.layer-row input { width: 20px; height: 20px; margin: .1rem 0 0; flex: none; accent-color: var(--brand); }
.layer-row label { flex: 1; cursor: pointer; min-width: 0; }
.layer-name { font-weight: 600; font-size: .92rem; display: block; }
.layer-agency { font-size: .8rem; color: var(--muted); display: block; }
.swatch { width: 18px; height: 18px; border-radius: 0; border: 2px solid; flex: none; margin-top: .1rem; }
.swatch.dashed { border-style: dashed; }
.badges { display: flex; flex-wrap: wrap; gap: .3rem; margin: .35rem 0 0 1.8rem; }
.badge { font: 500 .7rem/1.5 var(--mono); letter-spacing: .03em; padding: .05rem .4rem; border-radius: 0; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.err { background: var(--err-bg); color: var(--err-ink); }
.badge.old { background: var(--old-bg); color: var(--old-ink); }
.layer details { margin: .35rem 0 0 1.8rem; font-size: .82rem; color: var(--muted); }
.layer summary { cursor: pointer; color: var(--link); }
.layer dl { margin: .35rem 0 0; display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; }
.layer dt { font-weight: 600; color: var(--ink); }
.layer dd { margin: 0; overflow-wrap: anywhere; }

.hint { font-size: .8rem; color: var(--muted); margin: 0 0 .4rem; }
.item-list li { margin-bottom: .3rem; }
.item-btn {
  width: 100%; text-align: left; font: inherit; font-size: .85rem; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 0; padding: .4rem .6rem; cursor: pointer;
}
.item-btn small { display: block; color: var(--muted); }
.planned ul { padding-left: 1.1rem; font-size: .85rem; }
.planned li { margin-bottom: .5rem; }
.tag { font: 500 .66rem/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--rule-strong); background: var(--old-bg); color: var(--old-ink); padding: .05rem .4rem; border-radius: 0; }
.disclaimer { font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .75rem; margin-top: 1.2rem; }

.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.details {
  position: absolute; right: .75rem; top: .75rem; width: min(380px, calc(100% - 1.5rem)); max-height: calc(100% - 1.5rem);
  overflow-y: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 0;
  box-shadow: 0 6px 24px var(--shadow); padding: .75rem 1rem; z-index: 5;
}
.details-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.details-head h2 { font-size: 1rem; margin: 0; }
.details-head .btn { color: var(--ink); }
.feature + .feature { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .6rem; }
.feature h3 { font-size: .98rem; margin: .3rem 0; }
.feature dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; font-size: .85rem; margin: 0; }
.feature dt { font-weight: 600; }
.feature dd { margin: 0; overflow-wrap: anywhere; }
.feature .note { font-size: .8rem; color: var(--muted); }

dialog { background: var(--surface); color: var(--ink); max-width: 560px; border: none; border-radius: 0; padding: 1.2rem 1.4rem; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .btn { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.small { font-size: .8rem; color: var(--muted); }

.maplibregl-ctrl-attrib { font-size: 11px; }

.search { margin: .75rem 0 .3rem; }
.search label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
.search-row { display: flex; gap: .4rem; }
.search input {
  flex: 1; min-width: 0; font: inherit; font-size: 1rem; padding: .4rem .6rem; min-height: 40px;
  border: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--ink);
}
.btn-solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-solid:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.search-results { margin-bottom: .4rem; }
.exports { display: flex; flex-wrap: wrap; gap: .2rem .7rem; }
.changes { margin: 0; padding-left: 1rem; }
.changes li { margin-bottom: .2rem; }
.changes-feed li { font-size: .83rem; border-bottom: 1px solid var(--line); padding: .3rem 0; }
.changes-feed li span { display: block; color: var(--muted); }
.changes-feed li .layer-agency { display: inline; }

.legend {
  position: absolute; left: .75rem; bottom: 4.2rem; z-index: 4; max-width: min(300px, calc(100% - 1.5rem));
  max-height: 45%; overflow-y: auto; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 0; box-shadow: 0 3px 12px var(--shadow); padding: .35rem .6rem; font-size: .8rem;
}
.legend summary { cursor: pointer; font-weight: 700; padding: .15rem 0; }
.legend ul { list-style: none; margin: .3rem 0 .1rem; padding: 0; }
.legend li { display: flex; align-items: center; gap: .45rem; margin-bottom: .25rem; }
.legend .swatch { width: 14px; height: 14px; margin: 0; }
.legend small { color: var(--muted); }

:root[data-theme="dark"] .maplibregl-ctrl-group { background: var(--surface); }
:root[data-theme="dark"] .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
:root[data-theme="dark"] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib { background: rgba(14,16,18,.85); color: var(--ink); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib a { color: var(--link); }
:root[data-theme="dark"] .maplibregl-ctrl-scale { background: rgba(14,16,18,.85); color: var(--ink); border-color: var(--ink); }

@media (max-width: 760px) {
  .tagline { display: none; }
  .layout { flex-direction: column-reverse; }
  .panel { width: 100%; max-height: 40vh; max-height: 40dvh; border-right: 0; border-top: 1px solid var(--line); }
  .map-wrap { flex: 1; min-height: 0; }
  .topbar { padding-left: .6rem; padding-right: .6rem; gap: .5rem; }
  .topbar .btn { padding: .35rem .55rem; font-size: .85rem; }
  .legend { left: .5rem; bottom: 2.6rem; }
  .details { left: .5rem; right: .5rem; width: auto; top: .5rem; max-height: calc(100% - 1rem); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Links under the panel */
.panel-links { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 1rem 0 .5rem; font-size: .9rem; }
.panel-links a { color: var(--link); }

/* First-visit hint: non-modal, dismissible with the button or Escape */
.first-hint {
  position: absolute; z-index: 3; left: 50%; top: 1rem; transform: translateX(-50%);
  width: min(22rem, calc(100% - 2rem)); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 0; box-shadow: 0 4px 18px var(--shadow); padding: .8rem 1rem;
}
.first-hint h2 { margin: 0 0 .3rem; font-size: 1rem; }
.first-hint ul { margin: 0 0 .7rem; padding-left: 1.1rem; font-size: .92rem; }
.first-hint[hidden] { display: none; }

/* Swatches keep a hairline radius so dashed outlines read at small sizes. */
.swatch { border-radius: 2px; }
.layer-agency, .item-btn small, .changes-feed li span { font-variant-numeric: tabular-nums; }
.legend summary, .details-head h2, .first-hint h2 { font: 500 .74rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.first-hint { border-top: 2px solid var(--accent); }
.search label { font: 500 .72rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; }

.btn-small { min-height: 28px; padding: .05rem .5rem; font-size: .78rem; }
