:root {
  font: 16px/1.5 system-ui, "Apple SD Gothic Neo", sans-serif;
  --atlas-bg: #f1f3f4;
  --panel: #fff;
  --ink: #15202b;
  --muted: #536372;
  --border: #d3dde5;
  --soft: #ecf1f3;
  --accent: #255ba9;
  --line: var(--border);
  background: var(--atlas-bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
header, main { max-width: 1560px; margin: auto; padding-inline: clamp(16px, 4vw, 62px); }
header { min-height: 63px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.entry-bar { width: min(960px, calc(100% - 24px)); padding: 0; border: 0; gap: 12px; }
.brand { color: inherit; text-decoration: none; font-size: 1.35rem; font-weight: 800; letter-spacing: -.04em; }
.entry-bar nav a { color: var(--muted); font-size: .82rem; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
header button, dialog button { border: 1px solid #a9b3a7; background: #fffdf6; padding: 6px 12px; border-radius: 6px; }
select, input { font: inherit; color: inherit; }
dialog { width: min(540px, calc(100% - 2rem)); border: 1px solid var(--line); border-radius: 12px; padding: 1.3rem; }
dialog::backdrop { background: #17282185; }
dialog form { float: right; }
dialog a { color: var(--accent); }
.entry {
  width: min(960px, calc(100% - 24px));
  padding: clamp(16px, 3vw, 32px);
  border-radius: 12px;
  background: var(--panel);
  overflow-wrap: anywhere;
}
.entry h1 { margin: 0 0 12px; font-size: clamp(1.45rem, 4.8vw, 2rem); line-height: 1.25; letter-spacing: -.04em; }
.entry h2 { margin: 24px 0 8px; font-size: 1.12rem; }
.entry > nav:first-child { margin-bottom: 12px; font-size: .85rem; }
.entry p { margin: 0 0 12px; }
.entry .entry-note { margin: 6px 0 0; color: var(--muted); font-size: .85rem; }
.entry a, header nav a, .entry-footer a, .record a { color: var(--accent); }
.entry .entry-action, .map-jump {
  display: inline-flex; align-items: center; min-height: 44px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--soft);
  color: var(--ink); font-weight: 600; text-decoration: none;
}
.entry .entry-action:hover, .map-jump:hover { text-decoration: underline; }
.entry-list { display: grid; margin: 14px 0 0; padding: 0; list-style: none; }
.entry-list li { display: grid; gap: 3px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.entry-districts li { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; }
.entry-list span { color: var(--muted); font-size: .85rem; }
.entry-count { font-variant-numeric: tabular-nums; }
.entry-nav { display: flex; align-items: center; gap: 14px; }
.entry > .entry-nav { margin-top: 14px; }
.entry-fields { max-width: 650px; }
.entry-fields div { display: grid; grid-template-columns: clamp(5.5rem, 25%, 8rem) minmax(0, 1fr); gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.entry-fields dt { color: var(--muted); }
.entry-fields dd { margin: 0; }
.entry-footer { margin: auto; width: min(960px, calc(100% - 24px)); padding: 12px 0 24px; display: flex; flex-wrap: wrap; gap: 15px; align-items: center; font-size: .8rem; }
.entry-footer a { color: var(--muted); }
.analytics-button { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding: 5px 10px; }
.analytics-consent {
  position: fixed;
  inset: auto 0 max(12px, env(safe-area-inset-bottom));
  width: min(440px, calc(100% - 24px));
  max-height: calc(100% - 24px - env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 18px;
  border-color: #d3dde5;
  border-radius: 16px;
  background: #fff;
  color: #15202b;
  box-shadow: 0 12px 36px #15202b33;
  font-size: .9rem;
}
.analytics-consent::backdrop { background: #15202b59; }
.analytics-consent h2 { margin: 0; font-size: 1.1rem; }
.analytics-consent p { margin: 6px 0 8px; color: #435362; word-break: keep-all; }
.analytics-consent a { color: #435362; }
.analytics-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.analytics-actions button { min-height: 44px; padding: 6px; border-color: #99a7b3; border-radius: 8px; background: #fff; }
.analytics-actions button[data-choice="yes"] { background: #15202b; border-color: #15202b; color: #fff; }

.atlas-page {
  --ph: #008778;
  --cl: #2f6fda;
  --inactive: #a3afb9;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px clamp(12px, 1.1vw, 24px) 0;
  background: var(--atlas-bg);
  color: var(--ink);
  font-size: 14px;
}
.atlas-page :focus-visible { outline: 2px solid var(--cl); outline-offset: 2px; }
.atlas-page [hidden] { display: none !important; }
.atlas-bar, .atlas-workspace { width: 100%; max-width: none; margin: 0; padding: 0; }
.atlas-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px 22px; border: 0; }
.atlas-brand h1 { margin: 0; font-size: 1.35rem; line-height: 1.25; letter-spacing: -.04em; }
.atlas-brand h1 a { color: inherit; text-decoration: none; }
.atlas-brand nav { gap: 10px; margin-top: 3px; font-size: .76rem; }
.atlas-brand nav a, .atlas-brand nav button { color: var(--muted); }
.atlas-brand nav button { padding: 0; border: 0; background: none; text-decoration: underline; }
.timeline { display: flex; flex: 1 1 320px; min-width: 0; align-items: center; gap: 10px; }
.timeline input { flex: 1; min-width: 30px; accent-color: var(--ph); }
.timeline output { font-size: clamp(1.65rem, 3.1vw, 2.5rem); line-height: 1; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.timeline button, .map-controls button { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; }
.timeline button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.timeline #play { width: 38px; height: 38px; padding: 0; flex: none; border-radius: 50%; }
.time-unit { display: flex; flex: none; }
.time-unit button:first-child { border-radius: 8px 0 0 8px; }
.time-unit button:last-child { border-left: 0; border-radius: 0 8px 8px 0; }
.atlas-stats { display: flex; flex-wrap: wrap; gap: 5px 16px; font-variant-numeric: tabular-nums; }
.metric { display: grid; }
.metric strong { font-size: 1.1rem; line-height: 1.2; }
.metric span { color: var(--muted); font-size: .74rem; }
.inactive { --series: var(--inactive); }
.map-legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--series); }

.atlas-workspace { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(320px, 1fr); gap: 12px; min-height: 410px; }
.map-frame { position: relative; min-height: 0; min-width: 0; overflow: hidden; border-radius: 12px; background: #dce7ed; }
.map-surface { position: absolute; inset: 0; overflow: hidden; }
#map { position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; }
#map-points { z-index: 450; position: absolute; inset: 0; height: 100%; width: 100%; pointer-events: none; }
.map-note, .map-controls, .map-legend { position: absolute; z-index: 500; margin: 0; }
.map-note, .map-legend { left: 12px; max-width: calc(100% - 24px); padding: 6px 10px; border-radius: 8px; background: #ffffffed; font-size: .77rem; pointer-events: none; }
.map-note { top: 12px; max-width: calc(100% - 68px); color: var(--muted); }
.map-legend { bottom: 28px; pointer-events: auto; }
.map-legend summary { cursor: pointer; }
.map-legend ul { max-height: min(240px, 28svh); overflow: auto; overscroll-behavior: contain; margin: 6px 0 0; padding: 0 6px 0 0; list-style: none; }
.map-legend li { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding-block: 2px; }
.map-legend strong { font-variant-numeric: tabular-nums; }
.map-controls { display: grid; gap: 5px; right: 12px; top: 12px; }
.map-controls button { width: 34px; height: 34px; font-size: 1.15rem; padding: 0; }
.atlas-page .entry-footer { padding: 0 0 7px; width: 100%; max-width: none; font-size: .72rem; }
.atlas-page .entry-footer a { color: var(--muted); }

.panel { min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 12px; background: var(--panel); }
.panel-tools { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
#query, .atlas-filters select { width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--soft); }
#query { padding: 10px 12px; }
.atlas-filters { margin-top: 7px; font-size: .76rem; color: var(--muted); }
.atlas-filters summary { cursor: pointer; }
.atlas-filters .filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-top: 7px; }
.atlas-filters label { display: grid; gap: 3px; }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; }
#summary { color: var(--muted); font-size: .79rem; margin: 0 0 8px; }
#results { display: grid; gap: 5px; }
.result { text-align: start; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 6px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: transparent; }
.result:hover, .result:focus-visible { background: var(--soft); }
.result strong, .result-address { overflow-wrap: anywhere; }
.result span { color: var(--muted); font-size: .77rem; }
.result-address { grid-column: 1 / -1; }
.back { padding: 0; border: 0; background: transparent; color: var(--muted); text-align: start; }
.back:hover { text-decoration: underline; }
#detail h2 { line-height: 1.35; font-size: 1.14rem; margin: 10px 0 4px; overflow-wrap: anywhere; }
#detail h3 { color: var(--muted); font-size: .84rem; margin: 16px 0 7px; }
.detail-context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.map-jump { font-size: .85rem; }
.detail-area { display: inline-block; padding: 2px 8px; border-radius: 20px; background: var(--soft); font-size: .8rem; margin: 0; }
.detail-stats { font-size: .85rem; margin: 10px 0 0; }
.detail-note { color: var(--muted); font-size: .75rem; margin: 6px 0 0; }
.floor-stack { border: 1px solid var(--ink); border-top-width: 4px; border-radius: 3px 3px 0 0; }
.floor-row { display: grid; grid-template-columns: 55px minmax(0, 1fr); align-items: center; min-height: 28px; }
.floor-row + .floor-row { border-top: 1px solid var(--border); }
.floor-row.ground-line { border-top: 3px solid var(--ink); }
.floor-row.floor-gap { min-height: 16px; }
.floor-label { text-align: center; color: var(--muted); font-size: .75rem; }
.floor-contents { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 7px 4px 0; color: var(--muted); font-size: .75rem; }
.unknown-floor { border: 1px dashed var(--muted); border-radius: 6px; margin-top: 6px; }
.tenant { background: var(--series); color: #fff; text-decoration: none; border-radius: 4px; padding-inline: 6px; overflow-wrap: anywhere; }
.tenant:hover { text-decoration: underline; }
.chronology { padding: 0 10px 0 1px; }
.chronology-axis { position: relative; height: 21px; border-bottom: 1px solid var(--border); }
.chronology-axis span { position: absolute; color: var(--muted); font-size: .68rem; }
.chronology-row { padding: 6px 0; border-bottom: 1px solid var(--border); }
.chronology-label { display: flex; flex-wrap: wrap; gap: 1px 7px; align-items: baseline; }
.chronology-label a { color: var(--ink); text-decoration-color: var(--border); }
.chronology-label span { font-size: .72rem; color: var(--muted); }
.chronology-track { position: relative; height: 16px; margin-top: 3px; background: var(--soft); }
.chronology-bar, .chronology-cursor, .transfer { position: absolute; }
.chronology-bar { top: 4px; height: 8px; border-radius: 2px; background: var(--series); min-width: 2px; }
.chronology-bar.unknown-date { min-width: 8px; border: 1px dashed var(--series); background: transparent; }
.chronology-cursor { top: 0; bottom: 0; left: var(--cursor); border-left: 2px solid var(--ink); pointer-events: none; }
.transfer { top: -4px; transform: translateX(-50%); color: var(--ink); font-weight: 900; }

@media (min-width: 821px) {
  .atlas-page { height: 100svh; }
}
@media (max-width: 820px) {
  .atlas-workspace { grid-template-columns: minmax(0, 1fr); }
  .map-frame { height: clamp(330px, 58svh, 560px); }
  .panel-body { max-height: 650px; }
}
