:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #65676b;
  --line: #d7d7d2;
  --paper: #f3f2ed;
  --panel: #ffffff;
  --accent: #2f5d62;
  --sidebar-width: 300px;
  --tree-line: #8f908a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: calc(100% - var(--sidebar-width));
  height: 100vh;
  margin: 0 0 0 var(--sidebar-width);
  padding: 16px 18px;
}

.app-header {
  position: relative;
  z-index: 1050;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.eyebrow-mobile {
  display: none;
}

h1,
h2,
h3,
h4,
h5,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
  text-transform: capitalize;
}

h4 {
  margin: 0;
  font-size: 14px;
}

h5 {
  margin: 10px 0 4px;
  font-size: 15px;
  line-height: 1.3;
}

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fafaf8;
  color: #3d3d38;
  font-size: 12px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-search {
  position: relative;
  flex: 1 1 320px;
  max-width: 520px;
  align-self: center;
}

.site-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.site-search-icon {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  color: var(--accent);
  pointer-events: none;
}

.site-search-input {
  width: 100%;
  height: 46px;
  border: 2px solid var(--ink);
  border-radius: 23px;
  padding: 0 44px;
  background: var(--panel);
  color: inherit;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.site-search-input::placeholder {
  color: var(--muted);
}

.site-search-input::-webkit-search-cancel-button {
  display: none;
}

.site-search-input:hover {
  border-color: var(--accent);
}

.site-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent);
}

.site-search-clear {
  position: absolute;
  right: 8px;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.site-search-clear:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
}

.site-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.site-search-count {
  margin: 0;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.site-search-result {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  padding: 5px 12px;
  cursor: pointer;
  font: inherit;
}

.site-search-result:last-child {
  border-bottom: none;
}

.site-search-result:hover,
.site-search-result.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.site-search-result-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.site-search-result-meta {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.site-search-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.reference-page-link {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.app-shell {
  display: block;
  height: 100%;
  min-height: 0;
  padding-top: 10px;
}

.reference-body {
  height: auto;
  min-height: 100%;
  overflow: auto;
}

.reference-main {
  display: block;
  width: min(1120px, calc(100% - 32px));
  height: auto;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 42px;
}

.reference-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.reference-section {
  margin-top: 18px;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
}

.reference-section:first-of-type {
  border-top: 0;
}

.reference-nav {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0 12px;
  background: var(--paper);
}

.reference-nav a {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.reference-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.reference-lead,
.reference-empty,
.reference-placeholder p {
  max-width: 760px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.reference-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.reference-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}

.deity-sakyamuni {
  --deity-accent: #2f6f73;
  --deity-bg: #e7f1f0;
}

.deity-amitabha {
  --deity-accent: #8b5e20;
  --deity-bg: #f5ecdb;
}

.deity-medicine {
  --deity-accent: #2f6844;
  --deity-bg: #e6f1e8;
}

.deity-vairocana {
  --deity-accent: #6a517f;
  --deity-bg: #eee8f4;
}

.deity-maitreya {
  --deity-accent: #9a4c31;
  --deity-bg: #f5e7e1;
}

.deity-bodhisattva {
  --deity-accent: #3f668e;
  --deity-bg: #e7eef7;
}

.deity-arhat {
  --deity-accent: #6a6841;
  --deity-bg: #efefe2;
}

.deity-estimated {
  --deity-accent: #657078;
  --deity-bg: #edf0f1;
}

.reference-table th,
.reference-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.reference-table thead th {
  background: #f7f7f3;
  color: var(--accent);
  font-weight: 900;
}

.reference-table tbody th {
  width: 130px;
  color: var(--deity-accent, var(--ink));
  font-weight: 900;
}

.reference-table tbody tr {
  background:
    linear-gradient(90deg, var(--deity-accent, transparent) 0 5px, transparent 5px),
    color-mix(in srgb, var(--deity-bg, #fff) 58%, #fff);
}

.reference-table tbody tr:nth-child(even) {
  background:
    linear-gradient(90deg, var(--deity-accent, transparent) 0 5px, transparent 5px),
    color-mix(in srgb, var(--deity-bg, #fff) 72%, #fff);
}

.reference-table tr:last-child th,
.reference-table tr:last-child td {
  border-bottom: 0;
}

.deity-count-cell {
  width: 60px;
  color: var(--deity-accent, var(--ink));
  font-weight: 900;
  text-align: right;
}

.deity-total-row {
  border-top: 2px solid var(--line);
  background: #f7f7f3;
}

.deity-total-row th {
  color: var(--ink);
  text-align: right;
}

.deity-total-row .deity-count-cell {
  color: var(--accent);
}

.reference-list {
  display: grid;
  gap: 18px;
}

.reference-deity-group {
  border-top: 3px solid var(--deity-accent, var(--line));
  padding-top: 10px;
}

.reference-deity-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.reference-deity-group-header h3 {
  margin: 0;
  color: var(--deity-accent, var(--ink));
  font-size: 15px;
  font-weight: 900;
  text-transform: none;
}

.reference-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reference-title-row h1 {
  margin: 0;
}

.reference-deity-count {
  min-width: 22px;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--deity-accent, var(--accent));
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  display: inline-block;
}

.reference-deity-desc {
  font-size: 12px;
  color: #666;
  margin-left: 10px;
  font-weight: 500;
  letter-spacing: -0.3px;
}

@media (max-width: 768px) {
  .reference-deity-group-header {
    flex-wrap: wrap;
    gap: 6px 8px;
  }
  .reference-deity-desc {
    margin-left: 0;
    width: 100%;
    color: #777;
    font-size: 11px;
  }
}

.reference-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.reference-list-item {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--deity-accent, var(--line)) 34%, var(--line));
  border-radius: 8px;
  min-height: 102px;
  padding: 12px 96px 12px 12px;
  background:
    linear-gradient(90deg, var(--deity-accent, var(--accent)) 0 5px, transparent 5px),
    color-mix(in srgb, var(--deity-bg, var(--panel)) 60%, #fff);
  overflow: hidden;
}

.reference-list-heading {
  display: block;
  margin-bottom: 8px;
}

.reference-list-item h3 {
  margin: 0;
  text-transform: none;
  line-height: 1.35;
}

.reference-site-link {
  color: inherit;
  text-decoration: none;
}

.reference-site-link:hover,
.reference-site-link:focus-visible {
  color: var(--deity-accent, var(--period-accent, var(--accent)));
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reference-thumb-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 4px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  cursor: zoom-in;
  overflow: hidden;
  opacity: .58;
  pointer-events: auto;
  transition: opacity .15s ease, transform .15s ease;
}

.reference-thumb-button:hover,
.reference-thumb-button:focus-visible {
  opacity: .95;
  transform: scale(1.04);
  outline: 2px solid rgba(48, 99, 103, .22);
  outline-offset: 2px;
}

.reference-thumb-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.reference-deity {
  margin-bottom: 6px;
  color: var(--deity-accent, var(--accent));
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.reference-meta {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.reference-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 22, 23, .68);
}

.reference-modal {
  position: relative;
  width: fit-content;
  max-width: 92vw;
  max-height: 92vh;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  padding: 18px;
  background: #f8f7f3;
  box-shadow: 0 28px 70px rgba(0, 0, 0, .34);
}

.reference-modal img {
  display: block;
  max-width: calc(92vw - 36px);
  max-height: calc(92vh - 36px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.reference-modal-figure {
  position: relative;
  margin: 0;
}

.reference-modal-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 8px;
  background: rgba(28, 31, 32, .72);
  color: #fff;
  font-size: clamp(14px, 1.8vw, 20px);
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  overflow-wrap: anywhere;
  pointer-events: none;
}

.reference-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  background: rgba(38, 41, 42, .88);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.pagoda-chronology-list {
  display: grid;
  gap: 20px;
}

.period-baekje {
  --period-accent: #7c4d2b;
  --period-bg: #f3e8df;
}

.period-silla {
  --period-accent: #77702c;
  --period-bg: #efeddc;
}

.period-transition {
  --period-accent: #2f6f73;
  --period-bg: #e4f0ef;
}

.period-goryeo {
  --period-accent: #4c6f48;
  --period-bg: #e8f0e5;
}

.period-joseon {
  --period-accent: #526f90;
  --period-bg: #e7edf5;
}

.period-unknown {
  --period-accent: #657078;
  --period-bg: #edf0f1;
}

.pagoda-period-group {
  border-top: 3px solid var(--period-accent, var(--line));
  padding-top: 10px;
}

.pagoda-period-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.pagoda-period-header h2 {
  margin: 0;
  color: var(--period-accent, var(--ink));
  font-size: 16px;
  font-weight: 900;
}

.pagoda-period-group .reference-deity-count {
  background: var(--period-accent, var(--accent));
}

.pagoda-chronology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.pagoda-chronology-card {
  position: relative;
  min-height: 102px;
  border: 1px solid color-mix(in srgb, var(--period-accent, var(--line)) 34%, var(--line));
  border-radius: 8px;
  padding: 12px 96px 12px 12px;
  background:
    linear-gradient(90deg, var(--period-accent, var(--accent)) 0 5px, transparent 5px),
    color-mix(in srgb, var(--period-bg, var(--panel)) 64%, #fff);
  overflow: hidden;
}

.pagoda-chronology-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
  text-transform: none;
}

.pagoda-period {
  margin-bottom: 6px;
  color: var(--period-accent, var(--accent));
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.pagoda-reference-board {
  display: grid;
  grid-template-columns: minmax(700px, 780px) minmax(360px, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 14px;
}

.pagoda-explainer {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 12px;
  min-height: 1048px;
}

.pagoda-explainer article,
.pagoda-notes article,
.pagoda-terms article {
  border: 1px solid var(--section-border, var(--line));
  border-radius: 8px;
  padding: 12px 14px;
  background:
    linear-gradient(90deg, var(--section-accent, var(--accent)) 0 5px, transparent 5px),
    var(--section-bg, var(--panel));
  box-shadow: 0 8px 18px rgba(32, 33, 36, .06);
  overflow: hidden;
}

.pagoda-explainer .section-body,
.pagoda-explainer .section-base {
  align-self: start;
}

.pagoda-explainer h3,
.pagoda-notes h3,
.pagoda-terms h3 {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-bottom: 8px;
  border-radius: 6px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--section-accent, var(--accent)) 14%, #fff);
  color: var(--section-accent, var(--accent));
  text-transform: none;
}

.pagoda-explainer p,
.pagoda-notes p {
  margin-bottom: 9px;
  color: #27383b;
  font-size: 12px;
  line-height: 1.55;
}

.pagoda-section-card.section-finial {
  --section-accent: rgb(47, 93, 98);
  --section-bg: rgba(74, 128, 139, .14);
  --section-border: rgba(47, 93, 98, .34);
}

.pagoda-section-card.section-body {
  --section-accent: rgb(137, 94, 33);
  --section-bg: rgba(187, 139, 63, .14);
  --section-border: rgba(137, 94, 33, .32);
}

.pagoda-section-card.section-base {
  --section-accent: rgb(72, 92, 53);
  --section-bg: rgba(104, 125, 78, .15);
  --section-border: rgba(72, 92, 53, .34);
}

.pagoda-figure {
  position: sticky;
  top: 64px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #82785f;
}

.pagoda-actual-figure {
  position: relative;
  width: 740px;
  min-width: 740px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, .42);
  background: #f8f7f3;
  box-shadow: 0 12px 28px rgba(47, 45, 35, .22);
}

.pagoda-actual-figure img {
  display: block;
  width: 590px;
  height: auto;
}

.pagoda-annotation-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pagoda-number-lines line {
  display: none;
}

.pagoda-number-badges text {
  display: none;
}

.pagoda-section-guides path {
  display: none;
  fill: none;
  stroke: rgba(47, 93, 98, .72);
  stroke-width: .38;
  vector-effect: non-scaling-stroke;
}

.pagoda-section-tints rect {
  pointer-events: none;
  mix-blend-mode: multiply;
}

.pagoda-section-tints .tint-finial {
  fill: rgba(74, 128, 139, .18);
}

.pagoda-section-tints .tint-body {
  fill: rgba(187, 139, 63, .16);
}

.pagoda-section-tints .tint-base {
  fill: rgba(104, 125, 78, .18);
}

.pagoda-section-tint-labels text {
  font-size: 24px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke fill;
  stroke: rgba(255, 255, 255, .78);
  stroke-width: 4px;
  filter: url(#label-shadow);
}

.pagoda-section-tint-labels .label-finial {
  fill: rgb(47, 93, 98);
}

.pagoda-section-tint-labels .label-body {
  fill: rgb(137, 94, 33);
}

.pagoda-section-tint-labels .label-base {
  fill: rgb(72, 92, 53);
}

.pagoda-section-guides text {
  display: none;
  paint-order: stroke fill;
  stroke: #fff;
  stroke-width: 2px;
  fill: var(--accent);
  font-size: 2.3px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
  filter: url(#label-shadow);
}

.pagoda-svg-labels line {
  stroke: rgba(32, 33, 36, .7);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.pagoda-svg-labels .target-dot {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  filter: url(#label-shadow);
}

.pagoda-svg-labels rect {
  fill: rgba(255, 255, 255, .96);
  stroke: rgba(32, 33, 36, .78);
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
  filter: url(#label-shadow);
}

.pagoda-svg-labels g rect:nth-of-type(2) {
  fill: var(--ink);
  stroke: var(--ink);
}

.pagoda-svg-labels text {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
}

.pagoda-svg-labels text[text-anchor="start"] {
  text-anchor: start;
}

.pagoda-svg-labels .label-num {
  fill: #fff;
  font-size: 16px;
}

.structure-label {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  border: 1px solid rgba(32, 33, 36, .76);
  border-radius: 6px;
  padding: 3px 7px 3px 4px;
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(32, 33, 36, .16);
}

.structure-label span {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.structure-label::after {
  content: "";
  position: absolute;
  top: 50%;
  width: var(--line-width, 100px);
  border-top: 2px solid rgba(32, 33, 36, .62);
}

.label-1::after,
.label-2::after,
.label-3::after,
.label-4::after,
.label-5::after,
.label-6::after,
.label-7::after,
.label-8::after,
.label-13::after,
.label-14::after,
.label-17::after,
.label-18::after,
.label-19::after {
  left: 100%;
}

.label-9::after,
.label-10::after,
.label-11::after,
.label-12::after,
.label-15::after,
.label-16::after {
  right: 100%;
}

.label-1 { left: 28px; top: 42px; --line-width: 220px; }
.label-2 { left: 28px; top: 72px; --line-width: 218px; }
.label-3 { left: 28px; top: 102px; --line-width: 214px; }
.label-4 { left: 28px; top: 132px; --line-width: 210px; }
.label-5 { left: 28px; top: 162px; --line-width: 208px; }
.label-6 { left: 28px; top: 192px; --line-width: 210px; }
.label-7 { left: 28px; top: 222px; --line-width: 216px; }
.label-8 { left: 28px; top: 252px; --line-width: 218px; }
.label-9 { right: 28px; top: 318px; --line-width: 145px; }
.label-10 { right: 28px; top: 356px; --line-width: 145px; }
.label-11 { right: 28px; top: 396px; --line-width: 158px; }
.label-12 { right: 28px; top: 454px; --line-width: 142px; }
.label-13 { left: 28px; top: 520px; --line-width: 150px; }
.label-14 { left: 28px; top: 580px; --line-width: 160px; }
.label-15 { right: 28px; top: 646px; --line-width: 158px; }
.label-16 { right: 28px; top: 688px; --line-width: 156px; }
.label-17 { left: 28px; top: 760px; --line-width: 120px; }
.label-18 { left: 28px; top: 818px; --line-width: 130px; }
.label-19 { left: 28px; bottom: 62px; --line-width: 170px; }

.pagoda-figure > svg:not(.pagoda-annotation-overlay) {
  display: none;
  width: min(100%, 580px);
  min-width: 420px;
  height: auto;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, .42);
  box-shadow: 0 12px 28px rgba(47, 45, 35, .22);
}

.pagoda-figure figcaption {
  margin: 10px auto 0;
  max-width: 740px;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
}

.pagoda-terms {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

.pagoda-number-note {
  margin: 0;
  border: 1px solid rgba(47, 93, 98, .34);
  border-radius: 8px;
  padding: 11px 14px;
  background: linear-gradient(135deg, rgba(74, 128, 139, .14), rgba(104, 125, 78, .12));
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.5;
  box-shadow: 0 8px 18px rgba(32, 33, 36, .05);
}

.pagoda-section-divider {
  height: 0;
  margin: 8px 0 2px;
  border: 0;
  border-top: 2px solid rgba(47, 93, 98, .42);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .85);
}

.pagoda-explainer ol,
.pagoda-terms ol {
  margin: 0;
  padding-left: 22px;
  color: #263638;
  font-size: 12px;
  line-height: 1.52;
}

.pagoda-explainer li + li,
.pagoda-terms li + li {
  margin-top: 5px;
}

.pagoda-explainer li::marker,
.pagoda-terms li::marker {
  color: var(--section-accent, var(--accent));
  font-weight: 900;
}

.pagoda-explainer strong,
.pagoda-terms strong {
  color: var(--section-accent, var(--ink));
  font-weight: 900;
}

.site-explorer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #fbfbf8;
  padding: 18px 14px;
}

.tree-section-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.explorer-title {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.site-tree {
  flex: 1 1 auto;
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  font-family: "Cascadia Mono", "Consolas", "Malgun Gothic", monospace;
}

.recent-upload-panel {
  flex: 0 0 min(34vh, 300px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 150px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.recent-upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.recent-upload-header h2 {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
}

.recent-upload-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 18px;
  border-radius: 999px;
  padding: 0 6px;
  background: rgba(47, 93, 98, .14);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.recent-upload-list {
  display: grid;
  align-content: start;
  gap: 11px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.recent-upload-date-group {
  display: grid;
  gap: 4px;
}

.recent-upload-date-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.recent-upload-items {
  display: grid;
  gap: 2px;
}

.recent-upload-item {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 5px 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  word-break: keep-all;
}

.recent-upload-item:hover {
  background: #f0efea;
}

.recent-upload-item.active {
  background: var(--accent);
  color: #fff;
}

.recent-upload-item.missing {
  color: #8a8b86;
  cursor: default;
}

.recent-upload-item.missing:hover {
  background: transparent;
}

.recent-upload-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
}

.recent-upload-item.active .recent-upload-meta {
  color: rgba(255, 255, 255, .78);
}

.recent-upload-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e4e1d6;
  color: #6b6a5f;
  font-size: 9px;
  font-weight: 800;
  vertical-align: middle;
}

.recent-upload-item.active .recent-upload-badge {
  background: rgba(255, 255, 255, .25);
  color: #fff;
}

.recent-upload-badge-registered {
  background: #dbe7dc;
  color: #3f6b4a;
}

.recent-upload-item.active .recent-upload-badge-registered {
  background: rgba(255, 255, 255, .3);
  color: #fff;
}

.recent-upload-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tree-section {
  position: relative;
  padding-left: 14px;
}

.tree-root-summary {
  position: relative;
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  margin: 0 0 4px -14px;
  border-radius: 6px;
  padding: 5px 6px 5px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  list-style: none;
}

.tree-root-summary::-webkit-details-marker {
  display: none;
}

.tree-root-summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1px solid #a9aaa4;
  border-radius: 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.tree-section[open] > .tree-root-summary::before {
  content: "-";
}

.tree-root-summary:hover {
  background: #f0efea;
}

.tree-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 18px;
  border-radius: 999px;
  background: #e7e6df;
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-folder {
  position: relative;
  margin: 0;
  padding-left: 20px;
}

.tree-folder::before {
  content: none;
}

.tree-section[open] > .tree-folder::after {
  content: none;
}

.tree-section[open] > .tree-folder:last-child::after {
  bottom: calc(100% - 15px);
}

.tree-folder summary {
  position: relative;
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border-radius: 6px;
  padding: 5px 8px 5px 0;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style: none;
}

.tree-folder summary::-webkit-details-marker {
  display: none;
}

.tree-folder summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1px solid #a9aaa4;
  border-radius: 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.tree-folder[open] > summary::before {
  content: "-";
}

.tree-folder[open] > summary .tree-count,
.tree-section[open] > .tree-root-summary .tree-count {
  background: rgba(47, 93, 98, 0.14);
  color: var(--accent);
}

.tree-nested-list {
  display: grid;
  gap: 2px;
  margin: 0 0 4px 6px;
  padding-left: 12px;
}

.tree-type,
.tree-locality {
  padding-left: 14px;
}

.tree-type summary,
.tree-locality summary {
  min-height: 28px;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
}

.tree-type .tree-count,
.tree-locality .tree-count {
  min-width: 20px;
}

.tree-folder summary:hover {
  background: #f0efea;
}

.tree-list {
  position: relative;
  display: grid;
  gap: 0;
  margin: 0 0 4px 6px;
  padding-left: 14px;
  border-left: 0;
}

.tree-list.tree-nested-list {
  margin: 0 0 4px 14px;
  padding-left: 0;
  border-left: 0;
}

.tree-list.tree-nested-list > .tree-type {
  padding-left: 0;
}

.tree-list.tree-nested-list > .tree-type::before {
  content: none;
}

.tree-list.tree-nested-list > .tree-type:last-child::after {
  content: none;
}

.tree-site {
  position: relative;
  min-height: 28px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 5px 8px 5px 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  word-break: keep-all;
}

.tree-site::before {
  content: none;
}

.tree-site:last-child::after {
  content: none;
}

.tree-type-section .tree-folder {
  padding-left: 14px;
}

.tree-type-section .tree-folder::before,
.tree-type-section .tree-section::after,
.tree-type-section .tree-folder::after,
.tree-type-section .tree-site::before,
.tree-type-section .tree-site::after {
  content: none;
}

.tree-type-section .tree-list,
.tree-type-section .tree-list.tree-nested-list {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 0;
}

.tree-type-section .tree-type,
.tree-region-section .tree-locality {
  padding-left: 10px;
}

.tree-type-section .tree-site {
  min-height: 26px;
  padding-left: 8px;
}

.tree-site:hover {
  background: #f0efea;
}

.tree-site.active {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.tree-home {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  width: 100%;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #f2f1ea;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.tree-home::before {
  content: "◎";
  color: var(--accent);
  font-size: 14px;
}

.tree-home:hover {
  background: #f0efea;
}

.tree-home.active {
  background: var(--accent);
  color: #fff;
}

.tree-home.active::before {
  color: #fff;
}

.gallery {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  gap: 8px;
}

.site-summary {
  min-height: 24px;
}

.site-summary p,
.source,
.loading {
  color: var(--muted);
  font-size: 13px;
}

.asset-set {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.overview-page {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 24vw, 360px);
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.overview-map-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.overview-map {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e8e7e2;
  overflow: hidden;
}

.visit-planner {
  display: grid;
  grid-auto-rows: auto;
  align-content: start;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.visit-planner.is-drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, #fbfaf6);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

.visit-planner h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
}

.visit-planner-summary,
.visit-plan-empty,
.visit-search-empty,
.visit-search-count {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.visit-search {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  border-radius: 6px;
  background: #f7f6f1;
}

.visit-search input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.visit-search-results {
  display: grid;
  gap: 0;
  max-height: min(42vh, 420px);
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  overflow: auto;
}

.visit-search-count {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 5px 2px 4px;
  background: #f7f6f1;
  font-weight: 800;
}

.visit-search-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  padding: 3px 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: transparent;
}

.visit-search-result:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.visit-search-result[draggable="true"],
.overview-map .leaflet-marker-icon[draggable="true"],
.fallback-marker[draggable="true"] {
  cursor: grab;
}

.visit-search-result[draggable="true"]:active,
.overview-map .leaflet-marker-icon[draggable="true"]:active,
.fallback-marker[draggable="true"]:active {
  cursor: grabbing;
}

.visit-search-result-info {
  display: grid;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.visit-search-result-info strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-planner-actions,
.visit-plan-controls {
  display: flex;
  gap: 6px;
}

.visit-planner-actions {
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.visit-planner-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.visit-planner-button.is-compact {
  min-height: 24px;
  padding: 0 7px;
  font-size: 12px;
}

.visit-planner-button.is-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.visit-planner-button.is-icon {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  border-color: color-mix(in srgb, var(--line) 65%, transparent);
  background: #f7f6f1;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
}

.visit-planner-button:hover:not(:disabled),
.visit-planner-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.visit-planner-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.visit-plan-list {
  display: grid;
  gap: 4px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  counter-reset: visit-plan;
}

.visit-plan-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 32px;
  padding: 4px 6px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 6px;
  background: #fbfaf6;
  counter-increment: visit-plan;
}

.visit-plan-list li:nth-child(even) {
  background: #e7f1f0;
}

.visit-plan-list li:nth-child(odd) {
  background: #fffaf0;
}

.visit-plan-list li:nth-child(even) .visit-plan-name::before {
  background: #2f6b70;
}

.visit-plan-list li:nth-child(odd) .visit-plan-name::before {
  background: #8b5a2b;
}

.visit-plan-list li:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  background: #fff;
}

.visit-plan-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}

.visit-plan-header strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.visit-plan-header span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}

.visit-plan-info {
  min-width: 0;
}

.visit-plan-name {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-plan-name::before {
  content: counter(visit-plan);
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.visit-plan-controls {
  flex-shrink: 0;
  gap: 3px;
}

.visit-copy-box {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  border-radius: 6px;
  background: #f7f6f1;
}

.visit-copy-box strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.visit-copy-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.visit-planner-button.is-copy {
  min-height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.visit-copy-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.overview-map.hide-labels .marker-label,
.overview-map.hide-labels .fallback-marker span {
  display: none;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--panel);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.legend-toggle.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--accent);
}

.legend-total {
  font-weight: 800;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  background: var(--panel);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.legend-item.is-active {
  opacity: 1;
  border-color: transparent;
  color: var(--ink);
}

.legend-icon,
.marker-symbol,
.fallback-marker b {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.24);
}

.legend-icon {
  width: 22px;
  height: 22px;
  border-width: 1px;
  font-size: 12px;
  box-shadow: none;
}

.legend-icon.pagoda,
.heritage-marker.pagoda .marker-symbol,
.fallback-marker.pagoda b {
  background: #8b5a2b;
}

.legend-icon.buddha,
.heritage-marker.buddha .marker-symbol,
.fallback-marker.buddha b {
  background: var(--accent);
}

.legend-icon.stele,
.heritage-marker.stele .marker-symbol,
.fallback-marker.stele b {
  background: #475569;
}

.legend-icon.fortress,
.heritage-marker.fortress .marker-symbol,
.fallback-marker.fortress b {
  background: #5f6f3a;
}

.legend-icon.tomb,
.heritage-marker.tomb .marker-symbol,
.fallback-marker.tomb b {
  background: #8f3d5f;
  border-color: #4a1830;
}

.legend-icon.other,
.heritage-marker.other .marker-symbol,
.fallback-marker.other b {
  background: #5f6870;
}

.legend-icon.other,
.legend-icon.stele,
.legend-icon.fortress {
  font-size: 13px;
}

.heritage-div-icon {
  background: transparent;
  border: 0;
}

.heritage-marker {
  position: relative;
  display: grid;
  justify-items: center;
  pointer-events: auto;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.overview-map.has-search-matches .leaflet-marker-icon:not(.is-map-focus) .heritage-marker,
.overview-map.has-search-matches .fallback-marker:not(.is-map-focus) {
  opacity: 0.45;
  filter: grayscale(0.5) saturate(0.65);
}

.overview-map .leaflet-marker-icon.is-search-match {
  z-index: 900 !important;
}

.overview-map .leaflet-marker-icon.is-search-match .heritage-marker .marker-symbol,
.overview-map .fallback-marker.is-search-match b {
  border-color: #fff8bd;
  box-shadow:
    0 0 0 4px rgba(246, 197, 78, 0.42),
    0 6px 18px rgba(0, 0, 0, 0.34);
}

.overview-map .leaflet-marker-icon.is-search-match .marker-label,
.overview-map .fallback-marker.is-search-match span {
  color: #111827;
  font-weight: 900;
}

.overview-map .leaflet-marker-icon.is-in-visit-plan,
.overview-map .fallback-marker.is-in-visit-plan {
  z-index: 950 !important;
}

.map-plan-badge {
  position: absolute;
  right: 38px;
  bottom: 16px;
  z-index: 3;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #ff0000;
  color: #fff;
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

.fallback-marker .map-plan-badge {
  right: 48px;
  bottom: -2px;
}

.map-plan-route-svg {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-plan-route-svg polyline {
  fill: none;
  stroke: #ff0000;
  stroke-width: 0.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.marker-label {
  max-width: 148px;
  margin-bottom: 4px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.95),
    1px 0 2px rgba(255, 255, 255, 0.95),
    0 -1px 2px rgba(255, 255, 255, 0.95),
    -1px 0 2px rgba(255, 255, 255, 0.95);
}

.heritage-marker.pagoda .marker-label {
  color: #704516;
}

.heritage-marker.buddha .marker-label {
  color: var(--accent);
}

.heritage-marker.stele .marker-label {
  color: #334155;
}

.heritage-marker.fortress .marker-label {
  color: #4d5b2c;
}

.heritage-marker.tomb .marker-label {
  color: #7a2f4d;
}

.heritage-marker.other .marker-label {
  color: #4c555b;
}

.overview-map-fallback {
  position: relative;
  background:
    linear-gradient(135deg, rgba(47, 93, 98, 0.08), rgba(139, 90, 43, 0.08)),
    #e8e7e2;
}

.fallback-marker {
  position: absolute;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 150px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -100%);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.fallback-marker span {
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.95),
    1px 0 2px rgba(255, 255, 255, 0.95),
    0 -1px 2px rgba(255, 255, 255, 0.95),
    -1px 0 2px rgba(255, 255, 255, 0.95);
}

.fallback-marker.pagoda span {
  color: #704516;
}

.fallback-marker.buddha span {
  color: var(--accent);
}

.fallback-marker.stele span {
  color: #334155;
}

.fallback-marker.fortress span {
  color: #4d5b2c;
}

.fallback-marker.tomb span {
  color: #7a2f4d;
}

.fallback-marker.other span {
  color: #4c555b;
}

.map-site-leaflet-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  background: #f8f7f3;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .28);
}

.map-site-leaflet-popup .leaflet-popup-content {
  width: 210px;
  margin: 10px;
}

.map-site-popup-card {
  display: grid;
  gap: 7px;
  width: 210px;
  color: var(--ink);
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
}

.map-site-popup-image-link {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
}

.map-site-popup-image-link img {
  display: block;
  width: 100%;
  height: 128px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.map-site-popup-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.28;
  text-align: center;
  text-decoration: none;
}

.map-site-popup-title:hover,
.map-site-popup-title:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.map-site-popup-meta {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}

.map-site-fallback-popup {
  position: absolute;
  z-index: 8;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f7f3;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .28);
  transform: translate(-50%, -106%);
}

.map-site-hover-preview {
  position: absolute;
  z-index: 900;
  width: 230px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f7f3;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .28);
  pointer-events: none;
}

.map-site-hover-preview .map-site-popup-card {
  width: 100%;
}

.map-site-fallback-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px;
  background: rgba(38, 41, 42, .9);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.result-workspace {
  display: grid;
  grid-template-columns: clamp(116px, 9vw, 140px) minmax(0, 1fr) clamp(260px, 22vw, 320px);
  height: 100%;
  min-height: 0;
  gap: 10px;
}

.original-gallery {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border-right: 1px solid var(--line);
  padding-right: 10px;
}

.original-gallery h4 {
  margin-bottom: 8px;
  color: var(--muted);
}

.original-strip {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.original-thumb {
  position: relative;
  width: 100%;
  height: 78px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f5f0;
  cursor: pointer;
  overflow: hidden;
}

.original-thumb:focus-visible,
.modal-close:focus-visible,
.modal-nav:focus-visible {
  outline: 3px solid rgba(47, 93, 98, 0.35);
  outline-offset: 2px;
}

.original-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.derived-thumb {
  border-color: rgba(47, 93, 98, 0.55);
}

.thumb-index {
  position: absolute;
  left: 6px;
  bottom: 6px;
  min-width: 38px;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(20, 21, 20, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.thumb-kind {
  position: absolute;
  right: 6px;
  bottom: 6px;
  max-width: calc(100% - 54px);
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(47, 93, 98, 0.88);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.pair-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  gap: 10px;
  align-items: stretch;
}

.result-figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e8e7e2;
  overflow: hidden;
}

.result-figure img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 6px;
  object-fit: contain;
  object-position: center center;
  transform: scale(var(--result-image-scale, 1));
  transform-origin: var(--result-image-origin-x, 50%) var(--result-image-origin-y, 50%);
}

.result-figure figcaption {
  min-height: 28px;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.comparison {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e8e7e2;
  object-fit: contain;
  object-position: center top;
}

.source {
  margin: 8px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sign-panel {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  padding-left: 14px;
  color: var(--ink);
}

.sign-panel h4 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}

.sign-subtitle,
.sign-meta,
.sign-empty {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.sign-fact {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 6px;
  padding: 7px 8px;
  background: #fff;
  background: color-mix(in srgb, var(--accent) 7%, #fff);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.sign-fact span {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 700;
}

.sign-fact strong {
  min-width: 0;
  color: var(--accent);
  font-weight: 900;
}

.buddha-kind {
  margin-top: -2px;
}

.sign-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 4px;
}

.sign-title-row h5 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.heritage-link,
.reference-link {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  max-width: 96px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 0 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.reference-link {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
}

.heritage-link:hover,
.reference-link:hover {
  filter: brightness(1.08);
}

.sign-section {
  margin-top: 12px;
}

.map-panel {
  margin: 12px 0 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafaf8;
}

.map-panel h5 {
  margin: 0 0 8px;
  font-size: 13px;
}

.map-address,
.map-coords,
.map-source {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  word-break: keep-all;
}

.map-coords,
.map-source {
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
}

.map-panel iframe {
  display: block;
  width: 100%;
  height: 168px;
  border: 0;
  border-radius: 5px;
  background: #e8e7e2;
}

.map-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.map-links a {
  display: grid;
  place-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.map-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sign-section p {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.62;
}

.lit-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.lit-section h5 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink);
}

.lit-empty {
  color: var(--muted);
  font-size: 12px;
}

.lit-entry {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafafa;
}

.lit-source {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.lit-quote {
  margin: 0 0 4px;
  font-size: 13px;
  font-style: italic;
  color: var(--ink);
}

.lit-translation,
.lit-note {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.lit-source-link {
  font-size: 12px;
  color: var(--accent);
}

.sign-en {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sign-en p,
.sign-zh p {
  font-size: 12px;
  line-height: 1.5;
}

.sign-zh {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(22, 23, 23, 0.72);
  touch-action: none;
}

.modal {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(1100px, 100%);
  max-height: calc(100vh - 40px);
  padding: 14px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.modal-image-wrap {
  position: relative;
  overflow: hidden;
  max-height: calc(100vh - 122px);
  touch-action: none;
}

.modal-image-wrap.is-zoomed {
  cursor: grab;
}

.modal-image-wrap.is-zoomed.is-dragging {
  cursor: grabbing;
}

.modal img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 122px);
  object-fit: contain;
  background: #f5f4ef;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  user-select: none;
}

.modal-image-wrap.is-dragging img {
  transition: none;
}

.modal-date {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
}

.modal-date[hidden] {
  display: none;
}

.modal-caption {
  margin: 10px 56px 0 0;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.modal-close,
.modal-nav {
  z-index: 2;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  cursor: pointer;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 24px;
  line-height: 1;
}

.modal-nav {
  position: absolute;
  top: 50%;
  width: 42px;
  height: 58px;
  border-radius: 999px;
  font-size: 42px;
  line-height: 0.8;
  transform: translateY(-50%);
}

.modal-nav:disabled {
  opacity: 0.28;
  cursor: default;
}

.modal-prev {
  left: 24px;
}

.modal-next {
  right: 24px;
}

@media (max-width: 900px) {
  main {
    width: min(100% - 18px, 1440px);
    height: auto;
    min-height: 100vh;
    margin: 0 auto;
    padding-top: 12px;
  }

  .app-header {
    display: grid;
    align-items: start;
  }

  code {
    white-space: normal;
  }

  .gallery,
  .asset-set {
    min-height: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .site-explorer {
    position: static;
    width: auto;
    height: auto;
    max-height: 320px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }

  .site-tree {
    max-height: 180px;
  }

  .recent-upload-panel {
    flex-basis: 116px;
    min-height: 116px;
  }

  .result-workspace {
    grid-template-columns: 1fr;
  }

  .original-gallery {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 10px;
  }

  .original-strip {
    grid-auto-flow: column;
    grid-auto-columns: 96px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .original-thumb {
    height: 72px;
  }

  .comparison {
    height: auto;
  }

  .pair-view {
    grid-template-columns: 1fr;
  }


  .result-figure {
    min-height: 360px;
  }

  .sign-panel {
    max-height: 360px;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 10px 0 0;
  }

  .source {
    white-space: normal;
  }

  .reference-main {
    width: min(100% - 18px, 1120px);
    margin: 0 auto;
  }

  .reference-header,
  .pagoda-reference-board {
    grid-template-columns: 1fr;
  }

  .reference-header {
    display: grid;
    align-items: start;
  }

  .pagoda-terms {
    grid-template-columns: 1fr;
  }

  .pagoda-explainer {
    grid-template-rows: none;
    min-height: 0;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    max-height: calc(100vh - 20px);
    padding: 10px;
  }

  .modal-image-wrap,
  .modal img {
    max-height: calc(100vh - 98px);
  }

  .modal-prev {
    left: 14px;
  }

  .modal-next {
    right: 14px;
  }
}

.mobile-back-button {
  display: none;
}

.compare-tabs {
  display: none;
}

.scroll-top-button {
  display: none;
}

@media (max-width: 640px) {
  body {
    overflow: auto;
  }

  main {
    display: block;
    width: 100%;
    height: auto;
    min-height: 100vh;
    margin: 0;
    padding: 0;
  }

  .app-header {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 14px 8px;
  }

  body:not(.mobile-detail-active) .app-header {
    position: sticky;
    top: 0;
    background: var(--paper);
  }

  body.mobile-detail-active .app-header {
    display: none;
  }

  .app-title {
    text-align: center;
  }

  .eyebrow {
    display: none;
  }

  .eyebrow-mobile {
    display: block;
    position: absolute;
    top: 10px;
    right: 14px;
    margin: 0;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
  }

  .site-search {
    max-width: none;
    width: 90%;
    justify-self: center;
  }

  .header-actions {
    justify-content: center;
  }

  .site-search-input {
    height: 40px;
    padding: 0 40px;
  }

  .site-search-icon {
    left: 14px;
  }

  .site-search-clear {
    right: 6px;
  }

  .explorer-title {
    position: sticky;
    top: 131px;
    z-index: 15;
    margin-bottom: 0;
    padding: 8px 0;
    background: #fbfbf8;
  }

  .recent-upload-header {
    position: sticky;
    top: 131px;
    z-index: 15;
    margin-bottom: 0;
    padding: 8px 0;
    background: #fbfbf8;
  }

  .app-shell {
    display: block;
    height: auto;
  }

  .site-explorer {
    display: none;
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 12px 14px;
  }

  .site-tree {
    max-height: none;
    overflow-y: visible;
  }

  .recent-upload-panel {
    flex: none;
    min-height: auto;
  }

  .recent-upload-list {
    overflow-y: visible;
  }

  .gallery {
    display: none;
    height: auto;
    padding: 0 14px 24px;
  }

  body:not(.mobile-detail-active) .site-explorer {
    display: flex;
  }

  body.mobile-detail-active .gallery {
    display: grid;
  }

  .mobile-back-button {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1030;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    padding: 12px 14px;
    cursor: pointer;
  }

  body.mobile-detail-active .mobile-back-button {
    display: block;
  }

  body.mobile-detail-active .site-summary {
    position: sticky;
    top: 43px;
    z-index: 15;
    text-align: center;
    padding-top: 8px;
    padding-bottom: 8px;
    background: var(--paper);
  }

  .asset-set {
    overflow: visible;
  }

  .sign-panel {
    height: auto;
    max-height: none;
    overflow-y: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 10px;
  }

  .sign-panel h4 {
    top: 85px;
    z-index: 15;
    background: var(--paper);
  }

  .original-thumb {
    min-height: 44px;
  }

  .tree-folder summary,
  .tree-section summary {
    min-height: 22px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .tree-site {
    min-height: 26px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .site-search-result {
    padding: 5px 12px;
  }

  .site-search-result-meta {
    margin-top: 0;
  }

  .overview-page {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 58vh) auto;
    height: auto;
  }

  .overview-map-area {
    min-height: 360px;
  }

  .overview-map {
    min-height: 320px;
  }

  .visit-planner {
    max-height: none;
  }

  .sign-panel p {
    font-size: 15px;
    line-height: 1.6;
  }

  .compare-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
  }

  .compare-tab {
    flex: 1;
    padding: 5px 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  .compare-tab.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
  }

  .pair-view[data-compare-view="line"] .compare-photo {
    display: none;
  }

  .pair-view[data-compare-view="photo"] .compare-line {
    display: none;
  }

  .reference-main {
    width: min(100% - 18px, 1120px);
    padding: 14px 0 32px;
  }

  .reference-header {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 12px;
    padding-top: 10px;
    padding-bottom: 10px;
    background: var(--paper);
  }

  .reference-deity-group-header,
  .pagoda-period-header {
    position: sticky;
    top: 95px;
    z-index: 15;
    padding-top: 6px;
    padding-bottom: 6px;
    background: var(--paper);
  }

  .pagoda-figure {
    position: static;
    padding: 8px;
  }

  .pagoda-actual-figure {
    width: 100%;
    min-width: 0;
  }

  .pagoda-actual-figure img {
    /* The image file (941x1672) is narrower than the annotation
       overlay's hand-tuned viewBox (0 0 1180 1672) -- desktop's fixed
       740px container / 590px image widths happened to preserve the
       740/1180 ~= 590/941 ratio, leaving a margin to the right of the
       image (still inside the container) sized for the right-side
       labels, with the overlay stretched to the full container so its
       coordinate scale matches the image's real scale. Reproduce that
       same ~590/740 ratio responsively instead of matching the image
       to the container 1:1, or the overlay compresses (labels drift
       left of their real targets) or the right-side label boxes get
       clipped with no margin left to hold them. */
    width: 79.7%;
    height: auto;
  }

  .pagoda-figure > svg:not(.pagoda-annotation-overlay) {
    width: 100%;
    height: auto;
  }

  .scroll-top-button {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 20px;
    z-index: 1040;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
    cursor: pointer;
  }

  .scroll-top-button.is-visible {
    display: flex;
  }
}
