:root {
  --bg: #fafaf9;
  --card: #fff;
  --line: #e7e5e4;
  --text: #1c1917;
  --muted: #78716c;
  --soft: #f5f5f4;
  --accent: #1c1917;
  --r: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; height: 100vh; height: 100dvh; }
a { color: inherit; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---- Lock screen (light, plain) ---- */
.lock {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  background: var(--bg);
}
.lock-card {
  width: min(420px, 100%);
  text-align: center;
  padding: 40px 32px 36px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.lock-card .eyebrow {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.lock-card h1 {
  margin: 0 0 12px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(26px, 6vw, 34px);
  line-height: 1.1;
  letter-spacing: -.03em;
  text-transform: uppercase;
  color: var(--text);
}
.lock-hint {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}
#lock-form {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.lock-input {
  flex: 1; min-width: 160px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: 15px/1.4 var(--sans);
  letter-spacing: .16em;
  text-align: center;
  outline: none;
}
.lock-input:focus { border-color: #a8a29e; }
.lock-btn {
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: 500 14px/1.2 var(--sans);
  cursor: pointer;
}
.lock-btn:hover { background: #292524; }
.lock-error {
  margin: 14px 0 0;
  color: #b91c1c;
  font-size: 13px;
  min-height: 1.2em;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.lock-card.shake { animation: shake .4s ease; }

/* Top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: rgba(250,250,249,.88);
  border-bottom: 1px solid var(--line);
  pointer-events: none;
}
.topbar a { pointer-events: auto; color: var(--text); text-decoration: none; }
.brand { font-weight: 600; font-size: 14px; }
.topbar nav a {
  margin-left: 20px; color: var(--muted); font-size: 14px;
}
.topbar nav a:hover { color: var(--text); text-decoration: none; }

/* Hero map */
.hero-map {
  position: relative;
  height: 100vh; height: 100dvh;
  min-height: 560px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.hero-map:fullscreen,
.hero-map:-webkit-full-screen {
  width: 100vw; height: 100vh; height: 100dvh;
  min-height: 0; background: var(--soft);
}
.hero-map:fullscreen .title-block,
.hero-map:-webkit-full-screen .title-block { display: none; }
#mapview { position: absolute; inset: 0; }

.maplibregl-ctrl-attrib { font-size: 11px; }
.maplibregl-popup-content {
  background: var(--card) !important; color: var(--text) !important;
  border: 1px solid var(--line); border-radius: 10px !important;
  box-shadow: var(--shadow); padding: 12px 14px !important; font-size: 13px;
}
.maplibregl-popup-tip { border-top-color: var(--card) !important; }
.maplibregl-ctrl-group {
  background: var(--card) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
}
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }

.title-block {
  position: absolute; z-index: 5; left: 0; right: 0; top: 0;
  text-align: center; pointer-events: none;
  padding: 72px 20px 20px;
  background: transparent;
}
.eyebrow {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.title-block h1 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -.035em;
  text-transform: uppercase;
  color: var(--text);
  /* thin light edge so title stays readable over map labels */
  text-shadow: 0 0 2px #fafaf9, 0 1px 0 #fafaf9, 1px 0 0 #fafaf9, -1px 0 0 #fafaf9;
}

.layers-dock {
  position: absolute; z-index: 5;
  left: 20px; bottom: 28px;
  width: min(280px, calc(100% - 40px));
  max-height: calc(100% - 150px);
  display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
.layers-dock > * { pointer-events: auto; }
.layers-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 0 14px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); cursor: pointer; flex: none;
}
.layers-btn:hover { border-color: #d6d3d1; }
.layers-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.layers-icon { width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px,-2px); transition: transform .15s; }
.layers-btn[aria-expanded="false"] .layers-icon { transform: rotate(-135deg) translate(-2px,-2px); }
.layer-panel[hidden] { display: none !important; }
.layer-panel {
  position: relative;
  width: 100%; box-sizing: border-box;
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.layer-panel .row {
  display: flex; align-items: center; gap: 10px;
  margin: 7px 0; font-size: 13px; color: var(--text); cursor: pointer;
}
.layer-panel .row.opacity { color: var(--muted); font-size: 12px; padding-left: 26px; }
.layer-panel .row.opacity span { min-width: 52px; }
.layer-panel input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; }
.layer-panel input[type=range] { flex: 1; accent-color: var(--accent); height: 4px; }
.layer-panel hr {
  border: 0; border-top: 1px solid var(--line); margin: 10px 0;
}

/* Sections */
.wrap { max-width: 1040px; margin: 0 auto; padding: 80px 24px 0; }
.section-head { max-width: 640px; margin-bottom: 24px; }
.label {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 8px;
}
h2 {
  font-family: var(--sans); font-weight: 700;
  font-size: clamp(24px, 3.5vw, 32px); letter-spacing: -.02em;
  margin: 0 0 10px; color: var(--text);
}
.lede { margin: 0; color: var(--muted); font-size: 15px; }

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.legend-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.legend-card summary {
  list-style: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px;
  font-weight: 600; font-size: 15px;
  border-bottom: 1px solid transparent;
  user-select: none;
}
.legend-card summary::-webkit-details-marker { display: none; }
.legend-card[open] summary { border-bottom-color: var(--line); }
.legend-card summary::after {
  content: "+"; font-family: var(--mono); color: var(--muted); font-size: 16px;
}
.legend-card[open] summary::after { content: "−"; }
.legend-card .count {
  margin-left: auto; margin-right: 12px;
  color: var(--muted); background: var(--soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
}
.legend-scroll {
  max-height: 360px; overflow: auto;
  padding: 8px 10px 12px;
  scrollbar-width: thin;
}
.legend-item {
  display: grid;
  grid-template-columns: 16px minmax(72px, auto) 1fr;
  gap: 10px; align-items: start;
  padding: 7px 8px; border-radius: 8px;
}
.legend-item:hover { background: var(--soft); }
.swatch {
  width: 14px; height: 14px; border-radius: 3px; margin-top: 3px;
  border: 1px solid var(--line); flex-shrink: 0;
}
.legend-item .code {
  font-family: var(--mono); font-size: 11px; color: var(--text);
  padding-top: 2px; word-break: break-word; font-weight: 500;
}
.legend-item .meta { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.legend-item .meta strong { color: var(--text); font-weight: 500; display: block; }

.prose {
  display: grid; gap: 14px;
  max-width: 720px;
  font-size: 16px; color: var(--muted); line-height: 1.7;
}
.prose p { margin: 0; }

.site-foot {
  margin-top: 80px;
  border-top: 1px solid var(--line);
  padding: 24px 24px 40px;
  color: var(--muted); font-size: 14px;
}
.foot-inner {
  max-width: 1040px; margin: 0 auto;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.foot-inner p { margin: 0; }
.foot-inner a { color: var(--muted); }
.foot-inner a:hover { color: var(--text); }
.foot-inner .foot-atlas { font-size: 11px; opacity: .55; text-decoration: none; align-self: flex-end; }
.foot-inner .foot-atlas:hover { opacity: 1; }

@media (max-width: 800px) {
  .legend-grid { grid-template-columns: 1fr; }
  .title-block { padding-top: 64px; }
  .layers-dock { left: 12px; right: 12px; width: auto; bottom: 16px; max-height: calc(100% - 170px); }
  .topbar { padding: 12px 16px; }
  .topbar nav a { margin-left: 14px; font-size: 13px; }
  .wrap { padding-top: 56px; }
  .legend-scroll { max-height: 280px; }
  .lock-card { padding: 32px 22px 28px; }
}

@media (max-width: 480px) {
  .topbar nav a:nth-child(1),
  .topbar nav a:nth-child(2) { display: none; }
  .hero-map { min-height: 520px; }
}

.basemap-block { margin-top: 2px; }
.basemap-switch {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.basemap-switch button {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font: 500 10.5px/1.2 var(--sans);
  padding: 5px 8px;
  border-radius: 8px;
}
.basemap-switch button:hover { color: var(--text); border-color: #d6d3d1; }
.basemap-switch button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.legend-note{font-size:12px;color:#57534e;margin:8px 12px;line-height:1.45}
.kz15m-pop .ru{color:#44403c}
.legend-item .code.kz{min-width:64px;font-family:"JetBrains Mono",monospace;font-size:11px}
.hero-map.base-off #mapview, .hero-map.base-off .maplibregl-canvas-container { background: #fff; }
.hero-map.base-off { background: #fff; }
.mode-switch { display: flex; gap: 4px; margin: 2px 0 4px 24px; }
.mode-switch button { flex: 1; font: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid #e7e5e4; border-radius: 6px; background: #fff; color: #57534e; cursor: pointer; }
.mode-switch button.active { background: #1c1917; color: #fff; border-color: #1c1917; }

/* Short viewports: keep the map (and its Layers button) within the visible screen */
@media (max-height: 600px) {
  .hero-map { min-height: 0; }
}

.detailed-group { border: 1px solid var(--line); padding: 8px; border-radius: 8px; margin-bottom: 8px; }
.detail-fit { min-height: 44px; padding: 4px 8px; margin: 4px 8px 4px 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.detail-fit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.detail-status { font-size: 11px; line-height: 1.4; color: var(--muted); }

/* Purpose-first controls; dock/fullscreen/mobile anchoring remains unchanged. */
.panel-heading,.map-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.panel-heading { justify-content:space-between; }
.map-category { border-top:1px solid var(--line); margin-top:10px; padding-top:10px; }
.map-category h2 { font-weight:600; line-height:1.3; font-family:inherit; font-size:15px; margin:0 0 6px; }
.layer-panel button,.layer-panel summary,.layer-panel select,.layer-panel .row,.layer-panel a { min-height:44px; }
.layer-panel a { display:inline-flex; align-items:center; }
.layer-panel summary { cursor:pointer; padding:12px 0; font-weight:600; }
.layer-panel button:not(.active) { color:var(--text); }
.layer-panel button:focus-visible,.layer-panel summary:focus-visible,.layer-panel input:focus-visible,.layer-panel select:focus-visible,.layer-panel a:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.map-actions button,#map-help { border:1px solid var(--line); border-radius:6px; background:#fff; padding:6px 10px; font:inherit; cursor:pointer; }
#enabled-count { font-size:12px; flex-basis:100%; }
.map-warning,#map-help-text { font-size:12px; line-height:1.45; color:var(--muted); }
#detail-information { white-space:pre-line; font-size:12px; line-height:1.45; }
.layer-panel .row.opacity { padding-left:0; }
.layer-panel input[type=range] { min-height:44px; }
.layer-panel button { min-width:44px; }
.candidate-list { list-style:none; padding:0; margin:8px 0; }
.candidate-list li { display:flex; align-items:baseline; gap:8px; margin:6px 0; }
.popup-swatch { display:inline-block; width:12px; height:12px; flex-shrink:0; border:1px solid #777; }

/* Compact header and nonvisual document heading. */
.visually-hidden { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.topbar { gap:12px; }
.topbar .brand { min-width:0; max-width:65%; line-height:1.25; }
.topbar nav { display:flex; align-items:center; flex-shrink:0; }
.topbar nav a { white-space:nowrap; }
.prof-collection{border:1px solid var(--line);border-radius:6px;margin:6px 0 8px;padding:4px 8px 6px}
.prof-collection legend{font-size:12px;font-weight:600;padding:0 4px}
.prof-collection small{display:block}
