:root {
  --ink: #1d2a23;
  --ink-soft: #3b4a3f;
  --paper: #d7c18a;
  --paper-light: #e6d8aa;
  --paper-deep: #a88a54;
  --field: #1f2b25;
  --field-light: #2b3a31;
  --red: #a23b32;
  --red-bright: #c95742;
  --gold: #cbb273;
  --line: rgba(218, 192, 128, .28);
  --serif: "Noto Serif SC", "Songti SC", serif;
  --brush: "Ma Shan Zheng", "STKaiti", serif;
}
* { box-sizing: border-box; }
html { background: var(--field); }
body { margin: 0; color: var(--paper-light); background: radial-gradient(circle at 18% 12%, #344438 0, transparent 32%), radial-gradient(circle at 82% 80%, #17221d 0, transparent 42%), var(--field); font-family: var(--serif); min-height: 100vh; letter-spacing: .02em; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .16; background-image: repeating-linear-gradient(0deg, rgba(231,213,167,.2) 0 1px, transparent 1px 4px), repeating-linear-gradient(90deg, rgba(20,29,24,.22) 0 1px, transparent 1px 8px); mix-blend-mode: overlay; }
.grain { position: fixed; inset: 0; pointer-events: none; z-index: 10; opacity: .08; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.76' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E"); }
.site-header { max-width: 1500px; margin: 0 auto; padding: 38px 5vw 24px; display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--line); }
.seal { width: 54px; height: 54px; border: 2px solid var(--red-bright); color: var(--red-bright); display: grid; place-items: center; font: 700 27px var(--brush); transform: rotate(-5deg); position: relative; }
.seal::after { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(201,87,66,.58); }
.masthead { flex: 1; }
.eyebrow, .section-kicker { margin: 0 0 4px; color: var(--gold); font-size: 10px; letter-spacing: .24em; font-weight: 600; }
h1 { margin: 0; font: 400 clamp(44px, 6vw, 74px)/.92 var(--brush); color: var(--paper-light); letter-spacing: .06em; text-shadow: 3px 5px 0 rgba(0,0,0,.15); }
.subtitle { margin: 10px 0 0; color: rgba(225,212,173,.7); font-size: 13px; letter-spacing: .28em; }
.header-note { display: flex; align-items: center; gap: 12px; color: var(--gold); font-size: 12px; line-height: 1.75; letter-spacing: .2em; text-align: right; }
.header-note em { color: var(--red-bright); font-style: normal; }
.header-note-line { width: 32px; height: 1px; background: var(--red-bright); }
.page-shell { max-width: 1500px; margin: 0 auto; padding: 0 5vw 40px; }
.intro-strip { display: grid; grid-template-columns: 1.25fr 1fr 70px; gap: 40px; align-items: center; padding: 44px 0 34px; }
.intro-strip h2 { margin: 10px 0 0; font: 400 clamp(28px, 4vw, 48px)/1.2 var(--brush); color: var(--paper-light); }
.intro-strip p { margin: 0; max-width: 460px; color: rgba(231,216,174,.68); font-size: 13px; line-height: 2; }
.intro-stamp { justify-self: end; color: var(--red-bright); font: 400 18px/1.04 var(--brush); text-align: center; border: 1px solid rgba(201,87,66,.6); padding: 10px 8px; transform: rotate(4deg); }
.intro-stamp small { font-size: 12px; }
.workspace { display: grid; grid-template-columns: minmax(240px, 280px) minmax(460px, 1fr) minmax(250px, 310px); gap: 18px; align-items: stretch; }
.panel { border: 1px solid var(--line); background: rgba(18, 29, 23, .48); min-height: 660px; position: relative; overflow: hidden; }
.panel::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(218,192,128,.09); pointer-events: none; }
.panel-heading, .map-topline { display: flex; justify-content: space-between; align-items: center; padding: 24px 24px 20px; border-bottom: 1px solid var(--line); position: relative; z-index: 1; }
.panel-heading > div, .map-topline > div:first-child { display: flex; align-items: center; gap: 10px; }
.panel-index { color: var(--red-bright); font: 400 25px var(--brush); line-height: 1; }
h3 { margin: 0; font-size: 18px; font-weight: 500; letter-spacing: .16em; }
.event-count { color: var(--gold); font-size: 11px; letter-spacing: .1em; }
.filters { padding: 17px 20px 14px; display: grid; gap: 9px; border-bottom: 1px solid rgba(218,192,128,.12); }
.search-box, .filter-select { display: flex; align-items: center; gap: 8px; color: var(--gold); border-bottom: 1px solid rgba(218,192,128,.27); }
.search-box span { font-size: 20px; transform: rotate(-15deg); }
input, select { width: 100%; border: 0; outline: 0; color: var(--paper-light); background: transparent; font: 12px var(--serif); padding: 8px 0; }
input::placeholder { color: rgba(225,212,173,.42); }
select { appearance: none; cursor: pointer; }
select option { background: var(--field); color: var(--paper-light); }
.filter-select span { font-size: 11px; color: rgba(225,212,173,.48); }
.timeline { padding: 8px 20px 0; height: 485px; overflow: auto; scrollbar-color: var(--paper-deep) transparent; scrollbar-width: thin; }
.timeline-item { display: grid; grid-template-columns: 13px 1fr; gap: 12px; padding: 12px 4px 13px; cursor: pointer; border-bottom: 1px solid rgba(218,192,128,.09); transition: background .25s ease, transform .25s ease; }
.timeline-item:hover { background: rgba(211,181,111,.08); transform: translateX(3px); }
.timeline-item.active { background: rgba(162,59,50,.14); border-left: 2px solid var(--red-bright); padding-left: 8px; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; background: var(--gold); box-shadow: 0 0 0 3px rgba(203,178,115,.12); }
.timeline-dot.rear { background: #7ba58f; box-shadow: 0 0 0 3px rgba(123,165,143,.13); }
.timeline-dot.turn { background: var(--red-bright); box-shadow: 0 0 0 3px rgba(201,87,66,.14); }
.item-date { font-size: 11px; color: var(--gold); letter-spacing: .08em; }
.item-title { margin: 3px 0 0; color: var(--paper-light); font-size: 13px; line-height: 1.5; }
.item-meta { margin-top: 4px; color: rgba(225,212,173,.44); font-size: 10px; }
.timeline-foot { padding: 15px 22px; color: rgba(225,212,173,.39); font-size: 10px; letter-spacing: .08em; border-top: 1px solid rgba(218,192,128,.12); }
.map-panel { min-height: 660px; background: rgba(18, 29, 23, .3); }
.map-topline { padding-bottom: 16px; }
.map-legend { display: flex; gap: 14px; color: rgba(225,212,173,.56); font-size: 10px; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.dot-rear { background: #7ba58f; }.dot-turn { background: var(--red-bright); }
.map-stage { position: relative; height: 570px; padding: 24px 22px 16px; background: radial-gradient(ellipse at center, rgba(201,172,105,.18), transparent 70%); }
.three-map { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
.three-map:active { cursor: grabbing; }
.three-map canvas { display: block; width: 100%; height: 100%; }
.map-vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 47%, rgba(35,29,22,.28) 100%); mix-blend-mode: multiply; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #5f4935; font: 400 18px var(--brush); letter-spacing: .18em; background: #c4ac78; transition: opacity .55s ease, visibility .55s ease; }
.map-loading.loaded { opacity: 0; visibility: hidden; }
.map-hint { position: absolute; left: 30px; top: 24px; color: rgba(70,48,31,.64); font-size: 10px; letter-spacing: .08em; pointer-events: none; }
.map-grid path { fill: none; stroke: #a58b58; stroke-dasharray: 2 6; stroke-width: .7; }
.china-silhouette { fill: #c1a96d; stroke: #e2cc8b; stroke-width: 2; }
.map-wash { fill: url(#mapWash); }
.admin-lines path { fill: none; stroke: #745f3e; stroke-width: 1.15; stroke-opacity: .72; }
.map-labels text { font-family: var(--serif); font-size: 10px; fill: #705c3c; opacity: .82; }
.map-compass { position: absolute; top: 23px; right: 31px; color: var(--gold); font: 13px/1.05 var(--serif); text-align: center; opacity: .74; }
.map-compass span { font: 26px var(--brush); }
.map-scale { position: absolute; left: 32px; bottom: 35px; color: rgba(225,212,173,.5); font-size: 9px; letter-spacing: .08em; }
.map-caption { position: absolute; bottom: 15px; right: 27px; color: rgba(225,212,173,.43); font: 11px var(--brush); letter-spacing: .1em; }
.marker { cursor: pointer; transform-box: fill-box; transform-origin: center; animation: marker-in .55s both; }
.marker-core { fill: var(--gold); stroke: #f0db9c; stroke-width: 1; }
.marker-halo { fill: none; stroke: var(--gold); stroke-opacity: .36; stroke-width: 1.4; animation: pulse 2.4s ease-out infinite; }
.marker.rear .marker-core { fill: #7ba58f; stroke: #c2d5be; }.marker.turn .marker-core { fill: var(--red-bright); stroke: #f0b49d; }
.marker.active .marker-core { fill: #f2db9b; stroke: #fff1c4; stroke-width: 2; }.marker.active .marker-halo { stroke: var(--red-bright); stroke-width: 2; }
@keyframes marker-in { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(.65); opacity: .05; } 45% { transform: scale(1.35); opacity: .35; } }
.detail-panel { display: flex; flex-direction: column; }
.detail-heading { padding-right: 17px; }
.close-detail { width: 25px; height: 25px; border: 1px solid rgba(218,192,128,.25); background: transparent; color: var(--gold); font-size: 18px; line-height: 1; cursor: pointer; opacity: .7; }
.close-detail:hover { opacity: 1; border-color: var(--red-bright); color: var(--red-bright); }
.detail-content { min-height: 0; padding: 22px 25px; flex: 1; position: relative; z-index: 1; overflow-y: auto; scrollbar-color: var(--paper-deep) transparent; scrollbar-width: thin; }
.detail-content.is-muted { opacity: .2; filter: grayscale(.6); }
.detail-era { color: var(--red-bright); font-size: 11px; letter-spacing: .16em; }
.detail-title { margin: 8px 0 11px; font: 400 30px/1.25 var(--brush); color: var(--paper-light); }
.detail-place { display: flex; align-items: center; gap: 8px; color: var(--gold); font-size: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.place-pin { color: var(--red-bright); font-size: 19px; }
.detail-tag { display: inline-block; margin: 14px 0 10px; padding: 4px 9px; color: var(--paper-light); background: rgba(162,59,50,.33); border: 1px solid rgba(201,87,66,.48); font-size: 10px; letter-spacing: .13em; }
.detail-section-label { margin: 1px 0 8px; color: var(--gold); font-size: 10px; font-weight: 600; letter-spacing: .2em; }
.detail-desc { color: rgba(231,216,174,.74); font-size: 13px; line-height: 2.05; margin: 0; }
.detail-impact-label { margin-top: 22px; color: var(--red-bright); }
.detail-impact { margin: 0; color: rgba(231,216,174,.62); font-size: 13px; line-height: 2.05; }
.detail-quote { margin: 30px 0 0; padding: 17px 0 0 17px; border-left: 2px solid var(--gold); color: rgba(225,212,173,.55); font: 400 16px/1.75 var(--brush); }
.detail-quote::before { content: "“"; display: block; margin-bottom: -15px; color: var(--red-bright); font: 34px/1 var(--brush); }
.detail-footer { display: flex; gap: 5px; align-items: center; padding: 16px 24px 20px; color: rgba(225,212,173,.42); font-size: 10px; letter-spacing: .09em; border-top: 1px solid rgba(218,192,128,.13); }
.detail-footer #detailNumber { color: var(--red-bright); font: 18px var(--brush); }.footer-rule { height: 1px; width: 38px; margin-left: auto; background: var(--line); }
.empty-state { padding: 34px 10px; text-align: center; color: rgba(225,212,173,.45); font-size: 12px; line-height: 2; }
.site-footer { max-width: 1500px; margin: 0 auto; padding: 18px 5vw 28px; display: flex; justify-content: space-between; color: rgba(225,212,173,.36); font-size: 10px; letter-spacing: .12em; }
@media (max-width: 1120px) { .workspace { grid-template-columns: 240px minmax(420px, 1fr); }.detail-panel { grid-column: 1 / -1; min-height: 330px; }.detail-content { padding-bottom: 25px; }.detail-quote { display: none; } }
@media (max-width: 760px) { .site-header { padding: 26px 20px 19px; }.header-note { display: none; }.page-shell { padding: 0 15px 25px; }.intro-strip { grid-template-columns: 1fr 56px; gap: 18px; padding: 30px 0 24px; }.intro-strip p { grid-column: 1 / -1; font-size: 12px; }.intro-stamp { grid-column: 2; grid-row: 1; }.workspace { display: flex; flex-direction: column; gap: 14px; }.panel { min-height: auto; }.timeline-panel { order: 2; }.map-panel { order: 1; }.detail-panel { order: 3; }.map-stage { height: 430px; padding: 14px 8px 10px; }.map-legend { gap: 8px; font-size: 9px; }.map-legend span:nth-child(2) { display: none; }.timeline { height: 390px; }.site-footer { flex-direction: column; gap: 9px; padding-inline: 20px; }.detail-content { padding: 23px 20px; } }

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .three-map { touch-action: pan-y; }
  .map-stage { height: 450px; }
  .map-hint { top: 17px; left: 21px; font-size: 9px; }
  .map-caption { right: 15px; font-size: 10px; }
  .timeline-axis-label { display: none; }
  .timeline-item { grid-template-columns: 13px 1fr; }
  .timeline-item .timeline-dot { grid-column: 1; grid-row: 1 / 4; }
  .timeline-item .item-date { grid-column: 2; grid-row: 1; }
  .timeline-item .item-title { grid-column: 2; grid-row: 2; }
  .timeline-item .item-meta { grid-column: 2; grid-row: 3; }
}

/* Revised desktop composition: the browser viewport holds the whole atlas. */
@media (min-width: 761px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; }
  .site-header { padding-top: 20px; padding-bottom: 14px; }
  .site-header { flex: 0 0 auto; width: 100%; }
  .page-shell { flex: 1 1 auto; width: 100%; height: auto; min-height: 0; padding-bottom: 14px; display: flex; flex-direction: column; }
  .intro-strip { padding: 18px 0 16px; gap: 28px; }
  .intro-strip h2 { font-size: clamp(28px, 3.5vw, 44px); }
  .workspace { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 310px; grid-template-rows: minmax(0, 1fr) 198px; }
  .map-panel, .detail-panel, .timeline-panel { min-height: 0; height: 100%; }
  .detail-panel { grid-column: auto; }
  .timeline-panel { grid-column: 1 / -1; }
  .map-panel { display: flex; flex-direction: column; }
  .map-stage { flex: 1; min-height: 0; height: auto; }
  .detail-panel { display: flex; flex-direction: column; }
  .detail-content { overflow: auto; }
  .timeline-heading { padding-block: 13px 10px; }
  .timeline-wrap { position: relative; min-height: 118px; height: calc(100% - 51px); }
  .timeline { height: 100%; display: flex; gap: 0; overflow-x: auto; overflow-y: hidden; padding: 10px 46px 5px; scrollbar-color: var(--paper-deep) transparent; }
  .timeline::before { content: ""; position: absolute; left: 38px; right: 38px; top: 51px; height: 1px; background: rgba(203,178,115,.48); pointer-events: none; }
  .timeline-item { position: relative; flex: 0 0 148px; display: flex; flex-direction: column; padding: 0 11px 8px; border: 0; transform: none; z-index: 1; }
  .timeline-item:hover { background: transparent; transform: translateY(-2px); }
  .timeline-item.active { background: transparent; border: 0; padding-left: 11px; }
  .timeline-dot { order: 2; display: block; flex: 0 0 auto; width: 11px; height: 11px; margin: 8px auto 9px; border: 2px solid var(--field); box-shadow: 0 0 0 3px rgba(203,178,115,.22); }
  .timeline-item.active .timeline-dot { box-shadow: 0 0 0 3px rgba(201,87,66,.3), 0 0 0 6px rgba(201,87,66,.08); }
  .item-date, .item-title, .item-meta { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .item-date { order: 1; min-height: 17px; }
  .item-title { order: 3; }
  .item-meta { order: 4; }
  .item-title { font-size: 12px; }
  .item-meta { font-size: 9px; }
  .timeline-foot { display: none; }
  .map-stage { background: #c4ac78; box-shadow: inset 0 0 0 1px rgba(78,58,37,.2), inset 0 0 55px rgba(60,43,28,.28); }
  .map-stage::before { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(80,56,34,.35); pointer-events: none; }
  .map-caption { color: rgba(68,49,30,.72); }
  .map-scale { color: rgba(68,49,30,.62); }
  .map-compass { color: #6d553e; }
  .marker { transform-box: fill-box; transform-origin: center; }
  .marker-glyph { fill: #ad422f; stroke: #f4deb0; stroke-width: 1.25; filter: drop-shadow(0 2px 1px rgba(56,36,21,.3)); }
  .marker.rear .marker-glyph { fill: #3d7b67; }
  .marker.turn .marker-glyph { fill: #b65332; }
  .marker-core { fill: #f3d98b; stroke: #593b2c; stroke-width: 1; }
  .marker-halo { stroke: #f5e2ac; stroke-opacity: .45; }
  .marker.active .marker-glyph { fill: #de783c; stroke: #fff1c3; stroke-width: 2; }
  @keyframes marker-in { from { opacity: 0; } to { opacity: 1; } }
  .site-footer { display: none; }
}

.detail-index-label { color: rgba(225,212,173,.45); font-size: 10px; letter-spacing: .08em; }
.timeline-wrap { position: relative; }
.timeline-axis-label { position: absolute; top: 42px; color: var(--gold); font: 400 18px var(--brush); z-index: 2; pointer-events: none; }
.axis-start { left: 10px; }
.axis-end { right: 10px; }

/* Keep long dates and Chinese event names readable inside the horizontal axis. */
@media (min-width: 761px) {
  .timeline {
    padding-left: 76px;
    padding-right: 76px;
    scroll-padding-inline: 76px;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 76px, #000 calc(100% - 76px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 76px, #000 calc(100% - 76px), transparent 100%);
  }
  .timeline::before { left: 54px; right: 54px; }
  .timeline-item { flex-basis: 190px; min-width: 190px; padding-inline: 10px; scroll-snap-align: center; }
  .item-date, .item-title, .item-meta { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; word-break: break-word; }
  .item-date { min-height: 18px; font-size: 10px; line-height: 18px; }
  .item-title { min-height: 18px; line-height: 18px; }
  .item-meta { min-height: 18px; line-height: 18px; }
  .axis-start { left: 24px; }
  .axis-end { right: 24px; }
}

@media (max-width: 760px) {
  .timeline-item .item-date, .timeline-item .item-title, .timeline-item .item-meta { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; word-break: break-word; }
  .timeline-item .item-title { line-height: 1.45; }
  .timeline-item .item-meta { line-height: 1.35; }
}
