:root {
  --paper: #efebe3;
  --paper-deep: #e7e1d6;
  --land: #d8d0c2;
  --land-line: #c9c0b0;
  --ink: #1c1915;
  --ink-soft: #5c564c;
  --muted: #8a8378;
  --faint: #b3aba0;
  --seal: #9a3b2f;
  --seal-soft: rgba(154, 59, 47, 0.18);
  --panel: #f7f4ee;
  --shadow: 0 16px 50px rgba(28, 25, 21, 0.08);
  --serif: "Noto Serif SC", "Songti SC", "SimSun", "Cormorant Garamond", serif;
  --display: "Cormorant Garamond", "Noto Serif SC", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
}

#app {
  position: relative;
  height: 100%;
  width: 100%;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--paper);
}

.leaflet-container {
  background: var(--paper);
  font: inherit;
}

.leaflet-container,
.leaflet-pane,
.leaflet-top,
.leaflet-bottom {
  outline: none;
}

.leaflet-control-attribution,
.leaflet-control-zoom {
  display: none !important;
}

/* Brand */
.brand {
  position: absolute;
  top: 36px;
  left: 44px;
  z-index: 20;
  pointer-events: none;
}

.brand-mark {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.22em;
  line-height: 1;
  color: var(--ink);
}

.brand-sub {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--muted);
}

/* Quiet zoom */
.zoom-ctrl {
  position: absolute;
  top: 36px;
  right: 36px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zoom-ctrl button {
  width: 32px;
  height: 32px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--display);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.25s var(--ease);
}

.zoom-ctrl button:hover {
  color: var(--ink);
}

/* Search */
.search-wrap {
  position: absolute;
  top: 88px;
  left: 44px;
  z-index: 26;
  width: 252px;
}

#search {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--land-line);
  background: transparent;
  padding: 4px 0 6px;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink);
  outline: none;
  border-radius: 0;
}

#search::placeholder {
  color: var(--faint);
}

#search:focus {
  border-bottom-color: var(--ink-soft);
}

.search-results {
  margin-top: 8px;
  max-height: 42vh;
  overflow: auto;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--land-line) transparent;
}

.search-results button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 14px;
  font-family: var(--serif);
  cursor: pointer;
}

.search-results button:hover,
.search-results button:focus {
  background: var(--paper-deep);
}

.search-results .s-title {
  display: block;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.search-results .s-meta {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.search-empty {
  padding: 10px 14px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Chronicle list */
.chronicle {
  position: absolute;
  top: 148px;
  left: 44px;
  z-index: 20;
  width: 252px;
  max-height: calc(100% - 380px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--land-line) transparent;
  padding-right: 8px;
}


.era-head {
  margin: 0 0 14px;
  position: relative;
  padding-right: 24px;
}

.era-name,
.chronicle h2.era-name {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--ink);
}

.era-summary {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.85;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.era-count {
  margin: 8px 0 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--faint);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 0 0 18px;
}

.filter-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--faint);
  cursor: pointer;
  line-height: 1.4;
}

.filter-btn:hover {
  color: var(--ink-soft);
}

.filter-btn.is-on {
  color: var(--seal);
}

.sidebar-close {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.chronicle h2 {
  margin: 0 0 16px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.chronicle ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chronicle li {
  margin: 0 0 16px;
  cursor: pointer;
}

.chronicle .t {
  display: block;
  font-size: 13.5px;
  letter-spacing: 0.06em;
  line-height: 1.45;
  color: var(--ink-soft);
}

.chronicle .p {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--faint);
}

.chronicle li.tier-1 .t {
  font-weight: 500;
  color: var(--ink);
}

.chronicle li.tier-3 .t {
  color: var(--muted);
}

.chronicle .mark,
.chronicle .now {
  margin-left: 8px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.chronicle .mark {
  color: var(--seal);
}

.chronicle .now {
  color: var(--faint);
}

.chronicle li.is-active .t {
  color: var(--seal);
}

/* Year dock */
.year-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 56px 24px 28px;
  background: linear-gradient(
    to top,
    rgba(239, 235, 227, 0.96) 0%,
    rgba(239, 235, 227, 0.78) 42%,
    rgba(239, 235, 227, 0) 100%
  );
  text-align: center;
  pointer-events: none;
}

.year-dock > * {
  pointer-events: auto;
}

.year-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.year-prefix {
  font-size: 16px;
  letter-spacing: 0.18em;
  color: var(--muted);
  transform: translateY(-8px);
}

.year-num {
  display: block;
  font-family: var(--display);
  font-weight: 500;
  font-size: 86px;
  line-height: 0.85;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-variant-numeric: lining-nums;
}

.year-num.is-long {
  font-size: 64px;
}

.year-era {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--muted);
}

.slider-wrap {
  position: relative;
  width: min(760px, calc(100% - 48px));
  margin: 28px auto 0;
}

.slider-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}

.slider-wrap input[type="range"]:focus {
  outline: none;
}

.slider-wrap input[type="range"]:focus-visible {
  outline: 1px solid var(--seal);
  outline-offset: 6px;
}

.slider-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--ink);
  opacity: 0.28;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5.5px;
  border-radius: 50%;
  border: 0;
  background: var(--seal);
  box-shadow: 0 0 0 6px var(--paper);
  transition: transform 0.2s var(--ease);
}

.slider-wrap input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.15);
}

.slider-wrap input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--ink);
  opacity: 0.28;
  border: 0;
}

.slider-wrap input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 0;
  background: var(--seal);
  box-shadow: 0 0 0 6px var(--paper);
}

.era-ticks {
  position: relative;
  height: 22px;
  margin-top: 8px;
}

.era-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--faint);
  white-space: nowrap;
  border: 0;
  padding: 0;
  background: transparent;
  font-family: var(--serif);
  cursor: pointer;
}

.era-tick:hover {
  color: var(--ink-soft);
}

.era-tick.is-current {
  color: var(--ink);
}

.hint {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--faint);
}

/* Markers */
.pin-wrap {
  background: none !important;
  border: 0 !important;
  overflow: visible !important;
}

.pin {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: pointer;
}

.pin .dot {
  position: absolute;
  top: 50%;
  border-radius: 50%;
  background: var(--seal);
  box-shadow: 0 0 0 1px rgba(247, 244, 238, 0.9);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), opacity 0.3s ease;
}

.pin.tier-1 .dot {
  width: 11px;
  height: 11px;
}

.pin.tier-2 .dot {
  width: 8px;
  height: 8px;
  opacity: 0.85;
}

.pin.tier-3 .dot {
  width: 6px;
  height: 6px;
  background: #8a5a52;
  opacity: 0.7;
}

.pin.side-right .dot {
  left: 0;
  transform: translateY(-50%);
}

.pin.side-left .dot {
  right: 0;
  transform: translateY(-50%);
}

.pin:not(.has-label) .dot {
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
}

.pin .dot::before {
  content: "";
  position: absolute;
  inset: -12px;
}

.pin.is-active .dot,
.pin:hover .dot {
  opacity: 1;
}

.pin.side-right.is-active .dot,
.pin.side-right:hover .dot,
.pin.side-left.is-active .dot,
.pin.side-left:hover .dot {
  transform: translateY(-50%) scale(1.2);
}

.pin:not(.has-label).is-active .dot,
.pin:not(.has-label):hover .dot {
  transform: translate(-50%, -50%) scale(1.2);
}

.pin.tier-1.is-active .dot {
  box-shadow:
    0 0 0 1px rgba(247, 244, 238, 0.9),
    0 0 0 7px var(--seal-soft);
}

.pin .label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  opacity: 0.92;
}

.pin.side-right .label {
  left: 20px;
}

.pin.side-left .label {
  right: 20px;
  text-align: right;
}

.pin .region {
  display: block;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--muted);
  line-height: 1;
}

.pin .chapter {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink);
  line-height: 1.2;
}

.pin.tier-2 .chapter {
  font-weight: 400;
  font-size: 13px;
}

/* Panel */
.panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(440px, 92vw);
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateX(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease), transform 0.55s var(--ease);
  display: flex;
  flex-direction: column;
}

.panel.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.panel-close {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--display);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: color 0.2s ease;
}

.panel-close:hover {
  color: var(--ink);
}

.panel-scroll {
  flex: 1;
  overflow: auto;
  padding: 52px 48px 140px;
  scrollbar-width: thin;
  scrollbar-color: var(--land-line) transparent;
}

.panel-kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.panel-title {
  margin: 16px 0 0;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.panel-mark {
  margin-left: 12px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--seal);
  vertical-align: middle;
}

.panel-dates {
  margin: 12px 0 0;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.panel-body {
  margin: 18px 0 0;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 2;
  color: var(--ink);
}

.works {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.work figure {
  margin: 0;
}

.work img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 52vh;
  object-fit: contain;
  object-position: center top;
  background: var(--paper-deep);
  cursor: zoom-in;
}

.work figcaption,
.work-text {
  margin-top: 12px;
}

.work.is-text .work-text {
  margin: 0;
  padding: 18px 0;
  border-top: 1px solid var(--land-line);
  border-bottom: 1px solid var(--land-line);
}

.work-title {
  display: block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.work-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  line-height: 1.7;
}

.work-note {
  display: block;
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--faint);
  line-height: 1.7;
}

.panel-source {
  margin-top: 36px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.panel-source a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--land-line);
}

.panel-source a:hover {
  color: var(--ink);
}

.panel-note {
  margin-top: 16px;
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.8;
  color: var(--faint);
}


.panel-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--land-line);
}

.nav-btn {
  flex: 1;
  border: 0;
  padding: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 1.6;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
}

.nav-btn + .nav-btn,
.panel-nav .nav-btn:last-child {
  text-align: right;
}

.nav-btn:hover {
  color: var(--seal);
}

.nav-btn.is-disabled {
  color: var(--faint);
  cursor: default;
}

.sidebar-toggle {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(28, 25, 21, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 32px;
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox figure {
  margin: 0;
  max-width: min(1100px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
}

.lightbox img {
  display: block;
  max-width: 94vw;
  max-height: 82vh;
  object-fit: contain;
  background: transparent;
}

.lightbox figcaption {
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #efebe3;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: #efebe3;
  font-family: var(--display);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

@media (min-width: 821px) {
  #app.panel-open .year-dock {
    right: min(440px, 92vw);
  }

  #app.panel-open .zoom-ctrl {
    right: calc(min(440px, 92vw) + 16px);
  }
}

#app.is-booting .brand,
#app.is-booting .year-dock,
#app.is-booting .zoom-ctrl,
#app.is-booting .chronicle,
#app.is-booting .search-wrap,
#app.is-booting .sidebar-toggle {
  opacity: 0;
  transform: translateY(8px);
}

.brand,
.year-dock,
.zoom-ctrl,
.chronicle,
.search-wrap,
.sidebar-toggle {
  transition: opacity 1s var(--ease) 0.15s, transform 1s var(--ease) 0.15s;
}

@media (max-width: 820px) {
  .brand {
    top: 16px;
    left: 16px;
  }

  .brand-mark {
    font-size: 18px;
    letter-spacing: 0.16em;
  }

  .brand-sub {
    margin-top: 6px;
    font-size: 10px;
  }

  .search-wrap {
    top: 16px;
    left: 118px;
    right: 88px;
    width: auto;
  }

  .zoom-ctrl {
    top: 14px;
    right: 10px;
  }

  .sidebar-toggle {
    display: block;
    position: absolute;
    left: 16px;
    bottom: 168px;
    z-index: 28;
    border: 0;
    padding: 0;
    background: transparent;
    font-family: var(--serif);
    font-size: 12px;
    letter-spacing: 0.18em;
    color: var(--ink-soft);
    cursor: pointer;
  }

  .sidebar-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 31;
    background: rgba(28, 25, 21, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s var(--ease);
  }

  #app.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-close {
    display: block;
    position: absolute;
    top: 18px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-family: var(--display);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }

  .chronicle {
    left: 0;
    right: auto;
    top: 0;
    bottom: 0;
    width: min(86vw, 320px);
    max-height: none;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 28px 20px 160px;
    z-index: 32;
    transform: translateX(-105%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.45s var(--ease), opacity 0.45s var(--ease);
  }

  #app.sidebar-open .chronicle {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  .year-num {
    font-size: 52px;
  }

  .year-num.is-long {
    font-size: 40px;
  }

  .year-dock {
    padding: 32px 16px 18px;
  }

  .era-tick {
    font-size: 9px;
    letter-spacing: 0.02em;
  }

  .panel {
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    height: min(68vh, 640px);
    transform: translateY(16px);
    box-shadow: 0 -12px 40px rgba(28, 25, 21, 0.08);
    z-index: 40;
  }

  .panel.is-open {
    transform: none;
  }

  .panel-scroll {
    padding: 36px 28px 48px;
  }

  .panel-title {
    font-size: 24px;
  }

  .pin .chapter {
    font-size: 12px;
  }

  .hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}


/* Instant appearance for documentation screenshots (?shot=1). */
#app.is-shot,
#app.is-shot * {
  transition: none !important;
  animation: none !important;
}
