/* ==========================================================================
   WORLDWATCH — global monitoring station
   Dark command-center theme. No external fonts or assets.
   ========================================================================== */

:root {
  --bg-0: #0d0d0d;
  --bg-1: #141414;
  --bg-2: #1b1b1b;
  --bg-3: #242424;
  --panel: rgba(31, 31, 31, 0.72);
  --panel-solid: #1a1a1a;
  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.05);
  --ink: #ececec;
  --ink-dim: #a6a6a6;
  --ink-faint: #6e6e6e;
  --cyan: #38e1ff;
  --cyan-dim: #1b7f96;
  --amber: #ffb020;
  --red: #ff4d5e;
  --red-deep: #c31b2b;
  --green: #35d07f;
  --violet: #9a7bff;
  --orange: #ff8a3d;

  --sev-extreme: #ff3b52;
  --sev-high: #ff8a3d;
  --sev-moderate: #ffcc45;
  --sev-low: #48d29a;

  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", ui-monospace,
    Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 50% -12%, #1c1c1c, transparent 70%),
    #141414;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

::selection { background: rgba(56, 225, 255, 0.28); color: #fff; }

/* ---- inline icons & flags ---- */
.i { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex: none; }
.flag {
  width: 1.35em; height: 0.95em; object-fit: cover; border-radius: 2px;
  vertical-align: -0.12em; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  background: rgba(255, 255, 255, 0.05);
}

/* ---- scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.22) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 20px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.94), rgba(18, 18, 18, 0.72));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}


.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .globe {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  background:
    radial-gradient(9px 9px at 11px 10px, rgba(56,225,255,0.9), transparent 60%),
    conic-gradient(from 210deg, #123, #245, #123);
  border: 1px solid rgba(56,225,255,0.5);
  box-shadow: 0 0 18px rgba(56,225,255,0.35), inset 0 0 12px rgba(0,0,0,0.6);
  position: relative; animation: spin 26s linear infinite;
}
.brand .globe::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  background: repeating-linear-gradient(0deg, transparent 0 5px, rgba(0,0,0,0.25) 5px 6px),
              repeating-linear-gradient(90deg, transparent 0 6px, rgba(0,0,0,0.18) 6px 7px);
  opacity: 0.5;
}
@keyframes spin { to { transform: rotate(360deg); } }

.brand h1 {
  font-size: 17px; letter-spacing: 3px; margin: 0; font-weight: 800;
  background: linear-gradient(90deg, #eaf6ff, #7fd8ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .sub {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px;
  color: var(--ink-faint); text-transform: uppercase;
}

.topbar .spacer { flex: 1; }

.readout { display: flex; align-items: center; gap: 20px; }
.readout .cell { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.readout .cell .k { font-family: var(--mono); font-size: 9px; letter-spacing: 1.5px; color: var(--ink-faint); text-transform: uppercase; }
.readout .cell .v { font-family: var(--mono); font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.readout .cell .v.clock { color: var(--cyan); }

.live-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; font-weight: 700;
  color: #ffdfe3; padding: 6px 11px; border-radius: 999px;
  background: rgba(255, 77, 94, 0.12); border: 1px solid rgba(255, 77, 94, 0.4);
}
.live-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 0 rgba(255,77,94,0.7); animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,77,94,0.6); }
  70% { box-shadow: 0 0 0 9px rgba(255,77,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,77,94,0); }
}

.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
  color: var(--ink-dim); background: rgba(255,255,255,0.04);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 7px 12px; cursor: pointer; transition: 0.15s; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover { color: var(--ink); border-color: rgba(56,225,255,0.45); background: rgba(56,225,255,0.08); }
.btn:active { transform: translateY(1px); }
.btn .spin-ico { display: inline-block; }
.btn.loading .spin-ico { animation: spin 0.9s linear infinite; }

/* ==========================================================================
   Ticker
   ========================================================================== */
.ticker {
  display: flex; align-items: center; gap: 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255,77,94,0.06), rgba(18,18,18,0));
  overflow: hidden; height: 38px; position: sticky; top: 59px; z-index: 30;
}
.ticker .tag {
  flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: 2px;
  font-weight: 800; color: #ffd7db; background: var(--red-deep);
  padding: 0 14px; height: 100%; display: flex; align-items: center;
  text-transform: uppercase; box-shadow: 8px 0 20px rgba(195,27,43,0.4); z-index: 2;
}
.ticker .track-wrap { flex: 1; overflow: hidden; position: relative; height: 100%; }
.ticker .track {
  display: inline-flex; align-items: center; height: 100%;
  white-space: nowrap; will-change: transform;
  animation: marquee 90s linear infinite;
}
.ticker .track:hover { animation-play-state: paused; }
.ticker .item {
  font-size: 12.5px; color: var(--ink-dim); padding: 0 26px;
  position: relative; display: inline-flex; align-items: center; gap: 9px;
}
.ticker .item::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--cyan); flex: none; box-shadow: 0 0 8px var(--cyan);
}
.ticker .item b { color: var(--ink); font-weight: 600; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ==========================================================================
   Layout
   ========================================================================== */
.wrap { max-width: none; margin: 0; padding: 18px 20px; }

/* ==========================================================================
   Country intelligence drawer (left)
   ========================================================================== */
.country-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(390px, 92vw); z-index: 60;
  background: linear-gradient(180deg, rgba(22, 22, 22, 0.98), rgba(16, 16, 16, 0.98));
  border-right: 1px solid var(--line); box-shadow: 24px 0 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px); display: flex; flex-direction: column;
  transform: translateX(-101%); transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.country-drawer.open { transform: translateX(0); }
.cd-header {
  display: flex; align-items: center; gap: 12px; padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(56, 225, 255, 0.05), transparent);
}
.cd-flag { flex: none; display: inline-flex; }
.cd-flag .flag { width: 36px; height: 24px; border-radius: 3px; }
.cd-flag .i { width: 26px; height: 26px; color: var(--ink-dim); }
.cd-titles { flex: 1; min-width: 0; }
.cd-titles h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: 0.2px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-faint); margin-top: 2px; }
.cd-close {
  flex: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); color: var(--ink-dim);
  display: grid; place-items: center; transition: 0.14s;
}
.cd-close:hover { color: var(--ink); border-color: rgba(255, 77, 94, 0.5); background: rgba(255, 77, 94, 0.08); }
.cd-close .i { width: 16px; height: 16px; }
.cd-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.cd-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric {
  background: rgba(30, 30, 30, 0.55); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px;
}
.metric.wide { grid-column: 1 / -1; }
.metric-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.metric-name { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ink-dim); }
.metric-val { font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-val small { font-size: 11px; color: var(--ink-faint); font-weight: 500; }
.gauge { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; margin-top: 9px; }
.gauge > span { display: block; height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.metric-note { font-size: 10px; color: var(--ink-faint); margin-top: 7px; line-height: 1.4; }

.cd-section { display: flex; flex-direction: column; gap: 7px; }
.cd-section-h {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--ink-dim); display: flex; align-items: center; gap: 7px; margin-top: 4px;
}
.cd-section-h .i { width: 14px; height: 14px; color: var(--cyan); }
.cd-section-h .n { margin-left: auto; color: var(--ink-faint); }
.cd-mini {
  display: block; text-decoration: none; padding: 8px 10px; border-radius: 7px;
  border: 1px solid transparent; transition: 0.12s;
}
.cd-mini:hover { background: rgba(56, 225, 255, 0.06); border-color: var(--line); }
.cd-mini-t { display: block; font-size: 12px; color: var(--ink); line-height: 1.35; }
.cd-mini-m { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); margin-top: 3px; }
.cd-mini-m .src { color: var(--cyan); }
.cd-haz { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 7px 9px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; transition: 0.12s; }
.cd-haz:hover { background: rgba(56, 225, 255, 0.06); border-color: var(--line); }
.cd-haz-ic { display: inline-flex; }
.cd-haz-ic .i { width: 18px; height: 18px; }
.cd-haz-b { min-width: 0; display: flex; flex-direction: column; }
.cd-haz-t { display: block; font-size: 12px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-haz-m { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.cd-haz .d-sev { flex: none; }

/* maritime port table (IMF PortWatch) */
.mt-table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mt-row { display: grid; grid-template-columns: 1.3fr 0.85fr 0.8fr 0.72fr 0.75fr; gap: 6px; padding: 7px 10px; align-items: center; border-top: 1px solid var(--line-soft); }
.mt-row:first-child { border-top: 0; }
.mt-head { background: rgba(10, 10, 10, 0.6); }
.mt-head span { font-family: var(--mono); font-size: 8px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--ink-faint); line-height: 1.15; }
.mt-head span:not(:first-child), .mt-row > span:not(.mt-port) { text-align: right; }
.mt-port { font-size: 11.5px; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-n { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.mt-t { font-family: var(--mono); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.mt-up { color: var(--green); }
.mt-down { color: var(--red); }
.mt-flat { color: var(--ink-faint); }
.mt-src { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); margin-top: 6px; }
.cd-empty { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); padding: 8px 10px; }
.cd-skel { height: 60px; border-radius: var(--radius-sm); }
.cd-disclaim { font-size: 9.5px; color: var(--ink-faint); line-height: 1.5; border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 2px; }
@media (max-width: 620px) { .country-drawer { width: 100vw; } }

/* ---- map + countries panel ---- */
.map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}
.countries-panel { display: flex; flex-direction: column; min-width: 0; }
.country-filter { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.country-filter input {
  width: 100%; font-family: var(--mono); font-size: 12px; color: var(--ink);
  background: rgba(10, 10, 10, 0.7); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 11px; outline: none; transition: 0.15s;
}
.country-filter input:focus { border-color: rgba(56,225,255,0.5); box-shadow: 0 0 0 3px rgba(56,225,255,0.1); }
.country-scroll { flex: 1; min-height: 0; position: relative; }
.country-list { position: absolute; inset: 0; overflow-y: auto; padding: 6px; }
.c-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
  transition: 0.12s; user-select: none;
}
.c-item:hover { background: rgba(56,225,255,0.06); border-color: var(--line); }
.c-item.active { background: rgba(56,225,255,0.12); border-color: rgba(56,225,255,0.4); }
.c-item.active .c-name { color: var(--cyan); font-weight: 600; }
.c-flag { width: 22px; flex: none; display: inline-flex; justify-content: center; color: var(--ink-dim); }
.c-flag .flag { width: 21px; height: 14px; }
.c-flag .i { width: 15px; height: 15px; }
.c-name { font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-code { margin-left: auto; flex: none; font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); }
.c-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: transparent; }
.c-item.c-alert .c-dot { background: var(--red); box-shadow: 0 0 7px var(--red); animation: pulse 1.9s infinite; }
@media (max-width: 1100px) {
  .map-grid { grid-template-columns: 1fr; }
  .country-scroll { flex: none; height: 40vh; }
}

.mid-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
  gap: 18px;
  margin-top: 18px;
  align-items: stretch;   /* both columns share the taller one's height */
}
@media (max-width: 1100px) { .mid-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  overflow: hidden;
  position: relative;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.panel-head h2 {
  margin: 0; font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  font-weight: 700; color: var(--ink); font-family: var(--mono);
}
.panel-head .count {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.panel-head .hd-ico { color: var(--cyan); display: inline-flex; }
.panel-head .hd-ico .i { width: 16px; height: 16px; }

/* ==========================================================================
   Map
   ========================================================================== */
.map-panel { display: flex; flex-direction: column; }
.map-stage {
  position: relative; width: 100%;
  aspect-ratio: 1000 / 480; max-height: 74vh; min-height: 300px;
  background:
    radial-gradient(900px 500px at 50% 40%, rgba(44,44,44,0.4), transparent 70%),
    linear-gradient(180deg, #101010, #0b0b0b);
  cursor: grab; overflow: hidden;
  user-select: none; -webkit-user-select: none;   /* don't drag-select labels while panning */
}
.map-stage.grabbing { cursor: grabbing; }
/* The svg must be positioned with a z-index so it paints ABOVE the globe
   texture canvas (positioned elements otherwise paint over static ones). */
#map { width: 100%; height: 100%; display: block; touch-action: none; position: relative; z-index: 1; }

.map-stage .graticule { stroke: rgba(90,130,190,0.08); stroke-width: 0.5; fill: none; }
.country {
  fill: #2a2a2a; stroke: rgba(110,150,210,0.28);
  stroke-width: 0.6; vector-effect: non-scaling-stroke;
  transition: fill 0.15s;
}
.country:hover { fill: #3a3a3a; }
.country.selected { fill: #2b3b42; stroke: var(--cyan); }

.clabel {
  fill: rgba(223, 234, 255, 0.82); font-family: var(--mono); font-weight: 600;
  text-anchor: middle; letter-spacing: 0.4px; pointer-events: none;
  paint-order: stroke; stroke: rgba(4, 7, 14, 0.9); stroke-width: 2.4px;
  stroke-linejoin: round; vector-effect: non-scaling-stroke;
}
.map-labels.off { display: none; }

/* satellite basemap */
.sat-layer { display: none; }
#map.sat .sat-layer { display: block; }

/* ---- globe (Google-Earth style) ---- */
.globe-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; pointer-events: none; z-index: 0; }
.sat-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; pointer-events: none; z-index: 2; }
.layer-toggle.o .swatch { border-color: #6ee7ff; background: rgba(110,231,255,0.35); box-shadow: 0 0 6px rgba(110,231,255,0.6); }
#orbit-count { margin-left: 5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.layer-toggle.o:not(.off) #orbit-count { color: var(--cyan); }
.sat-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 21; display: none;
  flex-direction: column; gap: 4px; padding: 9px 11px; border-radius: var(--radius-sm);
  background: rgba(10, 12, 18, 0.72); border: 1px solid var(--line); backdrop-filter: blur(6px);
}
.sat-legend.show { display: flex; }
.sat-legend .row { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 10px; color: var(--ink-dim); }
.sat-legend .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.sat-legend .cap { font-family: var(--mono); font-size: 8.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 2px; }
.layer-toggle.w .swatch { border-color: var(--sev-high); background: rgba(255,138,61,0.4); box-shadow: 0 0 6px rgba(255,138,61,0.6); }
#storm-count { margin-left: 5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.layer-toggle.w:not(.off) #storm-count { color: var(--sev-high); }

/* ---- storm tracks ---- */
#storms { pointer-events: none; }
.storm-cone { fill-opacity: 0.13; stroke: none; }
.storm-track-past { fill: none; stroke: rgba(255,255,255,0.75); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.storm-track-fore { fill: none; stroke-width: 2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.storm-fp { fill: #fff; stroke: rgba(0,0,0,0.55); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.storm-center { pointer-events: auto; cursor: pointer; }
.storm-pulse { fill: currentColor; opacity: 0.28; transform-box: fill-box; transform-origin: center; animation: ping 2.6s ease-out infinite; }
.storm-eye { color: currentColor; }
.storm-lbl { fill: #fff; font-family: var(--mono); font-size: 8px; font-weight: 700; letter-spacing: 0.3px; paint-order: stroke; stroke: rgba(0,0,0,0.85); stroke-width: 2.6px; stroke-linejoin: round; }

/* ---- active storms list (top-right of map) ---- */
.storm-list {
  position: absolute; top: 12px; right: 12px; z-index: 21; display: none;
  width: 214px; max-height: calc(100% - 24px); flex-direction: column;
  background: rgba(10, 12, 18, 0.78); border: 1px solid var(--line); border-radius: var(--radius-sm);
  backdrop-filter: blur(8px); overflow: hidden;
}
.storm-list.show { display: flex; }
.sl-head { font-family: var(--mono); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-dim); padding: 9px 11px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 6px; }
.sl-head .i { width: 13px; height: 13px; color: var(--sev-high); }
.sl-body { overflow-y: auto; padding: 5px; }
.sl-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; transition: 0.12s; }
.sl-item:hover { background: rgba(56,225,255,0.06); border-color: var(--line); }
.sl-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sl-text { min-width: 0; }
.sl-name { display: block; font-size: 12px; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-meta { display: block; font-family: var(--mono); font-size: 9px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 620px) { .storm-list { width: 168px; } }
#map.globe #flat-grat, #map.globe #flat-countries, #map.globe .sat-layer { display: none; }
#map:not(.globe) #globe-root { display: none; }
#map.globe.sat .g-ocean, #map.globe.sat .g-shade { display: none; }
.mode-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-right: 4px; }
.mode-seg button {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.5px;
  padding: 6px 12px; background: transparent; color: var(--ink-dim);
  border: 0; cursor: pointer; transition: 0.14s;
}
.mode-seg button:hover { color: var(--ink); }
.mode-seg button.active { background: linear-gradient(90deg, var(--cyan), #6ee7ff); color: #04121a; font-weight: 700; }
#map.sat .country { fill: transparent; stroke: rgba(255, 255, 255, 0.55); }
#map.sat .country:hover { fill: rgba(56, 225, 255, 0.16); }
#map.sat .country.selected { fill: rgba(56, 225, 255, 0.2); stroke: var(--cyan); }
#map.sat .graticule { stroke: rgba(255, 255, 255, 0.07); }
#map.sat .clabel { fill: #ffffff; stroke: rgba(0, 0, 0, 0.95); stroke-width: 2.8px; }

.marker { cursor: pointer; }
.marker circle { transition: opacity 0.2s; }
.mk-quake { fill: rgba(255,180,32,0.16); stroke: var(--amber); }
.mk-quake-big { fill: rgba(255,77,94,0.2); stroke: var(--red); }
.mk-alert-red { fill: rgba(255,59,82,0.22); stroke: var(--sev-extreme); }
.mk-alert-orange { fill: rgba(255,138,61,0.2); stroke: var(--sev-high); }
.mk-alert-green { fill: rgba(53,208,127,0.16); stroke: var(--green); }
.mk-event { fill: rgba(154,123,255,0.18); stroke: var(--violet); }
.marker .ping {
  fill: none; stroke-width: 1.4; vector-effect: non-scaling-stroke;
  transform-box: fill-box; transform-origin: center;
  animation: ping 2.6s ease-out infinite;
}
@keyframes ping {
  0% { opacity: 0.9; transform: scale(0.4); }
  80%, 100% { opacity: 0; transform: scale(2.6); }
}

.map-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--line-soft);
  background: rgba(10, 10, 10, 0.6);
}
.layer-toggle {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.5px;
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-dim); user-select: none; transition: 0.15s;
}
.layer-toggle:hover { border-color: rgba(56,225,255,0.4); color: var(--ink); }
.layer-toggle.off { opacity: 0.42; }
.layer-toggle .swatch { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid; }
.layer-toggle.q .swatch { border-color: var(--amber); background: rgba(255,180,32,0.25); }
.layer-toggle.e .swatch { border-color: var(--violet); background: rgba(154,123,255,0.25); }
.layer-toggle.a .swatch { border-color: var(--sev-extreme); background: rgba(255,59,82,0.25); }
.layer-toggle.l .swatch { border-color: var(--ink-dim); background: rgba(223,234,255,0.25); }
.layer-toggle.s .swatch { border-color: var(--green); background: rgba(53,208,127,0.28); }
.map-toolbar .grow { flex: 1; }
.map-hint { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); letter-spacing: 0.5px; }
@media (max-width: 720px) { .map-hint { display: none; } }
.zoom-btns { display: inline-flex; gap: 6px; }
.zoom-btns button {
  width: 30px; height: 28px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
  color: var(--ink-dim); cursor: pointer; font-size: 15px; line-height: 1;
  font-family: var(--mono); transition: 0.15s;
}
.zoom-btns button:hover { color: var(--ink); border-color: rgba(56,225,255,0.45); }

.map-tooltip {
  position: absolute; pointer-events: none; z-index: 20;
  background: rgba(22, 22, 22, 0.96); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px; max-width: 280px;
  font-size: 12px; color: var(--ink); opacity: 0; transform: translateY(4px);
  transition: opacity 0.12s; box-shadow: 0 12px 30px rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}
.map-tooltip.show { opacity: 1; transform: translateY(0); }
.map-tooltip .tt-title { font-weight: 700; margin-bottom: 3px; }
.map-tooltip .tt-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); }
.map-tooltip .tt-sev { display: inline-block; padding: 1px 6px; border-radius: 4px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.5px; margin-top: 5px; }

/* ==========================================================================
   Live TV
   ========================================================================== */
.tv-panel { display: flex; flex-direction: column; }
.tv-open {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.5px; color: var(--ink-dim);
  text-decoration: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 9px; margin-left: 10px; transition: 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
#tv-status .tvs { display: inline-flex; align-items: center; gap: 5px; }
#tv-status .tvs.on { color: var(--red); }
.tv-open:hover { color: var(--cyan); border-color: rgba(56,225,255,0.45); }
.tv-player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.tv-frame-wrap { position: absolute; inset: 0; }
.tv-frame { width: 100%; height: 100%; border: 0; display: block; }
.tv-loading {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--ink-dim); font-family: var(--mono); font-size: 13px; gap: 10px; padding: 24px; flex-direction: column;
}
.tv-loading a { color: var(--cyan); text-decoration: none; border-bottom: 1px dotted var(--cyan); }
.tv-grid-head {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink-faint); padding: 11px 13px 2px; border-top: 1px solid var(--line-soft);
}
.tv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px; padding: 9px 13px 13px;
}
.tv-box {
  position: relative; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--line); background: #0d0d0d; cursor: pointer; padding: 0;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s; font-family: var(--sans);
}
.tv-box:hover { border-color: rgba(56,225,255,0.5); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.45); }
.tv-box.active { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(56,225,255,0.4), 0 8px 26px rgba(0,0,0,0.55); }
.tv-box.active::after {
  content: "ON AIR"; position: absolute; top: 6px; left: 6px; z-index: 2;
  font-family: var(--mono); font-size: 8px; font-weight: 700; letter-spacing: 0.5px;
  color: #04121a; background: var(--cyan); padding: 2px 6px; border-radius: 4px;
}
.tv-box-thumb { position: absolute; inset: 0; }
.tv-box-thumb .tv-box-ph { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 38%, #2a2a2a, #141414); }
.tv-box-thumb .thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tv-box-flag-lg { display: inline-flex; }
.tv-box-label {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  display: flex; align-items: center; gap: 5px; padding: 12px 7px 5px; font-size: 10px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.9));
}
.tv-box-flag { flex: none; display: inline-flex; }
.tv-box-flag .flag { width: 16px; height: 11px; }
.tv-box-flag-lg .flag { width: 40px; height: 27px; opacity: 0.6; box-shadow: none; }
.tv-box-name { font-family: var(--mono); font-weight: 600; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-box-live {
  margin-left: auto; flex: none; display: none; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: 8px; font-weight: 700; letter-spacing: 0.5px;
  color: #fff; background: var(--red); padding: 1px 5px; border-radius: 3px;
}
.tv-box-live.on { display: inline-flex; }
.tv-box-live::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
.tv-box.offline { opacity: 0.5; }

/* ==========================================================================
   Right column: stats + disasters
   ========================================================================== */
.side-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; min-height: 0; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--cyan)); opacity: 0.8;
}
.stat .n { font-family: var(--mono); font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat .l { font-family: var(--mono); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); margin-top: 6px; }
.stat.warn { --accent: var(--amber); }
.stat.danger { --accent: var(--red); }
.stat.ok { --accent: var(--green); }
.stat.info { --accent: var(--violet); }

.disasters { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* The scroll wrapper is absolutely-filled by the list, so the list's content
   never inflates the grid row — the row is sized by the Live TV panel, and
   this fills whatever height is left over (bottoms line up exactly). */
.disaster-scroll { flex: 1; min-height: 0; position: relative; }
.disaster-list { position: absolute; inset: 0; overflow-y: auto; padding: 6px; }
/* Stacked layout has no sibling to match, so give the feed a fixed height.
   Placed after the base rule so it wins on source order at ≤1100px. */
@media (max-width: 1100px) { .disaster-scroll { flex: none; height: 58vh; } }
.d-item {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  padding: 10px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; transition: 0.13s;
}
.d-item:hover { background: rgba(56,225,255,0.06); border-color: var(--line); }
.d-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  font-size: 17px; background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  color: var(--ink-dim);
}
.d-icon .i { width: 19px; height: 19px; }
.d-icon-extreme { color: var(--sev-extreme); border-color: rgba(255,59,82,0.3); background: rgba(255,59,82,0.06); }
.d-icon-high { color: var(--sev-high); border-color: rgba(255,138,61,0.28); background: rgba(255,138,61,0.06); }
.d-icon-moderate { color: var(--sev-moderate); }
.d-icon-low { color: var(--sev-low); }
.d-body { min-width: 0; }
.d-title { font-size: 13px; color: var(--ink); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.d-meta { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.d-sev {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; font-weight: 700;
  padding: 3px 7px; border-radius: 5px; white-space: nowrap; text-transform: uppercase;
}
.sev-extreme { background: rgba(255,59,82,0.16); color: #ff7684; border: 1px solid rgba(255,59,82,0.4); }
.sev-high { background: rgba(255,138,61,0.14); color: #ffa468; border: 1px solid rgba(255,138,61,0.38); }
.sev-moderate { background: rgba(255,204,69,0.14); color: #ffd772; border: 1px solid rgba(255,204,69,0.36); }
.sev-low { background: rgba(72,210,154,0.13); color: #6fe0b3; border: 1px solid rgba(72,210,154,0.34); }

/* ==========================================================================
   News section
   ========================================================================== */
.news-panel { margin-top: 18px; }
.news-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.field { position: relative; display: flex; align-items: center; }
.field .ico { position: absolute; left: 11px; color: var(--ink-faint); pointer-events: none; display: inline-flex; }
.select, .search-input {
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  background: rgba(10, 10, 10, 0.7); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px 9px 34px; outline: none;
  transition: 0.15s;
}
.select { padding-right: 30px; cursor: pointer; min-width: 190px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%);
  background-position: right 13px top 16px, right 8px top 16px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.search-input { min-width: 210px; }
.select:focus, .search-input:focus { border-color: rgba(56,225,255,0.5); box-shadow: 0 0 0 3px rgba(56,225,255,0.1); }
.search-form { display: flex; gap: 8px; }

.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.cat-tab {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.5px;
  color: var(--ink-dim); background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; cursor: pointer; transition: 0.14s; white-space: nowrap;
}
.cat-tab:hover { color: var(--ink); border-color: rgba(56,225,255,0.4); }
.cat-tab.active { color: #04121a; background: linear-gradient(90deg, var(--cyan), #6ee7ff); border-color: transparent; font-weight: 700; box-shadow: 0 4px 16px rgba(56,225,255,0.25); }
.cat-tab.hot.active { background: linear-gradient(90deg, var(--red), #ff7a88); box-shadow: 0 4px 16px rgba(255,77,94,0.3); color: #1a0508; }

.trends-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 10, 10, 0.35);
}
.trends-row .lbl { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-faint); display: inline-flex; align-items: center; gap: 6px; }
.trend-chip {
  font-family: var(--mono); font-size: 11px; color: var(--cyan);
  background: rgba(56,225,255,0.07); border: 1px solid rgba(56,225,255,0.22);
  border-radius: 999px; padding: 5px 11px; cursor: pointer; transition: 0.14s;
}
.trend-chip:hover { background: rgba(56,225,255,0.16); color: #baf4ff; }
.trend-chip .rank { color: var(--ink-faint); margin-right: 5px; }

.news-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px; padding: 16px;
}
.news-card {
  background: linear-gradient(180deg, rgba(30,30,30,0.55), rgba(22,22,22,0.55));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; display: flex; flex-direction: column; gap: 9px;
  text-decoration: none; color: inherit; transition: 0.16s; position: relative; overflow: hidden;
}
.news-card::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px transparent; transition: 0.16s; pointer-events: none;
}
.news-card:hover { transform: translateY(-2px); border-color: rgba(56,225,255,0.35); background: linear-gradient(180deg, rgba(38,38,38,0.65), rgba(24,24,24,0.65)); }
.news-card:hover::after { box-shadow: inset 0 0 0 1px rgba(56,225,255,0.2), 0 16px 40px rgba(0,0,0,0.4); }
.nc-top { display: flex; align-items: center; gap: 8px; }
.nc-src {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.5px; color: var(--cyan);
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px;
}
.nc-time { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-left: auto; white-space: nowrap; }
.nc-title { font-size: 14.5px; line-height: 1.38; font-weight: 600; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.nc-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.nc-flag { font-size: 15px; }
.nc-badge {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; color: var(--ink-dim);
  background: rgba(255,255,255,0.06); border: 1px solid var(--line);
}
.nc-read { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); display: inline-flex; align-items: center; gap: 4px; }
.news-card:hover .nc-read { color: var(--cyan); }

/* ---- states ---- */
.empty, .loading-block {
  grid-column: 1 / -1; text-align: center; padding: 48px 20px;
  color: var(--ink-faint); font-family: var(--mono); font-size: 12.5px;
}
.spinner {
  width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 14px;
  border: 2px solid rgba(255,255,255,0.14); border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}
.skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 132px; border-radius: var(--radius); }

.footer {
  text-align: center; padding: 26px 16px 40px; color: var(--ink-faint);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.5px; line-height: 1.8;
}
.footer a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px dotted var(--line); }
.footer a:hover { color: var(--cyan); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px);
  background: rgba(22,22,22,0.96); border: 1px solid var(--line); color: var(--ink);
  padding: 11px 18px; border-radius: 999px; font-family: var(--mono); font-size: 12px;
  z-index: 100; opacity: 0; transition: 0.25s; box-shadow: 0 12px 40px rgba(0,0,0,0.5); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255,77,94,0.5); color: #ffc4ca; }

@media (max-width: 620px) {
  .readout .cell.hide-sm { display: none; }
  .brand .sub { display: none; }
  .cat-tabs { margin-left: 0; }
  .news-grid { grid-template-columns: 1fr; }
}
