:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --paper: #fffdf7;
  --ink: #1f2528;
  --muted: #657073;
  --line: #d9d0c1;
  --teal: #00756f;
  --teal-deep: #00564f;
  --clay: #b65439;
  --gold: #b98717;
  --violet: #6c5aa8;
  --blue: #2e6f9e;
  --shadow: rgba(31, 37, 40, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(0, 117, 111, 0.10), transparent 22rem),
    linear-gradient(110deg, rgba(182, 84, 57, 0.10), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button {
  font: inherit;
}

.site-header,
main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  min-height: 52vh;
  padding: clamp(2rem, 7vw, 5rem) 0 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: start;
}

.site-header.compact {
  min-height: 0;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--teal-deep);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 12ch;
  margin-bottom: 1rem;
  font-size: clamp(3rem, 10vw, 8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0.55rem;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.lede {
  max-width: 46rem;
  color: #3e484b;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.source-link {
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.68rem 0.9rem;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.78);
  text-decoration: none;
  font-weight: 750;
}

.source-link:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

.summary-band,
.timeline-panel,
.lineage {
  margin-bottom: 1.25rem;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.55);
}

.summary-band article {
  min-height: 10rem;
  padding: 1.25rem;
}

.summary-band article + article {
  border-left: 1px solid var(--line);
}

.summary-band span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-band strong {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.summary-band p,
.lineage p,
.detail-card p {
  color: var(--muted);
}

.timeline-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: 0 22px 70px var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.filter {
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  font-weight: 760;
}

.filter:hover,
.filter.active {
  border-color: var(--teal);
  color: #ffffff;
  background: var(--teal);
}

.visual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.32fr);
  min-height: 39rem;
}

.chart-wrap {
  min-width: 0;
  overflow-x: auto;
  border-right: 1px solid var(--line);
}

#timeline {
  display: block;
  width: 100%;
  min-width: 920px;
  height: 680px;
}

.detail-card {
  padding: 1.25rem;
  background: #ffffff;
}

.detail-card h3 {
  margin-bottom: 0.25rem;
  font-size: 1.45rem;
  line-height: 1.12;
}

#detail-meta {
  margin-bottom: 1rem;
  font-weight: 750;
}

.detail-visual {
  margin: 1.25rem 0 0;
}

#detail-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.detail-image-bg {
  fill: #fffdf7;
  stroke: none;
}

.detail-visual figcaption {
  margin-top: 0.6rem;
  color: #8a9294;
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: center;
}

.lineage {
  padding: 2rem 0 4rem;
}

.lineage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 1.25rem;
  border: 1px solid var(--line);
  background: var(--line);
}

.lineage-grid article {
  min-height: 13rem;
  padding: 1rem;
  background: var(--paper);
}

.sources-panel {
  margin-bottom: 4rem;
}

.source-list {
  margin: 0;
  padding: 1.25rem 1.25rem 1.25rem 2.5rem;
}

.source-list li + li {
  margin-top: 0.8rem;
}

.node {
  cursor: pointer;
}

.node rect {
  fill: #ffffff;
  stroke-width: 2;
  filter: drop-shadow(0 7px 12px rgba(31, 37, 40, 0.10));
}

.node text {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 760;
  pointer-events: none;
}

.node .year {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.node.dim {
  opacity: 0.18;
}

.node.selected rect {
  stroke-width: 4;
}

.edge {
  fill: none;
  stroke: #9d9283;
  stroke-width: 2;
  marker-end: url(#arrow);
}

.edge.dim {
  opacity: 0.12;
}

.axis {
  stroke: #c9bfaf;
  stroke-width: 1.5;
}

.axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

button:focus-visible,
a:focus-visible,
.node:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

@media (max-width: 860px) {
  .site-header,
  .panel-head,
  .visual-grid,
  .summary-band,
  .lineage-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    min-height: auto;
  }

  .source-link {
    width: fit-content;
  }

  .summary-band article + article,
  .chart-wrap {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .panel-head {
    display: grid;
    align-items: start;
  }

  .controls {
    justify-content: start;
  }

  .visual-grid {
    min-height: 0;
  }

  .chart-wrap {
    border-right: 0;
  }

  #timeline {
    height: 620px;
  }
}
