:root {
  --bg: #f7f4ee;
  --bg-strong: #eee8de;
  --surface-solid: #fffdf8;
  --line: rgba(29, 26, 20, 0.12);
  --line-soft: rgba(29, 26, 20, 0.06);
  --text: #171410;
  --muted: #6f685f;
  --china: #b95037;
  --world: #2758b8;
  --shadow: 0 16px 38px rgba(53, 43, 32, 0.05);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --max: 1360px;
  font-family:
    "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Source Han Serif SC",
    "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 24%),
    linear-gradient(180deg, #faf6ee 0%, var(--bg) 48%, var(--bg-strong) 100%);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.ambient {
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(24px);
  opacity: 0.35;
}

.ambient-a {
  top: 64px;
  right: 8%;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(41, 98, 217, 0.12);
}

.ambient-b {
  left: 4%;
  bottom: 12%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(212, 90, 60, 0.12);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 176px), var(--max));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 30px 34px;
  border-radius: 36px;
  background: rgba(255, 252, 247, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 700;
}

.hero h1,
.timeline-header h3,
.event-line h4 {
  margin: 0;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.hero h1 {
  max-width: none;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 0.94;
  white-space: nowrap;
}

.event-line-summary {
  color: var(--muted);
  line-height: 1.7;
}

.timeline-nav {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: none;
}

.timeline-nav::-webkit-scrollbar {
  display: none;
}

.timeline-jump {
  border: 0;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  color: inherit;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line-soft);
  transition:
    background-color 220ms ease,
    border-color 220ms ease,
    color 220ms ease,
    box-shadow 220ms ease;
}

.timeline-jump.active {
  background: rgba(117, 104, 232, 0.12);
  color: #584fc1;
  border-color: rgba(117, 104, 232, 0.24);
  box-shadow: inset 0 0 0 1px rgba(117, 104, 232, 0.06);
}

.timeline-jump-range,
.timeline-jump-title {
  display: block;
}

.timeline-jump-range {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
}

.timeline-jump-title {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
}

.rail-nav {
  position: fixed;
  top: 28px;
  right: 16px;
  bottom: 24px;
  width: 116px;
  z-index: 2;
  padding: 16px 12px;
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.timeline-shell {
  margin-top: 18px;
  padding: 10px 18px 18px;
  border-radius: 36px;
  background: rgba(255, 252, 247, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.timeline-header {
  padding: 12px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.timeline-grid-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.timeline-column-head h3 {
  font-size: 30px;
}

.china-head {
  padding-right: 18px;
}

.china-head h3 {
  color: #8f3b27;
  text-align: right;
}

.world-head {
  padding-left: 18px;
}

.world-head h3 {
  color: #1f4db0;
}

.timeline-board {
  position: relative;
  display: grid;
  gap: 0;
  padding: 24px 24px 6px;
}

.timeline-board::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(99, 108, 255, 0.18), rgba(99, 108, 255, 0.72), rgba(99, 108, 255, 0.18));
  box-shadow: 0 0 0 10px rgba(99, 108, 255, 0.05);
}

.timeline-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  scroll-margin-top: 26px;
  padding: 28px 0 34px;
}

.timeline-column {
  position: relative;
}

.timeline-column-left {
  padding-right: 18px;
}

.timeline-column-right {
  padding-left: 18px;
}

.timeline-card-stack {
  display: grid;
  gap: 14px;
}

.timeline-center {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
}

.stage-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7080ff, #7f5dff);
  border: 4px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(99, 108, 255, 0.32);
  z-index: 1;
}

.period-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  padding: 10px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6d74ff, #7c55ff);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 16px 30px rgba(106, 99, 255, 0.22);
}

.stage-title {
  margin: 0;
  max-width: 10em;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.event-line {
  position: relative;
  padding: 18px 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(53, 43, 32, 0.06);
  box-shadow: 0 14px 26px rgba(53, 43, 32, 0.06);
}

.event-line-link {
  display: block;
  text-decoration: none;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.event-line-link:hover {
  transform: translateY(-2px);
  border-color: rgba(108, 109, 255, 0.16);
  box-shadow: 0 18px 32px rgba(53, 43, 32, 0.08);
}

.timeline-column-left .event-line::after,
.timeline-column-right .event-line::before {
  content: "";
  position: absolute;
  top: 28px;
  width: 18px;
  height: 2px;
  background: rgba(108, 109, 255, 0.5);
}

.timeline-column-left .event-line::after {
  right: -18px;
}

.timeline-column-right .event-line::before {
  left: -18px;
}

.event-line-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.event-date {
  display: inline-flex;
  width: fit-content;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.event-side-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.event-line.china .event-side-label {
  background: rgba(185, 80, 55, 0.08);
  color: var(--china);
}

.event-line.world .event-side-label {
  background: rgba(39, 88, 184, 0.08);
  color: var(--world);
}

.event-meta-inline {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.event-line h4 {
  margin-top: 8px;
  font-size: 20px;
  line-height: 1.28;
}

.event-line-summary {
  margin: 8px 0 0;
  font-size: 14px;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.source-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(247, 244, 255, 0.95);
  border: 1px solid rgba(108, 109, 255, 0.1);
  text-decoration: none;
  font-size: 12px;
  color: var(--muted);
  transition: transform 180ms ease, color 180ms ease, background 180ms ease;
}

.source-link:hover {
  transform: translateY(-1px);
  color: var(--text);
  background: #fff;
}

.empty-state {
  min-height: 120px;
  padding: 24px 18px;
  border-radius: 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.48);
  border: 1px dashed rgba(108, 109, 255, 0.18);
}

.empty-stage {
  margin-top: 8px;
}

.empty-state-compact {
  min-height: 0;
  padding: 18px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
}

@media (max-width: 1100px) {
  .app-shell {
    width: min(calc(100% - 22px), var(--max));
    margin: 0 auto;
    padding-right: 0;
  }

  .rail-nav {
    position: static;
    width: auto;
    margin: 18px auto 0;
    max-width: calc(100% - 22px);
  }

  .timeline-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .hero,
  .rail-nav,
  .timeline-header,
  .timeline-stage,
  .timeline-grid-head {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: none;
  }

  .dataset-tabs {
    width: 100%;
    flex-wrap: wrap;
  }

  .timeline-column-head,
  .china-head,
  .world-head {
    padding-left: 0;
    padding-right: 0;
  }

  .china-head h3,
  .world-head h3 {
    text-align: left;
  }

  .timeline-board::before {
    left: 28px;
  }

  .timeline-stage {
    gap: 12px;
    padding-left: 28px;
  }

  .timeline-center {
    justify-items: start;
    order: -1;
  }

  .stage-title {
    text-align: left;
    max-width: none;
  }

  .timeline-column-left,
  .timeline-column-right {
    padding: 0 0 0 28px;
  }

  .timeline-column-left .event-line::after,
  .timeline-column-right .event-line::before {
    left: -28px;
    right: auto;
    width: 28px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(calc(100% - 22px), var(--max));
    padding-top: 18px;
  }

  .hero,
  .timeline-shell {
    padding: 20px;
    border-radius: 24px;
  }

  .dataset-tabs {
    gap: 8px;
    padding: 5px;
  }

  .dataset-tab {
    flex: 1 1 0;
    text-align: center;
    padding: 10px 14px;
  }

  .timeline-shell {
    padding: 12px;
  }

  .timeline-jump {
    min-width: 0;
  }

  .timeline-nav {
    grid-template-columns: 1fr;
  }

  .timeline-header,
  .timeline-board,
  .timeline-stage {
    gap: 12px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .event-line-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .event-meta-inline {
    justify-content: flex-start;
  }

  .event-line h4 {
    font-size: 19px;
  }

  .timeline-board::before {
    left: 22px;
  }

  .timeline-stage {
    padding-left: 22px;
  }

  .timeline-column-left,
  .timeline-column-right {
    padding-left: 22px;
  }

  .timeline-column-left .event-line::after,
  .timeline-column-right .event-line::before {
    left: -22px;
    width: 22px;
  }
}
.hero-copy {
  display: grid;
  gap: 18px;
}

.dataset-tabs {
  display: inline-flex;
  width: fit-content;
  gap: 10px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(53, 43, 32, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.dataset-tab {
  border: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 200ms ease,
    color 200ms ease,
    box-shadow 200ms ease,
    transform 200ms ease;
}

.dataset-tab:hover {
  color: var(--text);
}

.dataset-tab.active {
  background: linear-gradient(135deg, #6d74ff, #7c55ff);
  color: #fff;
  box-shadow: 0 10px 20px rgba(106, 99, 255, 0.22);
}

@media (max-width: 1100px) {
  .dataset-tabs {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .dataset-tabs {
    gap: 8px;
    padding: 5px;
  }

  .dataset-tab {
    flex: 1 1 0;
    text-align: center;
    padding: 10px 14px;
  }
}
