:root {
  --ink: #172229;
  --paper: #f2f0e8;
  --panel: #19262d;
  --panel-soft: #22323a;
  --muted: #9eaaa9;
  --cyan: #66d1cf;
  --coral: #ff644f;
  --yellow: #edc457;
  --line: rgba(255, 255, 255, 0.13);
}

* { box-sizing: border-box; }

html, body, .app-shell { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  color: var(--paper);
  background: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

.app-shell { position: relative; }

#map { position: absolute; inset: 64px 0 0 88px; background: #ccd0c9; }

.topbar {
  position: absolute;
  z-index: 1000;
  inset: 0 0 auto 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 9px; height: 34px; background: var(--coral); }
.brand-block h1 { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.2; }
.brand-block p { margin: 3px 0 0; color: var(--muted); font: 11px/1.2 "IBM Plex Mono", monospace; }

.model-state { display: flex; align-items: center; gap: 8px; color: #cbd4d1; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px rgba(237, 196, 87, 0.13); }
.status-dot.ready { background: var(--cyan); box-shadow: 0 0 0 4px rgba(102, 209, 207, 0.13); }

.region-nav {
  position: absolute; z-index: 950; left: 0; top: 64px; bottom: 0; width: 88px;
  display: flex; flex-direction: column; background: #121d22; border-right: 1px solid var(--line);
}
.region-nav-title {
  height: 42px; display: grid; place-items: center; color: #637675;
  font: 9px/1 "IBM Plex Mono", monospace; border-bottom: 1px solid var(--line);
}
.region-button {
  position: relative; width: 100%; height: 82px; flex: 0 0 82px; padding: 10px 4px;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: #899997;
  background: transparent; cursor: pointer; font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
.region-button::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: transparent;
}
.region-button:hover { color: #fff; background: rgba(255,255,255,.035); }
.region-button:focus { outline: none; }
.region-button:focus-visible { outline: 1px solid var(--cyan); outline-offset: -3px; }
.region-button.active { color: #fff; background: #1b2a31; }
.region-button.active::before { background: var(--coral); }
.region-code { display: block; font: 500 12px/1 "IBM Plex Mono", monospace; }
.region-name { display: block; margin-top: 8px; font-size: 11px; }
.region-button i {
  position: absolute; right: 9px; top: 10px; width: 5px; height: 5px; border-radius: 50%;
  background: #52615f;
}
.region-button.active i { background: var(--cyan); box-shadow: 0 0 0 3px rgba(102,209,207,.12); }

.result-tabs {
  position: absolute; z-index: 880; top: 78px; left: calc(50% + 44px); transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(3, 1fr); width: 390px; height: 42px;
  background: rgba(25,38,45,.96); border: 1px solid rgba(255,255,255,.16); box-shadow: 0 8px 24px rgba(10,22,27,.2);
}
.result-tab {
  position: relative; min-width: 0; border: 0; border-right: 1px solid var(--line); border-radius: 0;
  color: #91a09e; background: transparent; cursor: pointer; font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
.result-tab:last-child { border-right: 0; }
.result-tab b { margin-right: 7px; color: #60716f; font: 500 9px/1 "IBM Plex Mono", monospace; }
.result-tab span { font-size: 11px; }
.result-tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; background: transparent; }
.result-tab:hover { color: #fff; }
.result-tab.active { color: #fff; background: rgba(255,255,255,.035); }
.result-tab.active b { color: var(--cyan); }
.result-tab.active::after { background: var(--coral); }
.result-tab:focus { outline: none; }
.result-tab:focus-visible { outline: 1px solid var(--cyan); outline-offset: -3px; }

.inspector {
  position: absolute;
  z-index: 900;
  top: 82px;
  right: 18px;
  width: min(340px, calc(100vw - 36px));
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding: 18px;
  background: rgba(25, 38, 45, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 42px rgba(10, 22, 27, 0.28);
  backdrop-filter: blur(10px);
}

.inspector-heading { display: flex; justify-content: space-between; align-items: start; }
.eyebrow { color: var(--cyan); font: 10px/1 "IBM Plex Mono", monospace; }
.inspector h2 { margin: 7px 0 0; font-size: 18px; font-weight: 600; }
.icon-button {
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 4px;
  color: var(--paper); background: var(--panel-soft); font-size: 18px; cursor: pointer;
}
.icon-button:hover { border-color: var(--cyan); color: var(--cyan); }

.primary-readout { margin: 18px -18px 0; padding: 17px 18px 16px; background: #121d22; border-block: 1px solid var(--line); }
.primary-readout span { display: block; color: var(--muted); font-size: 12px; }
.primary-readout strong { display: inline-block; margin-top: 3px; color: #fff; font: 500 37px/1 "IBM Plex Mono", monospace; }
.primary-readout strong.is-text { font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; font-size: 27px; font-weight: 600; }
.primary-readout small { margin-left: 7px; color: var(--muted); font: 10px/1 "IBM Plex Mono", monospace; }

.parameter-control { padding: 15px 0; border-bottom: 1px solid var(--line); }
.parameter-label { display: flex; align-items: center; justify-content: space-between; }
.parameter-label label { color: #d7ddda; font-size: 11px; }
.parameter-label output { color: var(--cyan); font: 500 14px/1 "IBM Plex Mono", monospace; }
.parameter-control input[type="range"] {
  width: 100%; height: 18px; margin: 9px 0 0; appearance: none; background: transparent; cursor: pointer;
}
.parameter-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; background: linear-gradient(90deg, var(--cyan), var(--yellow), var(--coral));
}
.parameter-control input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 18px; margin-top: -7px; border: 2px solid #fff;
  border-radius: 2px; background: var(--panel); box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.parameter-scale { display: flex; justify-content: space-between; color: #718280; font: 9px/1 "IBM Plex Mono", monospace; }
.compute-button {
  width: 100%; height: 36px; margin-top: 12px; border: 0; border-radius: 4px;
  color: #111c21; background: var(--cyan); font: 600 12px/1 "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; cursor: pointer;
}
.compute-button span { margin-right: 7px; font-size: 16px; vertical-align: -1px; }
.compute-button:hover { background: #84e0dd; }
.compute-button:disabled { color: #81908e; background: #304047; cursor: wait; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.metrics div { min-width: 0; padding: 13px 0; border-bottom: 1px solid var(--line); }
.metrics div:nth-child(odd) { padding-right: 12px; border-right: 1px solid var(--line); }
.metrics div:nth-child(even) { padding-left: 12px; }
.metrics dt { color: var(--muted); font-size: 11px; }
.metrics dd { margin: 5px 0 0; color: #f7f7f2; font: 500 13px/1.3 "IBM Plex Mono", monospace; overflow-wrap: anywhere; }

.path-key { padding: 13px 0; border-bottom: 1px solid var(--line); }
.path-key div { display: flex; align-items: center; gap: 10px; margin: 7px 0; color: #d7ddda; font-size: 11px; }
.line-sample { display: inline-block; width: 35px; height: 0; }
.line-sample.full { border-top: 2px dashed #f4f0dd; }
.line-sample.supported { border-top: 6px solid var(--coral); }

.layers { padding: 12px 0 3px; display: grid; gap: 9px; }
.layers label { display: flex; align-items: center; gap: 9px; color: #d7ddda; font-size: 11px; cursor: pointer; }
.layers input { width: 15px; height: 15px; margin: 0; accent-color: var(--coral); }
.coordinates { margin-top: 13px; color: #7f8f8e; font: 10px/1.4 "IBM Plex Mono", monospace; }

.legend {
  position: absolute; z-index: 850; left: 106px; bottom: 20px; width: 230px;
  padding: 12px 14px; color: var(--paper); background: rgba(25, 38, 45, 0.94);
  border: 1px solid rgba(255,255,255,.15); box-shadow: 0 10px 28px rgba(10, 22, 27, .22);
}
.legend-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; }
.legend-title b { color: var(--muted); font: 10px "IBM Plex Mono", monospace; }
.color-ramp { height: 9px; margin-top: 9px; background: linear-gradient(90deg, #222d34, #1f8297, #4eae92, #eac457, #e06748, #9a303f); }
.legend[data-mode="channel"] .color-ramp { background: linear-gradient(90deg, #222d34, #674830, #b76638, #eb9a47, #ffe7a6); }
.legend[data-mode="outlet"] .color-ramp { background: linear-gradient(90deg, #222d34, #584e66, #b15458, #eb914d, #ffe297); }
.legend-labels { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font: 10px "IBM Plex Mono", monospace; }

.loading {
  position: absolute; z-index: 1200; left: 50%; top: 84px; transform: translateX(-50%);
  display: flex; gap: 9px; align-items: center; padding: 9px 13px; background: var(--panel);
  border: 1px solid var(--line); font-size: 11px;
}
.loading[hidden] { display: none; }
.loading span { width: 9px; height: 9px; border-radius: 50%; background: var(--coral); animation: pulse 800ms ease-in-out infinite alternate; }
.region-notice {
  position: absolute; z-index: 1200; left: calc(50% + 44px); top: 82px; transform: translateX(-50%);
  padding: 9px 13px; color: #dce3df; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(10,22,27,.22); font-size: 11px;
}
.region-notice[hidden] { display: none; }
@keyframes pulse { to { opacity: .25; transform: scale(.65); } }

.leaflet-control-zoom a { border-radius: 0 !important; color: var(--ink) !important; }
.leaflet-container { font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; }
.leaflet-interactive { transition: stroke-width 150ms ease, opacity 150ms ease; }

@media (max-width: 720px) {
  .topbar { height: 58px; padding: 0 13px; }
  .brand-block p { display: none; }
  .region-nav {
    top: 58px; right: 0; bottom: auto; width: auto; height: 64px; flex-direction: row;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .region-nav-title { display: none; }
  .region-button { width: 25%; height: 64px; flex: 1 1 25%; border-right: 1px solid var(--line); border-bottom: 0; padding: 8px 2px; }
  .region-button::before { inset: auto 0 0; width: auto; height: 3px; }
  .region-button i { right: 8px; top: 8px; }
  .region-name { margin-top: 5px; font-size: 10px; }
  #map { inset: 122px 0 0; }
  .result-tabs { top: 132px; left: 50%; width: calc(100vw - 112px); height: 40px; }
  .result-tab b { display: none; }
  .result-tab span { font-size: 10px; }
  .model-state { font-size: 10px; }
  .inspector { top: auto; right: 10px; bottom: 10px; width: calc(100vw - 20px); max-height: 42vh; padding: 14px; }
  .primary-readout { margin-inline: -14px; padding-inline: 14px; }
  .legend { left: 56px; top: 180px; bottom: auto; width: 175px; padding: 9px 11px; }
  .primary-readout strong { font-size: 30px; }
  .compute-button { height: 40px; }
  .region-notice { left: 50%; top: 134px; }
}

.topbar-actions { display: flex; align-items: center; gap: 22px; }
.home-link { color: #cbd4d1; font-size: 12px; text-decoration: none; white-space: nowrap; }
.home-link:hover { color: var(--cyan); }
@media (max-width: 720px) { .topbar-actions { gap: 12px; } .home-link { font-size: 10px; } .brand-block h1 { font-size: 14px; } .model-state { max-width: 100px; } }
