@import "tailwindcss";

:root {
  --paper: #f3f0e8;
  --panel: rgba(250, 249, 245, 0.94);
  --panel-solid: #faf9f5;
  --ink: #16211f;
  --muted: #68746f;
  --line: rgba(26, 52, 47, 0.14);
  --teal: #087c75;
  --teal-dark: #075e59;
  --tx: #762b89;
  --tx-soft: #efe5f2;
  --amber: #c58e33;
  --shadow: 0 16px 45px rgba(25, 48, 43, 0.16);
  --header-h: 52px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  font-family: inherit !important;
}

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

html {
  font-family: system-ui, sans-serif;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, sans-serif;
}

button,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(8, 124, 117, 0.3);
  outline-offset: 2px;
}

.topbar {
  position: relative;
  z-index: 1000;
  height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #f8f6f0;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 3px 18px rgba(24, 43, 39, 0.08);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, var(--tx) 0 18%, var(--teal) 18% 76%, var(--amber) 76%);
}

.brand {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand span {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 15px;
  letter-spacing: 0.03em;
}

.brand small {
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.view-tabs {
  display: flex;
  max-width: min(100%, 520px);
  height: 34px;
  padding: 3px;
  gap: 2px;
  background: #eae7df;
  border-radius: 12px;
}

.view-tabs button {
  min-width: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  color: #53605c;
  transition: 160ms ease;
}

.view-tabs button:hover {
  color: var(--ink);
}

.view-tabs button.active {
  background: #fff;
  color: var(--tx);
  box-shadow: 0 2px 8px rgba(30, 42, 39, 0.12);
}

.view-tabs span {
  font-size: 10.5px;
  font-weight: 750;
}

.view-tabs small {
  font-family: ui-monospace, monospace;
  font-size: 8px;
  opacity: 0.72;
}

.header-actions {
  justify-self: end;
  display: flex;
  gap: 8px;
}

.icon-button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  color: #41504c;
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(8, 124, 117, 0.4);
  color: var(--teal);
  background: #fff;
}

.map-shell {
  position: relative;
  height: calc(100dvh - var(--header-h));
  min-height: 480px;
  isolation: isolate;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 74% 25%, rgba(118, 43, 137, 0.08), transparent 30%),
    #dce3dc;
}

#map.blank-base {
  background: #fff;
}

.map-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 110px rgba(26, 48, 43, 0.12);
}

.map-shell.blank-base::after {
  box-shadow: none;
}

.map-loading {
  position: absolute;
  z-index: 800;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  background:
    linear-gradient(rgba(241, 239, 232, 0.92), rgba(241, 239, 232, 0.92)),
    repeating-linear-gradient(45deg, #ddd 0 1px, transparent 1px 12px);
  transition: opacity 300ms ease;
}

.map-loading.ready {
  opacity: 0;
  pointer-events: none;
}

.loading-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px 18px 18px 6px;
  background: var(--tx);
  color: #fff;
  font-family: Georgia, serif;
  font-weight: 800;
  box-shadow: 0 13px 28px rgba(118, 43, 137, 0.25);
}

.map-loading strong {
  margin-top: 8px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 19px;
}

.map-loading small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.glass-panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
}

.control-panel {
  position: absolute;
  z-index: 500;
  top: 14px;
  left: 0;
  width: 240px;
  border-left: 0;
  border-radius: 0 16px 16px 0;
  max-height: calc(52% - 34px);
  overflow: auto;
  padding: 10px;
  scrollbar-width: thin;
}

.control-panel > .panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.eyebrow {
  color: var(--teal);
  font-family: ui-monospace, monospace;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.panel-heading h2,
.modal-head h2 {
  margin: 3px 0 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 21px;
  font-weight: 700;
}

.panel-close {
  display: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #edeae3;
  cursor: pointer;
  font-size: 19px;
}

.control-section {
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.control-panel > .control-section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.control-label > span,
.select-label {
  color: #2f3c38;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.control-label small {
  color: #89938f;
  font-size: 8.5px;
}

.period-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.period-tabs button {
  display: grid;
  gap: 1px;
  min-height: 38px;
  place-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.62);
  color: #53615c;
  cursor: pointer;
  font: inherit;
}

.period-tabs button span {
  font-size: 10px;
  font-weight: 800;
}

.period-tabs button small {
  color: var(--muted);
  font-size: 7.5px;
}

.period-tabs button.active {
  border-color: rgba(8, 124, 117, 0.35);
  background: var(--teal);
  color: #fff;
  box-shadow: 0 3px 9px rgba(8, 124, 117, 0.18);
}

.period-tabs button.active small {
  color: rgba(255, 255, 255, 0.76);
}

.period-tabs button[aria-busy="true"] {
  opacity: 0.55;
}

.period-status {
  margin: 5px 1px 0;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.4;
}

.segmented,
.metric-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 3px;
  background: #ebe9e2;
  border-radius: 10px;
}

.segmented button,
.metric-tabs button {
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #65716d;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.segmented button.active,
.metric-tabs button.active {
  background: #fff;
  color: var(--teal);
  box-shadow: 0 1px 5px rgba(22, 41, 37, 0.12);
}

.metric-tabs button:disabled {
  color: #a7aeab;
  cursor: not-allowed;
  text-decoration: line-through;
}

.select-label {
  display: block;
  margin: 7px 0 5px;
}

#stationSelect,
#clusterSelect {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
  font-size: 10.5px;
  cursor: pointer;
}

.cluster-section {
  display: grid;
  gap: 9px;
}

.cluster-section[hidden],
.cluster-view .land-view-only {
  display: none;
}

.cluster-level-toggles {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.cluster-level-dot {
  display: inline-block;
  width: 16px;
  height: 8px;
  margin-right: 7px;
  border: 2px solid;
  vertical-align: -1px;
}

.cluster-level-dot.strategy {
  border-color: #7c3aed;
  border-style: dashed;
  background: rgba(124, 58, 237, 0.04);
}

.cluster-level-dot.composite {
  border-color: #0f9f82;
  background: rgba(15, 159, 130, 0.12);
}

.cluster-level-dot.core {
  border-color: #d97706;
  background: rgba(245, 158, 11, 0.2);
}

.toggles {
  display: grid;
  gap: 6px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch-row > span {
  flex: 1;
  display: grid;
  gap: 2px;
}

.switch-row b {
  font-size: 10.5px;
}

.switch-row small {
  color: var(--muted);
  font-size: 8.5px;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-row i {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 20px;
  background: #c8cfcc;
  transition: 160ms ease;
}

.switch-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: 160ms ease;
}

.switch-row input:checked + i {
  background: var(--teal);
}

.switch-row input:checked + i::after {
  transform: translateX(14px);
}

.mesh-mode {
  padding: 5px 0 0;
  border-top: 0;
}

.metric-tabs {
  grid-template-columns: repeat(3, 1fr);
}

.coverage-note {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  background: #eef2ed;
}

.coverage-note > span {
  width: 7px;
  height: 7px;
  margin-top: 3px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
}

.coverage-note p {
  margin: 0;
  color: #61706b;
  font-size: 8.5px;
  line-height: 1.55;
}

.station-panel {
  position: absolute;
  z-index: 500;
  top: 18px;
  right: 0;
  width: 312px;
  border-right: 0;
  border-radius: 16px 0 0 16px;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  max-height: calc(100% - 70px);
  overflow: auto;
  scrollbar-width: thin;
}

.station-placeholder {
  display: grid;
  min-height: 260px;
  place-content: center;
  gap: 5px;
  color: var(--muted);
  text-align: center;
}

.station-placeholder span {
  font-family: ui-monospace, monospace;
  font-size: 8px;
  letter-spacing: 0.16em;
}

.station-placeholder strong {
  font-family: inherit;
  color: var(--ink);
}

.station-hero {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 19px 18px 16px;
  color: #fff;
  background:
    radial-gradient(circle at 92% 20%, rgba(255, 255, 255, 0.18), transparent 26%),
    linear-gradient(130deg, #164a48, #087c75);
}

.station-hero::after {
  content: attr(data-order);
  position: absolute;
  right: 8px;
  bottom: -22px;
  font-family: Georgia, serif;
  font-size: 92px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.11;
}

.station-kicker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: ui-monospace, monospace;
  font-size: 8px;
  letter-spacing: 0.14em;
  opacity: 0.8;
}

.station-kicker button {
  position: relative;
  z-index: 2;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 9px;
}

.station-hero h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: inherit;
  font-size: 25px;
  letter-spacing: 0.04em;
}

.station-hero p {
  position: relative;
  z-index: 1;
  margin: 4px 0 0;
  font-size: 9px;
  opacity: 0.82;
}

.station-hero.cluster-hero {
  background:
    radial-gradient(circle at 92% 20%, rgba(255, 255, 255, 0.2), transparent 28%),
    linear-gradient(130deg, color-mix(in srgb, var(--cluster-color) 72%, #172522), var(--cluster-color));
}

.cluster-hero .cluster-level-badge {
  display: inline-flex;
  margin-top: 8px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.station-content {
  padding: 16px 18px 18px;
}

.cluster-intro {
  margin: 0 0 14px;
  padding: 12px 13px;
  border-left: 3px solid var(--cluster-color, var(--tx));
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--cluster-color, var(--tx)) 7%, white);
}

.cluster-intro h3,
.cluster-sources h3 {
  margin: 0 0 5px;
  color: #273631;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.cluster-intro p {
  margin: 0;
  color: #33423d;
  font-size: 9.5px;
  line-height: 1.72;
}

.primary-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric-card {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.68);
}

.metric-card.highlight {
  background: var(--tx-soft);
  border-color: rgba(118, 43, 137, 0.14);
}

.metric-card.unavailable {
  background: #f1f0eb;
  color: #7e8884;
}

.metric-card.unavailable b {
  font-size: 15px;
  line-height: 1.45;
}

.metric-card small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.metric-card b {
  display: block;
  overflow: hidden;
  font-family: inherit;
  font-size: 21px;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.metric-card em {
  font-family: inherit;
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.mix-block {
  margin-top: 15px;
}

.mix-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  font-size: 9px;
  font-weight: 800;
}

.mix-title small {
  color: var(--muted);
  font-weight: 500;
}

.mix-strip {
  display: flex;
  overflow: hidden;
  height: 9px;
  border-radius: 9px;
  background: #e0ded7;
}

.mix-strip i {
  display: block;
  min-width: 1px;
}

.mix-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px 10px;
  margin-top: 9px;
}

.mix-list span {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: #586661;
  font-size: 8px;
}

.mix-list i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.mix-list b {
  overflow: hidden;
  color: #2c3935;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mix-list em {
  margin-left: auto;
  font-family: ui-monospace, monospace;
  font-style: normal;
}

.secondary-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.secondary-metrics div {
  padding: 9px 5px;
  background: #f9f8f4;
  text-align: center;
}

.secondary-metrics small {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.secondary-metrics b {
  display: block;
  margin-top: 3px;
  font-family: inherit;
  font-size: 14px;
}

.station-note {
  margin: 12px 0 0;
  color: #7b8682;
  font-size: 8px;
  line-height: 1.5;
}

.cluster-facts {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.cluster-facts div {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.58);
}

.cluster-facts dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.cluster-facts dd {
  margin: 0;
  color: #33423d;
  font-size: 9px;
  line-height: 1.5;
}

.cluster-audit {
  margin-top: 13px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--cluster-color, var(--tx)) 28%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--cluster-color, var(--tx)) 4%, white);
}

.cluster-audit h3 {
  margin: 0 0 7px;
  color: #33423d;
  font-size: 9px;
}

.cluster-audit-grid {
  display: grid;
  gap: 5px;
}

.cluster-audit-grid > div {
  display: grid;
  grid-template-columns: minmax(94px, 0.9fr) minmax(0, 1.6fr);
  align-items: baseline;
  gap: 8px;
  padding-top: 5px;
  border-top: 1px solid rgba(90, 106, 100, 0.13);
}

.cluster-audit-grid > div:first-child {
  padding-top: 0;
  border-top: 0;
}

.cluster-audit-grid small {
  color: var(--muted);
  font-size: 7.5px;
  line-height: 1.35;
}

.cluster-audit-grid b {
  min-width: 0;
  color: #26342f;
  font-size: 8.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cluster-audit p {
  margin: 7px 0 0;
  color: #687570;
  font-size: 7.5px;
  line-height: 1.45;
}

.cluster-sources {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.cluster-sources > div {
  display: grid;
  gap: 5px;
}

.cluster-sources a {
  display: grid;
  gap: 1px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: #33423d;
  text-decoration: none;
}

.cluster-sources a span {
  font-size: 8.5px;
  font-weight: 750;
  line-height: 1.35;
}

.cluster-sources a small {
  color: var(--muted);
  font-size: 7.5px;
  line-height: 1.35;
}

.cluster-sources a:hover,
.cluster-sources a:focus-visible {
  border-color: color-mix(in srgb, var(--cluster-color, var(--tx)) 55%, var(--line));
  background: color-mix(in srgb, var(--cluster-color, var(--tx)) 5%, white);
  outline: none;
}

.map-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: #ebe9e2;
}

.map-tools button {
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.map-actions {
  position: absolute;
  z-index: 500;
  right: 0;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-right: 0;
  border-radius: 10px 0 0 10px;
}

.scale-tools {
  display: flex;
  gap: 2px;
  padding-right: 4px;
  border-right: 1px solid var(--line);
}

.map-actions .map-tools {
  display: flex;
  gap: 2px;
  padding: 0;
  background: transparent;
}

.map-actions button {
  height: 25px;
  min-width: 38px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  cursor: pointer;
}

.map-actions button.active {
  background: var(--teal);
  color: #fff;
}

.map-tools button.active {
  background: var(--teal);
  color: #fff;
}

.legend-dock {
  position: absolute;
  z-index: 450;
  bottom: 14px;
  left: 0;
  width: 230px;
  max-height: min(48%, 320px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 0;
  border-radius: 0 14px 14px 0;
}

.legend,
.mesh-legend {
  min-height: 0;
  padding: 11px 12px;
}

.legend {
  overflow: auto;
}

.legend h3,
.mesh-legend > b {
  display: block;
  margin: 0 0 8px;
  font-size: 8.5px;
  letter-spacing: 0.04em;
}

.legend-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  margin: 5px 0;
}

.legend-row > i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-row span {
  overflow: hidden;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-row span small {
  display: none;
}

.legend-row code {
  color: #89938f;
  font-size: 7px;
}

.cluster-legend-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 7px;
  margin: 6px 0;
  color: #3e4b47;
  font-size: 8px;
}

.cluster-legend-row i {
  display: block;
  height: 8px;
  border: 2px solid;
}

.cluster-legend-row.strategy i {
  border-color: #7c3aed;
  border-style: dashed;
  background: rgba(124, 58, 237, 0.04);
}

.cluster-legend-row.composite i {
  border-color: #0f9f82;
  background: rgba(15, 159, 130, 0.12);
}

.cluster-legend-row.core i {
  border-color: #d97706;
  background: rgba(245, 158, 11, 0.2);
}

.cluster-color-strip {
  display: flex;
  gap: 3px;
  margin-top: 9px;
}

.cluster-color-strip i {
  width: 12px;
  height: 6px;
  flex: 1;
  border-radius: 2px;
}

.mesh-legend {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
}

.legend[hidden] + .mesh-legend {
  border-top: 0;
}

.mesh-legend > small {
  display: block;
  margin: -4px 0 7px;
  color: var(--muted);
  font-size: 7.5px;
  line-height: 1.35;
}

.mesh-legend div {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 7.5px;
}

.mesh-legend i {
  width: 17px;
  height: 7px;
  border-radius: 2px;
}

.mobile-dock {
  display: none;
}

.modal {
  width: min(720px, calc(100% - 32px));
  max-height: min(720px, calc(100dvh - 32px));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 19px;
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(17, 34, 30, 0.28);
}

.modal::backdrop {
  background: rgba(14, 28, 25, 0.48);
  backdrop-filter: blur(5px);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 22px 15px;
  border-bottom: 1px solid var(--line);
}

.modal-head button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #ece9e2;
  cursor: pointer;
  font-size: 20px;
}

.modal-body {
  max-height: calc(100dvh - 150px);
  overflow: auto;
  padding: 20px 22px 24px;
}

.version-credit {
  display: block;
  padding: 11px 22px 14px;
  border-top: 1px solid var(--line);
  color: var(--teal);
  font-size: 9px;
  text-decoration: none;
}

.version-credit:hover {
  text-decoration: underline;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.method-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.method-card span {
  color: var(--teal);
  font-family: ui-monospace, monospace;
  font-size: 8px;
  font-weight: 800;
}

.method-card h3 {
  margin: 4px 0 6px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 15px;
}

.method-card p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.formula {
  display: block;
  margin-top: 13px;
  padding: 12px;
  overflow: auto;
  border-radius: 9px;
  background: #202b28;
  color: #d9ebe7;
  font-size: 9px;
}

.source-list {
  margin: 15px 0 0;
  padding: 0;
  list-style: none;
}

.source-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 9px;
}

.source-list a {
  color: var(--teal);
}

.cluster-source-details {
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.cluster-source-details summary {
  cursor: pointer;
  color: var(--tx);
  font-size: 10px;
  font-weight: 800;
}

.cluster-source-details .source-list {
  margin-top: 10px;
}

.gallery-modal {
  width: min(920px, calc(100% - 32px));
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 13px;
  padding: 18px;
}

.gallery-grid a {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.gallery-grid a:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(28, 49, 44, 0.13);
}

.gallery-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border-bottom: 1px solid var(--line);
}

.gallery-grid span {
  display: grid;
  gap: 3px;
  padding: 11px;
}

.gallery-grid b {
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 13px;
}

.gallery-grid small {
  color: var(--muted);
  font-size: 8px;
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 0 !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
  border-color: var(--line) !important;
  color: var(--teal) !important;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.72) !important;
  font-size: 7px !important;
}

.leaflet-tooltip.station-name {
  border: 0;
  border-radius: 5px;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.88);
  color: #24332f;
  box-shadow: 0 2px 8px rgba(24, 48, 42, 0.16);
  font-size: 8px;
  font-weight: 750;
  white-space: nowrap;
}

.leaflet-tooltip.station-name::before {
  display: none;
}

.leaflet-tooltip.cluster-hover {
  border: 0;
  border-left: 4px solid var(--cluster-color, #762b89);
  border-radius: 7px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 16px rgba(24, 48, 42, 0.18);
  color: #25332f;
  font-size: 9px;
  line-height: 1.45;
}

.leaflet-tooltip.cluster-hover::before {
  display: none;
}

.cluster-label-icon {
  width: max-content !important;
  height: auto !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
  pointer-events: none !important;
}

.cluster-label-icon span {
  display: block;
  max-width: 150px;
  padding: 2px 5px;
  border-left: 3px solid var(--cluster-color);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 2px 7px rgba(24, 48, 42, 0.14);
  color: #25332f;
  font-size: 8px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
}

.leaflet-interactive[role="button"]:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.leaflet-popup-content-wrapper {
  border-radius: 10px;
  font-size: 10px;
}

.leaflet-control-zoom {
  margin-right: 8px !important;
  margin-bottom: 62px !important;
}

@media (max-width: 1050px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .view-tabs {
    position: absolute;
    top: 60px;
    left: 50%;
    z-index: 600;
    transform: translateX(-50%);
    box-shadow: var(--shadow);
  }

  .header-actions {
    grid-column: 2;
  }

  .station-panel {
    top: auto;
    bottom: 58px;
    max-height: 300px;
  }
}

@media (max-width: 760px) {
  :root {
    --header-h: 52px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 0 13px;
  }

  .brand img {
    width: 28px;
    height: 28px;
  }

  .brand strong {
    font-size: 13px;
  }

  .header-actions {
    display: none;
  }

  .view-tabs {
    top: 59px;
    width: calc(100% - 22px);
    height: 34px;
  }

  .view-tabs button {
    min-width: 0;
    flex: 1;
  }

  .view-tabs span {
    font-size: 10px;
  }

  .map-shell {
    min-height: 420px;
  }

  .control-panel,
  .station-panel {
    position: fixed;
    z-index: 2000;
    top: auto;
    right: 10px;
    bottom: 72px;
    left: 10px;
    width: auto;
    max-height: min(70dvh, 620px);
    transform: translateY(calc(100% + 100px));
    opacity: 0;
    pointer-events: none;
    transition: 220ms ease;
  }

  .control-panel.mobile-open,
  .station-panel.mobile-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .panel-close {
    display: grid;
    place-items: center;
  }

  .station-panel .station-hero {
    padding-right: 52px;
  }

  .mobile-dock {
    position: fixed;
    z-index: 1800;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 5px;
    border-radius: 14px;
  }

  .mobile-dock button {
    height: 42px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: #42504c;
    font-size: 10px;
    font-weight: 750;
  }

  .mobile-dock button:last-child {
    border-right: 0;
  }

  .legend-dock {
    position: fixed;
    z-index: 1700;
    right: auto;
    bottom: 72px;
    left: 10px;
    width: 190px;
    max-height: min(42dvh, 300px);
    border-left: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 14px;
  }

  .map-actions {
    position: fixed;
    z-index: 1700;
    top: auto;
    right: 10px;
    bottom: 72px;
    flex-direction: column;
    align-items: stretch;
    border-right: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 10px;
  }

  .map-actions .scale-tools {
    justify-content: center;
    padding-right: 0;
    padding-bottom: 4px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .leaflet-control-zoom {
    margin-right: 10px !important;
    margin-bottom: 144px !important;
  }

  .gallery-grid,
  .method-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    max-height: calc(100dvh - 110px);
    overflow: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
