/* jafo — minimal dark UI, inspired by terminal monitors */

:root {
  --bg:        #0d1117;
  --bg-alt:    #161b22;
  --bg-hover:  #1f2630;
  --border:    #30363d;
  --text:      #e6edf3;
  --text-dim:  #8b949e;
  --text-faint: #6e7681;
  --accent:    #58a6ff;
  --accent-bg: #1f2937;
  --good:      #3fb950;
  --warn:      #d29922;
  --bad:       #f85149;
  --crit:      #ff6b6b;

  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  /* Aliases used by the sidebar toggle/hover styles */
  --surface:        var(--bg-hover);
  --surface-deeper: var(--bg-alt);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  height: 100vh;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar timeline";
}

/* ---- Topbar ---- */
.topbar {
  grid-area: topbar;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo-img {
  height: 40px;
  width: auto;
  display: block;
  /* Soft white halo to lift the dark artwork off the dark topbar */
  filter:
    drop-shadow(0 0 5px rgba(255, 255, 255, 0.85))
    drop-shadow(0 0 12px rgba(88, 166, 255, 0.45));
}
.brand .sub { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; }

.stats-bar {
  display: flex;
  gap: 20px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.stat strong { color: var(--text); font-weight: 600; }

.actions { display: flex; align-items: center; gap: 12px; }
.auto-refresh {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  cursor: pointer; user-select: none;
}

/* ---- Sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  /* Three-zone layout: fixed top (cell + incident types), scrolling middle
     (aircraft seen + severity + talkgroups), fixed bottom (GMRS). */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
  min-height: 0;
}
.sidebar-fixed-top    { flex: 0 0 auto; }
.sidebar-fixed-bottom {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  margin: 8px -12px 0;
  padding: 10px 12px 4px;
  background: var(--bg-alt);
}
.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  margin: 0 -12px;
  padding: 0 12px;
  min-height: 0;  /* required so the flex child can actually shrink + scroll */
}
.filter-more-btn {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
  font-family: var(--font-sans);
}
.filter-more-btn:hover { text-decoration: underline; }
.filter-more-btn.hidden { display: none; }

/* Aircraft-seen now lives in the fixed top zone — cap its visible
   height so a busy sky doesn't push everything else off-screen. */
.aircraft-block .ac-types-list {
  max-height: 168px;
  overflow-y: auto;
}

/* AI-enriched sparkle on call cards. Purple-ish to distinguish from the
   Groq "Enhanced" badge (which uses the same SVG in green). */
.ai-enriched {
  display: inline-flex;
  align-items: center;
  color: #a78bfa;
  margin-right: 2px;
}
.ai-enriched .ai-star {
  width: 14px;
  height: 14px;
  filter: drop-shadow(0 0 3px rgba(167, 139, 250, 0.5));
}

/* GMRS section pinned at the bottom of the column. Internal scroll keeps
   the overall height capped while still showing all configured channels. */
.gmrs-block { margin-bottom: 0; }
.gmrs-block .filter-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.gmrs-now {
  font: 11px var(--font-mono);
  color: var(--text-faint);
}
.gmrs-list {
  max-height: 168px;   /* ~6 rows visible, rest scrolls inside */
  overflow-y: auto;
  font: 12px var(--font-mono);
}
.gmrs-list li { padding: 2px 6px; font-size: 12px; }
.gmrs-empty { padding: 4px 6px; }
.search-block { margin-bottom: 16px; }
.search-block input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-sans);
}
.search-block input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-block { margin-bottom: 18px; }
.filter-block h3 {
  margin: 0 0 6px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
}
.filter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.filter-list li {
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.filter-list li:hover { background: var(--bg-hover); }
.filter-list li.active {
  background: var(--accent-bg);
  color: var(--accent);
}
.filter-list li .count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}
.filter-list li.active .count { color: var(--accent); }

/* ---- Cell-network glance widget (sidebar, above talkgroups) ---- */
.cell-glance-block .filter-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.cell-glance-block .filter-more {
  font: 10px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-faint);
  text-decoration: none;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.cell-glance-block .filter-more:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.cell-glance-list {
  list-style: none;
  margin: 4px 0 0 0;
  padding: 0;
  font: 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
}
.cell-glance-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 3px;
}
.cell-glance-list li:hover { background: var(--bg-hover); }
.cell-glance-list .op-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
  flex: 0 0 auto;
}
.cell-glance-list .op-name {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-glance-list .op-meta {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 10px;
}
.cell-glance-list .op-q {
  display: inline-block;
  padding: 0 4px;
  margin-left: 2px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: 9px;
  letter-spacing: 0.02em;
}
.cell-glance-list .q-excellent { color: #4cc06b; }
.cell-glance-list .q-good      { color: #88c060; }
.cell-glance-list .q-fair      { color: #e8d23c; }
.cell-glance-list .q-poor      { color: #ec8a3c; }
.cell-glance-list .q-marginal  { color: #ec4848; }
.cell-glance-list .q-unknown   { color: var(--text-faint); }
.cell-glance-list .cell-glance-empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 10px;
  padding: 4px;
}

/* ---- Leaflet aircraft overlay ---- */
.ac-leaflet {
  background: transparent !important;
  border: 0 !important;
  pointer-events: auto;
  cursor: pointer;
  /* Common shadow stack — gives the icon edge contrast against any
     OSM tile color. Source-specific filters extend this below. */
  filter:
    drop-shadow(0 0 1px rgba(0,0,0,1))
    drop-shadow(0 0 4px rgba(0,0,0,0.85))
    drop-shadow(0 0 10px rgba(255,255,255,0.6));
  z-index: 600 !important;
}
.ac-leaflet svg { display: block; }

/* Source tinting:
     verified — seen by local AND cloud:  bright cyan halo (priority)
     local    — seen only by local:        green halo (rare)
     cloud    — adsb.lol-only/unverified:  dimmed so verified planes pop  */
.ac-leaflet.ac-src-verified {
  filter:
    drop-shadow(0 0 2px rgba(0,0,0,1))
    drop-shadow(0 0 5px rgba(255,255,255,1))
    drop-shadow(0 0 12px rgba(76,231,255,0.95))
    drop-shadow(0 0 22px rgba(76,231,255,0.55));
}
.ac-leaflet.ac-src-local {
  filter:
    drop-shadow(0 0 2px rgba(0,0,0,1))
    drop-shadow(0 0 5px rgba(255,255,255,1))
    drop-shadow(0 0 12px rgba(76,255,140,0.95))
    drop-shadow(0 0 22px rgba(76,255,140,0.55));
}
.ac-leaflet.ac-src-cloud {
  opacity: 0.78;
  filter:
    drop-shadow(0 0 2px rgba(0,0,0,1))
    drop-shadow(0 0 4px rgba(255,255,255,0.85))
    drop-shadow(0 0 9px rgba(255,255,255,0.45));
}

/* Source labels inside the popup */
.leaflet-popup .ac-src-verified { color: #4ce7ff; font-weight: 700; }
.leaflet-popup .ac-src-local    { color: #4cff8c; font-weight: 700; }
.leaflet-popup .ac-src-cloud    { color: #b0b0b0; }

.ac-leaflet.ac-emergency {
  animation: ac-emerg-pulse 0.9s ease-in-out infinite;
}
@keyframes ac-emerg-pulse {
  0%, 100% { filter:
    drop-shadow(0 0 2px rgba(255,255,255,1))
    drop-shadow(0 0 8px rgba(255,80,80,0.95))
    drop-shadow(0 0 16px rgba(255,40,40,0.7)); }
  50%      { filter:
    drop-shadow(0 0 4px rgba(255,255,255,1))
    drop-shadow(0 0 14px rgba(255,40,40,1))
    drop-shadow(0 0 24px rgba(255,40,40,0.85)); }
}

/* Aircraft popup card (Leaflet popup body) */
.leaflet-popup .ac-pop {
  font: 11px/1.35 ui-monospace, "SF Mono", Menlo, monospace;
  min-width: 200px;
}
.leaflet-popup .ac-pop-head {
  display: flex; justify-content: space-between; gap: 6px;
  border-bottom: 1px solid #cfd9e1;
  padding-bottom: 4px;
  margin-bottom: 4px;
}
.leaflet-popup .ac-pop-time {
  font-size: 10px; color: #6c7a86;
}
.leaflet-popup .ac-pop-row {
  display: flex; justify-content: space-between; gap: 8px;
}
.leaflet-popup .ac-pop-key { color: #6c7a86; }
.leaflet-popup .ac-pop-event {
  margin-top: 4px; padding: 2px 6px; border-radius: 3px;
  text-align: center; font-weight: 700; font-size: 10px;
}
.leaflet-popup .ac-pop-event.dep { background: #1f5b2e; color: #d6ffd6; }
.leaflet-popup .ac-pop-event.arr { background: #5a3a17; color: #ffd6b0; }
.leaflet-popup .ac-pop-logo-wrap {
  background: #ffffff;
  margin: 4px 0;
  padding: 4px;
  border-radius: 3px;
  text-align: center;
}
.leaflet-popup .ac-pop-logo { max-height: 28px; max-width: 100%; }
.leaflet-popup .ac-pop-summary {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #cfd9e1;
  color: #344;
}
.leaflet-popup .ac-pop-link {
  display: inline-block; margin-top: 4px;
  font-size: 10px; color: #1c6dd0; text-decoration: none;
}

/* Recent-call ring overlay (Leaflet circleMarker; CSS just controls
   the kind-specific pulse, the colors come from JS). */
.recent-call-marker.kind-fire path { animation: rc-pulse-fire 2.6s ease-in-out infinite; }
.recent-call-marker.kind-law  path { animation: rc-pulse-law  2.6s ease-in-out infinite; }
.recent-call-marker.kind-ems  path { animation: rc-pulse-ems  2.6s ease-in-out infinite; }
@keyframes rc-pulse-fire {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(239,72,72,0.4)); }
  50%      { filter: drop-shadow(0 0 8px rgba(239,72,72,0.95)); }
}
@keyframes rc-pulse-law {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(58,141,240,0.4)); }
  50%      { filter: drop-shadow(0 0 8px rgba(58,141,240,0.95)); }
}
@keyframes rc-pulse-ems {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(76,192,107,0.4)); }
  50%      { filter: drop-shadow(0 0 8px rgba(76,192,107,0.95)); }
}

/* "Open in timeline" highlight in the timeline list */
.call.flash {
  background: rgba(255, 232, 122, 0.18);
  box-shadow: inset 3px 0 0 #ffe87a;
  transition: background 1.6s ease, box-shadow 1.6s ease;
}

/* ---- Air-traffic strip (between map and stories) ---- */
.air-strip {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  overflow: hidden;
}
.air-strip-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.air-strip-title {
  margin: 0;
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7aa6c7;
}
#air-strip-count { color: #ffe87a; }
.air-strip-empty {
  font: 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-faint);
  font-style: italic;
}
.air-strip-cards {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 1px 6px 1px;
  scrollbar-width: thin;
}
.air-strip-cards::-webkit-scrollbar { height: 6px; }
.air-strip-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.ac-card {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: 11px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  text-align: left;
  min-width: 130px;
  max-width: 220px;
  transition: background 0.1s ease, transform 0.1s ease;
}
.ac-card:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.ac-card-logo {
  height: 22px;
  width: auto;
  background: #fff;
  padding: 1px 3px;
  border-radius: 2px;
  flex: 0 0 auto;
}
.ac-card-body { flex: 1 1 auto; min-width: 0; }
.ac-card-head {
  display: flex; align-items: baseline; gap: 6px;
  white-space: nowrap;
}
.ac-card-cs {
  font-weight: 700;
  color: #ffe87a;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-card-kind {
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ac-card-meta {
  display: flex; gap: 8px;
  margin-top: 2px;
  font-size: 10px;
  color: var(--text-dim);
}
.ac-card-alt { color: #88c060; }
.ac-card-kt  { color: #7aa6c7; }
.ac-card-event {
  font-size: 9px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 2px;
}
.ac-card-event.dep { background: #1f5b2e; color: #d6ffd6; }
.ac-card-event.arr { background: #5a3a17; color: #ffd6b0; }

/* Kind tinting on the left border */
.ac-card.kind-military    { border-left-color: #ec4848; }
.ac-card.kind-helicopter  { border-left-color: #4cc06b; }
.ac-card.kind-uav         { border-left-color: #ff8a4c; }
.ac-card.kind-heavy,
.ac-card.kind-commercial,
.ac-card.kind-jet         { border-left-color: #e8d23c; }
.ac-card.kind-light,
.ac-card.kind-glider,
.ac-card.kind-balloon     { border-left-color: #5fb7e8; }

/* Emergency: pulse + red border */
.ac-card.ac-card-emerg {
  border-left-color: #ff2a2a !important;
  box-shadow: 0 0 0 1px #ff2a2a, 0 0 8px rgba(255, 42, 42, 0.7);
  animation: ac-card-pulse 0.9s ease-in-out infinite;
}
@keyframes ac-card-pulse {
  0%, 100% { box-shadow: 0 0 0 1px #ff2a2a, 0 0 6px rgba(255, 42, 42, 0.5); }
  50%      { box-shadow: 0 0 0 1px #ff5050, 0 0 14px rgba(255, 80, 80, 1); }
}

/* ---- Sidebar: Aircraft seen rollup ---- */
.ac-types-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font: 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
}
.ac-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 3px;
}
.ac-type-row + .ac-type-row { margin-top: 1px; }
.ac-type-row:hover { background: var(--bg-hover); }
.ac-type-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.ac-type-label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-type-count {
  flex: 0 0 auto;
  color: #ffe87a;
  font-weight: 700;
}
.ac-type-row.anomaly { background: rgba(255, 232, 122, 0.05); }
.ac-type-row.anomaly .ac-type-label {
  color: #fff5b6;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Per-kind dot colors — match the map icons + air-strip border tints */
.ac-type-row.kind-emergency { background: rgba(255, 42, 42, 0.18); }
.ac-type-row.kind-emergency .ac-type-dot {
  background: #ff2a2a;
  box-shadow: 0 0 6px rgba(255, 42, 42, 0.9);
  animation: ac-card-pulse 0.9s ease-in-out infinite;
}
.ac-type-row.kind-emergency .ac-type-label { color: #ffb0b0; }
.ac-type-row.kind-military    .ac-type-dot { background: #ec4848; }
.ac-type-row.kind-helicopter  .ac-type-dot { background: #4cc06b; }
.ac-type-row.kind-uav         .ac-type-dot { background: #ff8a4c; }
.ac-type-row.kind-heavy       .ac-type-dot,
.ac-type-row.kind-commercial  .ac-type-dot,
.ac-type-row.kind-jet         .ac-type-dot { background: #e8d23c; }
.ac-type-row.kind-light       .ac-type-dot,
.ac-type-row.kind-glider      .ac-type-dot,
.ac-type-row.kind-balloon     .ac-type-dot { background: #5fb7e8; }

.ac-types-now {
  font: 10px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-faint);
}
.ac-types-empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 10px;
  padding: 4px 6px;
}

/* Air-traffic status block (bottom-left Leaflet control) */
.ac-status-wrap {
  background: rgba(10, 18, 24, 0.85);
  color: #d6e0e8;
  padding: 4px 9px;
  border-radius: 5px;
  font: 600 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}
.ac-status-label { color: #7aa6c7; font-weight: 500; }
.ac-status-count { color: #ffe87a; }
.ac-status-wrap .ac-source {
  display: inline-block;
  padding: 1px 6px;
  font-size: 9px;
  border-radius: 3px;
  border: 1px solid currentColor;
  letter-spacing: 0.06em;
}
.ac-status-wrap .ac-source.local  { color: #4cc06b; box-shadow: 0 0 6px rgba(76,192,107,0.5); }
.ac-status-wrap .ac-source.cloud  { color: #b0b0b0; }
.ac-status-wrap .ac-source.merged { color: #4ce7ff; box-shadow: 0 0 6px rgba(76,231,255,0.55); }

/* Airport reference markers (yellow triangle on a dark plate) */
.airport-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.55));
  opacity: 0.72;
}
.airport-marker svg { display: block; }
.airport-marker .airport-label {
  font: 600 9px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: #d6c45a;
  background: rgba(0, 18, 30, 0.6);
  border: 1px solid rgba(214, 196, 90, 0.35);
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.clear-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.clear-btn:hover { border-color: var(--text); color: var(--text); }

.sev { font-size: 8px; vertical-align: middle; margin-right: 4px; }
.sev-critical { color: var(--crit); }
.sev-high     { color: var(--bad); }
.sev-medium   { color: var(--warn); }
.sev-low      { color: var(--good); }
.sev-unknown  { color: var(--text-faint); }

/* ---- Timeline ---- */
.timeline {
  grid-area: timeline;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Map at the top of the timeline pane — single full-width Leaflet
   street map. Aircraft, airports, recent calls, and the heatmap all
   render as overlay layers on this one map. Capped at 38vh. */
.map-pane {
  flex: 0 0 auto;
  height: 34vh;
  max-height: 34vh;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  position: relative;
  overflow: hidden;
}
.map-pane .map-2d {
  width: 100%;
  height: 100%;
}
/* No CSS filter — basemap is CartoDB Positron (native light-gray slate
   tiles), so we leave the tile pane alone. */
/* Draggable column splitter between the 2D street map and the 3D
   air-traffic view. Width-based resize is persisted to localStorage. */
.map-splitter {
  flex: 0 0 6px;
  height: 100%;
  background: var(--border);
  cursor: col-resize;
  position: relative;
  z-index: 7;
  user-select: none;
  touch-action: none;
  transition: background 0.12s;
}
.map-splitter::before {
  content: "";
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 38px;
  background: var(--text-faint, #888);
  border-radius: 1px;
  opacity: 0.7;
  transition: background 0.12s, opacity 0.12s;
}
.map-splitter:hover, .map-splitter.dragging {
  background: var(--accent, #4cc06b);
}
.map-splitter:hover::before, .map-splitter.dragging::before {
  background: #fff;
  opacity: 1;
}
.map-pane .map-3d {
  flex: 0 0 30%;
  height: 100%;
  position: relative;
  background: #000;
  /* War-room aesthetic — push the satellite tiles cool/dark and crank
     contrast so terrain reads as relief rather than tourism photo. */
  isolation: isolate;
  overflow: hidden;
}
.map-pane .map-3d .maplibregl-canvas {
  outline: none;
  /* Lighter than the original war-room treatment — terrain reads clearly
     so aircraft icons can be the visual focus rather than fighting a
     near-black background. Hue rotate dropped, brightness raised. */
  filter: brightness(0.95) contrast(1.10) saturate(0.85);
}
/* Scanlines — kept but very faint so they don't dim the imagery. */
.map-pane .map-3d::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(96, 200, 255, 0.025) 0,
    rgba(96, 200, 255, 0.025) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 4;
  mix-blend-mode: screen;
}
/* Vignette — soft, mostly to keep the edges from washing out at high pitch.
   Much subtler than before so the map center stays bright. */
.map-pane .map-3d::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center,
      transparent 60%,
      rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
  z-index: 5;
  mix-blend-mode: multiply;
}
/* Aircraft markers — bright with a glowing halo so they punch through
   the dark imagery. Color comes from the SVG fill at altitude band.
   Scale multiplier (--ac-scale) is set per-marker by JS on map zoom so
   the icon grows when you zoom in. */
.map-pane .map-3d .ac-marker {
  /* The SVG sets its own width/height — the wrapper just floats. Wrapper
     anchored to the marker's bottom (ground) by MapLibre; the SVG is the
     full sky-tail-shadow stack so altitude reads as visual height. */
  background: transparent;
  cursor: pointer;
  z-index: 10;
  /* Strong, layered glow so the icon punches through any background tone. */
  filter:
    drop-shadow(0 0 1px rgba(0,0,0,0.95))
    drop-shadow(0 0 3px rgba(255,255,255,0.95))
    drop-shadow(0 0 9px rgba(255,220,120,0.85))
    drop-shadow(0 0 18px rgba(255,180,60,0.55));
}
.map-pane .map-3d .ac-marker > svg {
  display: block;
}

/* Airport markers — bright triangle on a dark plate so they read on
   the (now-lighter) satellite imagery. Label rides below the icon. */
.map-pane .map-3d .airport-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.85));
  z-index: 6;
}
.map-pane .map-3d .airport-marker svg { display: block; }
.map-pane .map-3d .airport-marker .airport-label {
  font: 600 9px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: #ffe87a;
  background: rgba(0, 18, 30, 0.85);
  border: 1px solid rgba(255, 232, 122, 0.5);
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
/* Recent-call markers on the 3D pane — small kind-colored ring at the
   call's geocoded location (street-precise where the enricher pulled an
   address, otherwise the talkgroup's city centroid jittered slightly so
   they don't perfectly stack). Sit between airports and aircraft in z-order
   so planes still read as "in front of / overhead" the dispatch site. */
.map-pane .map-3d .call-marker-3d {
  pointer-events: auto;
  cursor: pointer;
  z-index: 8;
  transition: opacity 0.4s ease, transform 0.15s ease;
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.85))
          drop-shadow(0 0 6px rgba(0,0,0,0.55));
}
.map-pane .map-3d .call-marker-3d:hover {
  transform: scale(1.25);
  z-index: 9;
}
.map-pane .map-3d .call-marker-3d > svg { display: block; }
.map-pane .map-3d .call-marker-3d.imprecise > svg {
  /* Approximate (city-centroid) calls — visibly softer so a precise marker
     and a city-level marker can be told apart at a glance. */
  opacity: 0.85;
}
.map-pane .map-3d .call-marker-3d.kind-fire { animation: call-pulse-fire 2.4s ease-in-out infinite; }
.map-pane .map-3d .call-marker-3d.kind-law  { animation: call-pulse-law  2.4s ease-in-out infinite; }
.map-pane .map-3d .call-marker-3d.kind-ems  { animation: call-pulse-ems  2.4s ease-in-out infinite; }

@keyframes call-pulse-fire {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)) drop-shadow(0 0 4px rgba(239,72,72,0.55)); }
  50%      { filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)) drop-shadow(0 0 12px rgba(239,72,72,0.95)); }
}
@keyframes call-pulse-law {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)) drop-shadow(0 0 4px rgba(58,141,240,0.55)); }
  50%      { filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)) drop-shadow(0 0 12px rgba(58,141,240,0.95)); }
}
@keyframes call-pulse-ems {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)) drop-shadow(0 0 4px rgba(76,192,107,0.55)); }
  50%      { filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)) drop-shadow(0 0 12px rgba(76,192,107,0.95)); }
}

/* Briefly highlight a call row in the timeline when the user clicks
   "Open in timeline" inside a 3D-map call popup. */
.call.flash {
  background: rgba(255, 232, 122, 0.18);
  box-shadow: inset 3px 0 0 #ffe87a;
  transition: background 1.6s ease, box-shadow 1.6s ease;
}

.map-pane .map-3d .ac-marker[data-kind="helicopter"] {
  /* helicopters get a slightly stronger pulse — they tend to loiter, so
     this draws the eye to "something is hovering here" */
  animation: ac-heli-pulse 2.6s ease-in-out infinite;
}
.map-pane .map-3d .ac-marker.ac-emergency {
  animation: ac-emerg-pulse 0.9s ease-in-out infinite;
}
@keyframes ac-emerg-pulse {
  0%, 100% { filter:
    drop-shadow(0 0 2px rgba(255,255,255,1))
    drop-shadow(0 0 8px rgba(255,80,80,0.95))
    drop-shadow(0 0 18px rgba(255,40,40,0.7)); }
  50%      { filter:
    drop-shadow(0 0 4px rgba(255,255,255,1))
    drop-shadow(0 0 14px rgba(255,80,80,1))
    drop-shadow(0 0 28px rgba(255,40,40,0.9)); }
}

/* Aircraft popup — styled to match the war-room aesthetic. */
.maplibregl-popup .ac-pop {
  font: 12px/1.35 -apple-system, system-ui, sans-serif;
  color: #d8eef9;
  min-width: 200px;
}
.maplibregl-popup .ac-pop-logo-wrap {
  display: flex; align-items: center; justify-content: center;
  margin: -2px -4px 6px -4px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.92);
  border-radius: 4px;
}
.maplibregl-popup .ac-pop-logo {
  max-width: 200px;
  max-height: 44px;
  object-fit: contain;
  display: block;
}
.maplibregl-popup .ac-pop-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 4px;
}
.maplibregl-popup .ac-pop-head strong {
  font-size: 13px; color: #fff; letter-spacing: 0.04em;
}
.maplibregl-popup .ac-pop-kind {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.25);
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.ac-kind-military   { background: rgba(255,91,58,0.25);  color: #ff8a72; border-color: #ff5b3a; }
.ac-kind-commercial { background: rgba(255,232,122,0.20); color: #ffe87a; }
.ac-kind-heavy      { background: rgba(255,155,58,0.22);  color: #ffb16e; }
.ac-kind-helicopter { background: rgba(122,240,122,0.18); color: #9ff5a3; }
.ac-kind-jet        { background: rgba(155,232,255,0.18); color: #b6ecff; }
.ac-kind-light      { background: rgba(95,183,232,0.18);  color: #8fcaee; }
.ac-kind-uav        { background: rgba(180,140,255,0.18); color: #c8acff; }
.ac-kind-glider     { background: rgba(232,232,232,0.18); color: #e8e8e8; }
.ac-kind-balloon    { background: rgba(255,168,216,0.18); color: #ffc6e2; }
.ac-pop-event {
  margin: 4px 0;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.ac-pop-event.dep { background: rgba(122,240,122,0.18); color: #9ff5a3; border-left: 3px solid #7af07a; }
.ac-pop-event.arr { background: rgba(255,179,90,0.18);  color: #ffd1a0; border-left: 3px solid #ffb35a; }
.ac-pop-tbl {
  width: 100%; border-collapse: collapse; margin: 3px 0;
}
.ac-pop-tbl td {
  padding: 1px 6px 1px 0; font-size: 11px;
}
.ac-pop-tbl td:first-child {
  color: #7da5b8; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; width: 32px;
}
.ac-pop-tbl td:last-child { color: #fff; font-variant-numeric: tabular-nums; }
.ac-pop-foot {
  margin-top: 5px; padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: #6f8896; font-size: 10px; letter-spacing: 0.04em;
}
.maplibregl-popup-content {
  background: rgba(8, 18, 28, 0.95) !important;
  border: 1px solid rgba(0,255,231,0.35);
  box-shadow: 0 0 18px rgba(0, 220, 255, 0.25);
  padding: 8px 10px !important;
  border-radius: 5px !important;
}
.maplibregl-popup-tip {
  border-top-color: rgba(8, 18, 28, 0.95) !important;
  border-bottom-color: rgba(8, 18, 28, 0.95) !important;
}
.maplibregl-popup-close-button {
  color: #6fb5d0 !important;
}
@keyframes ac-heli-pulse {
  0%, 100% { filter:
    drop-shadow(0 0 2px rgba(255,255,255,0.7))
    drop-shadow(0 0 6px rgba(120,220,255,0.55))
    drop-shadow(0 0 12px rgba(120,220,255,0.35)); }
  50% { filter:
    drop-shadow(0 0 4px rgba(255,255,255,0.9))
    drop-shadow(0 0 10px rgba(120,220,255,0.85))
    drop-shadow(0 0 18px rgba(120,220,255,0.5)); }
}
/* Make the existing call-pop marker match the war-room tone. */
.map-pane .map-3d .maplibregl-marker > div[style*="background:#ec4848"] {
  filter:
    drop-shadow(0 0 4px #ec4848)
    drop-shadow(0 0 10px rgba(236, 72, 72, 0.6));
}
.map-3d-overlay {
  position: absolute; left: 8px; top: 8px; right: 8px;
  z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
.map-3d-title {
  background: rgba(0, 16, 24, 0.75);
  color: #b8f4ff;
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid rgba(96, 200, 255, 0.35);
  font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(96, 200, 255, 0.55);
  z-index: 7;
  pointer-events: auto;
}
.map-3d-title #aircraft-count { color: #4cc06b; margin-left: 4px; text-shadow: 0 0 6px rgba(76, 192, 107, 0.7); }
/* ADS-B data-source badge — green when reading from local readsb/dump1090,
   gray when falling back to adsb.lol cloud API. */
.map-3d-title .ac-source {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font: 600 9px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.06em;
  border-radius: 3px;
  border: 1px solid currentColor;
  vertical-align: 1px;
}
.map-3d-title .ac-source.local { color: #4cc06b; box-shadow: 0 0 6px rgba(76, 192, 107, 0.5); }
.map-3d-title .ac-source.cloud { color: #b0b0b0; }
.map-3d-legend {
  background: rgba(0, 16, 24, 0.75);
  color: #b8f4ff;
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid rgba(96, 200, 255, 0.35);
  font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex; gap: 8px;
  z-index: 7;
  pointer-events: auto;
}
.map-3d-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 3px; }
.map-3d-legend .leg-call { background: #ec4848; }
.map-3d-legend .leg-ac   { background: #4cc06b; }
/* Aircraft marker — small triangle that rotates to track */
.ac-marker {
  width: 14px; height: 14px;
  background: transparent;
}
.ac-marker svg { display: block; }
.ac-label {
  position: absolute;
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(8px, -50%);
}

.timeline > .active-filters {
  flex: 0 0 auto;
  margin: 16px 20px 0 20px;
}

.timeline > .results {
  flex: 1 1 auto;
  overflow-y: auto;
  margin: 8px 20px 0 20px;
}

.timeline > .loading,
.timeline > .load-more {
  flex: 0 0 auto;
  margin: 8px 20px;
}

/* ---- Stories strip ---- */
.stories-strip {
  flex: 0 0 auto;
  padding: 12px 20px 4px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.stories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px 0;
}
.stories-title {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
}
.stories-sort { font-size: 11px; }
.stories-sort .seg-btn { padding: 3px 8px; font-size: 11px; }
.stories-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  perspective: 1200px;
}
.story-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
  transform-origin: top center;
  backface-visibility: hidden;
}
.story-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.story-card .story-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story-card .story-body {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story-card .story-meta {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
  margin-top: auto;
}
.story-card .sev-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.story-card.sev-critical .sev-dot { background: var(--crit); }
.story-card.sev-high     .sev-dot { background: var(--bad); }
.story-card.sev-medium   .sev-dot { background: var(--warn); }
.story-card.sev-low      .sev-dot { background: var(--good); }
.story-card.sev-unknown  .sev-dot { background: var(--text-faint); }

/* Flip-down animation for incoming cards */
.story-card.flipping-out {
  animation: story-flip-out 0.45s ease-in forwards;
}
.story-card.flipping-in {
  animation: story-flip-in 0.55s ease-out backwards;
}
@keyframes story-flip-out {
  0%   { transform: rotateX(0deg);    opacity: 1; }
  100% { transform: rotateX(90deg);   opacity: 0; }
}
@keyframes story-flip-in {
  0%   { transform: rotateX(-90deg);  opacity: 0; }
  100% { transform: rotateX(0deg);    opacity: 1; }
}

.stories-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-faint);
  padding: 20px;
  font-size: 12px;
  font-style: italic;
}

/* Favorites strip — mirrors .stories-strip layout but cards include
   inline audio. Sits between stories and the main results list. */
.favorites-strip {
  flex: 0 0 auto;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.favorites-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px 0;
  flex-wrap: wrap;
}
.favorites-title {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
}
.favorites-count {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
}
.favorites-hint { font-size: 10px; color: var(--text-faint); }
.favorites-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.favorite-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
}
.favorite-card .favorite-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.favorite-card .favorite-body {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.favorite-card .favorite-meta {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
}
.favorite-card .sev-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.favorite-card.sev-critical .sev-dot { background: var(--crit); }
.favorite-card.sev-high     .sev-dot { background: var(--bad); }
.favorite-card.sev-medium   .sev-dot { background: var(--warn); }
.favorite-card.sev-low      .sev-dot { background: var(--good); }
.favorite-card.sev-unknown  .sev-dot { background: var(--text-faint); }
.favorite-audio {
  width: 100%;
  height: 28px;
  margin-top: 2px;
}
.favorites-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-faint);
  padding: 16px;
  font-size: 12px;
  font-style: italic;
}

/* Star button in the sidebar talkgroup rows. The row layout puts
   star on the left, label in the middle, count on the right. */
.filter-list .fav-star {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 4px 0 0;
  font-size: 14px;
  line-height: 1;
  margin-right: 2px;
  transition: color 0.12s, transform 0.12s;
}
.filter-list .fav-star.active { color: #f5c542; }
.filter-list .fav-star:hover  { transform: scale(1.2); color: #f5c542; }

@media (max-width: 900px) {
  .favorites-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .favorites-cards { grid-template-columns: 1fr; }
}

/* Stories pager row — left arrow, dots, right arrow. The arrows are
   visible at all sizes (touch users get the swipe gesture too, but
   tappable arrows are more discoverable for trackpad/mouse users). */
.stories-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 6px;
  height: 22px;
}
.stories-arrow {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  width: 24px;
  height: 22px;
  padding: 0;
  border-radius: 4px;
  font: 14px/1 ui-monospace, "SF Mono", Menlo, monospace;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.stories-arrow:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-hover);
}
.stories-arrow:active { transform: translateY(1px); }
.stories-pager {
  display: flex;
  justify-content: center;
  gap: 6px;
  height: 14px;
  align-items: center;
}
.stories-pager .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}
.stories-pager .dot.active {
  background: var(--accent);
}

/* ---- Story modal ---- */
.story-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-modal.hidden { display: none; }
.story-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.story-modal-card {
  position: relative;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  max-width: 640px;
  width: calc(100% - 40px);
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.story-modal-card h2 {
  margin: 0 0 8px 0;
  font-size: 18px;
  line-height: 1.3;
}
.story-modal-meta {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  margin-bottom: 14px;
}
.story-modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 18px;
}
.story-modal-audio {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.story-modal-audio .audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.story-modal-audio .audio-row .ts {
  font-family: var(--font-mono);
  flex: 0 0 70px;
}
.story-modal-audio audio {
  flex: 1 1 auto;
  display: block;
}
.story-modal-close {
  position: absolute;
  top: 8px; right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.story-modal-close:hover { color: var(--text); }

/* Live-call marker — fade in/out over 5s, then self-removes via JS */
.map-pulse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 22px;
  line-height: 1;
  animation: jafo-pulse 5s ease-in-out forwards;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.7));
  user-select: none;
}
@keyframes jafo-pulse {
  0%   { opacity: 0; transform: scale(0.6); }
  15%  { opacity: 1; transform: scale(1.0); }
  80%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* Playback marker — persists while the call is playing, animated ring */
.map-playing {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 28px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.8));
  user-select: none;
}
.map-playing::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.6);
  animation: jafo-playing-ring 1.6s ease-out infinite;
}
@keyframes jafo-playing-ring {
  0%   { box-shadow: 0 0 0 0   rgba(88, 166, 255, 0.7); transform: scale(1.0); }
  70%  { box-shadow: 0 0 0 14px rgba(88, 166, 255, 0); transform: scale(1.0); }
  100% { box-shadow: 0 0 0 0   rgba(88, 166, 255, 0); transform: scale(1.0); }
}

/* Heatmap toggle button — sits on top of the map */
.heat-toggle-wrap {
  background: var(--bg-alt);
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
}
.heat-toggle {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}
.heat-toggle:hover { color: var(--text); }
.heat-toggle.active { color: var(--accent); }

/* Leaflet popup tweak to match dark UI */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.leaflet-popup-content { font-size: 12px; margin: 6px 10px; }

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.nav-link:hover { color: var(--text); border-color: var(--text-faint); }

.active-filters {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 12px;
  min-height: 22px;
}
.active-filter-chip {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
}
.active-filter-chip::after { content: " ×"; opacity: 0.7; }

.results { display: flex; flex-direction: column; gap: 8px; }

.call {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  display: grid;
  grid-template-columns: 80px 36px 1fr auto;
  gap: 10px;
  align-items: center;
  transition: border-color 0.15s;
}

.call .svc-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  user-select: none;
  line-height: 1;
}
.call .svc-col .svc-emoji {
  font-size: 20px;
  line-height: 1;
}
.call .svc-col .svc-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.call .svc-col .svc-link:hover .svc-emoji { transform: scale(1.1); transition: transform .15s; }
.call:hover { border-color: var(--text-faint); }
.call.selected { border-color: var(--accent); }

/* Subtle category tints — layered over var(--bg-alt). Alpha ~0.06–0.10. */
.call.cat-police       { background-color: var(--bg-alt); background-image: linear-gradient(rgba( 88,166,255,0.08), rgba( 88,166,255,0.08)); }
.call.cat-fire         { background-color: var(--bg-alt); background-image: linear-gradient(rgba(248, 81, 73,0.10), rgba(248, 81, 73,0.10)); }
.call.cat-ems          { background-color: var(--bg-alt); background-image: linear-gradient(rgba(255,130,100,0.09), rgba(255,130,100,0.09)); }
.call.cat-school       { background-color: var(--bg-alt); background-image: linear-gradient(rgba(255,200, 80,0.09), rgba(255,200, 80,0.09)); }
.call.cat-utility      { background-color: var(--bg-alt); background-image: linear-gradient(rgba(210,153, 34,0.09), rgba(210,153, 34,0.09)); }
.call.cat-water        { background-color: var(--bg-alt); background-image: linear-gradient(rgba( 80,180,220,0.09), rgba( 80,180,220,0.09)); }
.call.cat-power        { background-color: var(--bg-alt); background-image: linear-gradient(rgba(245,220, 80,0.09), rgba(245,220, 80,0.09)); }
.call.cat-transit      { background-color: var(--bg-alt); background-image: linear-gradient(rgba( 63,185, 80,0.10), rgba( 63,185, 80,0.10)); }
.call.cat-government   { background-color: var(--bg-alt); background-image: linear-gradient(rgba(150,150,160,0.08), rgba(150,150,160,0.08)); }
.call.cat-dispatch     { background-color: var(--bg-alt); background-image: linear-gradient(rgba(140,120,200,0.08), rgba(140,120,200,0.08)); }
.call.cat-traffic      { background-color: var(--bg-alt); background-image: linear-gradient(rgba(245,158, 80,0.09), rgba(245,158, 80,0.09)); }
.call.cat-hazmat       { background-color: var(--bg-alt); background-image: linear-gradient(rgba(220,240, 80,0.09), rgba(220,240, 80,0.09)); }
.call.cat-rescue       { background-color: var(--bg-alt); background-image: linear-gradient(rgba(255,140, 60,0.09), rgba(255,140, 60,0.09)); }
.call.cat-air          { background-color: var(--bg-alt); background-image: linear-gradient(rgba(180,100,220,0.09), rgba(180,100,220,0.09)); }
.call.cat-aviation     { background-color: var(--bg-alt); background-image: linear-gradient(rgba(180,100,220,0.09), rgba(180,100,220,0.09)); }
.call.cat-marine       { background-color: var(--bg-alt); background-image: linear-gradient(rgba( 60,180,180,0.09), rgba( 60,180,180,0.09)); }
.call.cat-hospital     { background-color: var(--bg-alt); background-image: linear-gradient(rgba(255,130,170,0.09), rgba(255,130,170,0.09)); }
.call.cat-construction { background-color: var(--bg-alt); background-image: linear-gradient(rgba(220,140, 60,0.08), rgba(220,140, 60,0.08)); }
.call.cat-k9           { background-color: var(--bg-alt); background-image: linear-gradient(rgba(160,120, 80,0.09), rgba(160,120, 80,0.09)); }
.call.cat-park         { background-color: var(--bg-alt); background-image: linear-gradient(rgba( 80,160,100,0.09), rgba( 80,160,100,0.09)); }
.call.cat-emergency    { background-color: var(--bg-alt); background-image: linear-gradient(rgba(255, 80, 80,0.10), rgba(255, 80, 80,0.10)); }
.call.cat-weather      { background-color: var(--bg-alt); background-image: linear-gradient(rgba(120,180,240,0.09), rgba(120,180,240,0.09)); }

.call .when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
}
.call .when .ago { color: var(--text-faint); font-size: 10px; }

.call .body { min-width: 0; }
.call .header-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 2px;
}
.call .tag {
  background: var(--bg-hover);
  color: var(--text);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.call .type {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}
.call .units {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}
.call .summary {
  color: var(--text);
  font-size: 13px;
  margin-bottom: 2px;
  line-height: 1.35;
}
.call .transcript {
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.call .location {
  color: var(--accent);
  font-size: 11px;
  margin-top: 2px;
}
.call .location::before { content: "📍 "; }

.call .meta-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  min-width: 100px;
}
.call .duration {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
}
.call .audio-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.call .audio-btn:hover { border-color: var(--accent); color: var(--accent); }
.call .pending {
  font-size: 10px;
  color: var(--warn);
  font-style: italic;
}

audio {
  margin-top: 8px;
  width: 100%;
  display: none;
}
audio.visible { display: block; }

.loading, .load-more {
  text-align: center;
  padding: 16px;
  color: var(--text-dim);
  font-size: 13px;
}
.load-more {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  margin: 16px auto 0;
  display: block;
  padding: 10px 20px;
  border-radius: 6px;
}
.load-more:hover { border-color: var(--accent); color: var(--accent); }
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
}

/* Hamburger — desktop hides it, mobile shows it */
.menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  margin-right: 8px;
}
.menu-btn:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  backdrop-filter: blur(2px);
}

/* Touch-primary devices (phones, tablets, touchscreen laptops): hide the
   3D air-traffic pane regardless of viewport width. Keeps the 2D map full
   width and avoids loading MapLibre + polling /api/aircraft on cellular. */
@media (pointer: coarse) {
  /* Hide the 3D air-traffic pane on every touch device (covers phones,
     tablets, and touch laptops regardless of viewport width). */
  .map-pane .map-2d { flex: 1 1 100% !important; border-right: 0 !important; }
  .map-pane .map-3d { display: none !important; }
  .map-splitter   { display: none !important; }

  /* Unlock natural document scroll on touch devices. The desktop layout
     uses overflow: hidden + height: 100vh on body to drive a per-pane
     scroll model; that's wrong for touch where users expect the whole
     page to scroll. !important here intentionally — we need to win
     against the unconditional base body rule on tablets > 760px wide. */
  html, body {
    height: auto !important;
    min-height: 100vh;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .timeline {
    height: auto !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 56px);
  }
  /* Map at the bottom of the column so stories + calls show first. */
  .timeline > .stories-strip   { order: 1; }
  .timeline > .active-filters  { order: 2; }
  .timeline > .results         { order: 3; overflow: visible !important; flex: 0 0 auto !important; }
  .timeline > #loading         { order: 4; }
  .timeline > #load-more       { order: 4; }
  .timeline > .map-pane        { order: 5; }
  .map-pane                    { flex: 0 0 auto !important; }
}

/* Responsive — mobile */
@media (max-width: 760px) {
  body {
    /* Abandon the desktop grid; let the document scroll naturally so the
       user can swipe through stories → calls → map without fighting nested
       scroll containers. Topbar is sticky at top. */
    display: block;
    grid-template-columns: none;
    grid-template-rows: none;
    grid-template-areas: none;
    height: auto;
    min-height: 100vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .menu-btn { display: inline-block; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 56px;
    grid-area: auto;
  }
  .stats-bar { display: none; }
  .actions .nav-link { font-size: 11px; padding: 3px 6px; }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 86%;
    max-width: 320px;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    z-index: 100;
    border-right: 1px solid var(--border);
    border-bottom: none;
    max-height: none;
    overflow-y: auto;
    grid-area: auto;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  /* Timeline grows with content rather than capping at viewport. */
  .timeline {
    grid-area: auto;
    height: auto;
    min-height: calc(100vh - 56px);
    overflow: visible;
    display: flex;
    flex-direction: column;
  }
  /* Push the map to the bottom of the timeline column on mobile so
     stories + calls are immediately visible under the topbar. */
  .timeline > .stories-strip   { order: 1; }
  .timeline > .active-filters  { order: 2; }
  .timeline > .results         { order: 3; }
  .timeline > #loading         { order: 4; }
  .timeline > #load-more       { order: 4; }
  .timeline > .map-pane        { order: 5; }
  /* Map stays the same fixed height block but is now last in the column. */
  .map-pane { height: 32vh; max-height: 32vh; flex: 0 0 auto; }
  .map-pane .map-2d { flex: 1 1 100%; border-right: 0; }
  .map-pane .map-3d { display: none; }
  .map-splitter   { display: none; }
  /* Results pane is no longer a nested scroller — let the body scroll. */
  .timeline > .results { overflow: visible; flex: 0 0 auto; }

  /* Stories: 2x2 grid on mobile so all 4 stay visible */
  .stories-strip { padding: 8px 12px 4px 12px; }
  .stories-header { margin-bottom: 6px; }
  .stories-title { font-size: 10px; }
  .stories-sort .seg-btn { padding: 2px 7px; font-size: 10px; }
  .stories-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .story-card {
    min-height: 88px;
    padding: 7px 9px;
    gap: 4px;
  }
  .story-card .story-title { font-size: 12px; }
  .story-card .story-body  { font-size: 11px; -webkit-line-clamp: 2; }
  .story-card .story-meta  { font-size: 9px; }

  /* Calls: stack vertically inside the card on narrow screens */
  .call {
    grid-template-columns: 60px 1fr auto;
    grid-template-rows: auto auto;
    padding: 6px 10px;
    gap: 8px;
  }
  .call .when { grid-row: 1; grid-column: 1; font-size: 10px; }
  .call .svc-col {
    grid-row: 1 / 3;
    grid-column: 1;
    display: none;  /* save horizontal real estate */
  }
  .call .body { grid-row: 1; grid-column: 2 / 4; min-width: 0; }
  .call .meta-right {
    grid-row: 2;
    grid-column: 1 / 4;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
  }
  audio.audio-inline { width: 180px; }
}

/* ============================================================
   Talkgroup grouping (segmented toggles + expandable sections)
   ============================================================ */

.filter-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.filter-header h3 {
  margin: 0;
}

.filter-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.seg-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-deeper, var(--surface));
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  border-right: 1px solid var(--border);
  transition: background 0.1s, color 0.1s;
}
.seg-btn:last-child {
  border-right: none;
}
.seg-btn:hover {
  color: var(--text);
  background: var(--surface);
}
.seg-btn.active {
  background: var(--accent, #4a8cff);
  color: white;
  font-weight: 500;
}

.filter-groups {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tg-group {
  border-radius: 4px;
  overflow: hidden;
}

.tg-group-header {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 4px 6px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 4px;
}
.tg-group-header:hover {
  background: var(--surface);
}
.tg-group-header .caret {
  width: 12px;
  font-size: 10px;
  color: var(--text-faint);
}
.tg-group-name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-group-header .count {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 8px;
}

.tg-group-filter-all {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-faint);
  padding: 3px 6px;
  margin: 2px 0 4px 16px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 4px;
  text-align: left;
  width: calc(100% - 16px);
}
.tg-group-filter-all:hover {
  border-color: var(--accent, #4a8cff);
  color: var(--text);
}
.tg-group-filter-all.active {
  background: var(--accent, #4a8cff);
  color: white;
  border-style: solid;
  border-color: var(--accent, #4a8cff);
}

.filter-list.nested {
  margin: 0 0 6px 16px;
  padding-left: 0;
}

.empty-tg {
  color: var(--text-faint);
  font-style: italic;
  padding: 8px 0;
  font-size: 12px;
}

.enc-tag {
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.6;
}

/* ============================================================
   Inline audio — replaces the old play-button pattern
   ============================================================ */

audio.audio-inline {
  display: block;
  margin-top: 0;
  width: 220px;
  height: 30px;
  filter: brightness(0.92);
}

/* Audio + share button row inside the call card meta-right column */
.call .audio-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.share-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
}
.share-btn:hover { color: var(--accent); border-color: var(--accent); }
.share-btn-inline {
  margin-left: 8px;
  font-size: 11px;
  padding: 1px 6px;
}

/* Share modal — local-friendly: preview + download/right-click-save */
.share-modal-card { max-width: 720px; }
.share-modal-formats {
  display: flex;
  gap: 8px;
  margin: 4px 0 16px;
}
.share-modal-formats .share-fmt {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  text-align: center;
  line-height: 1.3;
}
.share-modal-formats .share-fmt span {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 2px;
}
.share-modal-formats .share-fmt:hover { color: var(--text); border-color: var(--text-faint); }
.share-modal-formats .share-fmt.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}
.share-modal-formats .share-fmt.active span { color: var(--accent); opacity: 0.85; }

.share-modal-body {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 18px;
  align-items: start;
}
.share-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-preview img {
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  background: #000;
  cursor: context-menu;
}
.share-preview video {
  width: 100%;
  max-height: 220px;
  display: block;
  border-radius: 4px;
  background: #000;
}
.share-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.share-download-btn {
  display: block;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 10px;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  font-family: inherit;
  font-size: 13px;
}
.share-download-btn:hover { color: var(--accent); border-color: var(--accent); }
.share-download-btn.primary {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}
.share-download-btn.primary:hover { background: rgba(88, 166, 255, 0.18); }
.share-hint {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
  margin-top: 8px;
}
.share-hint strong { color: var(--text-dim); }

@media (max-width: 720px) {
  .share-modal-body { grid-template-columns: 1fr; }
}

/* Old popover styles kept for safety in case anything still uses them */
.share-popover {
  position: fixed;
  z-index: 1500;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 250px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}
.share-popover .share-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  padding: 6px 10px 4px;
  font-weight: 600;
}
.share-popover .share-format-row {
  display: flex;
  gap: 4px;
  padding: 0 6px 4px;
}
.share-popover .share-fmt {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  line-height: 1.2;
}
.share-popover .share-fmt:hover { color: var(--text); border-color: var(--text-faint); }
.share-popover .share-fmt.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}
.share-popover .share-row {
  display: block;
  padding: 7px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
  cursor: pointer;
}
.share-popover .share-row:hover { background: var(--bg-hover); color: var(--accent); }

/* On narrow viewports, let the audio fill the row */
@media (max-width: 640px) {
  audio.audio-inline {
    width: 100%;
    margin-top: 8px;
  }
}

/* ---------- Cloud banner (jafo.local → jafo.live promo) ---------- */
.cloud-banner {
  position: fixed; inset: 0;
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: cloud-banner-fade 0.18s ease-out;
}
.cloud-banner.hidden { display: none; }
.cloud-banner-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
}
.cloud-banner-card {
  position: relative;
  max-width: 520px;
  width: 100%;
  background: var(--bg-alt, #1a1a1a);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 14px;
  padding: 28px 28px 22px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  text-align: center;
}
.cloud-banner-logo {
  height: 56px;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.18));
}
.cloud-banner-card h2 {
  margin: 6px 0 14px;
  font-size: 20px;
  line-height: 1.3;
}
.cloud-banner-card p {
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim, #c8c8c8);
}
.cloud-banner-link-row {
  margin: 14px 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  font-size: 12px;
}
.cloud-banner-link-row a {
  color: var(--accent, #4cc06b);
  word-break: break-all;
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.cloud-banner-link-row a:hover { text-decoration: underline; }
.cloud-banner-actions {
  display: flex; gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 18px 0 12px;
}
.cloud-banner-btn {
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border, #2a2a2a);
  background: transparent;
  color: var(--text, #eee);
  transition: background 0.12s, border-color 0.12s;
}
.cloud-banner-btn:hover { background: var(--bg-hover, #2a2a2a); border-color: var(--text-faint, #777); }
.cloud-banner-btn.primary {
  background: var(--accent, #4cc06b);
  color: #052010;
  border-color: var(--accent, #4cc06b);
  font-weight: 600;
}
.cloud-banner-btn.primary:hover { filter: brightness(1.07); }
.cloud-banner-close {
  position: absolute; top: 10px; right: 12px;
  width: 28px; height: 28px;
  border: 0; background: transparent;
  font-size: 22px; line-height: 1; color: var(--text-faint, #888);
  cursor: pointer; border-radius: 4px;
}
.cloud-banner-close:hover { color: var(--text, #eee); background: var(--bg-hover, #2a2a2a); }
.cloud-banner-hint {
  font-size: 12px;
  color: var(--text-faint, #999);
  margin-top: 4px;
}
.cloud-banner-hint code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
}
@keyframes cloud-banner-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (max-width: 480px) {
  .cloud-banner-card { padding: 20px 18px 16px; }
  .cloud-banner-card h2 { font-size: 18px; }
  .cloud-banner-actions { flex-direction: column; }
  .cloud-banner-btn { width: 100%; }
}

/* ---------- Enhance Call button (Groq re-transcribe) ---------- */
.enhance-btn,
.enhance-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: inherit;
  line-height: 1;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
  user-select: none;
  margin-left: 6px;
}
.enhance-btn {
  cursor: pointer;
  background: linear-gradient(135deg, rgba(120, 90, 255, 0.10), rgba(80, 200, 255, 0.10));
  color: #b9a6ff;
  border-color: rgba(150, 120, 255, 0.45);
  transition: all 0.18s ease;
}
.enhance-btn:hover {
  background: linear-gradient(135deg, rgba(120, 90, 255, 0.22), rgba(80, 200, 255, 0.22));
  color: #d8c8ff;
  border-color: rgba(180, 150, 255, 0.75);
  box-shadow: 0 0 12px rgba(150, 120, 255, 0.25);
}
.enhance-btn:disabled,
.enhance-btn.enhancing {
  cursor: progress;
  opacity: 0.7;
}
.enhance-btn.enhancing .ai-star {
  animation: enhance-spin 1.4s linear infinite;
}
.enhance-btn.enhance-failed {
  border-color: var(--bad, #ec5050);
  color: var(--bad, #ec8a8a);
  background: rgba(255, 80, 80, 0.10);
}
.enhance-badge {
  cursor: default;
  background: rgba(76, 192, 107, 0.10);
  color: #7ed79a;
  border-color: rgba(76, 192, 107, 0.45);
}
.ai-star {
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px currentColor);
}
@keyframes enhance-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* When a transcript is the enhanced (premium) version, give it a subtle ring */
.transcript-enhanced {
  position: relative;
  border-left: 2px solid rgba(150, 120, 255, 0.55);
  padding-left: 8px;
}

/* On narrow viewports, allow the audio-row buttons to wrap below the player */
@media (max-width: 640px) {
  .enhance-btn span,
  .enhance-badge span { display: none; }     /* icon-only on phones */
  .enhance-btn,
  .enhance-badge {
    padding: 6px 8px;
    margin-left: 4px;
  }
}
