:root {
  color-scheme: light;
  --paper: #d8c9a5;
  --paper-light: #eadfbe;
  --ink: #272722;
  --muted: #6d6657;
  --rule: #887c63;
  --red: #8f2e33;
  --blue: #345e70;
  --shadow: rgba(54, 45, 31, .28);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 8%, rgba(255,255,255,.24), transparent 24rem),
    linear-gradient(135deg, #b7a57e, #d7c7a1 45%, #b9a883);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  overflow: hidden;
}

button, input, select { font: inherit; }

.paper-noise {
  position: fixed;
  inset: 0;
  opacity: .16;
  pointer-events: none;
  background-image:
    repeating-radial-gradient(circle at 20% 30%, rgba(55,45,30,.24) 0 1px, transparent 1px 4px);
  mix-blend-mode: multiply;
  z-index: 20;
}

.archive-header {
  height: 108px;
  padding: 17px 28px 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(232, 220, 186, .96);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 5px 18px var(--shadow);
  position: relative;
  z-index: 5;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--red);
  font: 700 11px/1.2 "Microsoft YaHei", sans-serif;
  letter-spacing: .2em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 38px);
  letter-spacing: .14em;
}

.subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .14em;
}

.archive-stamp {
  min-width: 165px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 10px;
  border: 3px double var(--red);
  color: var(--red);
  transform: rotate(-1deg);
  text-align: center;
}

.archive-stamp span { font-size: 11px; letter-spacing: .18em; }
.archive-stamp strong { grid-row: span 2; font-size: 23px; letter-spacing: .12em; }
.archive-stamp a {
  color: var(--blue);
  font: 12px "Microsoft YaHei", sans-serif;
  text-decoration: none;
  border-top: 1px solid currentColor;
}

.workspace {
  height: calc(100vh - 142px);
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr) 0;
  position: relative;
  transition: grid-template-columns .25s ease;
}

.workspace:has(.dossier.open) {
  grid-template-columns: 285px minmax(0, 1fr) 350px;
}

.control-panel, .dossier {
  background: rgba(231, 219, 186, .96);
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--rule);
}

.panel-section { padding: 15px 18px; border-bottom: 1px solid rgba(72,65,53,.26); }

.section-heading { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.section-heading > span {
  color: var(--red);
  font: 700 10px "Courier New", monospace;
}
.section-heading h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: .12em;
}

label > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font: 11px "Microsoft YaHei", sans-serif;
}

input, select {
  width: 100%;
  padding: 8px 9px;
  color: var(--ink);
  background: rgba(255, 249, 226, .54);
  border: 1px solid var(--rule);
  border-radius: 0;
  outline: none;
}
input:focus, select:focus { border-color: var(--red); box-shadow: 0 0 0 2px rgba(143,46,51,.12); }

.field-note { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.filter-grid label:last-child { grid-column: 1 / -1; }

.layer-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.layer-list label {
  font: 12px "Microsoft YaHei", sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
}
.layer-list input { width: auto; accent-color: var(--red); }

.place-index { min-height: 0; }
.result-count { margin: -4px 0 8px; color: var(--muted); font-size: 11px; }
#place-list { list-style: none; padding: 0; margin: 0; }
#place-list button {
  width: 100%;
  padding: 8px 6px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px dashed rgba(66,61,51,.25);
  text-align: left;
  cursor: pointer;
}
#place-list button:hover, #place-list button.active { color: var(--red); background: rgba(255,250,228,.55); }
#place-list small { color: var(--muted); font-family: "Courier New", monospace; }

.map-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr; background: var(--paper); }
.map-toolbar {
  min-height: 46px;
  padding: 7px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  background: rgba(217,204,168,.94);
  font-size: 12px;
}
.map-toolbar strong { margin-right: 8px; color: var(--red); letter-spacing: .08em; }
.map-toolbar span { color: var(--muted); }
.map-actions { display: flex; gap: 5px; }
.map-actions button {
  min-width: 31px;
  padding: 4px 8px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  cursor: pointer;
}
.map-actions button:hover { border-color: var(--red); color: var(--red); }

.map-frame { position: relative; min-height: 0; overflow: hidden; }
#map { width: 100%; height: 100%; display: block; background: #d8cba7; user-select: none; }

.leaflet-container {
  background: #d8cba7;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
}
.leaflet-control-zoom,
.leaflet-control-scale-line {
  border: 1px solid var(--rule) !important;
  border-radius: 0 !important;
  box-shadow: 2px 3px 7px var(--shadow) !important;
}
.leaflet-control-zoom a {
  color: var(--ink);
  background: rgba(235,223,189,.92);
  border-radius: 0 !important;
}
.leaflet-control-zoom a:hover { color: var(--red); background: var(--paper-light); }
.leaflet-control-scale-line {
  color: var(--ink);
  background: rgba(235,223,189,.82);
  border-top: 0 !important;
  font-family: "Microsoft YaHei", sans-serif;
}
.historical-tile { filter: saturate(.82) contrast(.97); }

.place-map-label {
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  border: 0;
  background: transparent;
  pointer-events: none;
  transition: opacity .12s ease;
}
.place-map-label span {
  position: relative;
  display: block;
  width: max-content;
  max-width: 170px;
  padding: 3px 7px 3px 8px;
  color: #292925;
  background: rgba(239, 227, 195, .94);
  border: 1px solid rgba(80, 71, 55, .72);
  box-shadow: 1px 2px 3px rgba(54,45,31,.22);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: .05em;
  white-space: nowrap;
}
.place-map-label span::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 16px;
  width: 11px;
  border-top: 1px solid rgba(80, 71, 55, .78);
  transform: rotate(-24deg);
  transform-origin: right center;
}
.place-map-label.is-selected { z-index: 1000 !important; }
.place-map-label.is-selected span {
  color: #fff4d7;
  background: var(--red);
  border-color: #652126;
  box-shadow: 0 0 0 2px rgba(244,232,199,.85), 2px 3px 7px var(--shadow);
}
.place-map-label.is-hidden { display: none !important; }
.place-map-marker,
.place-map-area { cursor: pointer; }

.feature-district { stroke: #5f594c; stroke-width: 1.2; stroke-dasharray: 6 4; fill-opacity: .36; }
.feature-industrial { fill: #876c55; fill-opacity: .17; stroke: #725947; stroke-width: 1.5; stroke-dasharray: 4 3; }
.feature-water { fill: none; stroke: #547a88; stroke-opacity: .62; stroke-linecap: round; }
.feature-road { fill: none; stroke: #6f6552; stroke-width: 2.2; stroke-linecap: round; }
.feature-rail { fill: none; stroke: #343434; stroke-width: 2.2; stroke-dasharray: 7 4; }
.feature-bridge { fill: none; stroke: #8e2f34; stroke-width: 3.2; }
.feature-label { fill: #4f493d; font-size: 12px; letter-spacing: .08em; paint-order: stroke; stroke: #d9cba8; stroke-width: 3px; }

.place-marker { cursor: pointer; }
.place-marker circle { fill: #f3e8c7; stroke: var(--red); stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.place-marker.estimated circle { stroke-dasharray: 3 2; }
.place-marker:hover circle, .place-marker.selected circle { fill: var(--red); stroke: #f2e4bf; }
.place-marker text { fill: #2c2b27; font-size: 10px; paint-order: stroke; stroke: #e4d7b6; stroke-width: 3px; pointer-events: none; }
.place-area { fill: rgba(143,46,51,.08); stroke: var(--red); stroke-width: 1.8; stroke-dasharray: 5 3; cursor: pointer; vector-effect: non-scaling-stroke; }

.map-legend {
  position: absolute;
  left: 15px;
  bottom: 14px;
  padding: 7px 10px;
  display: flex;
  gap: 12px;
  background: rgba(235,223,189,.88);
  border: 1px solid var(--rule);
  box-shadow: 2px 3px 7px var(--shadow);
  font: 10px "Microsoft YaHei", sans-serif;
  z-index: 500;
}
.map-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; display: inline-block; border: 2px solid var(--red); border-radius: 50%; background: #eee2c1; }
.legend-dot.estimated { border-style: dashed; }
.legend-line { width: 17px; display: inline-block; border-top: 2px dashed var(--ink); }
.legend-line.route { border-color: var(--red); }
.trajectory-line { fill: none; stroke: var(--red); stroke-width: 2.4; stroke-dasharray: 7 5; opacity: .72; vector-effect: non-scaling-stroke; }
.trajectory-node { fill: var(--paper-light); stroke: var(--red); stroke-width: 2; vector-effect: non-scaling-stroke; }

.map-status {
  position: absolute;
  right: 14px;
  bottom: 10px;
  padding: 5px 8px;
  color: var(--muted);
  background: rgba(235,223,189,.84);
  font-size: 10px;
  z-index: 500;
}

.dossier {
  border-left: 1px solid var(--rule);
  border-right: 0;
  position: relative;
  overflow-x: hidden;
}
.dossier:not(.open) { visibility: hidden; }
.dossier > .eyebrow { padding: 20px 22px 0; }
.close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
}
#dossier-content { padding: 5px 22px 28px; }
.empty-dossier { margin-top: 38vh; text-align: center; color: var(--muted); }
.dossier h2 { margin: 5px 0; font-size: 25px; }
.dossier .archive-id { color: var(--red); font: 12px "Courier New", monospace; }
.dossier dl { display: grid; grid-template-columns: 72px 1fr; gap: 7px; font-size: 13px; }
.dossier dt { color: var(--muted); }
.dossier dd { margin: 0; }
.dossier-section { margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--rule); }
.dossier-section h3 { margin: 0 0 8px; font-size: 14px; letter-spacing: .12em; }
.dossier-section p { margin: 0; font-size: 13px; line-height: 1.75; }
.confidence-badge { display: inline-block; padding: 2px 6px; color: var(--red); border: 1px solid var(--red); font-size: 11px; }

.archive-footer {
  height: 34px;
  padding: 8px 24px;
  display: flex;
  justify-content: space-between;
  background: #2f302c;
  color: #d7caab;
  font: 10px "Microsoft YaHei", sans-serif;
  letter-spacing: .08em;
}

.hidden-layer { display: none; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .archive-header { height: auto; padding: 14px 16px; }
  .archive-stamp { display: none; }
  .workspace, .workspace:has(.dossier.open) {
    height: auto;
    min-height: calc(100vh - 128px);
    grid-template-columns: 1fr;
    grid-template-rows: auto 65vh auto;
  }
  .control-panel { border-right: 0; border-bottom: 1px solid var(--rule); }
  .control-panel .panel-section:not(.date-section):not(:nth-child(2)) { display: none; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .dossier { border-left: 0; border-top: 1px solid var(--rule); }
  .dossier:not(.open) { display: none; }
  .map-legend { flex-wrap: wrap; max-width: 70%; }
  .archive-footer { height: auto; gap: 10px; }
}
