.history-intro { padding-block: clamp(26px, 4vw, 54px); }
.history-intro .hero img { aspect-ratio: 2.55; }

#history {
  border-top: 1px solid var(--line);
  padding-block: 40px 54px;
}
#history-periods {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  padding: 18px 22px 16px;
  box-shadow: var(--shadow-sm);
}
.timeline-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 14px;
}
.timeline-bar-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.timeline-era-pill {
  font-size: .74rem;
  font-weight: 600;
  color: var(--rust);
  background: var(--rust-soft);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}
.timeline-current-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.015em;
}
.timeline-current-range {
  font-size: .82rem;
  color: var(--muted);
}
.timeline-step-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.timeline-step-controls button {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: .8rem;
  font-weight: 500;
}
.timeline-step-controls button:hover:not(:disabled) {
  background: var(--green-soft);
  border-color: rgb(43 76 67 / 0.35);
  color: var(--green);
}
.timeline-counter {
  min-width: 3.6em;
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* Continuous interactive progress bar */
.timeline-scrub {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  margin: 0 calc(100% / 42) 6px;
}
.timeline-rail {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
  pointer-events: none;
}
.timeline-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, color-mix(in srgb, var(--green) 78%, var(--gold)) 0%, var(--green) 100%);
  transition: transform 180ms cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}
.timeline-scrub.is-scrubbing .timeline-fill {
  transition: none;
}
@media (prefers-reduced-motion: reduce) {
  .timeline-fill { transition: none; }
}
#history-progress-slider {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 0;
  cursor: pointer;
}
#history-progress-slider::-webkit-slider-runnable-track {
  background: transparent;
  border: 0;
}
#history-progress-slider::-moz-range-track {
  background: transparent;
}
#history-progress-slider::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -8px;
  background: #fcfbf8;
  border: 2.5px solid var(--green);
  box-shadow: 0 2px 8px rgb(43 76 67 / 0.32);
}
#history-progress-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #fcfbf8;
  border: 2.5px solid var(--green);
  box-shadow: 0 2px 8px rgb(43 76 67 / 0.32);
}

/* Single unified milestone strip underneath the progress rail */
.timeline-nodes-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 4px;
}
.timeline-nodes-track {
  display: grid;
  grid-template-columns: repeat(21, minmax(52px, 1fr));
  gap: 2px;
  align-items: start;
}
.timeline-stop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 5px 2px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: .73rem;
  line-height: 1.25;
  text-align: center;
}
.timeline-stop:hover:not(:disabled) {
  background: var(--surface-subtle);
  color: var(--ink);
  border-color: transparent;
}
.timeline-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: transform 160ms ease-out, background-color 160ms ease-out, box-shadow 160ms ease-out;
}
.timeline-stop.is-passed .timeline-dot {
  background: color-mix(in srgb, var(--green) 68%, var(--paper));
}
.timeline-stop.is-passed {
  color: var(--ink);
}
.timeline-stop[aria-pressed="true"] {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
  border-color: transparent;
}
.timeline-stop[aria-pressed="true"] .timeline-dot {
  background: var(--green);
  transform: scale(1.35);
  box-shadow: 0 0 0 3px rgb(43 76 67 / 0.2);
}
.timeline-stop-label {
  display: block;
  white-space: nowrap;
}

#history-results button {
  min-height: 36px;
  background: var(--surface-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--ink);
}
#history-results button:hover:not(:disabled) {
  background: rgb(42 36 28 / 0.07);
  border-color: transparent;
}

#history-results {
  margin-top: 12px;
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
#history-results p { margin: 0 0 8px; font-size: .84rem; color: var(--muted); }
#history-results button { margin: 0 6px 6px 0; }

#history-stage {
  display: grid;
  grid-template-columns: minmax(290px, 1.32fr) minmax(0, 3.1fr);
  gap: clamp(18px, 2.8vw, 34px);
  margin-top: 26px;
  align-items: start;
}
.stage-period {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stage-visual {
  margin: 0 0 14px;
}
.stage-visual-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-subtle);
  cursor: zoom-in;
}
.stage-visual-btn:hover {
  border-color: rgb(43 76 67 / 0.4);
  box-shadow: var(--shadow-sm);
}
.stage-visual-btn img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center 45%;
  transition: transform 280ms cubic-bezier(.2, .8, .2, 1);
}
.stage-visual-btn:hover img {
  transform: scale(1.025);
}
@media (prefers-reduced-motion: reduce) {
  .stage-visual-btn img { transition: none; }
  .stage-visual-btn:hover img { transform: none; }
}
.stage-visual-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgb(32 30 27 / 0.68);
  color: #fcfbf8;
  font-size: .7rem;
  font-weight: 500;
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 160ms ease-out;
}
.stage-visual-btn:hover .stage-visual-zoom,
.stage-visual-btn:focus-visible .stage-visual-zoom {
  opacity: 1;
}
#stage-visual-caption {
  margin-top: 7px;
  font-size: .76rem;
  line-height: 1.45;
  color: var(--muted);
}
#stage-range { color: var(--rust); margin: 0 0 5px; font-size: .78rem; font-weight: 600; }
#stage-summary { color: var(--muted); font-size: .85rem; line-height: 1.62; margin: 8px 0 0; }
#history-nodes { display: grid; gap: 6px; margin-top: 14px; }
#history-nodes button {
  text-align: left;
  background: var(--surface-subtle);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.4;
}
#history-nodes button:hover { background: rgb(0 0 0 / 0.06); border-color: transparent; }
#history-nodes button[aria-pressed="true"] {
  background: var(--wash);
  color: var(--green);
  border-color: rgb(43 76 67 / 0.35);
  font-weight: 600;
}
.node-btn-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.node-kind-badge {
  flex: none;
  font-size: .68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
}
.node-kind-badge.is-map { background: var(--rust-soft); color: var(--rust); }
#history-nodes small { display: block; color: var(--muted); margin-top: 3px; font-size: .75rem; font-weight: 400; }

.stage-graph { min-width: 0; }
#branch-title { font-size: 1.3rem; margin-bottom: 14px; color: var(--ink); }
#branches { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.branch-column h4 { margin: 0 0 10px; font-size: .8rem; font-weight: 600; color: var(--muted); }

.branch-card {
  position: relative;
  background: var(--white);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease-out, box-shadow 180ms ease-out, transform 160ms ease-out;
}
.branch-card:hover {
  border-color: rgb(43 76 67 / 0.35);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
@media (prefers-reduced-motion: reduce) {
  .branch-card:hover { transform: none; }
}
.branch-card.compare { border-style: dashed; border-color: var(--line-strong); }
.branch-card.technique { border-left: 3px solid var(--rust); }
.branch-card::before { content: ""; width: 14px; position: absolute; top: 24px; border-top: 1px solid var(--line-strong); }
.branch-in .branch-card::before { right: -15px; }
.branch-out .branch-card::before { left: -15px; }
.branch-card button { background: none; border: 0; padding: 2px 0; text-align: left; color: var(--green); font-weight: 600; }
.branch-card button:hover { text-decoration: underline; }
.branch-card p { margin: 3px 0; }
.edge-type { font-size: .72rem; color: var(--rust); font-weight: 600; }
.branch-period { font-size: .75rem; color: var(--muted); }
.branch-description { font-size: .83rem; line-height: 1.55; color: var(--ink); }

/* Apple Pro Dark Graphite Focal Card */
.branch-main {
  background: linear-gradient(160deg, #2c2c2e 0%, #1d1d1f 100%);
  color: #f5f5f7;
  padding: 22px;
  margin-top: 29px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(255 255 255 / 0.08);
  box-shadow: var(--shadow-lg);
}
.branch-main h4 {
  margin: 0;
  font: 700 clamp(1.3rem, 2vw, 1.85rem)/1.22 var(--font-serif);
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
  color: #ffffff;
}
.branch-main h4:focus-visible { outline-color: #ffffff; }
.branch-topic, .node-source { color: #a1a1a6; font-size: .78rem; margin: 0 0 8px; }
.node-source { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid rgb(255 255 255 / 0.14); }
.branch-summary { font-size: .9rem; line-height: 1.68; color: #e5e5ea; }
.branch-main button, .branch-main .city-map-link {
  margin-top: 12px;
  background: var(--green);
  color: #ffffff;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-weight: 500;
}
.branch-main button:hover, .branch-main .city-map-link:hover { background: var(--green-deep); }

@media (max-width: 950px) {
  #history-stage { grid-template-columns: 1fr; }
  #history-nodes { display: flex; flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .history-intro .hero img { aspect-ratio: 1.8; }
  #history-periods { padding: 4px 14px; }
  .era-group { grid-template-columns: 1fr; gap: 7px; }
  .period-row button { min-height: 44px; }
  #branches { grid-template-columns: 1fr; gap: 12px; }
  .branch-main { grid-row: 1; margin-top: 0; }
  .branch-out { grid-row: 2; }
  .branch-card::before { content: none; }
}
