/* Albany County Crime Tracker v5 — Mobile-First
   Feed-first, card-based, touch-optimized */

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-body: 'Satoshi', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;

  --header-h: 56px;
  --nav-h: 49px; /* Apple HIG: 49pt tab bar height */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== DARK THEME (default) — Navy + Gold palette ===== */
[data-theme="dark"] {
  --bg: #0a0f1c;
  --surface: #121825;
  --surface-2: #1e2535;
  --surface-3: #2a3347;
  --border: #334155;
  --border-subtle: #1e2535;

  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;

  /* Primary brand colours */
  --accent: #60a5fa;           /* bright navy-blue */
  --accent-gold: #fbbf24;      /* bright gold */

  /* Semantic incident colours */
  --violent: #ef4444;
  --property: #f59e0b;
  --live-dot: #22c55e;

  /* Legacy aliases — keep all existing selectors working */
  --cyan: var(--accent);
  --red: var(--violent);
  --amber: var(--property);
  --blue: var(--accent);
  --green: var(--live-dot);

  /* Dim / tinted variants */
  --red-dim: rgba(239,68,68,0.12);
  --amber-dim: rgba(245,158,11,0.12);
  --blue-dim: rgba(96,165,250,0.12);
  --green-dim: rgba(34,197,94,0.12);

  --elevated: var(--violent);
  --moderate: var(--property);
  --low: var(--live-dot);

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.45);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.55);
  --shadow-card: 0 0 0 1px rgba(255,255,255,0.05), 0 2px 8px rgba(0,0,0,0.45);
}

/* ===== LIGHT THEME — Navy + Gold palette ===== */
[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #cbd5e1;
  --border-subtle: #f1f5f9;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;

  /* Primary brand colours */
  --accent: #1e40af;           /* deep navy */
  --accent-gold: #d97706;      /* warm gold */

  /* Semantic incident colours */
  --violent: #dc2626;
  --property: #d97706;
  --live-dot: #16a34a;

  /* Legacy aliases */
  --cyan: var(--accent);
  --red: var(--violent);
  --amber: var(--property);
  --blue: var(--accent);
  --green: var(--live-dot);

  /* Dim / tinted variants */
  --red-dim: rgba(220,38,38,0.08);
  --amber-dim: rgba(217,119,6,0.08);
  --blue-dim: rgba(30,64,175,0.10);
  --green-dim: rgba(22,163,74,0.08);

  --elevated: var(--violent);
  --moderate: var(--property);
  --low: var(--live-dot);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-card: 0 0 0 1px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  height: 100dvh;
  position: fixed;
  width: 100%;
}

button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== SKELETON ===== */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.skeleton-text { height: 14px; margin-bottom: var(--sp-2); }
.skeleton-text.short { width: 60%; }
.skeleton-card { padding: var(--sp-4); background: var(--surface); border-radius: var(--r-md); margin-bottom: var(--sp-2); }

/* ===== HEADER (compact single-row) ===== */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 200;
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
  padding: 0 var(--sp-3);
  gap: var(--sp-2);
}

.header-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.logo-icon {
  width: 28px; height: 28px;
  display: block; object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 40%, transparent));
}
.header-title { display: flex; flex-direction: column; line-height: 1.15; }
.header-name { font-size: 14px; font-weight: 700; letter-spacing: 0.01em; color: var(--text); }
.header-sub { font-size: 7px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; }

.header-center {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 5px; min-width: 0;
}
.header-date {
  font-size: 10px; font-weight: 500; color: var(--text-3); white-space: nowrap;
}
.header-sep {
  font-size: 9px; color: var(--text-3); opacity: 0.4;
}
.header-time {
  font-size: 10px; font-weight: 600; color: var(--text-2, #b0b0b0);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
@media (max-width: 420px) {
  .header-date, .header-sep { display: none; }
}

.header-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ── Sticky sub-header: Live|News tabs + filter chips ── */
.home-sub-header {
  position: sticky; top: 0;
  z-index: 15;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Quick filter chips (horizontal scroll) ── */
.filter-chips {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--text-3); }
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Filter bottom sheet ── */
.filter-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 900;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.filter-sheet-backdrop.open {
  opacity: 1; pointer-events: auto;
}
.filter-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  z-index: 901;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.3s;
  max-height: 75vh;
  overflow-y: auto;
}
.filter-sheet.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0s;
}
.filter-sheet-handle {
  width: 36px; height: 4px;
  background: var(--text-3); opacity: 0.4;
  border-radius: 2px; margin: 0 auto 12px;
}
.filter-sheet-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  margin: 0 0 14px;
}
.filter-sheet-section { margin-bottom: 16px; }
.filter-sheet-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3); margin: 0 0 8px;
}
.filter-sheet-options {
  display: flex; flex-wrap: wrap; gap: 6px 12px;
}
.filter-sheet-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text); cursor: pointer;
  min-height: 32px;
}
.filter-sheet-check input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
}
.filter-sheet-actions {
  display: flex; gap: 10px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.filter-sheet-btn {
  flex: 1; padding: 10px; border-radius: 10px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: none; cursor: pointer;
}
.filter-sheet-btn--reset {
  background: var(--surface-2); color: var(--text-2);
}
.filter-sheet-btn--apply {
  background: var(--accent); color: #fff;
}

@media (max-width: 680px) {
  .feed-controls {
    flex-direction: column;
  }
  .feed-summary-grid {
    grid-template-columns: 1fr;
  }
  .feed-summary-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .feed-sort-select,
  .feed-priority-toggle,
  .feed-summary-select,
  .map-select,
  .map-search-input {
    width: 100%;
    min-width: 0;
  }
  .feed-order-btn {
    flex: 1;
  }
}

.overflow-menu {
  position: fixed;
  top: var(--header-h);
  right: 8px;
  z-index: 999;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
}
.overflow-menu[hidden] {
  display: none;
}
.overflow-link {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  text-align: left;
}
.overflow-link:hover,
.overflow-link:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.live-indicator {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 100px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  transition: background 0.3s;
}
.live-dot.active {
  background: var(--live-dot);
  box-shadow: 0 0 6px color-mix(in srgb, var(--live-dot) 60%, transparent);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px color-mix(in srgb, var(--live-dot) 35%, transparent); }
  50% { box-shadow: 0 0 12px color-mix(in srgb, var(--live-dot) 75%, transparent); }
}
.live-text { white-space: nowrap; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: var(--surface-3); }

/* ===== MAIN ===== */
.main {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  overflow: hidden;
}

/* ===== VIEWS ===== */
.view {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.view.active { display: flex; flex-direction: column; }
.home-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 16px;
}

/* Scrollable views */
.view-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
#viewFeed { overflow: hidden; }

/* ===== SITUATION CARD ===== */
.situation-card {
  margin: var(--sp-3) var(--sp-3) 0;
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.situation-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-gold));
  opacity: 0.85;
}
.situation-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-2);
}
.threat-badge {
  display: inline-flex; align-items: center;
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.12em;
  background: var(--surface-2);
  color: var(--text-3);
  transition: all 0.4s;
}
.threat-badge.low { background: var(--green-dim); color: var(--green); }
.threat-badge.moderate { background: var(--amber-dim); color: var(--amber); }
.threat-badge.elevated { background: var(--red-dim); color: var(--red); }
.threat-badge.high { background: var(--red-dim); color: var(--red); }

.situation-time {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-3);
}
.situation-text {
  font-size: 13px; font-weight: 500; color: var(--text);
  line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.situation-expand-btn {
  display: inline-flex; align-items: center; gap: 2px;
  margin-top: var(--sp-2);
  font-size: 11px; font-weight: 600;
  color: var(--cyan);
  opacity: 0.8;
  background: none; border: none; cursor: pointer;
  padding: 0;
  transition: opacity 0.15s;
}
.situation-expand-btn:hover { opacity: 1; }
.situation-expand-btn.expanded .material-icons { transform: rotate(180deg); }
.situation-text-full {
  font-size: 13px; color: var(--text-2);
  line-height: 1.55;
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
}

/* ===== STATS ROW ===== */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3) 0;
}
.stat-chip {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--sp-3) var(--sp-1);
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.stat-val {
  font-family: var(--font-mono);
  font-size: 20px; font-weight: 700; line-height: 1.1;
  color: var(--text);
}
.stat-violent .stat-val { color: var(--violent); }
.stat-property .stat-val { color: var(--property); }
.stat-lbl {
  font-size: 9px; font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 3px;
}


/* Legacy subtabs — hidden; unified feed uses section headers */
.feed-subtabs {
  display: none;
}

/* ── Unified feed section headers ───────────────────────────── */
.feed-section-header {
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 16px 0 6px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.feed-section-header:first-child {
  padding-top: 8px;
}
/* LIVE header — red accent with pulsing dot */
.feed-section-header--live {
  color: #E53935;
  font-weight: 700;
}
.feed-live-dot {
  width: 8px; height: 8px;
  background: #E53935;
  border-radius: 50%;
  display: inline-block;
  animation: liveDotPulse 1.5s ease-in-out infinite;
}
@keyframes liveDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Per-card LIVE badge — inline pill in meta row */
.feed-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #E53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1;
}
.feed-live-badge .feed-live-dot {
  width: 6px; height: 6px;
}
/* Subtle left-border accent on live cards */
.feed-item--live {
  border-left: 3px solid #E53935;
}

.feed-controls {
  display: flex;
  gap: 8px;
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}
.home-mode-bar {
  display: flex;
  flex-shrink: 0;
}
.home-mode-btn {
  flex: 1;
  min-height: 40px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.home-mode-btn:hover { color: var(--text-2); }
.home-mode-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.home-mode-panel {
  display: none;
  flex: 1;
  overflow: hidden;
}
.home-mode-panel.active {
  display: flex;
  flex-direction: column;
}
.home-mode-panel .home-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 16px;
}

.home-summary-strip {
  padding: 6px 10px 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}
.home-feed-panel {
  margin: 0;
  padding: 0 10px;
}
.home-summary-grid .feed-summary-card {
  min-height: 56px;
}

.home-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: 10px 10px 4px;
  margin: 0;
}

.home-major,
.home-developing {
  border-bottom: 1px solid var(--border-subtle);
}
.home-stories-list {
  padding: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.home-story-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
  min-height: 44px;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.home-story-card:active { background: var(--surface-2); }
.home-story-card--major {
  border-left: 3px solid var(--violent);
}
.home-story-card--developing {
  border-left: 3px solid var(--property);
  opacity: 0.92;
}
.home-story-body {
  flex: 1;
  min-width: 0;
}
.home-story-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-story-desc {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.home-story-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-3);
}
.home-story-pill--sev-high { color: var(--violent); }
.home-story-pill--sev-critical { color: var(--violent); background: var(--red-dim); }
.home-story-pill--source { color: var(--accent); }

.home-feed-panel {
  margin-top: 0;
  padding: 0 10px;
}

.home-recaps {
  border-top: 1px solid var(--border-subtle);
  padding-bottom: 20px;
}
.home-recaps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0 10px;
}
.home-recap-card {
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.home-recap-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}
.home-recap-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.home-recap-detail {
  margin-top: 2px;
  font-size: 10px;
  color: var(--text-2);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 420px) {
  .home-recaps-grid {
    grid-template-columns: 1fr;
  }
}
/* Map legend (legacy, kept for compatibility) */
.map-legend { display: none; }

.map-popup {
  font-family: var(--font-body);
  max-width: 280px;
  min-width: 200px;
}
.map-popup-cat {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.map-popup-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 4px;
}
.map-popup-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 2px;
}
.map-popup-source {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.map-popup-actions {
  display: flex;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.map-popup-actions a {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.map-popup-actions a:hover { text-decoration: underline; }

/* ── Map floating right controls ── */
.map-float-right {
  position: absolute; right: 10px; top: 60px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 10; pointer-events: auto;
}
.map-fab {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface); border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text);
}
.map-fab .material-icons { font-size: 22px; }
.map-fab.active { color: var(--accent); }
.map-chip--layer { padding: 0 8px; min-width: 36px; }
.map-chip--layer.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Map time scrubber ── */
.map-time-scrubber {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
}
.map-scrubber-label {
  font-size: 9px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap; min-width: 24px; text-align: center;
}
.map-scrubber-range {
  flex: 1; height: 4px; min-width: 120px;
  -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 2px; outline: none;
}
.map-scrubber-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ── Map incident bottom sheet ── */
.map-sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 20; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.map-sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.map-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  z-index: 21;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.3s;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  max-height: 45%;
}
.map-sheet.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0s;
}
.map-sheet-handle {
  width: 36px; height: 4px; background: var(--text-3); opacity: 0.3;
  border-radius: 2px; margin: 0 auto 10px;
}
.map-sheet-cat {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #fff; padding: 3px 8px; border-radius: 4px;
  margin-bottom: 6px;
}
.map-sheet-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  line-height: 1.3; margin-bottom: 4px;
}
.map-sheet-meta {
  font-size: 12px; color: var(--text-2); margin-bottom: 4px;
}
.map-sheet-source {
  font-size: 11px; color: var(--text-3); margin-bottom: 10px;
}
.map-sheet-actions {
  display: flex; gap: 10px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.map-sheet-actions a, .map-sheet-actions button {
  flex: 1; padding: 10px; border-radius: 10px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  text-align: center; text-decoration: none;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.map-sheet-actions .material-icons { font-size: 16px; }

/* ── Map marker pulse animation (for <60min incidents) ── */
@keyframes mapMarkerPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.feed-search-input,
.feed-sort-select {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  padding: 7px 10px;
  font-family: inherit;
}
.feed-search-input {
  flex: 1;
  min-width: 0;
}
.feed-sort-select {
  min-width: 140px;
}
.feed-priority-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
}
.feed-order-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 7px 10px;
  color: var(--text-2);
}
.feed-order-btn.active {
  background: var(--accent);
  color: #fff;
}
.feed-summary-panel {
  margin: 0 12px 8px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--surface);
}
.feed-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.feed-summary-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.feed-summary-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.feed-summary-label {
  font-size: 11px;
  color: var(--text-2);
}
.feed-summary-select {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  padding: 6px 8px;
}
.feed-summary-grid {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.feed-summary-grid::-webkit-scrollbar { display: none; }
.feed-summary-card {
  flex: 1 1 0;
  min-width: 70px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  text-align: center;
}
.feed-summary-card--hero {
  background: var(--accent);
  border-color: var(--accent);
}
.feed-summary-card--hero .feed-summary-v { color: #fff; }
.feed-summary-card--hero .feed-summary-k { color: rgba(255,255,255,0.85); }
.feed-summary-k {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  line-height: 1.2;
}
.feed-summary-v {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.feed-summary-sub {
  display: none;
}
.feed-summary-list {
  margin-top: 1px;
  font-size: 10px;
  color: var(--text-2);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-summary-empty {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-3);
}
.feed-summary-list {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.35;
}

.feed-subtab {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.feed-subtab:hover { background: var(--surface-2); color: var(--text-2); }
.feed-subtab.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

/* Tiny live pulse dot inside the Live tab button */
.live-pulse-sm {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}
.feed-subtab.active .live-pulse-sm { background: var(--surface); }

/* Feed tab content panels */
.feed-tab-content {
  display: none;
}
.feed-tab-content.active { display: block; }

/* ===== NEWS AI CARDS (Daily Briefing / Monthly Overview / Monthly Projection) ===== */
.news-ai-card {
  margin: var(--sp-3) var(--sp-3) 0;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.news-ai-card:empty { display: none; }

/* Card header row */
.nac-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  border-bottom: 1px solid var(--border-subtle);
}
.nac-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3);
  display: flex; align-items: center; gap: 6px;
}
.nac-label-icon { font-size: 12px; }
.nac-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 100px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.nac-badge.trend-up     { background: var(--red-dim);    color: var(--red);    }
.nac-badge.trend-down   { background: var(--green-dim);  color: var(--green);  }
.nac-badge.trend-stable { background: var(--surface-2);  color: var(--text-3); }
.nac-badge.level-high     { background: var(--red-dim);    color: var(--red);    }
.nac-badge.level-elevated { background: rgba(234,88,12,.15); color: var(--amber); }
.nac-badge.level-moderate { background: rgba(202,138,4,.12);  color: #ca8a04;     }
.nac-badge.level-low      { background: var(--green-dim);  color: var(--green);  }

/* Card body */
.nac-body { padding: var(--sp-3) var(--sp-4); }
.nac-briefing {
  font-size: 13px; color: var(--text-2); line-height: 1.55;
  margin-bottom: var(--sp-3);
}

/* Daily top incidents */
.nac-incidents { display: flex; flex-direction: column; gap: var(--sp-2); }
.nac-incident {
  display: flex; gap: var(--sp-2); align-items: flex-start;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--border-subtle);
}
.nac-incident.violent { border-left-color: var(--red); }
.nac-incident.property { border-left-color: var(--amber); }
.nac-incident.other { border-left-color: var(--cyan); }
.nac-incident-title {
  font-size: 12px; font-weight: 600; color: var(--text-1);
  margin-bottom: 2px;
}
.nac-incident-meta {
  font-size: 11px; color: var(--text-3); line-height: 1.4;
}

/* Monthly highlights list */
.nac-highlights { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--sp-3); }
.nac-highlight {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--text-2); line-height: 1.4;
}
.nac-highlight::before { content: "▸"; color: var(--cyan); flex-shrink: 0; margin-top: 1px; }

/* Projection / watch areas */
.nac-projection {
  font-size: 13px; color: var(--text-2); line-height: 1.55;
  margin-bottom: var(--sp-3);
}
.nac-watch-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-3);
  margin-bottom: var(--sp-2);
}
.nac-watch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nac-watch-chip {
  padding: 3px 10px; border-radius: 100px;
  background: rgba(234,88,12,.12); color: var(--amber);
  font-size: 11px; font-weight: 600;
}

/* Daily patterns list */
.nac-patterns { display: flex; flex-direction: column; gap: 4px; margin-top: var(--sp-2); }
.nac-pattern {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--text-2);
}
.nac-pattern::before { content: "◆"; color: var(--amber); font-size: 8px; flex-shrink: 0; margin-top: 3px; }

/* Divider between AI cards and raw article list */
.news-section-divider {
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3);
}

/* Legacy selectors kept for backwards compatibility with any cached HTML */
.monthly-summary-card { display: none; }
.monthly-trend-badge.up   { background: var(--red-dim); color: var(--red); }
.monthly-trend-badge.down { background: var(--green-dim); color: var(--green); }
.monthly-trend-badge.stable { background: var(--surface-2); color: var(--text-3); }

/* ===== SOCIAL INTEL CARDS ===== */
.social-intel-section {
  padding: var(--sp-3) var(--sp-3) 0;
}
.social-intel-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}
.social-intel-card {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  border-left: 3px solid var(--cyan);
  margin-bottom: var(--sp-2);
}
.social-intel-body { flex: 1; min-width: 0; }
.social-intel-source {
  font-size: 11px; font-weight: 700;
  color: var(--cyan);
  margin-bottom: 3px;
}
.social-intel-text {
  font-size: 12px; color: var(--text);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.social-intel-time { font-size: 10px; color: var(--text-3); margin-top: 3px; }

/* Promoted social posts banner inside Live tab */
.promoted-social-header {
  padding: var(--sp-2) var(--sp-4) var(--sp-1);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent-gold);
  display: flex; align-items: center;
}
#promotedSocialPosts .social-intel-card {
  border-left-color: var(--accent-gold);
  margin: 0 var(--sp-3) var(--sp-2);
}
#socialIntelList .social-intel-card {
  margin: var(--sp-2) var(--sp-3) 0;
}

/* ===== FEED LIST ===== */
.feed-list {
  padding: 8px 0 24px;
  display: flex; flex-direction: column;
  gap: 8px;
}

.feed-item {
  display: flex; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  text-decoration: none; color: inherit;
  transition: background 0.12s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.feed-item:hover { text-decoration: none; }
.feed-item:active { background: var(--surface-2); }

.feed-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.feed-dot.violent { background: var(--violent); }
.feed-dot.property { background: var(--property); }
.feed-dot.other { background: var(--accent); }

.feed-body { min-width: 0; flex: 1; }
.feed-title {
  font-size: 14px; font-weight: 700; line-height: 1.3;
  color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-summary-line {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.feed-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-top: 6px; font-size: 10px; color: var(--text-3);
}
/* Time in meta row (moved from head-row) */
.feed-meta .feed-time {
  margin-left: auto;
}
/* feed-meta-pill base defined below (~line 3638) */
.feed-hood { font-weight: 600; color: var(--text-2); }
.feed-age { font-weight: 600; color: var(--text-2); }
.feed-age--fresh {
  color: var(--accent-gold);
  font-weight: 700;
}
/* Time decay: >12h cards fade slightly */
.feed-item.feed-item--stale,
.feed-item.feed-item--aged {
  opacity: 0.85;
}
/* Pulsing dot on <1h items */
.feed-time-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: #E53935;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
  animation: timeDotPulse 1.5s ease-in-out infinite;
}
@keyframes timeDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.feed-item.feed-item--high-priority {
  border-left: 4px solid var(--accent-gold);
  box-shadow: var(--shadow-card), 0 0 0 1px color-mix(in srgb, var(--accent-gold) 40%, transparent);
}
.feed-item.feed-item--quiet {
  opacity: 0.67;
}
.feed-age--stale {
  color: var(--text-3);
  font-weight: 500;
  font-style: italic;
}

.feed-live-stale-note {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-2);
  padding: var(--sp-2) var(--sp-3);
  margin: 0 0 var(--sp-2) 0;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--text-3) 35%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-gold) 8%);
}
[data-theme="dark"] .feed-live-stale-note {
  background: color-mix(in srgb, var(--surface) 88%, var(--accent-gold) 12%);
}

/* Multiple sources for same story */
.multi-source { color: var(--text-3); }
.src-sep { opacity: 0.5; margin: 0 1px; }

/* Official police source feed items */
.feed-item.feed-item-official {
  border-left: 3px solid var(--cyan);
  background: color-mix(in srgb, var(--surface) 95%, var(--cyan) 5%);
}
[data-theme="dark"] .feed-item.feed-item-official {
  background: color-mix(in srgb, var(--surface) 90%, var(--cyan) 10%);
}

.feed-item.feed-item-official-prominent {
  border-left-width: 4px;
  box-shadow: var(--shadow-sm);
}

.feed-item.feed-item-scanner-crime {
  border-left: 4px solid var(--accent-gold);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-gold) 8%);
}
[data-theme="dark"] .feed-item.feed-item-scanner-crime {
  background: color-mix(in srgb, var(--surface) 88%, var(--accent-gold) 12%);
}

/* Official source badge */
.official-badge {
  display: inline-flex; align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.07em;
  background: var(--accent);
  color: #ffffff;
}

.official-badge--lg {
  padding: 3px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  letter-spacing: 0.1em;
}

/* Scanner intel in feed */
.feed-item.scanner-intel {
  background: var(--surface-2);
  border-left: 3px solid var(--cyan);
}
.scanner-dot { background: var(--accent); box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 45%, transparent); }
.scanner-feed-badge {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  background: var(--accent);
  color: #ffffff;
  border-radius: 3px;
}

.scanner-feed-badge--lg {
  padding: 3px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
}
.scanner-feed-badge--critical {
  background: linear-gradient(135deg, #b45309 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--violent) 35%, transparent);
}
.scanner-feed-badge--priority {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: #fff;
}
.scanner-feed-badge--trend {
  background: color-mix(in srgb, var(--accent) 80%, #fff 20%);
  color: #fff;
}
.feed-item.feed-item-scanner-critical {
  border-left: 3px solid var(--violent);
  box-shadow: var(--shadow-card), inset 3px 0 0 0 color-mix(in srgb, var(--violent) 25%, transparent);
}

.feed-x-cta {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cyan);
  margin-left: 4px;
}
.feed-x-cta::after {
  content: " \2197";
  font-size: 9px;
  opacity: 0.85;
  margin-left: 2px;
}

/* ===== MAP ===== */
/* ===== MAP VIEW — full-screen with floating overlays ===== */
#viewMap { display: none; position: absolute; inset: 0; }
#viewMap.active { display: block; }
#viewMap #map {
  position: absolute;
  inset: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Floating filter chips — top overlay */
.map-float-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 60px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}
.map-chip {
  pointer-events: auto;
  padding: 8px 16px;
  border-radius: 22px;
  border: none;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  transition: background 0.15s, color 0.15s, transform 0.1s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.map-chip::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.map-chip[data-filter="all"]::before { background: var(--accent); }
.map-chip[data-filter="violent"]::before { background: #E53935; }
.map-chip[data-filter="property"]::before { background: #FB8C00; }
.map-chip[data-filter="other"]::before { background: #1E88E5; }
.map-chip:active { transform: scale(0.96); }
.map-chip.active[data-filter="all"]      { background: var(--accent); color: #fff; }
.map-chip.active[data-filter="all"]::before { background: #fff; }
.map-chip.active[data-filter="violent"]  { background: #E53935; color: #fff; }
.map-chip.active[data-filter="violent"]::before { background: #fff; }
.map-chip.active[data-filter="property"] { background: #FB8C00; color: #fff; }
.map-chip.active[data-filter="property"]::before { background: #fff; }
.map-chip.active[data-filter="other"]    { background: #1E88E5; color: #fff; }
.map-chip.active[data-filter="other"]::before { background: #fff; }

/* Floating bottom bar — count + share */
.map-float-bottom {
  position: absolute;
  bottom: 20px;
  left: 12px;
  right: 12px;
  z-index: 10;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.map-count {
  pointer-events: auto;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.map-count:empty { display: none; }
.map-share-btn {
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.map-share-btn:active { transform: scale(0.92); }
.map-share-btn .material-icons { font-size: 22px; }

/* Legend items (used in top-bar legend strip) */
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.violent { background: var(--violent); }
.legend-dot.property { background: var(--property); }
.legend-dot.other { background: var(--accent); }

/* ===== NEW SCANNER (sc-*) ===== */
.sc-filters {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}
.sc-filter {
  flex: 1;
  min-height: 42px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.sc-filter:hover { color: var(--text-2); }
.sc-filter.active { color: var(--text); border-bottom-color: var(--accent); }
.sc-filter--police.active { border-bottom-color: var(--accent); }
.sc-filter--fire.active { border-bottom-color: var(--violent); color: var(--violent); }
.sc-filter--ems.active { border-bottom-color: var(--property); color: var(--property); }

.sc-player {
  margin: 8px 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.sc-player-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sc-player-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sc-player-agency {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-player-summary {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-player-meta {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.sc-player-play {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.12s, background 0.12s;
}
.sc-player-play:hover:not(:disabled) { transform: scale(1.06); }
.sc-player-play:disabled { opacity: 0.35; cursor: default; }
.sc-player-play.playing { background: var(--violent); }
.sc-player-play .material-icons { font-size: 20px; }

.sc-player-bar-wrap {
  margin-top: 6px;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.sc-player-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-gold);
  border-radius: 2px;
  transition: width 0.08s linear;
}
.sc-player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.sc-player-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.sc-player-icon-btn .material-icons { font-size: 18px !important; }
.sc-player-icon-btn.muted { background: var(--red-dim); color: var(--violent); border-color: var(--violent); }
.sc-player-vol {
  flex: 1;
  min-width: 60px;
  max-width: 120px;
  accent-color: var(--accent);
  height: 3px;
}
.sc-player-auto-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  user-select: none;
}
.sc-player-auto-cb {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}
.sc-player-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--violent);
}

.sc-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 10px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.sc-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text);
  outline: none;
}
.sc-search-input::placeholder { color: var(--text-3); }

.sc-note {
  padding: 4px 12px 6px;
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.35;
}

.sc-list {
  flex: 1;
}

.sc-card {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 3px solid transparent;
  min-height: 44px;
  transition: background 0.15s;
  cursor: pointer;
}
.sc-card:hover { background: var(--surface-2); }
.sc-card--active {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border-left-width: 4px;
}
.sc-card--police { border-left-color: var(--accent); }
.sc-card--fire { border-left-color: var(--violent); }
.sc-card--ems { border-left-color: var(--property); }
.sc-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sc-card-agency-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sc-card-agency {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-card-dept {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.2;
}
.sc-row-play {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.sc-row-play:active,
.sc-row-play.playing { background: var(--accent); color: #fff; }
.sc-row-play .material-icons { font-size: 16px; }
.sc-card-time {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
  flex-shrink: 0;
  white-space: nowrap;
}
.sc-card-summary {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
}
.sc-card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.sc-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface-3);
  color: var(--text-3);
}
.sc-pill--police { background: var(--blue-dim); color: var(--accent); }
.sc-pill--fire { background: var(--red-dim); color: var(--violent); }
.sc-pill--ems { background: var(--amber-dim); color: var(--property); }
.sc-pill--ai { background: color-mix(in srgb, var(--accent) 15%, var(--surface-2)); color: var(--accent); font-style: italic; }
.sc-pill--whisper { background: color-mix(in srgb, #4caf50 15%, var(--surface-2)); color: #4caf50; }
.sc-pill--bcfy { background: color-mix(in srgb, #2196f3 15%, var(--surface-2)); color: #2196f3; }
.sc-pill--live { background: color-mix(in srgb, #4caf50 15%, var(--surface-2)); color: #4caf50; font-weight: 700; }
.sc-pill--emergency { background: #E53935; color: #fff; font-weight: 700; animation: emergencyPulse 1.2s ease-in-out infinite; }
.sc-pill--rr { background: color-mix(in srgb, #9c27b0 12%, var(--surface-2)); color: #9c27b0; }
@keyframes emergencyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Responding unit badges */
.sc-card-units {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-3);
}
.sc-unit-badge {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-2);
}

/* Stream alerts section */
.sc-stream-alerts {
  margin: 0 12px 12px;
  border-radius: var(--r-md);
  overflow: hidden;
}
.sc-stream-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: color-mix(in srgb, #E53935 8%, var(--surface));
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.sc-stream-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
}
.sc-stream-list {
  max-height: 300px;
  overflow-y: auto;
}
.sc-stream-card {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border);
}
.sc-stream-card--critical { border-left-color: #E53935; background: color-mix(in srgb, #E53935 5%, var(--surface)); }
.sc-stream-card--high { border-left-color: #FB8C00; background: color-mix(in srgb, #FB8C00 4%, var(--surface)); }
.sc-stream-card--medium { border-left-color: #1E88E5; }
.sc-stream-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.sc-stream-feed {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sc-stream-time {
  font-size: 10px;
  color: var(--text-3);
}
.sc-stream-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}
.sc-stream-keywords {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Source info in scanner note */
.sc-source-info {
  display: inline-block;
  font-size: 10px;
  color: var(--text-3);
  margin-left: 4px;
  font-style: italic;
}

/* Whisper transcription display */
.sc-card-transcript {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  margin-top: 4px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-2));
  border-radius: var(--r-sm);
  border-left: 3px solid var(--accent);
}
.sc-card-summary--secondary {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Alert banners for critical/high keyword matches */
.sc-alert-banner {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  margin: -10px -12px 8px -12px;
  border-radius: var(--r-md) var(--r-md) 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sc-alert-banner--critical {
  background: #E53935;
  color: #fff;
}
.sc-alert-banner--high {
  background: #FB8C00;
  color: #fff;
}
.sc-alert-keyword {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  margin-left: 2px;
}

/* Alert card borders */
.sc-card--alert-critical {
  border: 2px solid #E53935 !important;
  box-shadow: 0 0 12px rgba(229, 57, 53, 0.2) !important;
}
.sc-card--alert-high {
  border: 2px solid #FB8C00 !important;
  box-shadow: 0 0 12px rgba(251, 140, 0, 0.15) !important;
}

/* Nav alert flash */
.nav-btn--alert,
.tab-bar-item--alert {
  animation: navAlertPulse 0.8s ease-in-out 4;
}
@keyframes navAlertPulse {
  0%, 100% { color: var(--text-3); }
  50% { color: #E53935; }
}

.sc-card-expand {
  margin-top: 6px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
}
.sc-card-expand summary {
  cursor: pointer;
  list-style: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
}
.sc-card-expand summary::-webkit-details-marker { display: none; }
.sc-card-raw {
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.sc-card-audio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.sc-card-play {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}
.sc-card-play:active { background: var(--accent); color: #fff; }
.sc-card-play.playing { background: var(--violent); color: #fff; }
.sc-card-play .material-icons { font-size: 14px; }

.sc-links {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
}
.sc-links .link-btn {
  font-size: 12px;
  min-height: 38px;
  padding: 8px 12px;
}

/* ===== LEGACY SCANNER (kept for backwards compat) ===== */
.scanner-header-card {
  padding: var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}
.scanner-header-top {
  display: flex; align-items: center; gap: var(--sp-2);
}
.scanner-title { font-size: 14px; font-weight: 600; color: var(--text); }
.live-badge {
  font-size: 10px; font-weight: 700;
  color: var(--red);
  letter-spacing: 0.04em;
  padding: 2px 8px;
  background: var(--red-dim);
  border-radius: 100px;
}
.scanner-ts {
  margin-left: auto;
  font-size: 10px; color: var(--text-3);
  font-family: var(--font-mono);
}
.scanner-subtitle {
  font-size: 11px; color: var(--text-3); margin-top: 3px;
}
.scanner-warning {
  margin-top: 8px;
  font-size: 11px;
  color: var(--amber);
  line-height: 1.35;
}

/* ── Scanner toolbar (search + filters) ───────────────────────── */
.scanner-toolbar {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.scanner-search-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.scanner-search-icon {
  font-size: 18px !important;
  color: var(--text-3);
  flex-shrink: 0;
}
.scanner-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: var(--sp-2) 0;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text);
  outline: none;
}
.scanner-search-input::placeholder { color: var(--text-3); }
.scanner-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.scanner-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.scanner-chip:hover { color: var(--text); border-color: var(--text-3); }
.scanner-chip.active {
  background: var(--blue-dim);
  border-color: var(--accent);
  color: var(--text);
}
.scanner-chip-police.active { background: var(--blue-dim); border-color: var(--accent); }
.scanner-chip-fire.active { background: var(--red-dim); border-color: var(--violent); color: var(--text); }
.scanner-chip-ems.active { background: var(--amber-dim); border-color: var(--property); color: var(--text); }

/* ── Scanner player card (replaces scanner-audio-card) ── */
.scanner-player-card {
  padding: var(--sp-4);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--surface) 96%, var(--accent) 4%),
    var(--surface-2));
  border-bottom: 1px solid var(--border);
}
.scanner-player-header {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  color: var(--text-2);
}
.scanner-player-title {
  font-size: 13px; font-weight: 700; color: var(--text); flex: 1;
}
.scanner-live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  background: var(--red-dim);
  color: var(--violent);
  border-radius: 100px;
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.live-pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--violent);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
.scanner-player-card audio {
  width: 100%; height: 44px;
  border-radius: var(--r-md);
  display: block;
}
.scanner-player-footer {
  display: flex; align-items: center; gap: 4px;
  margin-top: var(--sp-2);
  font-size: 10px; color: var(--text-3);
}

/* ── Larger player variant ─────────────────────────────────────── */
.scanner-player-card--large {
  padding: var(--sp-5) var(--sp-4);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--surface) 92%, var(--accent) 8%),
    color-mix(in srgb, var(--surface) 95%, var(--accent-gold) 5%));
  border: 1px solid color-mix(in srgb, var(--border) 70%, var(--accent) 30%);
  border-radius: var(--r-lg);
  margin: var(--sp-3) 0;
}
.scanner-player-card--large .scanner-player-header {
  margin-bottom: var(--sp-3);
}
.scanner-player-title-group {
  display: flex; flex-direction: column; gap: 1px; flex: 1;
}
.scanner-player-title-group .scanner-player-title { flex: unset; }
.scanner-player-sub {
  font-size: 10px; color: var(--text-3); font-weight: 400;
}
.scanner-player-body { margin-bottom: var(--sp-2); }

/* ── Custom clean player (replaces Broadcastify embed) ───────── */
.main-player-track {
  display: flex; align-items: center; gap: var(--sp-3);
}
.main-player-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.main-player-dept {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.main-player-meta {
  font-size: 10px; color: var(--text-3); font-weight: 500;
}
.main-player-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 40%, transparent);
}
.main-player-btn:hover:not(:disabled) { transform: scale(1.07); background: var(--accent-gold); }
.main-player-btn:disabled { opacity: 0.35; cursor: default; }
.main-player-btn.playing { background: var(--violent); }
.main-player-btn .material-icons { font-size: 22px; }
.main-player-progress-wrap {
  margin-top: var(--sp-2);
  height: 3px; border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.main-player-bar {
  height: 100%; width: 0%;
  background: var(--accent-gold);
  border-radius: 2px;
  transition: width 0.08s linear;
}

.main-player-now-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--sp-2);
}
.main-player-now-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.main-player-now-agency {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-player-controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
}
.main-player-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.main-player-icon-btn .material-icons { font-size: 20px !important; }
.main-player-icon-btn:hover { background: var(--surface-3); color: var(--text); }
.main-player-icon-btn.muted { background: var(--red-dim); color: var(--violent); border-color: var(--violent); }
.main-player-vol-label {
  display: flex;
  align-items: center;
  color: var(--text-3);
}
.main-player-vol-label .material-icons { font-size: 16px !important; }
.main-player-volume {
  flex: 1;
  min-width: 80px;
  max-width: 160px;
  accent-color: var(--accent);
  height: 4px;
}
.main-player-autoplay-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  margin-left: auto;
  cursor: pointer;
  user-select: none;
}
.main-player-autoplay-cb {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ── Duration badge ────────────────────────────────────────────── */
.scanner-dur-badge {
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 100px;
  background: var(--surface-3); color: var(--text-2);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* live indicator inside section-label */
.scanner-tg-live {
  margin-left: auto;
  font-size: 10px; font-weight: 700; color: var(--violent);
  animation: pulse-dot 2s ease-in-out infinite;
}

/* no-traffic empty state */
.scanner-no-traffic {
  padding: var(--sp-8) var(--sp-4);
  text-align: center;
  font-size: 13px; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center;
}

/* legacy alias kept for fallback */
.scanner-audio-card { display: none; }

.section-label {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}

.scanner-calls { flex: 1; }

.scanner-call-item {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.12s, transform 0.1s;
  border-left: 4px solid transparent;
  min-height: 44px;
}
.scanner-call-item:active { background: var(--surface-2); }
.scanner-cat-police { border-left-color: var(--accent); }
.scanner-cat-fire { border-left-color: var(--violent); }
.scanner-cat-ems { border-left-color: var(--property); }

.scanner-call-item--clickable {
  cursor: pointer;
  user-select: none;
}
.scanner-call-item--clickable:hover {
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface) 30%);
}
.scanner-call-item--clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.scanner-call-item-hint {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.scanner-call-item-hint .material-icons { font-size: 12px !important; opacity: 0.6; }

.scanner-call-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.scanner-call-tg {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.35;
}
.scanner-priority-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-3);
  opacity: 0.65;
}
.scanner-priority-dot--high {
  background: var(--violent) !important;
  opacity: 1;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--violent) 55%, transparent);
  animation: scanner-priority-pulse 1.25s ease-in-out infinite;
}
@keyframes scanner-priority-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--violent) 45%, transparent); transform: scale(1); }
  50% { box-shadow: 0 0 0 6px transparent; transform: scale(1.15); }
}
.scanner-call-time {
  font-size: 10px; color: var(--text-3); font-family: var(--font-mono);
  flex-shrink: 0;
}
.scanner-call-bottom {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: 8px;
  flex-wrap: wrap;
}
.scanner-call-summary {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
}
.scanner-call-details {
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}
.scanner-call-details summary {
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}
.scanner-call-details summary::-webkit-details-marker {
  display: none;
}
.scanner-call-raw {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-3);
}
.scanner-call-freq { font-size: 10px; color: var(--cyan); font-family: var(--font-mono); }

/* Location suffix inside the call title: "Dept Name — Colonie / Latham" */
.scanner-call-loc {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}

/* Second-line detail row: "855.7125 MHz · 12s" */
.scanner-call-detail {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin: 1px 0 4px;
  line-height: 1.3;
}
.scanner-call-dur { font-size: 10px; color: var(--text-3); font-family: var(--font-mono); }
.scanner-call-id { font-size: 10px; color: var(--text-3); font-family: var(--font-mono); }
.scanner-call-cat {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px; border-radius: 3px;
  background: var(--surface-3); color: var(--text-3);
}
.scanner-cat-police .scanner-call-cat { background: var(--blue-dim); color: var(--blue); }
.scanner-cat-fire .scanner-call-cat { background: var(--red-dim); color: var(--red); }
.scanner-cat-ems .scanner-call-cat { background: var(--amber-dim); color: var(--amber); }

/* Category-specific tags on individual transmission rows */
.scanner-cat-tag-police { background: var(--blue-dim);  color: var(--accent);   }
.scanner-cat-tag-fire   { background: var(--red-dim);   color: var(--violent);  }
.scanner-cat-tag-ems    { background: var(--amber-dim); color: var(--property); }

/* Scanner intel cards in the live feed — category border colours */
.feed-item.scanner-intel-police { border-left: 3px solid var(--accent);   background: color-mix(in srgb, var(--surface) 95%, var(--accent) 5%); }
.feed-item.scanner-intel-fire   { border-left: 3px solid var(--violent);  background: color-mix(in srgb, var(--surface) 95%, var(--violent) 5%); }
.feed-item.scanner-intel-ems    { border-left: 3px solid var(--property); background: color-mix(in srgb, var(--surface) 95%, var(--property) 5%); }

/* Clickable scanner intel card */
.feed-item.scanner-intel-clickable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.1s;
}
.feed-item.scanner-intel-clickable:hover {
  filter: brightness(1.08);
  transform: translateX(2px);
}
.feed-item.scanner-intel-clickable:active {
  transform: translateX(3px) scale(0.99);
}

/* Small "Tap for scanner" hint in the meta row */
.scanner-intel-tap-hint {
  font-size: 9px;
  color: var(--text-3);
  margin-left: auto;
  opacity: 0.7;
  letter-spacing: 0.02em;
}

/* Scanner dot colours per category */
.scanner-dot-police { background: var(--accent)   !important; box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 50%, transparent); }
.scanner-dot-fire   { background: var(--violent)  !important; box-shadow: 0 0 6px color-mix(in srgb, var(--violent) 50%, transparent); }
.scanner-dot-ems    { background: var(--property) !important; box-shadow: 0 0 6px color-mix(in srgb, var(--property) 50%, transparent); }

/* Scanner feed badge variants */
.scanner-badge-police { background: var(--accent);   color: #fff; }
.scanner-badge-fire   { background: var(--violent);  color: #fff; }
.scanner-badge-ems    { background: var(--property); color: #fff; }

.scanner-play-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
  transition: all 0.15s;
  margin-left: auto;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.scanner-play-btn:active { background: var(--cyan); color: #fff; }
.scanner-play-btn.playing { background: var(--red); color: #fff; }

.scanner-status-ok {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: 11px;
  font-weight: 600;
  color: var(--live-dot);
  background: var(--green-dim);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}
.scanner-status-ok::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--live-dot);
  animation: scanner-status-scan 2.5s ease-in-out infinite;
}
@keyframes scanner-status-scan {
  0%, 100% { opacity: 0.5; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.25); }
}
.scanner-status-ok svg {
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}
.scanner-status-text { font-weight: 700; margin-right: auto; }
.scanner-status-meta {
  font-size: 10px;
  opacity: 0.85;
  font-family: var(--font-mono);
}
.scanner-call-dept { font-weight: 700; }
.scanner-call-detail--prominent {
  font-size: 11px !important;
  font-weight: 600;
  color: var(--text-2) !important;
}

.dir-agency-card.dir-agency-highlight {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-md);
  transition: outline-color 0.3s;
}

.empty-state {
  padding: var(--sp-8) var(--sp-4);
  text-align: center;
  font-size: 13px; color: var(--text-3);
}

.scanner-fallback {
  padding: var(--sp-4);
}
.scanner-fallback-header {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-bottom: var(--sp-2);
}
.scanner-fallback-text {
  font-size: 12px; color: var(--text-3); line-height: 1.5;
}

.scanner-links {
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
}

/* ===== SHARED BUTTONS ===== */
.link-btn {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500; color: var(--text-2);
  transition: all 0.15s;
  text-decoration: none;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.link-btn:hover { border-color: var(--cyan); color: var(--cyan); text-decoration: none; }
.link-btn:active { background: var(--surface-2); }

/* ===== CHAT ===== */
#viewChat { flex-direction: column; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-3);
  -webkit-overflow-scrolling: touch;
}

.chat-msg { display: flex; flex-direction: column; }
.chat-msg.chat-user { align-items: flex-end; }
.chat-msg.chat-ai { align-items: flex-start; }

.chat-bubble {
  max-width: 88%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  font-size: 14px; line-height: 1.55;
}
.chat-user .chat-bubble {
  background: var(--cyan);
  color: #ffffff;
  border-bottom-right-radius: var(--r-sm);
}
.chat-ai .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--r-sm);
  box-shadow: var(--shadow-card);
}
.chat-bubble.is-streaming {
  white-space: pre-wrap;
}

/* Markdown in chat */
.md-rendered p { margin-bottom: 0.5em; }
.md-rendered p:last-child { margin-bottom: 0; }
.md-rendered strong { color: var(--text); font-weight: 600; }
.md-rendered h3, .md-rendered h4 { color: var(--text); font-weight: 600; margin: 0.8em 0 0.3em; font-size: 14px; }
.md-rendered ul, .md-rendered ol { padding-left: 1.2em; margin: 0.4em 0; }
.md-rendered li { margin-bottom: 0.2em; }
.md-rendered blockquote { border-left: 3px solid var(--amber); padding-left: 0.8em; margin: 0.5em 0; color: var(--text-2); font-style: italic; }
.md-rendered code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 3px; }
.md-rendered pre { background: var(--surface-3); padding: var(--sp-3); border-radius: var(--r-sm); overflow-x: auto; margin: 0.5em 0; }
.md-rendered pre code { background: none; padding: 0; }
.md-rendered table { border-collapse: collapse; margin: 0.5em 0; width: 100%; font-size: 12px; }
.md-rendered th, .md-rendered td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.md-rendered th { background: var(--surface-3); font-weight: 600; }
.md-rendered hr { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }
.md-rendered a { color: var(--cyan); }

.chat-actions { display: flex; gap: var(--sp-1); margin-top: var(--sp-1); }
.chat-action-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: all 0.15s;
}
.chat-action-btn:active { background: var(--surface-3); color: var(--text); }
.chat-action-btn.copied { color: var(--green); }

.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-suggestions {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-1) 0;
}
.suggest-chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px; font-weight: 500; color: var(--text-2);
  transition: all 0.15s;
  min-height: 44px;
  display: flex; align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.suggest-chip:active { border-color: var(--cyan); color: var(--cyan); }

.chat-input {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input input {
  flex: 1;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 15px; color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  min-height: 44px;
  -webkit-appearance: none;
}
.chat-input input:focus { border-color: var(--cyan); }
.chat-input input::placeholder { color: var(--text-3); }
.chat-input button {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: var(--r-md);
  color: #ffffff;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

/* ===== MORE VIEW ===== */
.more-section {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.more-section-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 16px; font-weight: 700; color: var(--text);
  margin-bottom: var(--sp-3);
}
.more-section-title svg { color: var(--cyan); flex-shrink: 0; }

.patterns-cards { display: flex; flex-direction: column; gap: var(--sp-2); }

.pattern-card {
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.pattern-card-header {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
}
.pattern-icon { width: 14px; height: 14px; flex-shrink: 0; }
.pattern-icon.high { color: var(--red); }
.pattern-icon.medium { color: var(--amber); }
.pattern-icon.low { color: var(--green); }
.pattern-text { font-size: 13px; color: var(--text); line-height: 1.4; }

.hotspot-bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; }
.hotspot-name { font-size: 12px; font-weight: 500; color: var(--text); width: 90px; flex-shrink: 0; }
.hotspot-track { flex: 1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.hotspot-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.hotspot-fill.violent { background: var(--red); }
.hotspot-fill.property { background: var(--amber); }
.hotspot-fill.mixed { background: var(--blue); }
.hotspot-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); width: 24px; text-align: right; }

.trends-chart-wrap { margin-top: var(--sp-4); }
.subsection-label {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin-bottom: var(--sp-3);
}
.meta-text { font-weight: 400; color: var(--text-3); font-size: 11px; }
.chart-container { height: 200px; }

/* NIBRS */
.nibrs-desc { font-size: 12px; color: var(--text-3); margin-bottom: var(--sp-3); line-height: 1.5; }
.nibrs-agency-list { display: flex; flex-direction: column; }

.nibrs-agency-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--r-sm);
  transition: background 0.12s;
  min-height: 44px;
}
.nibrs-agency-item + .nibrs-agency-item { border-top: 1px solid var(--border-subtle); }
.nibrs-clickable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nibrs-clickable:active { background: var(--surface-2); }
.nibrs-agency-item.selected { background: var(--surface-3); }

.nibrs-agency-info { display: flex; flex-direction: column; min-width: 0; }
.nibrs-agency-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nibrs-agency-meta {
  font-size: 10px; color: var(--text-3); font-family: var(--font-mono);
  margin-top: 1px;
}

.nibrs-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
}
.nibrs-active { background: var(--green-dim); color: var(--green); }
.nibrs-inactive { background: var(--surface-3); color: var(--text-3); }

.nibrs-breakdown { min-height: 48px; }
.placeholder-text, .nibrs-note { font-size: 12px; color: var(--text-3); padding: var(--sp-2) 0; }
.nibrs-loading {
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4) 0;
}

.nibrs-offense-list { display: flex; flex-direction: column; }
.nibrs-offense-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.nibrs-offense-row:last-child { border-bottom: none; }
.nibrs-offense-name { color: var(--text-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nibrs-offense-count { font-family: var(--font-mono); font-weight: 500; color: var(--text); margin-left: var(--sp-3); }

.iframe-wrap {
  border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.iframe-wrap iframe { display: block; }

.resource-card {
  display: flex; flex-direction: column;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
  transition: border-color 0.15s;
  text-decoration: none;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.resource-card:active { border-color: var(--cyan); text-decoration: none; }
.resource-title { font-size: 13px; font-weight: 500; color: var(--text); }
.resource-desc { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.more-footer {
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center;
  font-size: 11px; color: var(--text-3);
  text-align: center;
}
.more-footer a { color: var(--text-3); }

/* ===== BOTTOM NAV ===== */
/* ═══════════════════════════════════════════════════════════════════════════
   TAB BAR — Apple HIG compliant
   Height: 49pt content + safe-area-inset-bottom
   Touch targets: 44pt minimum
   Typography: 10px Medium (SF system fallback)
   Icons: 25pt, filled when active
   ═══════════════════════════════════════════════════════════════════════════ */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
  /* Translucent background material per HIG */
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid color-mix(in srgb, var(--border) 60%, transparent);
  z-index: 200;
}
.tab-bar-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  /* 10pt Medium — Apple HIG tab bar label spec */
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--text-2) 55%, transparent);
  transition: color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 49px;
  min-width: 44px; /* 44pt touch target */
  border: none; background: none; cursor: pointer;
  padding: 0;
  position: relative;
}
.tab-bar-icon {
  font-size: 25px !important;
  line-height: 1;
  transition: color 0.18s ease, font-variation-settings 0.18s ease;
}
.tab-bar-label {
  line-height: 1;
  text-transform: none; /* Apple HIG: sentence case, not uppercase */
}
/* Active state — bold, prominent */
.tab-bar-item.active {
  color: var(--cyan);
  font-weight: 600;
}
.tab-bar-item.active .tab-bar-icon {
  color: var(--cyan);
}
/* Inactive state — higher contrast for accessibility */
.tab-bar-item:not(.active) {
  color: var(--text-2);
}
.tab-bar-item:not(.active) .tab-bar-icon {
  color: var(--text-2);
}
/* Tap feedback */
.tab-bar-item:active {
  opacity: 0.7;
  transition: opacity 0.05s;
}

/* ── More sheet (iOS action sheet pattern) ─────────────────────────────── */
.more-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 250;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.more-sheet-backdrop.visible { opacity: 1; }

.more-sheet {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  left: 0; right: 0;
  background: var(--surface);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  z-index: 260;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
  max-height: 60vh;
}
.more-sheet.visible {
  transform: translateY(0);
}
.more-sheet-handle {
  width: 36px; height: 5px;
  background: color-mix(in srgb, var(--text-3) 30%, transparent);
  border-radius: 2.5px;
  margin: 8px auto 4px;
}
.more-sheet-list {
  padding: 4px 0 8px;
}
.more-sheet-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 20px;
  border: none; background: none; cursor: pointer;
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  font-size: 17px; font-weight: 400;
  color: var(--text-1);
  text-align: left;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.more-sheet-item:active {
  background: color-mix(in srgb, var(--text-3) 12%, transparent);
}
.more-sheet-icon {
  font-size: 22px !important;
  color: var(--cyan);
  flex-shrink: 0;
}
.more-sheet-text {
  flex: 1;
}
.more-sheet-chevron {
  font-size: 18px !important;
  color: color-mix(in srgb, var(--text-3) 40%, transparent);
  flex-shrink: 0;
}
/* Separator lines between items */
.more-sheet-item + .more-sheet-item {
  border-top: 0.5px solid var(--border);
}

/* Alert animation on tab bar items */
.tab-bar-item--alert {
  animation: navAlertPulse 0.8s ease-in-out 4;
}

/* ===== GOOGLE MAPS INFOWINDOW OVERRIDES ===== */
.gm-style .gm-style-iw-c {
  background: var(--surface) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border) !important;
  padding: 0 !important;
}
.gm-style .gm-style-iw-d {
  overflow: auto !important;
  padding: 12px 14px !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  font-family: var(--font-body) !important;
  color: var(--text) !important;
}
.gm-style .gm-style-iw-tc::after {
  background: var(--surface) !important;
}
.gm-style .gm-ui-hover-effect {
  opacity: 0.6 !important;
}
.gm-style .gm-ui-hover-effect:hover {
  opacity: 1 !important;
}
.gm-style .gm-style-iw-d strong { color: var(--text) !important; }
.gm-style .gm-style-iw-d span { color: var(--text-2) !important; }
.gm-style .gm-style-iw-d a { color: var(--cyan) !important; }

/* ===== DESKTOP TABS (hidden on mobile) ===== */
.desktop-tabs {
  display: none;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ================================================================
   TABLET (>=768px)
   ================================================================ */
@media (min-width: 768px) {
  :root {
    --nav-h: 0px;
    --dtabs-h: 40px;
  }

  .tab-bar { display: none; }
  .more-sheet, .more-sheet-backdrop { display: none; }

  .desktop-tabs {
    display: flex;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    height: var(--dtabs-h);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    z-index: 150;
    padding: 0 12px;
    gap: 6px;
    align-items: stretch;
  }
  .desktop-tab {
    flex: 0 0 auto;
    min-width: 88px;
    padding: var(--sp-2) 14px;
    font-size: 12px; font-weight: 600;
    color: var(--text-3);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    text-align: center;
  }
  .desktop-tab:hover { color: var(--text-2); }
  .desktop-tab.active { color: var(--text); border-bottom-color: var(--cyan); }

  .main {
    top: calc(var(--header-h) + var(--dtabs-h));
    bottom: 0;
    display: block;
  }

  .view {
    position: absolute;
    inset: 0;
    display: none;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .view.active { display: flex; flex-direction: column; }
  .feed-list {
    gap: 10px;
  }
  .map-controls {
    flex-wrap: nowrap;
  }

  .more-footer {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* ================================================================
   DESKTOP (>=1200px)
   ================================================================ */
@media (min-width: 1200px) {
  .home-scroll {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
  }
  .chat-bubble { max-width: 85%; }
}

/* ================================================================
   WIDE DESKTOP (>=1600px)
   ================================================================ */
@media (min-width: 1600px) {
  .home-scroll {
    max-width: 1280px;
  }
}

@media (max-width: 767px) {
  .desktop-tabs { display: none; }
  .overflow-menu {
    left: 12px;
    right: 12px;
    min-width: 0;
  }
}

/* ================================================================
   LAW ENFORCEMENT DIRECTORY (.dir-*)
   ================================================================ */
.dir-header-card {
  margin: var(--sp-3) var(--sp-3) 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
.dir-header-top {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.dir-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.dir-subtitle {
  margin-top: var(--sp-2);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-3);
}

.dir-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) 0;
}
.dir-stat-chip {
  flex: 1 1 72px;
  min-width: 72px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  text-align: center;
}
.dir-stat-val {
  display: block;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.dir-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.dir-toolbar {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.dir-search-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
}
.dir-search-input::placeholder { color: var(--text-3); }
.dir-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--blue-dim);
}

.dir-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.dir-filter-btn {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.dir-filter-btn:hover { color: var(--text); border-color: var(--text-3); }
.dir-filter-btn.active {
  color: var(--text);
  background: var(--blue-dim);
  border-color: var(--accent);
}

.dir-section {
  padding: 0 var(--sp-3) var(--sp-4);
}
.dir-section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
}

.dir-agencies-list,
.dir-muni-list,
.dir-media-list,
.dir-community-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.dir-card {
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.dir-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.dir-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
}
.dir-tier-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.dir-tier-pill[data-tier="federal"] { background: var(--red-dim); color: var(--violent); border-color: rgba(239,68,68,0.35); }
.dir-tier-pill[data-tier="state"] { background: var(--blue-dim); color: var(--accent); border-color: rgba(96,165,250,0.35); }
.dir-tier-pill[data-tier="county"] { background: var(--amber-dim); color: var(--property); border-color: rgba(245,158,11,0.35); }
.dir-tier-pill[data-tier="municipal"] { background: var(--green-dim); color: var(--live-dot); border-color: rgba(34,197,94,0.35); }

.dir-card-meta {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
  margin-bottom: var(--sp-2);
}
.dir-card-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.dir-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.dir-link:hover { text-decoration: underline; }
.dir-link .material-icons { font-size: 14px; opacity: 0.85; }

.dir-muni-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: flex-start;
}
.dir-muni-name { font-weight: 700; font-size: 13px; color: var(--text); flex: 1 1 140px; }
.dir-muni-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.dir-muni-coverage {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

.dir-scanner-sys {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: var(--sp-3);
}
.dir-scanner-sys strong { color: var(--text); }
.dir-feed-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.dir-feed-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.dir-feed-label { font-size: 13px; font-weight: 600; color: var(--text); flex: 1 1 200px; }
.dir-feed-meta { font-size: 11px; color: var(--text-3); }
.dir-freq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  color: var(--text-2);
}
.dir-freq-table th,
.dir-freq-table td {
  padding: var(--sp-2);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.dir-freq-table th {
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.dir-media-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.dir-media-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
  margin-top: var(--sp-2);
}

.dir-community-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--property);
  margin-bottom: 4px;
}
.dir-community-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
  margin-top: var(--sp-2);
}

/* Incident intelligence — operational badges + summary */
.feed-op-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 6px 0 4px;
}
.op-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(77, 143, 219, 0.2);
  color: var(--accent, #4d8fdb);
  border: 1px solid rgba(77, 143, 219, 0.35);
}
.feed-inc-type {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
  text-transform: capitalize;
}
.feed-inc-type-label {
  font-weight: 600;
  color: var(--text-2);
}
.feed-why {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
  margin: 4px 0 2px;
}
.feed-confidence {
  font-size: 10px;
  color: var(--text-3);
  margin-bottom: 2px;
  opacity: 0.9;
}
.feed-now-channel {
  font-size: 10px;
  color: var(--text-3);
  margin: 4px 0 2px;
  line-height: 1.35;
}
.now-channel-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(212, 168, 75, 0.15);
  color: var(--accent-gold, #d4a84b);
  font-weight: 600;
  text-transform: capitalize;
  margin-right: 6px;
}
.now-score-hint {
  opacity: 0.85;
  font-weight: 400;
}

.stat-sublbl {
  display: block;
  font-size: 10px;
  color: var(--text-3);
  font-weight: 400;
  margin-top: 2px;
  line-height: 1.2;
}

.feed-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin: 14px 0 8px;
  padding: 0 2px;
}
.feed-section-title:first-child {
  margin-top: 4px;
}
.feed-section-note {
  font-size: 10px;
  color: var(--text-3);
  margin: -4px 0 10px;
  padding: 0 2px;
  line-height: 1.35;
}

.feed-op-line {
  font-size: 10px;
  color: var(--text-2);
  margin: 4px 0 2px;
  line-height: 1.35;
}
.feed-op-line .feed-op-k {
  color: var(--text-3);
  margin-right: 4px;
}

/* ================================================================
   PHASE 1 UI IMPROVEMENTS
   ================================================================ */

/* ── IMPROVED INCIDENT CARDS ── */
.feed-item {
  display: flex;
  gap: 0;
  padding: 0;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s, box-shadow 0.12s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
.feed-item:hover {
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
.feed-item:active { background: var(--surface-2); }

/* Left color indicator strip */
.feed-indicator {
  width: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  padding-top: 0;
  background: var(--surface-3);
}
.feed-item--violent .feed-indicator { background: var(--violent); }
.feed-item--property .feed-indicator { background: var(--property); }
.feed-item--other .feed-indicator { background: var(--accent); }

.feed-body {
  min-width: 0;
  flex: 1;
  padding: 10px 12px;
}

/* Title row: just the headline now (time moved to meta row) */
.feed-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.feed-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

/* Time display with freshness */
.feed-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.feed-time--fresh {
  color: var(--accent-gold);
  font-weight: 700;
}
.feed-time--stale {
  color: var(--text-3);
  opacity: 0.7;
  font-style: italic;
}

.feed-summary-line {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Meta pills row */
.feed-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.feed-meta-icon {
  font-size: 11px !important;
  margin-right: 1px;
  opacity: 0.7;
}

.feed-meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.feed-meta-pill--area {
  color: var(--text-2);
}
.feed-meta-pill--source {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}
/* Severity card borders (color communicated via indicator strip, not text pill) */
.feed-item--sev-critical {
  box-shadow: var(--shadow-card), inset 0 0 0 1px color-mix(in srgb, var(--violent) 20%, transparent);
}
.feed-item--sev-critical .feed-indicator { background: var(--violent); }
.feed-item--sev-high {
  box-shadow: var(--shadow-card), inset 0 0 0 1px color-mix(in srgb, var(--accent-gold) 20%, transparent);
}
.feed-item--quiet {
  opacity: 0.65;
}

/* Hide the old feed-dot since we're using the strip indicator now */
.feed-dot { display: none; }

/* ── IMPROVED NEWS STORY CARDS ── */
a.home-story-card {
  text-decoration: none;
  color: inherit;
  display: block;
}
a.home-story-card:hover {
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
a.home-story-card:active {
  background: var(--surface-2);
}

.home-story-card {
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--sp-2);
  transition: box-shadow 0.12s, background 0.12s;
}
.home-story-card--major {
  border-left: 4px solid var(--accent-gold);
}
.home-story-card--developing {
  border-left: 4px solid var(--accent);
}

.home-story-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.home-story-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.home-story-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.home-story-desc {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.home-story-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
}
.home-story-pill--source {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}
.home-story-pill--sev-critical {
  color: var(--violent);
  background: var(--red-dim);
  border-color: color-mix(in srgb, var(--violent) 30%, transparent);
  text-transform: uppercase;
  font-weight: 700;
}
.home-story-pill--sev-high {
  color: var(--property);
  background: var(--amber-dim);
  border-color: color-mix(in srgb, var(--property) 30%, transparent);
  text-transform: uppercase;
  font-weight: 700;
}

/* ── HOME RECAP CARDS ── */
.home-recaps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-2);
}
.home-recap-card {
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.home-recap-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 4px;
}
.home-recap-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.home-recap-detail {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.4;
  margin-top: 2px;
}

/* ── HOME SECTION LABELS ── */
.home-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
  padding-top: var(--sp-2);
}

/* ── STREAMING CURSOR ── */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 0.8s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.chat-bubble.is-streaming p:last-child {
  display: inline;
}

/* ── IMPROVED CHAT INPUT ── */
.chat-input button:active {
  opacity: 0.7;
}
.chat-input button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── DIRECTORY AGENCY HIGHLIGHT ── */
.dir-agency-highlight {
  animation: dir-highlight 2s ease-out;
}
@keyframes dir-highlight {
  0% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: var(--shadow-card); }
}

/* ── EMPTY STATE IMPROVEMENTS ── */
.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.5;
}
.feed-summary-empty {
  text-align: center;
  padding: var(--sp-4);
  color: var(--text-3);
  font-size: 12px;
}

/* ── MOBILE FIXES ── */
@media (max-width: 480px) {
  .feed-title { font-size: 13px; }
  .feed-summary-line { -webkit-line-clamp: 1; font-size: 11px; }
  .feed-time { font-size: 10px; }
  .feed-meta-pill { font-size: 9px; padding: 1px 5px; }
  .home-story-title { font-size: 13px; }
  .home-story-desc { -webkit-line-clamp: 2; }
  .home-recaps-grid { grid-template-columns: 1fr; }

  /* Small padding so last card isn't flush against the edge */
  .view { padding-bottom: 8px; }
  .feed-list { padding-bottom: 16px; }

  /* Scanner player fits on small screens */
  .sc-player { padding: var(--sp-2) var(--sp-3); }
  .sc-card-summary { font-size: 12px; }
}

/* ── SUMMARY STRIP IMPROVEMENTS ── */
.home-summary-grid .feed-summary-card {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.feed-summary-v {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.feed-summary-v--sm {
  font-size: 13px;
  font-weight: 600;
}
.feed-summary-k {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── LIVE INDICATOR IMPROVEMENTS ── */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live-dot);
  animation: pulse-live 2s ease-in-out infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--live-dot); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px transparent; }
}
.live-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--live-dot);
}

/* ── FRESHNESS INDICATOR ── */
.feed-freshness {
  font-size: 10px;
  color: var(--text-3);
  text-align: center;
  padding: 6px 12px 2px;
  letter-spacing: 0.02em;
  transition: color 0.3s;
}
.feed-freshness:empty { display: none; }
.feed-freshness--stale {
  color: var(--property);
}

/* ── SEARCH (removed from home; kept minimal for future use) ── */
.feed-search-count {
  font-size: 11px;
  color: var(--text-muted, #888);
  padding: 4px 0 8px;
}

/* ── ERROR STATE ── */
.feed-error-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted, #888);
}
.feed-error-state .material-icons {
  font-size: 36px;
  display: block;
  margin: 0 auto 8px;
  opacity: 0.5;
}
.feed-error-state p {
  margin: 4px 0;
  font-size: 13px;
}
.feed-error-retry {
  margin-top: 12px;
  padding: 8px 20px;
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  background: transparent;
  color: var(--text, #eee);
  cursor: pointer;
  font-size: 13px;
}
.feed-error-retry:hover {
  background: var(--bg-hover, rgba(255,255,255,0.06));
}

/* ── VIEW SCROLL FIX ── */
.view-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 16px;
}
.home-scroll {
  padding-bottom: 16px;
}
