/* stevenstills.com palette: lime headline, mint secondary, deep teal panels */
:root {
  --so-night: #29494F;
  --so-midnight: #183036;
  --so-day: #F1F2F1;
  --so-dusk: #6F8488;
  --so-midday: #FFFFFF;
  --so-morning: #BAF084;
  --so-electric: #E1FE73;
  --so-hydro: #60D0B8;
  --so-dear: #FF646D;
  --so-mint: #60D0B8;

  --accent: var(--so-electric);          /* tint lng tier */
  --tanker: var(--so-hydro);             /* tint tanker tier */
  --other: var(--so-dusk);               /* tint other tier */

  --panel-bg: rgba(24, 48, 54, 0.88);
  --panel-fg: var(--so-day);
  --panel-muted: #A9B8BA;
  --panel-border: rgba(241, 242, 241, 0.14);
  --panel-hover: rgba(241, 242, 241, 0.08);
  --radius: 24px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  font-family: "Poppins", "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; background: var(--so-night); }
#map { position: absolute; inset: 0; z-index: 0; }

button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- frame floating panels ---- */
.panel {
  position: absolute;
  z-index: 1000;
  background: var(--panel-bg);
  color: var(--panel-fg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---- style scrollbars ---- */
.hl-list, #controls, .src-body, .kpidrop-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(241, 242, 241, 0.22) transparent;
}
.hl-list::-webkit-scrollbar,
#controls::-webkit-scrollbar, .src-body::-webkit-scrollbar,
.kpidrop-list::-webkit-scrollbar {
  width: 8px; height: 8px;
}
.hl-list::-webkit-scrollbar-track,
#controls::-webkit-scrollbar-track, .src-body::-webkit-scrollbar-track,
.kpidrop-list::-webkit-scrollbar-track {
  background: transparent;
}
.hl-list::-webkit-scrollbar-thumb,
#controls::-webkit-scrollbar-thumb, .src-body::-webkit-scrollbar-thumb,
.kpidrop-list::-webkit-scrollbar-thumb {
  background: rgba(241, 242, 241, 0.2);
  border: 2px solid transparent;
  border-radius: 6px;
  background-clip: padding-box;
}
.hl-list::-webkit-scrollbar-thumb:hover,
#controls::-webkit-scrollbar-thumb:hover, .src-body::-webkit-scrollbar-thumb:hover,
.kpidrop-list::-webkit-scrollbar-thumb:hover {
  background: rgba(241, 242, 241, 0.36);
  background-clip: padding-box;
}

/* ---- dock zoom controls under the chart ---- */
.zoom-dock {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}
.zoom-dock-label {
  display: block; margin-bottom: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--panel-muted);
}
.zoom-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.zoom-row:last-child { margin-bottom: 0; }
.zoom-name { font-size: 13px; font-weight: 600; color: var(--panel-fg); }
.zoom-btns { display: flex; gap: 6px; }
.zoom-btns button {
  width: 36px; height: 30px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 400; line-height: 1;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 9px;
}
.zoom-btns button:hover { background: rgba(241, 242, 241, 0.16); color: var(--accent); }
.zoom-btns .wide-btn { width: 78px; font-size: 13px; font-weight: 600; }

/* ---- minimised view: compact summary bar and replay, top right ---- */
#mini { display: none; top: 18px; right: 18px; padding: 6px; gap: 6px; }
body.min .panel:not(#kpibar):not(#mini) { display: none; }
body.min #mini { display: flex; }
body.min #kpibar {
  left: auto !important; right: 116px; transform: none;
  max-width: none !important; height: 48px;
}
body.min #kpibar.tight .kpi:not(.kpi-insight) { display: flex; }
body.min #kpibar .kpi-insight { display: none; }
body.min #kpibar .kpi { padding: 6px 12px; }
body.min #kpibar .kv { font-size: 15px; }
body.min #kpibar .kl { font-size: 9px; margin-top: 2px; }

/* ---- frame header badge ---- */
#header {
  top: 18px;
  left: 18px;
  padding: 14px 18px;
  max-width: 340px;
}
#header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
#header .sub {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--panel-muted);
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--so-mint);
  box-shadow: 0 0 0 0 rgba(96, 208, 184, 0.6);
  animation: ping 2s infinite;
}
.dot.travel { background: var(--so-morning); animation: none; }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(96, 208, 184, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(96, 208, 184, 0); }
  100% { box-shadow: 0 0 0 0 rgba(96, 208, 184, 0); }
}

/* ---- mark strait status line ---- */
.strait-line { color: var(--panel-fg); font-weight: 600; }
.sdot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--so-dusk); display: inline-block; flex: none;
}
.sdot.ok { background: var(--so-mint); }
.sdot.warn { background: var(--so-morning); }
.sdot.bad { background: var(--so-dear); }
.sdetail { color: var(--panel-muted); font-weight: 400; }

/* ---- dock control panel ---- */
#controls {
  top: 18px;
  right: 18px;
  width: 290px;
  padding: 4px 0 10px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}
.section { padding: 14px 18px; border-top: 1px solid var(--panel-border); }
.section:first-child { border-top: none; }
.section h2 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--panel-muted);
}

/* ---- style filter rows ---- */
.filter {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 6px;
  background: var(--panel-hover);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--panel-fg);
  text-align: left;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}
.filter:hover { background: rgba(241, 242, 241, 0.14); }
.filter[aria-pressed="false"] { opacity: 0.4; }
.filter[aria-pressed="true"] { border-color: var(--panel-border); }
.filter .glyph { flex: none; display: grid; place-items: center; }
.filter .label { flex: 1; }
.filter .name { font-size: 13px; font-weight: 600; display: block; }
.filter .desc { font-size: 11px; color: var(--panel-muted); }
.filter .count {
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* size tier swatches */
.swatch-lng {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent));
}
.swatch-tanker {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--tanker);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
}
.swatch-other {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--other);
}
.swatch-chokepoint {
  width: 22px; height: 0;
  border-top: 4px solid var(--so-dear);
}
.swatch-trails {
  width: 22px; height: 0;
  border-top: 2px solid var(--so-hydro);
  border-radius: 2px;
}
/* a hex, matching the jamming cells drawn on the map */
.swatch-jamming {
  width: 13px; height: 15px;
  background: #d9622a;
  opacity: 0.75;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

/* ---- style swatch controls ---- */
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatches button {
  width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid transparent;
}
.swatches button[aria-pressed="true"] { border-color: var(--so-midday); }
.swatches input[type="color"] {
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 8px; background: none; cursor: pointer;
}

.note { font-size: 11px; line-height: 1.5; color: var(--panel-muted); }
.note strong { color: var(--so-morning); font-weight: 600; }

/* ---- lay out time-travel bar ---- */
#timebar {
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 36px));
  padding: 14px 20px 16px;
}
#timebar .row { display: flex; align-items: center; gap: 14px; }
.tt-btn {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--panel-fg);
  background: var(--panel-hover);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}
.tt-btn:hover { background: rgba(241, 242, 241, 0.16); }
#liveBtn {
  flex: none;
  padding: 0 16px; height: 38px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--so-night);
  background: var(--so-mint);
  border: none; border-radius: 10px;
}
#liveBtn[data-live="false"] { background: var(--panel-hover); color: var(--panel-fg); }

#tt-stamp {
  flex: none;
  min-width: 168px;
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* speed cycles on tap: one wide target beats a slider */
.speed-btn {
  width: auto; min-width: 46px; padding: 0 10px;
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* style range and boat thumb */
#tt-range {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--so-hydro) 100%);
  opacity: 0.85;
}
#tt-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 34px; height: 34px;
  background: var(--so-night) center/20px no-repeat;
  background-image: var(--boat-thumb);
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
#tt-range::-moz-range-thumb {
  width: 34px; height: 34px;
  background: var(--so-night) center/20px no-repeat;
  background-image: var(--boat-thumb);
  border: 2px solid var(--accent);
  border-radius: 50%;
}
#tt-caption {
  margin-top: 8px;
  font-size: 11px; color: var(--panel-muted);
  text-align: center;
}

/* ---- lay out kpi strip ---- */
#kpibar {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 0;
  /* a narrow corridor scrolls the bar rather than pushing it under a panel */
  overflow-x: auto;
  scrollbar-width: none;
}
#kpibar::-webkit-scrollbar { display: none; }
/* too tight to fit: drop the fleet totals, as the phone layout does,
   so the crossing counts and the insights cap stay readable */
#kpibar.tight .kpi:not(.kpi-btn):not(.kpi-insight) { display: none; }
.kpi {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  /* shrinkable, so a tight corridor compresses the bar instead of clipping it */
  padding: 12px 16px; min-width: 0; flex: 0 1 auto;
  border-right: 1px solid var(--panel-border);
}
.kpi:last-child { border-right: none; }
.kpi .kv {
  font-size: 20px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi .kv.accent { color: var(--accent); }
.kpi .kl {
  margin-top: 4px; font-size: 10px; color: var(--panel-muted);
  text-transform: lowercase; letter-spacing: 0.02em;
}
.kpi-btn {
  cursor: pointer; font: inherit; color: var(--panel-fg); border: none;
  background: none; border-radius: 10px; transition: background 0.15s;
}
.kpi-btn:hover, .kpi-btn[aria-expanded="true"] { background: var(--panel-hover); }
.kpi-btn .kl::after { content: " ▾"; opacity: 0.55; }

/* insights entry caps the bar, filled in the highlight colour */
.kpi-insight {
  /* flex, so the arrow sits beside the label rather than under it */
  display: flex; flex-direction: row; align-items: center;
  justify-content: center; gap: 5px;
  padding: 0 20px; min-width: 0; flex: none;
  font: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: 0.01em; white-space: nowrap;
  color: var(--so-night); background: var(--accent);
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: filter 0.15s;
}
.kpi-insight::after { content: "\2197"; }
.kpi-insight:hover { filter: brightness(1.08); }

/* ---- frame kpi dropdown ---- */
#kpiDrop {
  top: 86px;
  transform: translateX(-50%);
  width: 300px; padding: 0; overflow: hidden; z-index: 1100;
}
.kpidrop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--panel-border);
}
#kpiDropTitle {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--panel-muted);
}
#kpiDropClose {
  width: 22px; height: 22px; line-height: 1;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 7px; font-size: 14px;
}
.kpidrop-list { max-height: 320px; overflow-y: auto; padding: 6px 8px 10px; }
.kpidrop-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px; border-radius: 10px;
  background: none; border: none; color: var(--panel-fg); text-align: left;
}
.kpidrop-row:hover { background: var(--panel-hover); }
.kpidrop-row + .kpidrop-row { border-top: 1px solid var(--panel-border); }
.kpidrop-dir {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.kpidrop-dir.inbound { background: rgba(96, 208, 184, 0.2); color: var(--so-mint); }
.kpidrop-dir.outbound { background: rgba(186, 240, 132, 0.18); color: var(--so-morning); }
.kpidrop-main { flex: 1; min-width: 0; }
.kpidrop-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpidrop-meta {
  font-size: 11px; color: var(--panel-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpidrop-time { flex: none; font-size: 11px; color: var(--panel-muted); }
.kpidrop-empty { padding: 12px; font-size: 12px; color: var(--panel-muted); }

/* ---- stack the left column so panels never collide ---- */
#leftcol {
  position: absolute;
  top: 152px;             /* clear the header badge with an even gap */
  bottom: 22px;
  left: 18px;
  width: 290px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;   /* gaps pass clicks through to the map */
}
#leftcol > .panel {
  position: static;
  pointer-events: auto;
  min-height: 0;          /* allow inner scroll areas to shrink */
}

/* ---- frame headlines panel ---- */
#headlines {
  width: 290px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;         /* news takes the spare height */
}
.hl-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px;
}
.hl-head h2 {
  margin: 0; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--panel-muted);
}
.hl-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--so-dear); animation: ping 2s infinite;
}

/* ---- feed switch: news vs truth social ---- */
.feed-switch {
  display: inline-flex; gap: 2px;
  background: var(--panel-hover);
  border: 1px solid var(--panel-border);
  border-radius: 9px; padding: 2px;
}
.feed-tab {
  padding: 4px 9px; border: none; background: none; border-radius: 7px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--panel-muted);
  transition: background 0.15s, color 0.15s;
}
.feed-tab:hover { color: var(--panel-fg); }
.feed-tab[aria-selected="true"] { background: var(--panel-fg); color: var(--so-night); }
.feed-tab[aria-selected="true"]:hover { color: var(--so-night); }

/* ---- truth social post cards ---- */
.tw-item {
  display: block; padding: 9px 8px; border-radius: 10px;
  text-decoration: none; color: var(--panel-fg);
}
.tw-item:hover { background: var(--panel-hover); }
.tw-item + .tw-item { border-top: 1px solid var(--panel-border); }
.tw-src {
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--so-morning);
}
.tw-text {
  font-size: 12px; line-height: 1.4; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
  overflow: hidden;
}
.hl-list { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 10px; }
.hl-item {
  display: block; padding: 8px; border-radius: 10px;
  text-decoration: none; color: var(--panel-fg);
}
.hl-item:hover { background: var(--panel-hover); }
.hl-item + .hl-item { border-top: 1px solid var(--panel-border); }
.hl-src {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--panel-muted);
}
.hl-item.primary .hl-src { color: var(--so-morning); }
.hl-title { font-size: 12px; line-height: 1.35; margin-top: 2px; }
.hl-time {
  font-size: 10px; color: var(--panel-muted); margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.hl-empty { padding: 8px; font-size: 12px; color: var(--panel-muted); }

/* ---- size trend mini chart ---- */
#trend { width: 100%; height: 56px; }
#trend svg { width: 100%; height: 100%; display: block; overflow: visible; }
#trend rect { transition: opacity 0.15s; }
#trend rect:hover { opacity: 0.7; }

/* ---- dock ship finder at the foot of the news ---- */
.ship-finder { flex: 0 0 auto; border-top: 1px solid var(--panel-border); }
.sf-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 11px 16px; background: none; border: none;
  color: var(--panel-fg); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.sf-chev { color: var(--panel-muted); transition: transform 0.2s; }
.ship-finder:not(.collapsed) .sf-chev { transform: rotate(180deg); }
.ship-finder.collapsed .sf-body { display: none; }
.sf-body { padding: 0 16px 12px; }
#shipSearch {
  width: 100%; padding: 8px 10px;
  font-size: 12px; font-family: inherit;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 10px;
}
#shipSearch::placeholder { color: var(--panel-muted); }
.cx-search-hint {
  display: block; margin-top: 5px; min-height: 12px;
  font-size: 10px; color: var(--panel-muted);
}

/* ---- dock the map scale at the sources tray foot ---- */
.scale-tray {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--panel-border);
}
.scale-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--panel-muted);
}
.scale-tray .leaflet-control {
  float: none; margin: 0;
}
.scale-tray .leaflet-control-scale-line {
  border: 1px solid var(--panel-border); border-top: none;
  background: var(--panel-hover); color: var(--panel-fg);
  font-size: 10px; line-height: 1.5; padding: 1px 8px 2px;
  text-align: center; white-space: nowrap; text-shadow: none;
  font-variant-numeric: tabular-nums;
}

/* ---- highlight search marker ---- */
.search-marker svg { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)); }

/* ---- frame sources tray ---- */
#sources { bottom: 22px; right: 18px; width: 262px; padding: 0; overflow: hidden; }
.src-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 16px; background: none; border: none;
  color: var(--panel-fg); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.src-chev { color: var(--panel-muted); transition: transform 0.2s; }
#sources.collapsed .src-chev { transform: rotate(180deg); }
#sources.collapsed .src-body { display: none; }
.src-body { padding: 0 16px 14px; }
.src-group { padding: 8px 0; border-top: 1px solid var(--panel-border); }
.src-label {
  display: block; margin-bottom: 4px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--panel-muted);
}
.src-group a {
  font-size: 12px; color: var(--so-hydro); text-decoration: none;
  margin-right: 10px; border-bottom: 1px solid transparent;
}
.src-group a:hover { border-bottom-color: var(--so-hydro); }
.src-note {
  display: block; margin-top: 4px;
  font-size: 10px; line-height: 1.4; color: var(--panel-muted);
}

/* ---- style lng vessel marker ---- */
/* vessel dots: carriers and tankers, sized by tier.
   --dot-scale grows them with zoom so they hold their own against the
   imagery; scaling from the centre keeps the dot on its anchor. */
.v-dot {
  display: block; width: 100%; height: 100%;
  border-radius: 50%;
  transform: scale(var(--dot-scale, 1));
}
.v-lng {
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 7px var(--accent);
}
.v-tanker {
  background: var(--tanker);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
}

/* ---- theme leaflet popups ---- */
.leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  color: var(--panel-fg);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}
.leaflet-popup-tip { background: var(--panel-bg); }
.vpop .vname { font-size: 14px; font-weight: 700; margin-bottom: 1px; }
.vpop .vflag { font-size: 12px; color: var(--panel-muted); margin-bottom: 7px; }
.vpop .vtier {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 999px; margin-bottom: 8px;
  background: var(--accent); color: var(--so-night);
}
.vpop table { font-size: 12px; border-collapse: collapse; }
.vpop td { padding: 2px 0; }
.vpop td.k { color: var(--panel-muted); padding-right: 12px; }
.vpop td.v { font-variant-numeric: tabular-nums; }

/* ---- port atlas: faint always-on, bright when a carrier is bound there ---- */
.port-marker { display: flex; align-items: center; gap: 6px; }
.port-square {
  flex: none; width: 9px; height: 9px;
  background: none; border: 1.5px solid var(--so-dusk); border-radius: 2px;
  opacity: 0.7;
}
.port-label {
  display: none;                 /* faint names appear only when zoomed in */
  background: rgba(24, 48, 54, 0.58);
  color: var(--so-day);
  font-size: 10px; font-weight: 400; opacity: 0.85;
  padding: 1px 5px; border-radius: 5px; white-space: nowrap;
}
.ports-named .port-marker .port-label { display: block; }
.port-marker.active .port-square {
  width: 11px; height: 11px; border: 2px solid var(--so-dear); opacity: 1;
}
.port-marker.active .port-label {
  display: block; opacity: 1;
  background: rgba(24, 48, 54, 0.7); font-size: 11px;
}

/* ---- phone: map first, feeds and controls stand down ---- */
#phoneDock { display: none; }

@media (max-width: 720px) {
  /* the feed column and the control panel are desktop-only */
  #leftcol, #controls { display: none; }

  /* header shrinks to a status strip across the top */
  #header {
    top: 8px; left: 8px; right: 8px;
    max-width: none; padding: 9px 12px;
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  }
  #header h1 { font-size: 14px; }
  #header .sub { margin-top: 0; font-size: 11px; }
  /* the strait status and the clock earn the space, the poll time does not */
  #header .live-line { display: none; }
  #header .insight-link { display: none; }   /* the dock carries this on phone */

  /* port names only once zoomed in, or they pile up on each other */
  #map:not(.ports-named) .port-label { display: none; }

  /* kpi numbers sit under the header, whatever height it wraps to */
  #kpibar {
    top: calc(var(--head-h, 85px) + 16px); left: 8px; right: 8px;
    width: auto; transform: none;
    display: flex; gap: 0;
    overflow-x: auto; scrollbar-width: none;
    padding: 8px 4px;
  }
  #kpibar::-webkit-scrollbar { display: none; }
  #kpibar .kpi { flex: 1 1 auto; padding: 0 10px; }
  #kpibar .kpi-insight { display: none; }   /* the dock carries this on phone */
  #kpibar .kv { font-size: 17px; }
  /* the fleet totals go, so the crossing counts fit without scrolling */
  #kpibar .kpi:not(.kpi-btn) { display: none; }

  /* time travel spans the width, above the action dock */
  #timebar {
    left: 8px; right: 8px; bottom: 86px;
    width: auto; transform: none;
    padding: 10px 12px 12px;
  }
  #timebar .row { gap: 9px; }
  #liveBtn { padding: 0 11px; height: 34px; font-size: 11px; }
  .tt-btn { width: 34px; height: 34px; }
  #tt-range { min-width: 0; }
  #tt-stamp { min-width: 0; font-size: 11px; }
  #tt-caption { font-size: 10px; margin-top: 6px; }
  /* the speed reading earns the line, the instruction does not */
  .tt-hint { display: none; }

  /* the dock holds the night switch and the insights button */
  #phoneDock {
    display: flex; align-items: center; gap: 10px;
    left: 8px; right: 8px; bottom: 8px;
    padding: 10px 12px;
  }
  #phoneDock .mode-switch { flex: none; }
  #phoneDock .insights-banner { flex: 1; width: auto; margin: 0; padding: 11px 12px; }

  /* attribution leaves the top and opens as a sheet from the dock */
  #sources {
    top: auto; bottom: 86px; left: 8px; right: 8px; width: auto;
    max-height: 58vh; overflow-y: auto;
  }
  #sources.collapsed { display: none; }
  #sources .src-toggle { padding: 10px 14px; font-size: 10px; }
  #scaleTray { display: none; }

  /* the bloom tightens, or a crowd of vessels merges into one blob */
  body.night .v-lng {
    box-shadow: 0 0 2px #FFFFFF, 0 0 5px var(--accent), 0 0 11px var(--accent);
  }
  body.night .v-tanker {
    box-shadow: 0 0 2px #FFFFFF, 0 0 5px var(--tanker), 0 0 10px var(--tanker);
  }
}

/* ---- insights entry link in the dark header ---- */
.insight-link {
  margin-top: 10px; align-self: flex-start;
  background: none; border: none; padding: 0;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--accent);
}
.insight-link::after { content: " \2197"; }
.insight-link:hover { text-decoration: underline; text-underline-offset: 3px; }


/* ---- map mode switch ---- */
.mode-switch {
  display: flex; gap: 6px;
}
.mode-switch button {
  padding: 0 12px; height: 30px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 9px;
}
.mode-switch button[aria-pressed="true"] {
  color: var(--so-night); background: var(--accent); border-color: transparent;
}

/* ---- night mode: dark chart-room look over a desaturated basemap ---- */
body.night {
  --panel-bg: rgba(7, 13, 24, 0.9);
  --panel-fg: #E6EEF8;
  --panel-muted: #8C9FB4;
  --panel-border: rgba(126, 180, 240, 0.2);
  --panel-hover: rgba(126, 180, 240, 0.1);
  --shadow: 0 12px 46px rgba(0, 0, 0, 0.7);
}
body.night, body.night html { background: #050a13; }
/* hold enough colour for the sea to stay blue, then darken hard */
body.night .leaflet-tile-pane {
  filter: saturate(0.7) brightness(0.34) contrast(1.35) hue-rotate(-14deg);
}
/* neon: a white-hot core inside a deep bloom of the tier colour */
body.night .v-lng {
  background: #FBFFE8;
  box-shadow:
    0 0 3px #FFFFFF,
    0 0 8px var(--accent),
    0 0 16px var(--accent),
    0 0 30px var(--accent),
    0 0 48px var(--accent);
}
body.night .v-tanker {
  background: #EAFEFF;
  box-shadow:
    0 0 3px #FFFFFF,
    0 0 7px var(--tanker),
    0 0 14px var(--tanker),
    0 0 26px var(--tanker),
    0 0 42px var(--tanker);
}
/* port and label chrome lifts off the darker ground */
body.night .port-label {
  color: #EAF2FF;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 1);
}

/* popup footnote: says when a dot is projected rather than measured */
.vnote {
  margin-top: 8px; padding-top: 7px;
  border-top: 1px solid var(--panel-border);
  font-size: 10.5px; line-height: 1.4; color: var(--panel-muted);
}

/* incidents feed rows: badges carry the type and the vessel's fate */
.inc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.inc-badge {
  padding: 1px 7px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--panel-border); color: var(--panel-muted);
}
.inc-badge.attack, .inc-badge.sunk { border-color: var(--so-dear); color: var(--so-dear); }
.inc-badge.held { border-color: var(--so-morning); color: var(--so-morning); }
.inc-why { margin-top: 5px; }

/* ---- tint swatches in the vessels legend ---- */
/* the swatch is its own click target, so it needs the pointer cue */
.filter .glyph.tintable { cursor: pointer; border-radius: 50%; }
.filter .glyph.tintable:hover { box-shadow: 0 0 0 3px var(--panel-hover); }

/* ---- colour row in the settings dock ---- */
.tint-btns { display: flex; gap: 6px; }
.tint-btns button {
  width: 36px; height: 30px;
  display: grid; place-items: center;
  background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 9px;
}
.tint-btns button:hover { background: rgba(241, 242, 241, 0.16); }
.tint-btns i { width: 14px; height: 14px; border-radius: 50%; display: block; }
.tint-btns .tint-lng i { background: var(--accent); }
.tint-btns .tint-tanker i { background: var(--tanker); }

/* ---- colour picker popover ---- */
.cp {
  position: fixed;
  z-index: 2000;
  width: 208px;
  padding: 12px;
  background: var(--panel-bg);
  color: var(--panel-fg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  user-select: none;
}
.cp-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px;
}
.cp-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--panel-muted);
}
.cp-close {
  width: 20px; height: 20px; line-height: 1;
  font-size: 15px; color: var(--panel-muted);
  background: none; border: 0; border-radius: 6px;
}
.cp-close:hover { color: var(--panel-fg); background: var(--panel-hover); }

/* the saturation and brightness field, hue behind two gradients */
.cp-field {
  position: relative;
  height: 128px;
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
}
/* the hue rail runs the full gamut */
.cp-hue {
  position: relative;
  height: 14px;
  margin-top: 10px;
  border-radius: 999px;
  cursor: ew-resize;
  touch-action: none;
  background: linear-gradient(to right,
    #FF0000, #FFFF00, #00FF00, #00FFFF, #0000FF, #FF00FF, #FF0000);
}
.cp-field:focus-visible, .cp-hue:focus-visible { outline-offset: 3px; }

/* one knob style serves both tracks */
.cp-knob {
  position: absolute;
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cp-hue .cp-knob { top: 50%; }

.cp-foot { display: flex; align-items: center; gap: 7px; margin-top: 11px; }
.cp-chip {
  width: 22px; height: 22px; flex: none;
  border-radius: 7px;
  border: 1px solid var(--panel-border);
}
.cp-hex {
  flex: 1; min-width: 0;
  padding: 4px 7px;
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 7px;
}
.cp-reset {
  padding: 4px 9px;
  font-size: 11px; font-weight: 600;
  color: var(--panel-muted); background: none;
  border: 1px solid var(--panel-border); border-radius: 7px;
}
.cp-reset:hover { color: var(--panel-fg); background: var(--panel-hover); }
