/* LocalPulse — single stylesheet, mobile-first, WCAG-AAA-friendly contrast. */
:root {
  --bg: #F7F9FC;
  --bg-card: #FFFFFF;
  --bg-elev: #FFFFFF;
  --fg: #0B1020;
  --fg-muted: #4A5468;
  --fg-soft: #6B7280;
  --border: #E4E8EF;
  --border-strong: #C9D1DC;
  --accent: #FF6B35;
  --accent-soft: #FFE7DC;
  --info: #1E66F5;
  --ok: #1B873F;
  --warn: #B25E09;
  --danger: #B42318;
  --rumor: #6B21A8;
  --shadow-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --shadow-2: 0 4px 14px rgba(15,23,42,.08);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --maxw: 1200px;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #0B0F1A;
  --bg-card: #131826;
  --bg-elev: #1A2030;
  --fg: #ECEFF6;
  --fg-muted: #B6BCCB;
  --fg-soft: #8993A8;
  --border: #232A3B;
  --border-strong: #2E3650;
  --accent: #FF8C5A;
  --accent-soft: #3A1E14;
  --info: #6FA8FF;
  --ok: #44D17A;
  --warn: #F0B452;
  --danger: #FF6B6B;
  --rumor: #C084FC;
  --shadow-1: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
  --shadow-2: 0 8px 24px rgba(0,0,0,.5);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* a11y skip link */
.skip-link {
  position: absolute; left: -9999px; top: 0; padding: 8px 12px;
  background: var(--fg); color: var(--bg); z-index: 9999; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; outline: 2px solid var(--accent); }

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* App bar */
.appbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(160%) blur(8px);
}
.appbar-dark { background: rgba(11,15,26,.85); border-bottom-color: #1E2538; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 600; font-size: 18px; color: var(--fg); }
.brand-text { letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; letter-spacing: .15em; color: var(--accent); margin-left: 8px; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 4px; }
.brand-logo { position: relative; width: 22px; height: 22px; display: inline-block; }
.brand-logo .ring { position: absolute; inset: 0; border: 2px solid var(--accent); border-radius: 50%; animation: pulse-ring 2.4s ease-out infinite; }
.brand-logo .dot { position: absolute; inset: 7px; background: var(--accent); border-radius: 50%; }
@keyframes pulse-ring {
  0% { transform: scale(.6); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.appnav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.appnav::-webkit-scrollbar { display: none; }
.nav-link {
  font-size: 14px; font-weight: 500; color: var(--fg-muted);
  padding: 8px 12px; border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-link:hover { background: var(--accent-soft); color: var(--fg); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .nav-link.is-active { color: var(--accent); }

.appbar-tail { display: flex; align-items: center; gap: 8px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  background: rgba(27,135,63,.1); color: var(--ok);
  border: 1px solid rgba(27,135,63,.25);
}
.status-pill[data-state="stale"] { background: rgba(178,94,9,.12); color: var(--warn); border-color: rgba(178,94,9,.3); }
.status-pill[data-state="offline"] { background: rgba(180,35,24,.12); color: var(--danger); border-color: rgba(180,35,24,.3); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: dot-pulse 1.6s ease-out infinite; }
@keyframes dot-pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 100% { box-shadow: 0 0 0 8px transparent; } }

.lang-select-wrap select, .theme-toggle {
  font: inherit; font-size: 13px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--fg);
}
.theme-toggle { display: inline-flex; align-items: center; padding: 6px 8px; cursor: pointer; }
.theme-toggle:hover { background: var(--accent-soft); }

/* layout */
.container {
  max-width: var(--maxw); margin: 0 auto; padding: 20px;
}
@media (min-width: 768px) { .container { padding: 28px; } }

.hero { padding: 28px 0 16px; }
.hero-title {
  font-family: var(--font-head); font-weight: 700;
  font-size: clamp(28px, 5vw, 44px); line-height: 1.1; margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.hero-sub {
  display: block; font-family: var(--font-body); font-weight: 400;
  font-size: clamp(15px, 2.4vw, 18px); color: var(--fg-muted); margin-top: 4px;
  letter-spacing: 0;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.privacy-note { font-size: 13px; color: var(--fg-soft); margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; font: inherit; font-weight: 500; font-size: 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: transform .08s ease, background .12s ease, border-color .12s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: #E55A28; }
.btn-secondary { background: var(--bg-card); color: var(--fg); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* KPI strip */
.kpi-strip {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px;
  margin: 8px 0 22px;
}
@media (min-width: 720px) { .kpi-strip { grid-template-columns: repeat(4, minmax(0,1fr)); } }
.kpi {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-1);
}
.kpi-num { font-family: var(--font-head); font-size: clamp(22px, 4vw, 32px); font-weight: 600; line-height: 1; letter-spacing: -0.01em; }
.kpi-label { font-size: 12px; color: var(--fg-soft); margin-top: 6px; text-transform: uppercase; letter-spacing: .08em; }

/* cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-1); padding: 18px; margin: 0 0 22px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: -2px 0 14px; flex-wrap: wrap;
}
.card-head h2 {
  margin: 0; font-family: var(--font-head); font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
}
.badge {
  font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 8px; border-radius: var(--radius-pill);
}
.muted { color: var(--fg-muted); }
.small { font-size: 13px; }

/* grids */
.grid-2col { display: grid; gap: 22px; grid-template-columns: 1fr; margin: 0 0 22px; }
@media (min-width: 980px) { .grid-2col { grid-template-columns: 1.2fr 1fr; } }

/* map */
.map { width: 100%; height: 360px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.map-tall { height: 540px; }
.leaflet-popup-content { font-family: var(--font-body); font-size: 13px; }

/* filters / chips */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 12px; font-weight: 500; padding: 6px 10px;
  border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--bg-card); color: var(--fg-muted); cursor: pointer;
}
.chip.is-active { background: var(--accent); color: white; border-color: var(--accent); }
.chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* summary list */
.summary-list { list-style: none; padding: 0; margin: 0 0 12px; }
.summary-list li {
  display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.summary-list li::before {
  content: ""; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; margin-top: 8px; flex: 0 0 6px;
}
.summary-list li:last-child { border-bottom: 0; }

/* incident list */
.incident-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.incident-list-dense { gap: 8px; }
.incident {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 12px;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.incident:hover { border-color: var(--border-strong); }
.incident-bar { width: 4px; border-radius: 2px; align-self: stretch; }
.incident[data-sev="high"] .incident-bar { background: var(--danger); }
.incident[data-sev="medium"] .incident-bar { background: var(--warn); }
.incident[data-sev="low"] .incident-bar { background: var(--info); }
.incident[data-sev="info"] .incident-bar { background: var(--info); }
.incident[data-cat="rumor"] .incident-bar { background: var(--rumor); }
.incident-title { font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.incident-summary { color: var(--fg-muted); font-size: 14px; margin: 0; }
.incident-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--fg-soft); margin-top: 6px; }
.trust-bar {
  width: 80px; height: 6px; border-radius: 3px; background: var(--border); position: relative; overflow: hidden;
}
.trust-bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--danger), var(--warn), var(--ok)); }

.cat-tag {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
}
.cat-tag[data-cat="road"] { background: #FFE7DC; color: #B45309; }
.cat-tag[data-cat="shelter"] { background: #DCFCE7; color: #166534; }
.cat-tag[data-cat="power"] { background: #FEF3C7; color: #B45309; }
.cat-tag[data-cat="water"] { background: #DBEAFE; color: #1E40AF; }
.cat-tag[data-cat="medical"] { background: #FCE7F3; color: #9D174D; }
.cat-tag[data-cat="rumor"] { background: #F3E8FF; color: #6B21A8; }
[data-theme="dark"] .cat-tag { filter: brightness(.9) saturate(.9); }

/* shelters */
.shelter-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .shelter-grid { grid-template-columns: repeat(3, 1fr); } }
.shelter {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px;
  background: var(--bg-card);
}
.shelter h3 { margin: 0 0 4px; font-size: 15px; font-family: var(--font-head); }
.shelter .occ {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--fg-muted);
}
.shelter .occ-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.shelter .occ-fill { height: 100%; background: var(--ok); }
.shelter[data-full="1"] .occ-fill { background: var(--danger); }
.shelter .amen { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.shelter .amen span { font-size: 11px; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--bg); color: var(--fg-muted); border: 1px solid var(--border); }

/* form */
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field-wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  font: inherit; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--fg);
}
.field textarea { resize: vertical; }
.field :focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form-status { grid-column: 1 / -1; min-height: 1.2em; font-size: 13px; color: var(--ok); }
.form-status[data-state="err"] { color: var(--danger); }

/* footer */
.appfoot {
  max-width: var(--maxw); margin: 30px auto 50px; padding: 18px 20px;
  border-top: 1px solid var(--border); color: var(--fg-soft); font-size: 13px;
  display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap;
}

/* responder shell */
.responder-body { background: var(--bg); }
.responder-shell {
  display: grid; gap: 16px;
  grid-template-columns: 1fr; padding: 16px; max-width: 1500px; margin: 0 auto;
}
@media (min-width: 1024px) { .responder-shell { grid-template-columns: 240px 1fr; padding: 22px; } }
.responder-sidebar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  align-content: start;
}
@media (min-width: 1024px) { .responder-sidebar { grid-template-columns: 1fr; position: sticky; top: 78px; } }
.op-kpi {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
}
.op-kpi-num { font-family: var(--font-head); font-size: 24px; font-weight: 600; line-height: 1; }
.op-kpi-label { font-size: 11px; color: var(--fg-soft); text-transform: uppercase; letter-spacing: .08em; }
.threat-meter { padding: 10px; border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--border); grid-column: 1 / -1; }
.threat-meter-label { font-size: 11px; color: var(--fg-soft); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.threat-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.threat-bar > span { display: block; height: 100%; width: 62%; background: linear-gradient(90deg, var(--ok), var(--warn), var(--danger)); }
.threat-meter-state { font-weight: 600; margin-top: 6px; color: var(--warn); font-size: 14px; }
.legend { grid-column: 1 / -1; display: grid; gap: 6px; padding-top: 4px; border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 10px; font-size: 12px; color: var(--fg-muted); }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-high { background: var(--danger); }
.dot-med { background: var(--warn); }
.dot-low { background: var(--info); }
.dot-rumor { background: var(--rumor); }

.responder-grid {
  display: grid; gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 1100px) {
  .responder-grid {
    grid-template-columns: 1.4fr 1fr;
    grid-template-areas:
      "map feed"
      "summary feed"
      "stream shelters";
  }
  .op-map-card { grid-area: map; }
  .op-feed-card { grid-area: feed; }
  .op-summary-card { grid-area: summary; }
  .op-stream-card { grid-area: stream; }
  .op-shelters-card { grid-area: shelters; }
}
.stream {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; max-height: 240px; overflow: auto; margin: 0;
  color: var(--fg-muted);
}

/* voice */
.voice-container { padding-top: 24px; }
.voice-hero h1 { font-family: var(--font-head); font-size: clamp(28px, 5vw, 40px); margin: 0 0 8px; letter-spacing: -.02em; }
.voice-hero .lead { font-size: 17px; color: var(--fg-muted); max-width: 64ch; }
.voice-hero .prod-note { font-size: 13px; color: var(--fg-soft); max-width: 70ch; margin-top: 6px; }
.voice-stage { display: grid; gap: 24px; grid-template-columns: 1fr; align-items: start; margin: 24px 0; }
@media (min-width: 920px) { .voice-stage { grid-template-columns: 320px 1fr; } }

.phone-frame {
  width: 280px; max-width: 100%; aspect-ratio: 9/19; margin: 0 auto;
  background: linear-gradient(180deg, #14192A 0%, #1B2236 100%);
  border-radius: 38px; padding: 12px;
  box-shadow: 0 20px 60px rgba(15,23,42,.25), inset 0 0 0 2px rgba(255,255,255,.05);
  position: relative; isolation: isolate;
}
.phone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 90px; height: 18px; background: #0B0F1A; border-radius: 0 0 14px 14px; z-index: 1;
}
.phone-screen {
  background: linear-gradient(180deg, #FFF8F4 0%, #FFEEE5 100%);
  color: #1B1100;
  border-radius: 28px; height: 100%; padding: 28px 14px 14px; display: flex; flex-direction: column; gap: 12px;
}
[data-theme="dark"] .phone-screen { background: linear-gradient(180deg, #FFE7DC 0%, #FFD2BE 100%); }
.phone-status { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: #6B3E1B; }
.orb-wrap { display: grid; place-items: center; padding: 4px 0 8px; }
.orb {
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFD9C2 0%, #FF7A3D 60%, #B23A0D 100%);
  position: relative; box-shadow: 0 18px 38px rgba(255,107,53,.45);
}
.orb-pulse {
  position: absolute; inset: -10px; border-radius: 50%; border: 3px solid rgba(255,107,53,.35);
  animation: orb-pulse 2s ease-out infinite;
}
.orb.is-listening .orb-pulse { animation-duration: .9s; border-color: rgba(180,35,24,.6); }
.orb.is-speaking .orb-pulse { animation-duration: 1.4s; border-color: rgba(27,135,63,.55); }
@keyframes orb-pulse { 0% { transform: scale(.92); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }

.caption-wrap { display: grid; gap: 4px; min-height: 80px; flex: 1; }
.caption-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #8A4A1A; }
.caption-line { font-size: 14px; line-height: 1.45; color: #1B1100; min-height: 1.2em; }
.caption-bot { font-weight: 500; }
.caption-meta { display: flex; justify-content: space-between; font-size: 11px; color: #8A4A1A; margin-top: 4px; }
.caption-meta code { font-family: var(--font-mono); background: rgba(255,255,255,.55); padding: 1px 6px; border-radius: 4px; color: #1B1100; }

.phone-controls { display: grid; place-items: center; }
.phone-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14px;
  background: #1B1100; color: #FFE7DC; border: none; border-radius: var(--radius-pill); padding: 12px 18px;
  cursor: pointer; box-shadow: 0 8px 20px rgba(0,0,0,.18);
}
.phone-btn:hover { transform: translateY(-1px); }
.phone-btn-call.is-active { background: #B42318; color: white; }
.phone-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.voice-side h2 { font-family: var(--font-head); font-size: 16px; margin: 0 0 8px; }
.suggest-list { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.suggest {
  font: inherit; text-align: left; width: 100%; padding: 10px 12px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--fg); cursor: pointer; font-size: 14px;
}
.suggest:hover { border-color: var(--accent); }
.lang-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.lang-list li { padding: 4px 10px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 500; }

.transcript { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: t; }
.transcript li {
  display: grid; grid-template-columns: 70px 1fr; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card);
  font-size: 14px;
}
.transcript .who { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-soft); }
.transcript .who.user { color: var(--info); }
.transcript .who.bot { color: var(--accent); }

/* print: hide chrome */
@media print {
  .appbar, .appfoot, .filters, .hero-actions, .form-card, .phone-controls { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}
