:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", Arial, sans-serif;
  color: #182421;
  background: #eef2ef;
  --header-height: 76px;
  --panel-width: 340px;
  --line: #d8e0dc;
  --muted: #66736e;
  --green: #146a5b;
  --red: #e64b35;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body { min-width: 320px; }
button, select { font: inherit; }
button { color: inherit; }

.page-shell {
  width: 100%;
  height: 100%;
  background: #f8faf8;
}

.site-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.97);
}

.site-header h1 {
  margin: 0;
  color: #15221f;
  font-size: clamp(20px,2vw,27px);
  font-weight: 650;
  letter-spacing: .02em;
}

.site-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.project-mark {
  flex: none;
  color: #47635b;
  font-size: 12px;
  letter-spacing: .08em;
}

.workspace {
  height: calc(100% - var(--header-height));
  display: grid;
  grid-template-columns: var(--panel-width) minmax(0,1fr);
}

.control-panel {
  z-index: 2;
  min-height: 0;
  padding: 24px 22px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fff;
}

.summary {
  padding-bottom: 20px;
  border-bottom: 1px solid #e5ebe8;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
}

.total {
  margin: 0;
  color: #123f37;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 1.15;
}

.summary-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.filters { padding: 20px 0 16px; }

.filters h2 {
  margin: 0 0 15px;
  font-size: 15px;
  font-weight: 650;
}

.field-group { min-width: 0; }

.field-group label {
  display: block;
  margin: 13px 0 6px;
  color: #3f4d48;
  font-size: 12px;
}

.field-group select {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 10px;
  border: 1px solid #cbd5d0;
  border-radius: 4px;
  color: #1f2d29;
  background: #fff;
  cursor: pointer;
}

.field-group select:hover:not(:disabled) { border-color: #7e9b91; }

.field-group select:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(20,106,91,.24);
  outline-offset: 1px;
}

.field-group select:disabled {
  color: #7f8b87;
  background: #f4f6f5;
  cursor: not-allowed;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 16px 0 4px;
  padding: 3px;
  border: 1px solid #d5ddd9;
  border-radius: 5px;
  background: #f1f4f2;
}

.mode-switch button {
  height: 34px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #5c6964;
  font-size: 12px;
  cursor: pointer;
}

.mode-switch button.is-active {
  color: #173f37;
  background: #fff;
  box-shadow: 0 1px 4px rgba(25,45,38,.12);
  font-weight: 600;
}

.mode-controls[hidden] { display: none; }

.field-hint {
  margin: 7px 0 0;
  color: #89938f;
  font-size: 11px;
  line-height: 1.45;
}

.add-layer-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 62px;
  align-items: end;
  gap: 8px;
}

.add-layer-row button {
  height: 40px;
  border: 1px solid #376f63;
  border-radius: 4px;
  background: #fff;
  color: #215c50;
  font-size: 12px;
  cursor: pointer;
}

.add-layer-row button:hover:not(:disabled) { background: #eff6f3; }
.add-layer-row button:disabled { opacity: .45; cursor: not-allowed; }

.layer-list {
  display: grid;
  gap: 7px;
  margin-top: 13px;
}

.layer-item {
  display: grid;
  grid-template-columns: 13px minmax(0,1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 7px 7px 9px;
  border: 1px solid #dce3df;
  border-left: 3px solid transparent;
  border-radius: 4px;
  background: #fafbfa;
}

.layer-item.is-focused {
  border-left-color: var(--layer-color);
  background: #f4f7f5;
}

.layer-swatch {
  width: 12px;
  height: 28px;
  border-radius: 2px;
  background: var(--layer-color);
}

.layer-focus {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.layer-focus strong,
.layer-focus small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-focus strong { font-size: 12px; font-weight: 600; }
.layer-focus small { margin-top: 3px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

.layer-actions { display: flex; align-items: center; gap: 4px; }

.layer-visibility {
  width: 26px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 3px;
  color: #50605a;
  background: transparent;
  cursor: pointer;
}

.layer-visibility[aria-pressed="false"] { color: #a2aaa7; }

.layer-remove {
  width: 26px;
  height: 28px;
  border: 0;
  border-radius: 3px;
  color: #7b8581;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
}

.layer-visibility:hover,
.layer-remove:hover { background: #e9eeeb; }
.scale-field { margin-top: 12px; }

.high-res-controls {
  margin-top: 15px;
  padding-top: 2px;
  border-top: 1px solid #edf1ef;
}

.high-res-controls .field-group label { margin-top: 12px; }

.method-note {
  padding-top: 16px;
  border-top: 1px solid #e5ebe8;
}

.method-note p {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
}

.method-note strong { color: #3b4c46; font-weight: 500; text-align: right; }

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #dfe6e2;
}

#map { position: absolute; inset: 0; }

.loading-panel,
.map-notice,
.legend {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(207,217,212,.9);
  border-radius: 4px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 2px 8px rgba(28,45,39,.08);
  backdrop-filter: blur(5px);
}

.loading-panel {
  top: 16px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  color: #3f4e49;
  font-size: 12px;
  transform: translateX(-50%);
  transition: opacity 180ms ease;
}

.loading-panel.is-hidden { opacity: 0; pointer-events: none; }

.loading-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #1a9a83;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: .35; transform: scale(.76); } }

.map-notice {
  top: 16px;
  left: 16px;
  max-width: min(420px,calc(100% - 32px));
  padding: 10px 12px;
  color: #72521c;
  border-color: #ead8b1;
  background: rgba(255,249,235,.96);
  font-size: 12px;
}

.legend {
  right: 16px;
  bottom: 28px;
  width: 196px;
  padding: 11px 12px 9px;
}

.legend-heading,
.legend-labels {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.legend-heading { margin-bottom: 8px; color: #2f3d39; font-size: 11px; font-weight: 600; }
.legend-heading span:last-child,
.legend-labels { color: #75807c; font-size: 9px; font-weight: 400; }

.legend-ramp {
  height: 8px;
  border-radius: 1px;
  background: linear-gradient(90deg,#d9f2e9 0%,#72d0bc 24%,#168f91 49%,#f0a140 72%,#e4552d 88%,#bf2f3b 100%);
}

.legend-labels { margin-top: 5px; }
.compare-legend { display: grid; grid-template-columns: repeat(4,1fr); height: 8px; }
.compare-legend span { background: var(--layer-color); }
.legend p { margin: 7px 0 0; color: #75807c; font-size: 9px; line-height: 1.4; }

.maplibregl-ctrl-top-right { top: 6px; right: 6px; }
.maplibregl-ctrl-group { border-radius: 4px; box-shadow: 0 1px 6px rgba(24,44,37,.2); }
.maplibregl-ctrl-attrib { font-family: inherit; }

noscript { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: #fff; }

@media (max-width: 760px) {
  :root { --header-height: 62px; }
  html, body { overflow: auto; }
  .page-shell { min-height: 100%; height: auto; }
  .site-header { padding: 0 16px; }
  .site-header h1 { font-size: 19px; }
  .site-header p, .project-mark { display: none; }
  .workspace { height: auto; display: flex; flex-direction: column; }
  .control-panel { flex: none; width: 100%; padding: 14px 16px 13px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .summary { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2px 14px; padding-bottom: 12px; }
  .eyebrow { margin: 0; }
  .total { grid-column: 2; grid-row: 1 / span 2; font-size: 25px; }
  .summary-note { margin: 3px 0 0; }
  .filters { padding: 12px 0 0; }
  .filters h2 { display: none; }
  .filters > .field-group { width: calc(50% - 4px); display: inline-block; vertical-align: bottom; }
  .filters > .field-group label { margin-top: 0; }
  .mode-switch { width: calc(50% - 4px); display: inline-grid; margin: 0 0 0 4px; vertical-align: bottom; }
  .mode-controls { margin-top: 7px; }
  .add-layer-row .field-group label { margin-top: 5px; }
  .layer-list { grid-template-columns: 1fr 1fr; gap: 6px; }
  .layer-item { min-width: 0; }
  .scale-field, .method-note { display: none; }
  .high-res-controls { margin-top: 10px; }
  .map-stage { flex: none; height: max(500px,calc(100svh - 330px)); }
  .legend { right: 10px; bottom: 30px; width: 174px; }
  .loading-panel { top: 10px; max-width: calc(100% - 100px); white-space: nowrap; }
  .map-notice { top: 10px; left: 10px; }
}

@media (max-width: 450px) {
  .summary-note { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .layer-list { grid-template-columns: 1fr; }
  .map-stage { height: max(480px,calc(100svh - 390px)); }
}

@media (prefers-reduced-motion: reduce) { .loading-dot { animation: none; } }
