:root {
  color-scheme: light;
  --surface: rgba(252, 252, 251, 0.95);
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  /* vessel types: validated categorical slots 1-3, gray for the rest */
  --type-cargo: #2a78d6;
  --type-passenger: #eb6834;
  --type-service: #1baf7a;
  --type-other: #898781;
  /* status palette, reused for the dwell ramp and flooding */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --serious: #ec835a;
  --building: #000000;   /* buildings render black in both themes */
  --flooded: #d03b3b;
  --live: #0ca30c;
  --down: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: rgba(26, 26, 25, 0.95);
    --ink-1: #f0efec;
    --ink-2: #c3c2b7;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: rgba(26, 26, 25, 0.95);
  --ink-1: #f0efec;
  --ink-2: #c3c2b7;
  --hairline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
}

html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0d0d0d;
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink-1);
}
#viewer { position: absolute; inset: 0; }
.cesium-viewer-bottom { left: auto; right: 6px; }

#tabs {
  position: absolute; top: 12px; left: 12px; z-index: 2; display: flex; gap: 2px;
  padding: 3px; border-radius: 8px; background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 2px 8px rgba(0, 0, 0, 0.25);
}
#tabs button {
  border: 0; border-radius: 6px; padding: 6px 16px; background: transparent;
  font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
#tabs button:hover { color: var(--ink-1); background: var(--hairline); }
#tabs button[aria-selected="true"] { color: #fff; background: var(--accent); }
#tabs button:focus-visible, .panel button:focus-visible, .panel input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.panel {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 280px;
  max-height: calc(100% - 60px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}
.panel[hidden] { display: none; }
.card {
  padding: 12px 14px; border-radius: 8px; background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 2px 8px rgba(0, 0, 0, 0.25);
}
.card h2 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.muted { color: var(--muted); }
.note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--hairline); color: var(--muted); font-size: 12px; }

.hero { display: flex; align-items: baseline; gap: 4px; font-size: 32px; font-weight: 600; line-height: 1.15; }
.hero.small { font-size: 17px; }
.hero .unit { font-size: 15px; font-weight: 500; color: var(--ink-2); }
.trend { margin-left: 8px; font-size: 24px; color: var(--ink-2); }

.status::before { content: "●"; margin-right: 5px; color: var(--muted); }
.status[data-state="live"]::before { color: var(--live); }
.status[data-state="down"]::before { color: var(--down); }
.status[data-state="stale"]::before { color: var(--warning); }
.hint { margin-top: 2px; color: var(--ink-2); font-size: 12px; }

.notice { box-shadow: inset 3px 0 0 var(--warning), 0 0 0 1px var(--border), 0 2px 8px rgba(0, 0, 0, 0.25); }
.notice p { margin: 0; color: var(--ink-2); }
.notice p + p { margin-top: 8px; }
.notice b { color: var(--ink-1); }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }

.legend { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend .count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.swatch { width: 12px; height: 12px; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); }
.dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px var(--border); }

.slider-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.slider-row input { flex: 1; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-label { display: flex; justify-content: space-between; margin-top: 12px; color: var(--ink-2); }
.slider-label output { font-weight: 600; color: var(--ink-1); font-variant-numeric: tabular-nums; }
.ticks, .ramp-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.ticks { margin-left: 36px; }
.ramp { height: 10px; margin-top: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--good), var(--warning) 50%, var(--critical)); }

.icon-button {
  width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 11px; cursor: pointer;
}
.text-button {
  margin-top: 8px; padding: 0; border: 0; background: none; font: inherit;
  color: var(--accent); cursor: pointer;
}
.text-button:hover { text-decoration: underline; }

#tooltip {
  position: absolute; z-index: 3; pointer-events: none; max-width: 260px;
  padding: 8px 10px; border-radius: 6px; background: var(--surface); color: var(--ink-1);
  box-shadow: 0 0 0 1px var(--border), 0 2px 8px rgba(0, 0, 0, 0.3);
}
#tooltip b { font-size: 13px; }
#tooltip .muted { font-size: 12px; }

@media (max-width: 640px) {
  .panel { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: 45%; }
}
