/* Page layout: tokens only. */
html, body { height: 100%; }
body { display: flex; flex-direction: column; min-height: 100vh; font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 3vw, 32px);
  background: var(--ink-field); color: var(--on-ink);
}
.top h1 { font-family: var(--font-display); font-weight: var(--w-display); letter-spacing: var(--tr-display); font-size: clamp(1.15rem, 0.9rem + 1vw, 1.6rem); line-height: 1.15; }
.top__sub { color: var(--on-ink-muted); font-size: var(--fs-small); margin-top: 4px; }
.icon-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: var(--radius-button); border: 1px solid color-mix(in srgb, var(--on-ink) 30%, transparent);
  background: transparent; color: var(--on-ink); cursor: pointer;
}

.rail { background: var(--field-1); color: var(--field-1-ink); padding: 10px clamp(16px, 3vw, 32px) 8px; border-bottom: 1px solid var(--line); }
.rail__controls { display: flex; align-items: center; gap: 10px; }
.rail input[type="range"] { flex: 1; accent-color: var(--accent); height: 44px; }
.step-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; cursor: pointer;
  border-radius: var(--radius-button); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.rail__steps { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin-top: 2px; }
.rail__steps button {
  width: 100%; min-height: 44px; display: flex; align-items: baseline; gap: 6px; text-align: left;
  padding: 6px 8px; border: 0; border-top: 3px solid transparent; background: transparent; color: var(--muted-strong);
  font: inherit; font-size: var(--fs-micro); line-height: 1.2; cursor: pointer; hyphens: auto; overflow-wrap: anywhere;
}
.rail__steps b { font-size: 1rem; color: var(--ink); }
.rail__steps button[aria-current="step"] { border-top-color: var(--accent); color: var(--ink); font-weight: 600; }
.rail__steps button.done { border-top-color: var(--line-strong); }

.work { flex: 1; display: grid; grid-template-columns: 1fr; min-height: 0; }
.map { height: 58vh; min-height: 340px; background: var(--surface-2); }
.panel { padding: 18px clamp(16px, 3vw, 28px) 28px; background: var(--bg); }
.eyebrow { text-transform: var(--case-eyebrow); letter-spacing: var(--tr-eyebrow); font-size: var(--fs-micro); color: var(--accent-text); font-weight: 600; }
.panel h2 { font-family: var(--font-display); font-weight: var(--w-display); letter-spacing: var(--tr-h2); font-size: clamp(1.35rem, 1.1rem + 0.8vw, 1.75rem); line-height: 1.15; margin-top: 4px; }
.panel h3 { font-size: var(--fs-body); font-weight: 650; }
#st-text { color: var(--muted-strong); margin-top: 8px; }
.panel__block { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 16px; }
.panel__block:empty { display: none; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 16px; border-top: 1px solid var(--line); }
.facts div { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { font-size: var(--fs-micro); color: var(--muted); line-height: 1.3; }
.facts dd { font-size: 1.45rem; font-weight: 650; line-height: 1.2; color: var(--ink); }
.facts dd small { font-size: var(--fs-small); color: var(--muted); font-weight: 400; }

.field-label { display: block; font-size: var(--fs-small); color: var(--muted-strong); margin-bottom: 6px; }
select { width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.check { display: flex; gap: 8px; align-items: center; min-height: 40px; font-size: var(--fs-small); color: var(--muted-strong); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-size: var(--fs-small); color: var(--muted); margin: 4px 0 8px; }

.legend li button {
  width: 100%; display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center;
  min-height: 36px; padding: 4px 6px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-small); text-align: left; cursor: pointer; border-radius: var(--radius-sm);
}
.legend li button:hover, .legend li button[aria-pressed="true"] { background: var(--surface-2); }
.legend .sw { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line-strong); }
.legend .kind { display: block; font-size: var(--fs-micro); color: var(--muted); }
.legend .n { font-weight: 650; }

.checks li { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-small); }
.checks .ok { color: var(--ok); font-weight: 650; }
.checks .bad { color: var(--warn); font-weight: 650; }
.groups li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-small); }
.groups b { display: block; color: var(--ink); }
.groups span { color: var(--muted); }

.foot { margin-top: 20px; font-size: var(--fs-micro); color: var(--muted); }
.noscript { padding: 16px; }

/* Leaflet popups follow the theme */
.leaflet-container { font-family: var(--font-body); background: var(--surface-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); border-radius: var(--radius-sm); }
.leaflet-popup-content { margin: 12px 14px; font-size: var(--fs-small); line-height: 1.45; }
.pop h4 { font-size: var(--fs-body); margin: 0 0 6px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.pop dt { color: var(--muted); }
.pop dd { margin: 0; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--accent-text) !important; }
.leaflet-tooltip.kust-tip { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); font-weight: 650; }

@media (max-width: 759px) {
  .rail__steps { grid-template-columns: repeat(9, minmax(118px, 1fr)); overflow-x: auto; scrollbar-width: thin; }
}
@media (min-width: 1000px) {
  .work { grid-template-columns: minmax(0, 1fr) 400px; }
  .map { height: auto; min-height: 0; }
  .panel { overflow-y: auto; max-height: calc(100vh - 170px); border-left: 1px solid var(--line); }
  body { height: 100vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.map.dark-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9); }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { min-height: 44px; border: 0; border-left: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-small); cursor: pointer; padding: 4px; }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--accent-soft); }
