:root {
  /* Dark is the product default. Chrome is neutral grey only — no blue, teal, or green. */
  color-scheme: dark;
  --bg: #0a0a0a;
  --ink: #e8e8e8;
  --muted: #9a9a9a;
  --line: #2a2a2a;
  --card: #161616;
  --prose: #d0d0d0;
  --on-ink: #121212;
  --accent: #e8e8e8;
  --track: #2a2a2a;
  --mixed: #c8c8c8;
  --pad: 1.25rem;
  --radius: 0.75rem;
}
html.dark {
  color-scheme: dark;
  --bg: #0a0a0a;
  --ink: #e8e8e8;
  --muted: #9a9a9a;
  --line: #2a2a2a;
  --card: #161616;
  --prose: #d0d0d0;
  --on-ink: #121212;
  --accent: #e8e8e8;
  --track: #2a2a2a;
  --mixed: #c8c8c8;
}
html.light {
  color-scheme: light;
  --bg: #f4f4f4;
  --ink: #141414;
  --muted: #6a6a6a;
  --line: #e4e4e4;
  --card: #fff;
  --prose: #3a3a3a;
  --on-ink: #fff;
  --accent: #141414;
  --track: #e4e4e4;
  --mixed: #4a4a4a;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
a { color: var(--accent); }
.btn { text-decoration: none; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }

.header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0.85rem var(--pad);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.header p { color: var(--muted); font-size: 0.75rem; margin-top: 0.15rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: nowrap; }
.header-menu { position: relative; flex-shrink: 0; }
.header-menu-btn {
  display: grid;
  place-items: center;
  padding: 0.4rem 0.5rem;
  line-height: 0;
}
.header-menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  left: auto;
  z-index: 30;
  min-width: 13.5rem;
  max-width: min(18rem, calc(100vw - 1.5rem));
  margin: 0;
  padding: 0.45rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
}
.header-menu-panel > li { display: block; min-width: 0; }
.header-menu-panel > li:has(> a.hidden),
.header-menu-panel > li:has(> button.hidden) { display: none; }
.header-menu-panel .btn {
  display: block;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
}
.header-menu-panel .auth-user {
  padding: 0.2rem 0.45rem 0.5rem;
  margin-bottom: 0.1rem;
  border-bottom: 1px solid var(--line);
}
.auth-user { display: flex; align-items: center; gap: 0.45rem; }
.auth-user img {
  width: 28px; height: 28px; border-radius: 999px; object-fit: cover; background: var(--line); flex-shrink: 0;
}
.auth-user span { font-size: 0.78rem; color: var(--muted); min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-hint { color: var(--muted); font-size: 0.75rem; margin-top: 0.2rem; max-width: 28rem; }
#btn-anon:disabled {
  opacity: 0.85;
  cursor: default;
}

.tabs { display: flex; border: 1px solid var(--line); border-radius: 0.5rem; overflow: hidden; }
.tabs button {
  background: var(--card);
  border: 0;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  color: var(--prose);
  font-size: 0.85rem;
}
.tabs button.active { background: var(--ink); color: var(--on-ink); }
.tabs button:focus-visible,
.btn:focus-visible,
button.pill:focus-visible,
.legend-item:focus-visible,
.person-card:focus-visible,
.story-card:focus-visible,
.source-card:focus-visible,
.sources-tag:focus-visible,
#inspector-close:focus-visible,
.canvas-fit-icon:focus-visible,
.canvas-filter-btn:focus-visible,
.filter-drop summary:focus-visible,
#search:focus-visible,
.chip:focus-visible,
.linkish:focus-visible,
.cluster-row:focus-visible,
.layer-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toolbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0.65rem var(--pad);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
#chrome-search-home { flex: 1; min-width: 12rem; }
#chrome-year-home {
  flex: 1;
  min-width: 14rem;
  max-width: 32rem;
}
#chrome-toolbar #year-slider {
  width: 100%;
  max-width: none;
  min-width: 0;
}
#search {
  width: 100%;
  max-width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--ink);
}
#legend {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 12rem;
}
.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.legend-kicker {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.2rem;
}
button.pill {
  cursor: pointer;
  font: inherit;
}
.pill.armed {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.pill.filtered {
  box-shadow: 0 0 0 2px #f59e0b;
}
#year-slider {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  flex: 1;
  min-width: 14rem;
  max-width: 32rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.year-play-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.year-play-head .section-label {
  margin: 0;
}
.year-follow {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 650;
  padding: 0.18rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}
.year-follow:hover,
.year-follow.is-on {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
.year-follow:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.year-ka-hint {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--muted);
}
.year-range {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}
.year-play {
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.year-play svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: currentColor;
  display: block;
}
.year-play:hover,
.year-play.is-playing {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
.year-play:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.year-range-track {
  position: relative;
  flex: 1;
  height: 1.35rem;
  cursor: pointer;
  touch-action: none;
}
.year-range-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0.28rem;
  margin-top: -0.14rem;
  background: var(--track);
  border-radius: 999px;
}
.year-range-fill {
  position: absolute;
  top: 0;
  height: 100%;
  cursor: grab;
  touch-action: none;
  z-index: 1;
}
.year-range-fill::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0.28rem;
  margin-top: -0.14rem;
  background: var(--ink);
  border-radius: 999px;
}
.year-range.is-panning .year-range-fill { cursor: grabbing; }
.year-range-thumb {
  position: absolute;
  top: 50%;
  width: 1.35rem;
  height: 1.35rem;
  margin: -0.675rem 0 0 -0.675rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  cursor: ew-resize;
  touch-action: none;
  z-index: 2;
}
.year-range-thumb::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.35);
}
.year-range-thumb:hover::after,
.year-range-thumb:focus-visible::after {
  transform: scale(1.12);
}
.year-range-thumb:focus-visible { outline: 0; }
.year-range.is-dragging .year-range-thumb { cursor: grabbing; }

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--card);
  color: var(--ink);
}
.chip-row, .doc-row, .jump-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }

main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.85rem var(--pad) var(--pad);
}
.workspace {
  --left-w: 20rem;
  --right-w: 24rem;
  --tools-grow: 50;
  --inset-grow: 50;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
}
.workspace > main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#context-pane {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--left-w);
  width: var(--left-w);
  background: var(--card);
  border-right: 1px solid var(--line);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
#context-chrome {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.focus-toggle {
  display: block;
}
.focus-toggle .btn {
  width: 100%;
  font-weight: 650;
  font-size: 0.78rem;
}
#context-search-slot { min-width: 0; }
#context-year-slot { min-width: 0; width: 100%; }
#context-chrome #search { width: 100%; }
#context-chrome #year-slider {
  flex: none;
  min-width: 0;
  max-width: none;
  width: 100%;
}
#context-chrome .year-range { min-width: 0; }
#context-chrome #yr-label {
  flex: 0 0 auto;
  font-size: 0.68rem;
  white-space: nowrap;
}
#context-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#context-tools,
#context-inset {
  min-height: 0;
}
#context-tools {
  flex: var(--tools-grow) 1 0;
  order: 1;
  overflow: hidden;
  padding: 0.55rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
}
#context-pane[data-mode="people"] #context-tools,
#context-pane[data-mode="stories"] #context-tools {
  flex: 1 1 auto;
}
#context-tools .insp-block { gap: 0.2rem; }
#context-tools .muted { margin: 0; }
#context-inset {
  flex: var(--inset-grow) 1 0;
  order: 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.35rem 0.65rem 0.75rem;
}
#context-inset::before {
  content: attr(data-label);
  flex: none;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 650;
  padding: 0 0.15rem 0.35rem;
  line-height: 1.3;
}
#split-context { order: 2; }
.split {
  flex: 0 0 8px;
  position: relative;
  z-index: 3;
  background: var(--bg);
  touch-action: none;
}
.split::after {
  content: "";
  position: absolute;
  background: var(--line);
  border-radius: 999px;
}
.split-h {
  cursor: col-resize;
}
.split-h::after {
  top: 0.85rem;
  bottom: 0.85rem;
  left: 3px;
  width: 2px;
}
.split-v {
  cursor: row-resize;
  align-self: stretch;
}
.split-v::after {
  left: 0.75rem;
  right: 0.75rem;
  top: 3px;
  height: 2px;
}
.split:hover,
.split.is-drag {
  background: var(--line);
}
.split:hover::after,
.split.is-drag::after {
  background: var(--muted);
}
body.is-resizing { user-select: none; }
body.is-resizing-x { cursor: col-resize; }
body.is-resizing-y { cursor: row-resize; }
body.is-resizing #map-root,
body.is-resizing #cy-root,
body.is-resizing .leaflet-container {
  pointer-events: none;
}
.canvas-home {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.65rem;
  position: relative;
}
.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pane.scroll {
  overflow: auto;
}
.hidden { display: none !important; }

.tree-shell, #map-root {
  flex: 1;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.canvas-fit {
  appearance: none;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.2;
  padding: 0.28rem 0.5rem;
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  border: 2px solid rgb(0 0 0 / 0.22);
  box-shadow: 0 1px 5px rgb(0 0 0 / 0.28);
  cursor: pointer;
}
.canvas-fit:hover { background: var(--bg); }
.tree-zoom {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid rgb(0 0 0 / 0.22);
  box-shadow: 0 1px 5px rgb(0 0 0 / 0.28);
  background: var(--card);
}
.tree-zoom .canvas-fit-icon {
  appearance: none;
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.tree-zoom .canvas-fit-icon:hover { background: var(--bg); }
.leaflet-control-zoom-fit {
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.leaflet-control-zoom-fit svg { display: block; }
.canvas-filter-overlay {
  position: absolute;
  top: calc(0.65rem + 10px);
  right: calc(0.65rem + 10px);
  z-index: 25;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.canvas-filter-overlay[hidden] { display: none; }
.canvas-home:has(> #tree-shell) > .canvas-filter-overlay {
  display: none !important;
}
.canvas-filter-overlay .canvas-filter-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
.canvas-filter-overlay .filter-drop {
  position: relative;
  min-width: 0;
  box-shadow: 0 1px 5px rgb(0 0 0 / 0.28);
  border: 2px solid rgb(0 0 0 / 0.22);
}
.canvas-filter-overlay .filter-drop summary {
  padding: 0.28rem 0.5rem;
  font-size: 0.72rem;
}
.canvas-filter-overlay .filter-drop-list {
  position: absolute;
  right: 0;
  top: calc(100% + 2px);
  z-index: 2;
  min-width: 10rem;
  max-height: min(16rem, 50vh);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
}
#context-inset .tree-zoom,
#context-inset .canvas-filter-overlay {
  display: none !important;
}
#context-inset .tree-shell,
#context-inset #map-root {
  flex: 1;
  min-height: 0;
  border-radius: 0.5rem;
}
#context-inset .leaflet-control-zoom a {
  width: 22px;
  height: 22px;
  line-height: 22px;
  font-size: 13px;
}
#context-inset .leaflet-control-attribution {
  font-size: 8px;
  max-width: calc(100% - 0.4rem);
}
#cy-root, #map-root { flex: 1; min-height: 0; width: 100%; background: var(--bg); }
.leaflet-container { background: var(--bg); }
#map-root, .story-map {
  isolation: isolate;
  z-index: 0;
  transform: translateZ(0);
}
#map-root.leaflet-container,
.story-map.leaflet-container {
  z-index: 0 !important;
}
.page-head {
  margin-bottom: 1rem;
}
.page-filters {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 22rem;
}
.page-head h2 { font-size: 1.05rem; }
.page-head p { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
  gap: 0.75rem;
}
.person-card, .story-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.person-card {
  cursor: pointer;
  border-left-width: 3px;
}
.person-card.selected,
.story-card.selected,
.source-card.selected { box-shadow: inset 0 0 0 2px #f59e0b; }
.source-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.source-card h3 { font-size: 0.95rem; font-weight: 650; }
.source-notes { white-space: pre-wrap; }
.person-card h3 {
  font-size: 0.9rem;
  font-weight: 650;
}
.card-sum, .muted { color: var(--muted); font-size: 0.8rem; }
.card-sum { margin-top: 0.4rem; line-height: 1.4; }
.card-tags { margin-top: 0.45rem; }
.sources-tag {
  appearance: none;
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 0.05rem 0.35rem;
  cursor: pointer;
  line-height: 1.3;
}
.sources-tag:hover { color: var(--ink); }
.section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 650;
  margin: 1.25rem 0 0.5rem;
}
.section-label:first-child { margin-top: 0; }

.story-grid,
.people-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.story-card {
  margin: 0;
  border-left-width: 3px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: start;
  cursor: pointer;
}
.story-card.has-map {
  grid-template-columns: minmax(0, 1fr) 12.5rem;
}
.story-card.is-future {
  display: none;
}
.story-card:not(.is-open) {
  padding: 0.55rem 0.8rem;
  gap: 0.35rem;
}
.story-card:not(.is-open) .story-head { margin-bottom: 0.15rem; }
.story-card:not(.is-open) h3 {
  margin-bottom: 0.1rem;
  font-size: 0.92rem;
}
.story-card:not(.is-open) .prose,
.story-card:not(.is-open) .story-map,
.story-card:not(.is-open) .story-links,
.story-card:not(.is-open) .card-tags {
  display: none;
}
.story-card:not(.is-open).has-map {
  grid-template-columns: 1fr;
}
.story-card.is-past:not(.is-open) {
  opacity: 0.4;
}
.story-card.is-now,
.story-card.is-open {
  opacity: 1;
}
@media (max-width: 720px) {
  .story-card.has-map { grid-template-columns: 1fr; }
}
.story-map {
  height: 12.5rem;
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
}
.leaflet-tooltip.mini-map-lab {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #ececec;
  font-size: 0.62rem;
  font-weight: 650;
  padding: 0.05rem 0.2rem;
  white-space: nowrap;
  text-shadow: 0 0 4px #000, 0 1px 3px #000, 0 0 8px #000;
}
html.light .leaflet-tooltip.mini-map-lab {
  color: #1c1917;
  text-shadow: 0 0 3px #fff, 0 1px 2px rgba(255, 255, 255, 0.9);
}
.leaflet-tooltip.mini-map-lab::before { display: none; }
.story-head {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.story-card h3 { font-size: 1.02rem; margin: 0 0 0.45rem; line-height: 1.3; }
.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  background: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  color: var(--muted);
}
.linkish { background: none; border: 0; padding: 0; font-weight: 600; cursor: pointer; color: var(--ink); }
.prose { font-size: 0.9rem; line-height: 1.55; color: var(--prose); }
.story-links {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
}

#inspector {
  display: flex;
  flex: 0 0 var(--right-w);
  width: var(--right-w);
  min-width: 0;
  background: var(--card);
  border-left: 1px solid var(--line);
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 1;
}
.insp-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem var(--pad);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.insp-head h2 { font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
#inspector-meta { margin-top: 0.15rem; }
#inspector-close {
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 0.4rem;
  line-height: 1;
  font-size: 1.15rem;
}
#inspector-body {
  flex: 1;
  overflow: auto;
  padding: 1rem var(--pad) 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  font-size: 0.9rem;
  min-height: 0;
}
.insp-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
#inspector-body .muted { margin: 0; }
#inspector-body .section-label { margin: 0.15rem 0 0; }
.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.event-list li {
  font-size: 0.82rem;
  line-height: 1.4;
}
.event-list li .prose {
  margin-top: 0.35rem;
  font-size: 0.8rem;
}
#inspector .story-card.has-map { grid-template-columns: 1fr; }
#inspector .story-map { height: 9rem; }
#inspector-body.insp-feed {
  gap: 0.85rem;
}
.overview-map {
  height: 12rem;
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  isolation: isolate;
  z-index: 0;
}
.insp-detail {
  border-top: 1px solid var(--line);
  margin-top: 0.35rem;
  padding-top: 0.15rem;
}
.insp-detail:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}
.insp-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.insp-sel-head {
  padding: 0.55rem 0 0.2rem;
}
.insp-sel-head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
}
.insp-sel-head .muted { margin-top: 0.15rem; }
.legend-col {
  --legend-gap: 0.2rem;
  --legend-row: calc(0.68rem * 1.2 + 0.36rem + 0.7rem + 4px);
  display: flex;
  flex-direction: column;
  gap: var(--legend-gap);
  max-height: calc(4 * var(--legend-row) + 3 * var(--legend-gap));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.legend-item:hover { background: var(--bg); }
.legend-item.filtered {
  box-shadow: inset 0 0 0 2px #f59e0b;
}
.legend-item .pill { max-width: none; flex: 1; }
.depth-ctrl {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.depth-ctrl input[type=range] { width: 100%; }
#inspector-foot {
  padding: 0.75rem var(--pad);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex-shrink: 0;
}
.btn {
  background: var(--ink);
  color: var(--on-ink);
  border: 0;
  border-radius: 0.45rem;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.btn.ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
#btn-anon.active,
#btn-anon:disabled.active,
.btn.ghost.active {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
.doc-thumb { display: flex; flex-direction: column; width: 6.5rem; text-decoration: none; color: inherit; font-size: 0.7rem; }
.doc-thumb img, .doc-ph {
  width: 6.5rem; height: 4.5rem; object-fit: cover;
  border-radius: 0.4rem; background: var(--line);
  display: grid; place-items: center;
}
.filter-drop {
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--card);
}
.filter-drop + .filter-drop { margin-top: 0.35rem; }
.filter-drop summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  list-style: none;
}
.filter-drop summary::-webkit-details-marker { display: none; }
.filter-drop summary::after {
  content: "";
  width: 0.35rem;
  height: 0.35rem;
  margin-left: auto;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  flex: 0 0 auto;
}
.filter-drop[open] summary::after { transform: rotate(225deg); }
.filter-drop summary .muted {
  font-weight: 500;
  font-size: 0.75rem;
}
.filter-drop-lead {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
  margin-right: auto;
}
.filter-drop-list {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.15rem 0.55rem 0.45rem;
  border-top: 1px solid var(--line);
}
.filter-drop-list.chip-row {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.15rem 0;
  user-select: none;
}
.layer-item input { accent-color: var(--ink); }
.assumed-flag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 0.25rem;
  padding: 0.05rem 0.3rem;
  vertical-align: 0.1em;
}
.event-card {
  cursor: pointer;
  gap: 0.35rem;
}
.event-card h3 { font-size: 0.95rem; margin: 0; }

.leaflet-div-icon.place-icon,
.leaflet-div-icon.mc-wrap,
.leaflet-div-icon.naruto-nation {
  background: transparent;
  border: 0;
  overflow: visible !important;
}
.leaflet-naruto-nations-pane {
  pointer-events: none;
}
.naruto-nation {
  background: transparent !important;
  border: 0 !important;
}
.naruto-nation-lab {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  color: #ececec;
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.88;
  mix-blend-mode: normal;
  text-shadow: 0 0 4px #000, 0 0 8px #000, 0 1px 2px #000;
}
html.light .naruto-nation-lab {
  color: #8a847c;
  opacity: 0.62;
  mix-blend-mode: multiply;
  text-shadow: 0 0 3px rgba(250, 246, 234, 0.55);
}
.naruto-nation-lab.is-hidden { visibility: hidden; }
#context-inset .naruto-nation-lab {
  font-size: 0.5rem;
  letter-spacing: 0.06em;
}
.naruto-nation.rank-2 .naruto-nation-lab { font-size: 0.56rem; letter-spacing: 0.12em; opacity: 0.5; }
.naruto-nation.rank-3 .naruto-nation-lab { font-size: 0.48rem; letter-spacing: 0.1em; opacity: 0.42; }
.leaflet-naruto-nations-pane .rank-2,
.leaflet-naruto-nations-pane .rank-3 { display: none; }
.leaflet-naruto-nations-pane.show-rank-2 .rank-2 { display: block; }
.leaflet-naruto-nations-pane.show-rank-3 .rank-2,
.leaflet-naruto-nations-pane.show-rank-3 .rank-3 { display: block; }
.mig-decor {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 450;
}
.mig-decor-chev {
  opacity: 0.48;
}
.mig-decor-label {
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  paint-order: stroke fill;
  stroke: rgba(10, 10, 10, 0.9);
  stroke-width: 3px;
  stroke-linejoin: round;
  opacity: 0.92;
}
html.light .mig-decor-label {
  stroke: rgba(255, 248, 236, 0.86);
}
.mig-decor-label.is-hidden { display: none; }
#context-inset .mig-decor-label { font-size: 10px; }
.naruto-place-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.15rem;
  padding: 0.08rem 0.35rem;
  border: 1px solid #3a3a3a;
  border-radius: 0.3rem;
  background: #1c1c1c;
  color: #ececec;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
html.light .naruto-place-label {
  border: 1px solid #d6d3d1;
  background: #faf6ea;
  color: #1c1917;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.place-mark,
.mc {
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-sizing: border-box;
  font-family: Inter, system-ui, sans-serif;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 1px 2px rgba(0, 0, 0, 0.35);
}
.place-mark {
  width: 18px;
  height: 18px;
  background: var(--c, var(--mixed));
  border: 2px solid var(--c, var(--mixed));
}
.place-mark.multi {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}
.place-mark.mixed {
  background: #fff;
  background-image: linear-gradient(var(--c, var(--mixed)) 50%, #fff 50%);
  color: #121212;
}
.mc {
  background: #121212;
}
.mc-n {
  display: grid;
  place-items: center;
  width: 58%;
  height: 58%;
  border-radius: 50%;
  background: #fff;
  color: #121212;
  line-height: 1;
}
.mc-sm { width: 32px; height: 32px; font-size: 0.72rem; }
.mc-md { width: 40px; height: 40px; font-size: 0.78rem; }
.mc-lg { width: 48px; height: 48px; font-size: 0.85rem; }
.mc-dots {
  position: relative;
  display: block;
  pointer-events: none;
}
.mc-dot {
  position: absolute;
  border-radius: 50%;
  border: 2px solid;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px #fff, 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  cursor: pointer;
}
.mc-dot::after {
  content: "";
  position: absolute;
  inset: -5px;
}
.leaflet-cluster-spider-leg {
  stroke: transparent;
  stroke-opacity: 0;
}

.cluster-popup .leaflet-popup-content {
  margin: 0.7rem 0.8rem 0.75rem;
}
.cluster-pop header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}
.cluster-pop header strong { font-size: 0.9rem; }
.cluster-pop header span { font-size: 0.75rem; color: var(--muted); }
.cluster-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 16rem;
  overflow: auto;
}
.cluster-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
}
.cluster-row:hover { background: var(--bg); }
.cluster-row.selected {
  box-shadow: inset 0 0 0 2px #f59e0b;
  background: #fffbeb;
}
.cluster-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
}
.cluster-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.25;
}
.cluster-copy b { font-size: 0.8rem; font-weight: 650; }
.cluster-copy i {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.error { color: #b91c1c; padding: 2rem; }

.admin { max-width: 52rem; margin: 1.5rem auto; padding: 0 1rem 4rem; }
.admin form, .admin fieldset {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin: 1rem 0; display: grid; gap: 0.5rem;
}
.admin label { display: grid; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
.admin input, .admin textarea, .admin select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--ink);
}
.tag-picks { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-picks label { display: flex; align-items: center; gap: 0.25rem; color: var(--ink); }
.grant-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 0.75rem; }
.grant-table th, .grant-table td { text-align: left; padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--line); }
.grant-table button { font-size: 0.75rem; }
.grant-table select { font-size: 0.8rem; max-width: 8rem; }
.source-upload {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1.25rem;
  display: grid;
  gap: 0.5rem;
  max-width: 36rem;
}
.source-upload h3 { font-size: 0.95rem; }
.source-upload label { display: grid; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
.source-upload input, .source-upload textarea {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--ink);
}
.source-upload-actions { display: flex; gap: 0.5rem; align-items: center; }
.ai-pass-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.ai-pass-table th, .ai-pass-table td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }

.insp-backdrop { display: none; }

@media (max-width: 900px) {
  #context-inset,
  #split-context,
  #split-left,
  #split-right { display: none !important; }
  #context-pane {
    flex-basis: 12.5rem;
    width: 12.5rem;
  }
  #context-tools { flex: 1 1 auto; }
  .workspace { position: relative; }
  .insp-backdrop:not(.hidden) {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 7;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgb(0 0 0 / 0.45);
    cursor: pointer;
  }
  #inspector-close:not(.hidden) { display: grid; }
  body.canvas-view:not(.insp-open) #inspector,
  body.list-view:not(.insp-open) #inspector { display: none; }
  body.canvas-view.insp-open #inspector,
  body.list-view.insp-open #inspector {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(22rem, 78vw);
    flex: none;
    box-shadow: -12px 0 24px rgba(0, 0, 0, 0.28);
    z-index: 8;
  }
}

html.dark .leaflet-container {
  background: var(--bg);
}
html.dark .canvas-fit,
html.dark .tree-zoom,
html.dark .canvas-filter-overlay .filter-drop {
  border-color: rgb(200 200 200 / 0.28);
  box-shadow: 0 1px 5px rgb(0 0 0 / 0.45);
}
html.dark .canvas-filter-overlay .canvas-filter-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
html.dark .leaflet-bar a {
  background: var(--card);
  color: var(--ink);
  border-bottom-color: var(--line);
}
html.dark .leaflet-bar a:hover {
  background: var(--bg);
}
html.dark .leaflet-bar a.leaflet-disabled {
  background: var(--card);
  color: var(--muted);
}
html.dark .leaflet-control-attribution {
  background: rgb(10 10 10 / 0.72);
  color: var(--muted);
}
html.dark .leaflet-control-attribution a {
  color: var(--accent);
}
html.dark .leaflet-popup-content-wrapper,
html.dark .leaflet-popup-tip {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.45);
}
html.dark .leaflet-container a.leaflet-popup-close-button {
  color: var(--muted);
}
html.dark .leaflet-tooltip {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
html.dark .leaflet-tooltip-top:before { border-top-color: var(--card); }
html.dark .leaflet-tooltip-bottom:before { border-bottom-color: var(--card); }
html.dark .leaflet-tooltip-left:before { border-left-color: var(--card); }
html.dark .leaflet-tooltip-right:before { border-right-color: var(--card); }
html.dark .leaflet-tooltip.mini-map-lab {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #ececec;
  text-shadow: 0 0 4px #000, 0 1px 3px #000, 0 0 8px #000;
}
html.dark .naruto-nation-lab {
  color: #ececec;
  opacity: 0.88;
  mix-blend-mode: normal;
  text-shadow: 0 0 4px #000, 0 0 8px #000, 0 1px 2px #000;
}
html.dark .naruto-place-label {
  background: #1c1c1c;
  color: #ececec;
  border-color: #3a3a3a;
}
html.dark .cluster-row.selected {
  background: #422006;
}
html.dark .assumed-flag {
  color: #fdba74;
  background: #431407;
  border-color: #9a3412;
}
html.dark .year-range-thumb::after {
  border-color: var(--card);
}

