:root {
  --paper: #f1e8dd;
  --paper-deep: #e6d8c6;
  --paper-light: #f8f3ec;
  --ink: #413e3c;
  --ink-soft: #746c64;
  --rule: #cdbda9;
  --rule-soft: rgba(91, 76, 62, 0.16);
  --lacquer: #c94531;
  --lacquer-dark: #8e2f23;
  --map: #183f41;
  --map-soft: #b9c9c4;
  --brass: #967943;
  --white: #fffdf9;
  --masthead-h: 72px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
  overflow: hidden;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--lacquer);
  outline-offset: 3px;
}

.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;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.65rem 0.9rem;
  color: var(--white);
  background: var(--map);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: none;
}

.masthead {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(245px, 1fr) auto minmax(245px, 1fr);
  align-items: stretch;
  min-height: var(--masthead-h);
  color: var(--ink);
  background: rgba(241, 232, 221, 0.97);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 3px 18px rgba(62, 45, 30, 0.06);
  backdrop-filter: blur(14px);
}

.bookplate,
.data-seal,
.lens-tab {
  border: 0;
  background: transparent;
}

.bookplate {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
  padding: 0.7rem 1.2rem;
  text-align: left;
}

.bookplate-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 46px;
  place-items: center;
  color: var(--paper-light);
  background: var(--lacquer);
  border-radius: 19px 19px 4px 4px;
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.bookplate strong,
.bookplate small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookplate strong {
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.bookplate small,
.data-seal small {
  margin-top: 0.18rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lens-nav {
  display: flex;
  align-items: stretch;
  height: var(--masthead-h);
}

.lens-tab {
  position: relative;
  min-width: 91px;
  padding: 0.65rem 0.85rem 0.55rem;
  color: var(--ink-soft);
}

.lens-tab::after {
  position: absolute;
  right: 0.8rem;
  bottom: -1px;
  left: 0.8rem;
  height: 3px;
  background: var(--lacquer);
  content: "";
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 180ms ease;
}

.lens-tab:hover,
.lens-tab.is-active {
  color: var(--ink);
}

.lens-tab.is-active::after {
  transform: scaleX(1);
}

.lens-tab span,
.lens-tab small {
  display: block;
}

.lens-tab span {
  font-size: 0.93rem;
}

.lens-tab small {
  margin-top: 0.2rem;
  font-family: var(--sans);
  font-size: 0.58rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.data-seal {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 0.65rem;
  min-width: 235px;
  padding: 0.7rem 1.2rem;
  text-align: left;
}

.seal-dot {
  width: 9px;
  height: 9px;
  background: var(--brass);
  border: 2px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--brass);
}

.data-seal strong,
.data-seal small {
  display: block;
}

.data-seal strong {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 650;
}

#workspace,
.lens-view {
  height: 100%;
}

.lens-view {
  padding-top: var(--masthead-h);
}

.lens-view[hidden] {
  display: none !important;
}

.read-view {
  background: var(--paper-deep);
}

.reader-shell {
  position: relative;
  height: 100%;
}

#book-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--paper);
}

.reader-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  color: var(--ink-soft);
  background: var(--paper);
  text-align: center;
  transition: opacity 220ms ease;
}

.reader-loading.is-done {
  pointer-events: none;
  opacity: 0;
}

.loading-rule {
  display: block;
  width: 4.5rem;
  height: 1px;
  margin: 0 auto 0.9rem;
  overflow: hidden;
  background: var(--rule);
}

.loading-rule::after {
  display: block;
  width: 55%;
  height: 100%;
  background: var(--lacquer);
  content: "";
  animation: loading 1.1s ease-in-out infinite alternate;
}

@keyframes loading {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(180%);
  }
}

.evidence-ribbon {
  position: fixed;
  z-index: 46;
  top: calc(var(--masthead-h) + 0.85rem);
  left: 50%;
  display: grid;
  grid-template-columns: auto 44px minmax(0, 560px) auto;
  align-items: center;
  max-width: calc(100vw - 2rem);
  min-height: 66px;
  color: var(--paper-light);
  background: rgba(24, 63, 65, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 35px rgba(26, 34, 33, 0.25);
  transform: translateX(-50%);
}

.return-button,
.ribbon-close {
  height: 100%;
  color: inherit;
  background: transparent;
  border: 0;
}

.return-button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  font-family: var(--sans);
  font-size: 0.71rem;
  letter-spacing: 0.04em;
}

.ribbon-thread {
  position: relative;
  width: 44px;
  height: 100%;
}

.ribbon-thread::before {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--lacquer);
  content: "";
}

.ribbon-thread::after {
  position: absolute;
  top: calc(50% - 4px);
  right: 0;
  width: 7px;
  height: 7px;
  background: var(--lacquer);
  border-radius: 50%;
  content: "";
}

.ribbon-copy {
  min-width: 0;
  padding: 0.65rem 0.8rem;
}

.ribbon-copy small {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--map-soft);
  font-family: var(--sans);
  font-size: 0.61rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ribbon-copy q {
  display: block;
  overflow: hidden;
  font-size: 0.84rem;
  font-style: italic;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ribbon-close {
  width: 44px;
  font-size: 1.4rem;
}

.explorer-view {
  display: grid;
  grid-template-columns: minmax(225px, 17vw) minmax(450px, 1fr) minmax(290px, 23vw);
  min-height: 0;
  background: var(--paper);
}

.index-panel,
.evidence-panel,
.time-intro {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--paper-light);
}

.index-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
}

.index-heading {
  padding: 1.65rem 1.35rem 1rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--lacquer-dark);
  font-family: var(--sans);
  font-size: 0.63rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.index-heading h1,
.time-intro h1,
.about-sheet h1 {
  margin: 0;
  font-size: clamp(2.1rem, 3vw, 3.6rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.94;
}

.index-heading > p:last-child,
.time-intro > p,
.about-sheet > p {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
}

.search-field {
  position: relative;
  display: block;
  margin: 0 1rem 0.8rem;
}

.search-field input,
.timeline-search input {
  width: 100%;
  padding: 0.7rem 2.1rem 0.7rem 0.75rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  font-family: var(--sans);
  font-size: 0.76rem;
}

.search-field > span:last-child {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  color: var(--ink-soft);
  font-size: 1rem;
}

.entity-list {
  flex: 1;
  overflow: auto;
  padding-bottom: 1.5rem;
}

.entity-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.6rem;
  width: 100%;
  padding: 0.72rem 1.35rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
}

.entity-button:hover {
  background: rgba(150, 121, 67, 0.08);
}

.entity-button.is-active {
  background: rgba(201, 69, 49, 0.08);
  border-left-color: var(--lacquer);
}

.entity-button strong {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-button small,
.entity-button .entity-count {
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.63rem;
}

.entity-button small {
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(90, 69, 48, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 69, 48, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

.canvas-heading,
.map-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.45rem 1.6rem 1rem;
}

.canvas-heading h2,
.map-bar h2,
.evidence-panel h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  font-weight: 500;
  line-height: 1.15;
}

.canvas-note {
  max-width: 230px;
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-style: italic;
  line-height: 1.4;
  text-align: right;
}

.people-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}

.people-mode-switch {
  display: flex;
  border: 1px solid var(--rule);
}

.people-mode-switch button {
  min-width: 76px;
  padding: 0.45rem 0.7rem;
  color: var(--ink-soft);
  background: rgba(248, 243, 236, 0.72);
  border: 0;
  border-right: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.people-mode-switch button:last-child {
  border-right: 0;
}

.people-mode-switch button.is-active {
  color: var(--paper-light);
  background: var(--map);
}

.graph-stage {
  position: absolute;
  inset: 116px 0 48px;
  overflow: hidden;
}

.graph-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.genealogy-stage {
  position: absolute;
  inset: 116px 0 48px;
  overflow: visible;
}

.genealogy-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.genealogy-viewport svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.genealogy-viewport svg.is-panning {
  cursor: grabbing;
}

.genealogy-viewport svg:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: -3px;
}

.genealogy-controls {
  position: absolute;
  z-index: 4;
  top: 0.75rem;
  right: 0.85rem;
  display: grid;
  grid-template-columns: 32px 48px 32px auto;
  height: 32px;
  overflow: hidden;
  background: color-mix(in srgb, var(--paper-light) 94%, transparent);
  border: 1px solid rgba(24, 63, 65, 0.28);
  box-shadow: 0 5px 16px rgba(52, 39, 28, 0.12);
  font-family: var(--sans);
}

.genealogy-controls button,
.genealogy-controls output {
  display: grid;
  min-width: 0;
  height: 100%;
  place-items: center;
  padding: 0;
  color: var(--map);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule);
  font: inherit;
}

.genealogy-controls button {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
}

.genealogy-controls button:hover {
  color: var(--paper-light);
  background: var(--map);
}

.genealogy-controls output {
  color: var(--ink-soft);
  font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
}

.genealogy-controls .genealogy-fit {
  padding: 0 0.7rem;
  border-right: 0;
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.03em;
}

.genealogy-pan-hint {
  position: absolute;
  z-index: 3;
  right: 0.9rem;
  bottom: 0.6rem;
  margin: 0;
  padding: 0.3rem 0.45rem;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  font-family: var(--sans);
  font-size: 0.58rem;
  letter-spacing: 0.03em;
}

.generation-label {
  fill: var(--ink-soft);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

.generation-rule {
  fill: none;
  stroke: var(--rule-soft);
  stroke-width: 1;
  stroke-dasharray: 1 7;
  vector-effect: non-scaling-stroke;
}

.genealogy-line,
.genealogy-partner-line {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.genealogy-line {
  stroke: var(--lacquer);
  stroke-width: 1.8;
}

.genealogy-partner-line {
  stroke: var(--brass);
  stroke-width: 2.2;
}

.genealogy-line.is-inferred,
.genealogy-partner-line.is-inferred {
  stroke-dasharray: 4 4;
  opacity: 0.58;
}

.genealogy-node {
  cursor: pointer;
}

.genealogy-node rect {
  fill: var(--paper-light);
  stroke: var(--map);
  stroke-width: 1.3;
  filter: drop-shadow(0 4px 6px rgba(52, 39, 28, 0.1));
}

.genealogy-node text {
  fill: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
}

.genealogy-node.is-focus rect {
  fill: var(--lacquer);
  stroke: var(--lacquer-dark);
}

.genealogy-node.is-focus text {
  fill: var(--white);
}

.graph-edge {
  stroke: rgba(24, 63, 65, 0.45);
  stroke-width: 1.8;
}

.graph-edge.is-explicit {
  stroke: var(--map);
}

.graph-edge.is-reciprocal {
  stroke-width: 1.65;
}

#graph-arrow path {
  fill: var(--map);
}

.graph-edge-label {
  fill: var(--ink-soft);
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.015em;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 5px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.graph-node {
  cursor: pointer;
}

.graph-node circle {
  fill: var(--paper-light);
  stroke: var(--map);
  stroke-width: 1.6;
  filter: drop-shadow(0 4px 7px rgba(52, 39, 28, 0.12));
}

.graph-node.is-focus circle {
  fill: var(--lacquer);
  stroke: var(--lacquer-dark);
}

.graph-node text {
  fill: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.graph-node.is-focus text {
  fill: var(--white);
  stroke: var(--lacquer);
}

.graph-empty {
  display: grid;
  height: 100%;
  place-content: center;
  padding: 2rem;
  color: var(--ink-soft);
  font-style: italic;
  text-align: center;
}

.graph-key {
  position: absolute;
  right: 1.4rem;
  bottom: 1rem;
  left: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.61rem;
}

.genealogy-key {
  justify-content: flex-end;
}

.lineage-line,
.inferred-line,
.partner-line {
  width: 18px;
  height: 2px;
}

.lineage-line {
  background: var(--lacquer);
}

.inferred-line {
  height: 0;
  border-top: 2px dashed var(--lacquer);
  opacity: 0.6;
}

.partner-line {
  background: var(--brass);
}

.graph-key span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.key-node {
  width: 9px;
  height: 9px;
  background: var(--paper-light);
  border: 1px solid var(--map);
  border-radius: 50%;
}

.key-focus {
  background: var(--lacquer);
  border-color: var(--lacquer);
}

.key-line {
  width: 16px;
  height: 1px;
  background: var(--map);
}

.key-arrow {
  min-width: 18px;
  color: var(--map);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.evidence-panel {
  border-left: 1px solid var(--rule);
  padding-bottom: 2rem;
}

.evidence-head {
  position: relative;
  padding: 1.55rem 1.45rem 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.candidate-mark {
  display: inline-block;
  margin-top: 0.65rem;
  color: var(--brass);
  font-family: var(--sans);
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.evidence-summary {
  margin: 0.75rem 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.5;
}

.alias-list {
  margin-top: 0.7rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.45;
}

.resolution-note {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.7rem;
  margin-top: 0.8rem;
  padding: 0.65rem 0.7rem;
  background: rgba(150, 121, 67, 0.09);
  border-left: 2px solid var(--brass);
}

.resolution-note strong,
.resolution-note span,
.resolution-note small {
  display: block;
}

.resolution-note strong {
  font-family: var(--sans);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.resolution-note span {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.resolution-note small {
  color: var(--brass);
  font-family: var(--sans);
  font-size: 0.54rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.evidence-section {
  padding: 1.2rem 1.45rem 0;
}

.section-label {
  margin: 0 0 0.65rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.claim-card {
  margin-bottom: 0.75rem;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--rule-soft);
}

.claim-card:first-of-type {
  border-top-color: var(--rule);
}

.claim-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem;
}

.claim-line strong {
  font-size: 0.81rem;
  line-height: 1.35;
}

.relationship-card-meta {
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.56rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.relationship-statement {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(68px, 0.72fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
  margin: 0.7rem 0 0.55rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
}

.relationship-statement > strong {
  min-width: 0;
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}

.relationship-operator {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  color: var(--map);
}

.relationship-operator small {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.53rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
}

.relationship-operator i {
  width: 100%;
  margin-top: -0.05rem;
  font-family: var(--sans);
  font-size: 1.15rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.certainty {
  flex: 0 0 auto;
  color: var(--brass);
  font-family: var(--sans);
  font-size: 0.57rem;
  text-transform: uppercase;
}

.claim-card q {
  display: block;
  margin: 0.5rem 0 0.65rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-style: italic;
  line-height: 1.52;
}

.source-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  color: var(--lacquer-dark);
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  font-family: var(--sans);
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.source-button::after {
  content: "→";
}

.empty-note {
  padding: 1rem 1.45rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.5;
}

.map-canvas {
  display: flex;
  flex-direction: column;
  background: #d5d2c4;
}

.map-bar {
  flex: 0 0 auto;
  background: rgba(241, 232, 221, 0.94);
  border-bottom: 1px solid var(--rule);
}

.map-controls {
  display: flex;
  gap: 0.35rem;
}

.map-controls button {
  min-width: 34px;
  height: 34px;
  padding: 0 0.7rem;
  color: var(--map);
  background: var(--paper-light);
  border: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.68rem;
}

.map-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: #b9b9aa;
}

.map-viewport:active {
  cursor: grabbing;
}

.map-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 5088px;
  height: 7527px;
  transform-origin: 0 0;
  will-change: transform;
}

.map-tile {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
}

.map-overlay {
  position: absolute;
  inset: 0;
  width: 5088px;
  height: 7527px;
  overflow: visible;
  pointer-events: none;
}

.map-region {
  fill: rgba(201, 69, 49, 0.2);
  stroke: var(--lacquer);
  stroke-width: 12px;
  vector-effect: non-scaling-stroke;
}

.map-pulse {
  fill: none;
  stroke: var(--lacquer);
  stroke-width: 10px;
  opacity: 0.85;
  vector-effect: non-scaling-stroke;
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  to {
    r: 130px;
    opacity: 0;
  }
}

.map-caption {
  position: absolute;
  right: 0.8rem;
  bottom: 0.7rem;
  left: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.65rem;
  color: var(--paper-light);
  background: rgba(24, 63, 65, 0.88);
  font-family: var(--sans);
  font-size: 0.59rem;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.journey-row {
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule-soft);
}

.journey-route {
  display: grid;
  grid-template-columns: 1fr 18px 1fr;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.76rem;
}

.journey-route span:nth-child(2) {
  color: var(--lacquer);
  text-align: center;
}

.journey-travelers {
  margin: 0.4rem 0 0.55rem;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.timeline-view {
  display: grid;
  grid-template-columns: minmax(245px, 18vw) minmax(470px, 1fr) minmax(290px, 23vw);
  min-height: 0;
  background: var(--paper);
}

.time-intro {
  padding: 1.7rem 1.4rem 2rem;
  border-right: 1px solid var(--rule);
}

.time-stat {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--rule);
}

.time-stat strong {
  color: var(--lacquer);
  font-size: 1.65rem;
  font-weight: 400;
}

.time-stat span {
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.4;
}

.timeline-controls {
  margin-top: 1rem;
}

.timeline-controls label {
  display: block;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-controls select {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 0.5rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  font-family: var(--serif);
  font-size: 0.82rem;
  text-transform: none;
}

.timeline-canvas {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(90deg, transparent 96px, var(--rule) 96px, var(--rule) 97px, transparent 97px),
    var(--paper);
}

.timeline-canvas .canvas-heading {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(241, 232, 221, 0.95);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(10px);
}

.timeline-search {
  width: min(260px, 40%);
}

.timeline-list {
  margin: 0;
  padding: 0 1.8rem 1rem 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 1.25rem;
  min-height: 100px;
  padding: 1rem 0;
}

.timeline-item::before {
  position: absolute;
  top: 1.35rem;
  left: 92px;
  width: 9px;
  height: 9px;
  background: var(--paper);
  border: 2px solid var(--lacquer);
  border-radius: 50%;
  content: "";
  transform: translateX(-50%);
}

.timeline-date {
  padding-top: 0.05rem;
  color: var(--lacquer-dark);
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: right;
}

.timeline-event {
  padding-left: 0.35rem;
}

.timeline-event button {
  width: 100%;
  padding: 0;
  text-align: left;
  background: transparent;
  border: 0;
}

.timeline-event h3 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.35;
}

.timeline-event p {
  display: -webkit-box;
  margin: 0.35rem 0 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.timeline-item.is-active {
  background: linear-gradient(90deg, transparent 96px, rgba(201, 69, 49, 0.07) 96px);
}

.timeline-item.is-active::before {
  background: var(--lacquer);
}

.event-type {
  display: inline-block;
  margin-top: 0.45rem;
  color: var(--brass);
  font-family: var(--sans);
  font-size: 0.57rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.load-more {
  display: block;
  margin: 0.5rem auto 2rem;
  padding: 0.65rem 1rem;
  color: var(--map);
  background: transparent;
  border: 1px solid var(--map);
  font-family: var(--sans);
  font-size: 0.67rem;
  letter-spacing: 0.06em;
}

.event-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.event-meta div {
  border-top: 1px solid var(--rule);
  padding-top: 0.5rem;
}

.event-meta small,
.event-meta strong {
  display: block;
}

.event-meta small {
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.event-meta strong {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
}

.about-view {
  display: grid;
  overflow: auto;
  place-items: center;
  padding-right: 1.5rem;
  padding-bottom: 2rem;
  padding-left: 1.5rem;
  background:
    radial-gradient(circle at 20% 15%, rgba(201, 69, 49, 0.09), transparent 32%),
    var(--paper-deep);
}

.about-sheet {
  position: relative;
  width: min(780px, 100%);
  margin: auto;
  padding: clamp(2rem, 5vw, 4.5rem);
  background: var(--paper-light);
  border: 1px solid var(--rule);
  box-shadow: 0 20px 60px rgba(73, 53, 36, 0.14);
}

.about-sheet::before {
  position: absolute;
  top: 1rem;
  bottom: 1rem;
  left: 1rem;
  width: 3px;
  background: var(--lacquer);
  content: "";
}

.about-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 50%;
  font-size: 1.35rem;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 1.8rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.about-number {
  padding: 1rem;
  border-right: 1px solid var(--rule);
}

.about-number:nth-child(3n) {
  border-right: 0;
}

.about-number strong,
.about-number span {
  display: block;
}

.about-number strong {
  color: var(--lacquer);
  font-size: 1.7rem;
  font-weight: 400;
}

.about-number span {
  margin-top: 0.2rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.about-warning {
  padding: 0.9rem 1rem;
  color: var(--ink) !important;
  background: rgba(150, 121, 67, 0.1);
  border-left: 3px solid var(--brass);
}

.status-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  padding: 0.65rem 0.9rem;
  color: var(--paper-light);
  background: var(--map);
  box-shadow: 0 7px 22px rgba(24, 63, 65, 0.18);
  font-family: var(--sans);
  font-size: 0.68rem;
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-toast.is-hidden {
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
}

@media (max-width: 1120px) {
  .masthead {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .data-seal {
    display: none;
  }

  .explorer-view,
  .timeline-view {
    grid-template-columns: 220px 1fr;
  }

  .evidence-panel {
    position: fixed;
    z-index: 40;
    top: var(--masthead-h);
    right: 0;
    bottom: 0;
    width: min(340px, 88vw);
    box-shadow: -12px 0 35px rgba(62, 45, 30, 0.16);
  }

  .evidence-panel:empty {
    display: none;
  }
}

@media (max-width: 760px) {
  :root {
    --masthead-h: 116px;
  }

  .masthead {
    grid-template-columns: 1fr;
    grid-template-rows: 58px 58px;
  }

  .bookplate {
    justify-content: center;
    padding: 0.4rem 0.75rem;
  }

  .bookplate-mark {
    width: 30px;
    height: 38px;
    flex-basis: 30px;
  }

  .bookplate small {
    display: none;
  }

  .lens-nav {
    height: 58px;
    justify-content: stretch;
    border-top: 1px solid var(--rule-soft);
  }

  .lens-tab {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.2rem;
  }

  .lens-tab small {
    display: none;
  }

  .explorer-view,
  .timeline-view {
    display: block;
    overflow: auto;
  }

  .index-panel,
  .time-intro {
    min-height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .entity-list {
    display: flex;
    max-height: 180px;
    overflow: auto;
  }

  .entity-button {
    flex: 0 0 180px;
    border-bottom: 3px solid transparent;
    border-left: 0;
  }

  .entity-button.is-active {
    border-bottom-color: var(--lacquer);
  }

  .canvas-panel {
    min-height: 58vh;
  }

  .people-tools {
    align-items: flex-end;
  }

  .canvas-note {
    display: none;
  }

  .graph-stage,
  .genealogy-stage {
    top: 100px;
  }

  .genealogy-controls {
    top: -46px;
    right: 0.5rem;
  }

  .genealogy-pan-hint {
    top: 0.45rem;
    right: auto;
    bottom: auto;
    left: 0.5rem;
  }

  .genealogy-key {
    gap: 0.65rem;
    justify-content: flex-start;
  }

  .evidence-panel {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    min-height: 300px;
    overflow: visible;
    border-top: 1px solid var(--rule);
    border-left: 0;
    box-shadow: none;
  }

  .timeline-canvas {
    min-height: 70vh;
    overflow: visible;
  }

  .timeline-search {
    width: 48%;
  }

  .evidence-ribbon {
    top: calc(var(--masthead-h) + 0.5rem);
    grid-template-columns: auto 20px minmax(0, 1fr) 38px;
    width: calc(100vw - 1rem);
  }

  .return-button {
    padding: 0.6rem;
  }

  .return-button span:last-child {
    display: none;
  }

  .ribbon-copy q {
    max-width: 56vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
