:root {
  --ink: #0c2a4d;
  --muted: #627389;
  --border: #d7e1ea;
  --surface: #ffffff;
  --map-bg: #eef7fb;
  --country: #f8fbfd;
  --country-stroke: #a9bfd0;
  --teal: #079b8c;
  --teal-dark: #06776d;
  --amber: #f2ad2e;
  --coral: #e76f51;
  --blue: #377dba;
  --slate: #8c9aa7;
  --purple: #7768ae;
  --danger: #b84b4b;
  --shadow: 0 18px 45px rgba(20, 52, 78, .12);
  --font: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow-x: hidden; }
body { font-family: var(--font); color: var(--ink); background: #fff; }
button, input, select { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100%; background: var(--surface); }
.topbar {
  min-height: 84px;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.brand { color: var(--ink); text-decoration: none; font-size: 27px; font-weight: 800; letter-spacing: -.04em; }
.title-block { text-align: center; }
.title-block h1 { margin: 0; font-size: clamp(24px, 2.2vw, 36px); line-height: 1.15; letter-spacing: -.035em; }
.title-block p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; gap: 10px; }
.button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.button:hover { border-color: var(--teal); }
.button.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }

.workspace {
  position: relative;
  height: calc(100vh - 84px);
  min-height: 650px;
  display: grid;
  grid-template-columns: 250px minmax(480px, 1fr) 330px;
}
.filters, .detail-panel { background: #fff; overflow: auto; }
.filters { padding: 24px 20px; border-right: 1px solid var(--border); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.panel-heading h2 { font-size: 18px; margin: 0; }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.text-button { border: 0; background: none; color: var(--teal-dark); cursor: pointer; font-size: 13px; font-weight: 650; }
.mobile-filter-close { display: none; border: 1px solid var(--border); border-radius: 5px; background: #fff; padding: 5px 8px; font-size: 12px; font-weight: 700; cursor: pointer; }
.filter-backdrop { display: none; }
.field { display: block; margin-bottom: 17px; }
.field > span { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.field input, .field select {
  width: 100%; height: 40px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 6px; color: #243e5a; background: #fff;
  font-size: 13px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(7, 155, 140, .1); }
.filter-note { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.filter-note strong { font-size: 13px; }
.filter-note p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

.map-stage { min-width: 0; display: flex; flex-direction: column; background: var(--map-bg); }
.map-toolbar {
  min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 18px;
  padding: 10px 16px; border-bottom: 1px solid rgba(169,191,208,.7); background: rgba(255,255,255,.82);
}
.mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: #fff; }
.mode-switch button { min-width: 105px; height: 36px; border: 0; border-right: 1px solid var(--border); background: #fff; font-size: 13px; font-weight: 700; cursor: pointer; }
.mode-switch button:last-child { border-right: 0; }
.mode-switch button[aria-selected="true"] { color: #fff; background: var(--teal); }
.result-summary { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mobile-filter-button { display: none; }

.map-frame { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#mapSvg { width: 100%; height: 100%; min-height: 500px; display: block; touch-action: none; cursor: grab; }
#mapSvg.dragging { cursor: grabbing; }
.ocean { fill: var(--map-bg); }
.country-shape { fill: var(--country); stroke: var(--country-stroke); stroke-width: .8; vector-effect: non-scaling-stroke; transition: fill .18s, opacity .18s; cursor: pointer; }
.country-shape:hover, .country-shape.selected { stroke: var(--ink); stroke-width: 1.4; }
.country-shape.muted { opacity: .42; }
.park-marker { stroke: #fff; stroke-width: 1.4; vector-effect: non-scaling-stroke; cursor: pointer; transition: opacity .18s; }
.park-marker:hover, .park-marker.selected { stroke: var(--ink); stroke-width: 2.4; }
.marker-group { cursor: pointer; }
.mixed-marker-segment { stroke: #fff; stroke-width: .7; vector-effect: non-scaling-stroke; }
.mixed-status-outline { fill: none; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.cluster-count { pointer-events: none; text-anchor: middle; dominant-baseline: central; font-family: Arial, sans-serif; font-size: 8px; font-weight: 700; fill: #fff; }

.zoom-controls { position: absolute; right: 14px; top: 14px; display: grid; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: #fff; box-shadow: 0 6px 20px rgba(20,52,78,.09); }
.zoom-controls button { width: 34px; height: 34px; border: 0; border-bottom: 1px solid var(--border); background: #fff; font-size: 18px; font-weight: 700; cursor: pointer; }
.zoom-controls button:last-child { border-bottom: 0; font-size: 15px; }
.zoom-controls button:hover { background: #f2f7f8; }
.legend { position: absolute; left: 14px; bottom: 34px; min-width: 150px; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255,255,255,.94); box-shadow: 0 8px 24px rgba(20,52,78,.09); }
.legend-title { margin-bottom: 8px; font-size: 12px; font-weight: 800; }
.legend-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: #3b526a; font-size: 11px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.legend-swatch { width: 17px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.legend-mixed { display: inline-flex; width: 16px; height: 10px; overflow: hidden; border-radius: 5px; flex: 0 0 auto; }
.legend-mixed i { flex: 1; height: 100%; }
.island-shortcuts { position: absolute; left: 14px; top: 14px; z-index: 3; display: none; width: 176px; padding: 9px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255,255,255,.94); box-shadow: 0 8px 24px rgba(20,52,78,.09); }
.island-shortcuts.visible { display: block; }
.island-shortcuts strong { display: block; margin-bottom: 5px; font-size: 11px; }
.island-shortcuts button { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 5px 2px; border: 0; border-bottom: 1px solid #e8eef3; background: transparent; color: #334d66; font-size: 10px; text-align: left; cursor: pointer; }
.island-shortcuts button:last-child { border-bottom: 0; }
.island-shortcuts button:hover { color: var(--teal-dark); }
.island-shortcuts button span:last-child { color: var(--muted); white-space: nowrap; }
.map-attribution { position: absolute; right: 10px; bottom: 8px; color: #60758a; font-size: 10px; }
.loading-state { position: absolute; inset: 0; display: grid; place-items: center; background: var(--map-bg); color: var(--muted); font-size: 14px; }
.loading-state.hidden { display: none; }
.scope-note { min-height: 38px; padding: 8px 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; color: var(--muted); background: #fff; border-top: 1px solid var(--border); font-size: 11px; }

.detail-panel { position: relative; padding: 26px 22px; border-left: 1px solid var(--border); }
.detail-close { position: absolute; right: 12px; top: 11px; width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.empty-detail { padding-top: 70px; text-align: center; }
.empty-detail h2 { font-size: 17px; margin: 0 0 10px; }
.empty-detail p { margin: 0 auto; max-width: 240px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.detail-kicker { margin: 0 0 6px; color: var(--teal-dark); font-size: 12px; font-weight: 750; }
.detail-title { margin: 0 32px 8px 0; font-size: 21px; line-height: 1.35; }
.detail-original { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.status-pill { display: inline-block; padding: 5px 9px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 750; }
.detail-grid { margin: 20px 0 0; }
.detail-row { padding: 11px 0; border-bottom: 1px solid #e8eef3; }
.detail-row dt { margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.detail-row dd { margin: 0; color: #233d58; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.source-link { display: inline-flex; margin-top: 18px; color: #0668c2; font-size: 13px; font-weight: 700; text-decoration: none; }
.source-link:hover { text-decoration: underline; }
.precision-note { margin-top: 16px; padding: 11px; background: #f2f7f8; color: #4f667d; border-radius: 6px; font-size: 11px; line-height: 1.65; }
.cluster-list { margin: 16px 0 0; padding: 0; list-style: none; }
.cluster-list button { width: 100%; padding: 11px 0; text-align: left; border: 0; border-bottom: 1px solid #e8eef3; background: #fff; cursor: pointer; }
.cluster-list button:hover strong { color: var(--teal-dark); }
.cluster-list strong { display: block; font-size: 13px; line-height: 1.45; }
.cluster-list span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.load-more-button { width: 100%; margin-top: 14px; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: #f7fafc; color: var(--teal-dark); font-size: 12px; font-weight: 750; cursor: pointer; }
.load-more-button:hover { border-color: var(--teal); background: #f0f8f7; }
.country-stat { font-size: 42px; line-height: 1; font-weight: 800; color: var(--teal-dark); }
.country-stat-label { margin-top: 7px; color: var(--muted); font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translate(-50%, 20px); padding: 10px 14px; border-radius: 6px; color: #fff; background: rgba(12,42,77,.94); font-size: 13px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 230px minmax(460px, 1fr); }
  .detail-panel { position: absolute; z-index: 8; right: 0; top: 0; bottom: 0; width: 340px; transform: translateX(105%); box-shadow: var(--shadow); transition: transform .22s ease; }
  .detail-panel.open { transform: translateX(0); }
}

@media (max-width: 820px) {
  .topbar { min-height: 112px; grid-template-columns: 1fr auto; gap: 10px; padding: 13px 16px; }
  .brand { font-size: 22px; }
  .title-block { grid-column: 1 / -1; grid-row: 2; text-align: left; }
  .title-block h1 { font-size: 24px; }
  .top-actions .secondary { display: none; }
  .button { min-height: 38px; padding: 0 12px; }
  .workspace { position: relative; height: calc(100vh - 112px); min-height: 560px; display: block; }
  .filters { position: absolute; z-index: 10; inset: 0 auto 0 0; width: min(86vw, 310px); transform: translateX(-105%); box-shadow: var(--shadow); transition: transform .22s ease; }
  .filters.open { transform: translateX(0); }
  .mobile-filter-close { display: inline-block; }
  .filter-backdrop { position: absolute; z-index: 9; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(12,42,77,.32); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .filter-backdrop.open { display: block; opacity: 1; pointer-events: auto; }
  .map-stage { height: 100%; }
  .map-toolbar { justify-content: flex-start; flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .mode-switch { order: 2; width: 100%; }
  .mode-switch button { min-width: 0; flex: 1; }
  .mobile-filter-button { display: block; min-height: 34px; padding: 0 13px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 12px; font-weight: 700; }
  .result-summary { margin-left: auto; }
  .detail-panel { top: 0; width: min(92vw, 360px); }
  .scope-note { align-items: flex-start; flex-direction: column; gap: 2px; }
  .legend { bottom: 48px; }
  .island-shortcuts { left: auto; right: 8px; top: 54px; width: 150px; }
  #mapSvg { min-height: 420px; }
}

@media (max-width: 520px) {
  .top-actions .primary { font-size: 12px; }
  .result-summary { font-size: 11px; }
  .legend { left: 8px; bottom: 54px; padding: 9px; min-width: 132px; }
  .zoom-controls { right: 8px; top: 8px; }
  .map-attribution { font-size: 9px; }
}

@media print {
  .filters, .detail-panel, .top-actions, .zoom-controls, .mobile-filter-button { display: none !important; }
  .workspace { display: block; height: auto; }
  .map-stage { height: 880px; }
  .topbar { grid-template-columns: 180px 1fr; }
  .map-stage, .map-frame { break-inside: avoid; }
}
