:root {
  /* BluArmor tokens */
  --base-dark: #06080A;
  --raised: #1F2123;
  --overlay: #38393B;
  --muted: #515254;
  --mid: #6A6B6C;
  --text-primary: #D2D3D3;
  --text-secondary: #9B9C9D;
  --text-tertiary: #6A6B6C;
  --text-accent: #FFFFFF;
  --button-secondary: #1A1C1E;
  --positive: #20DD1C;
  --negative: #E61212;
  --warning: #FFC426;
  --lava-a: #F27D58;
  --lava-b: #FB3307;
  --lava: linear-gradient(135deg, var(--lava-a), var(--lava-b));
  --blue: #4CA9DF;
  --blue-b: #292E91;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", monospace;
  --bar: 40px;   /* bottom session bar height */
  /* notch / home-indicator safe areas (0 on devices without them) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--base-dark);
  color: var(--text-primary);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  /* Kill mobile long-press/swipe text selection. Selecting text is what
     triggers the browser's "Search Web / Google Search / Translate" menu and
     Android Chrome's swipe-up "Touch to Search" Google bar. No text in this
     tracking UI needs to be selectable, so we disable it app-wide. */
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  /* Disable the iOS long-press callout ("Look Up / Translate / Search Web"). */
  -webkit-touch-callout: none;
  /* Stop iOS from auto-linking numbers/addresses into tappable Google/Maps links. */
  -webkit-tap-highlight-color: transparent;
}
[v-cloak] { display: none; }

/* ---------- map ---------- */
#map {
  position: absolute; inset: 0; z-index: 1;
  background: var(--base-dark);
}
.leaflet-container { background: #e8e8e8; font-family: var(--body); }
.leaflet-control-zoom { border: none !important; margin: 16px !important; box-shadow: none !important; }
.leaflet-control-zoom a {
  background: var(--raised) !important; color: var(--text-secondary) !important;
  border: 1px solid #2A2D30 !important; width: 32px; height: 32px; line-height: 32px;
  font-family: var(--body); font-weight: 600;
}
.leaflet-control-zoom a:first-child { border-radius: 8px 8px 0 0 !important; }
.leaflet-control-zoom a:last-child { border-radius: 0 0 8px 8px !important; }
.leaflet-control-zoom a:hover { background: var(--overlay) !important; color: var(--text-accent) !important; }
.leaflet-control-attribution {
  background: rgba(6,8,10,.7) !important; color: var(--text-tertiary) !important;
  font-family: var(--mono); font-size: 9.5px !important; backdrop-filter: blur(4px);
}
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
.leaflet-bottom.leaflet-left { bottom: calc(var(--bar) + var(--safe-bottom)); } /* clear the session bar */

/* grain overlay (from BluArmor) */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: .3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- current location marker (plain blue circle, thick border) ---------- */
.live-dot-marker {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue);
  border: 4px solid var(--text-accent);
  box-shadow: 0 0 0 1px rgba(6,8,10,.6), 0 4px 10px rgba(0,0,0,.5);
  cursor: pointer;
}

/* ---------- navigate popup (BluArmor dark) ---------- */
.leaflet-popup.nav-popup .leaflet-popup-content-wrapper {
  background: var(--raised); color: var(--text-primary);
  border: 1px solid #2A2D30; border-radius: 14px;
  box-shadow: 0 20px 56px -18px rgba(0,0,0,.95);
}
.leaflet-popup.nav-popup .leaflet-popup-content { margin: 0; }
.leaflet-popup.nav-popup .leaflet-popup-tip { background: var(--raised); box-shadow: none; }
.leaflet-popup.nav-popup .leaflet-popup-close-button { color: var(--text-tertiary); padding: 8px 8px 0 0; }
.leaflet-popup.nav-popup .leaflet-popup-close-button:hover { color: var(--text-accent); }

.nav-pop { padding: 14px 15px 15px; width: 218px; font-family: var(--body); }
.nav-title {
  font-family: var(--display); font-size: 17px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-accent); line-height: 1;
}
.nav-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-tertiary); margin: 5px 0 4px; }
.nav-opt {
  display: flex; align-items: center; gap: 11px; text-decoration: none;
  margin-top: 9px; padding: 11px 12px; border-radius: 10px;
  background: var(--button-secondary); border: 1px solid #2A2D30;
  color: var(--text-primary); font-size: 13.5px; font-weight: 500;
  transition: border-color .14s, color .14s, transform .14s;
}
.nav-opt:hover { border-color: var(--mid); color: var(--text-accent); transform: translateX(2px); }
.nav-opt .ic { width: 24px; height: 24px; flex: none; display: grid; place-items: center; }
.nav-opt .ic svg { width: 24px; height: 24px; display: block; }
.nav-opt .chev { margin-left: auto; color: var(--text-tertiary); width: 15px; height: 15px; }

/* crash-origin pin */
.crash-marker {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--negative);
  border: 3px solid var(--text-accent);
  box-shadow: 0 0 0 1px rgba(6,8,10,.6);
}

/* ---------- subject panel (top-left) ---------- */
.subject {
  position: absolute; top: calc(18px + var(--safe-top)); left: calc(18px + var(--safe-left)); z-index: 600;
  width: 318px;
  background: var(--raised);
  border: 1px solid #2A2D30;
  border-radius: 12px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.9);
  overflow: hidden;
}
.subject-bar {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 10px 15px;
  background: var(--button-secondary);
  border: none; border-bottom: 1px solid #15181B;
  font-family: inherit; color: inherit; text-align: left; cursor: pointer;
}
.subject.collapsed .subject-bar { border-bottom: none; }
.subject-peek {
  flex: 1 1 auto; min-width: 0; text-align: right; margin-right: 2px;
  font-family: var(--mono); font-size: 11px; color: var(--text-secondary);
  letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subject-chev {
  margin-left: 8px; flex: none; width: 17px; height: 17px;
  color: var(--text-primary); transition: transform .2s, color .15s;
}
.subject-bar:hover .subject-chev { color: var(--text-accent); }
.subject:not(.collapsed) .subject-chev { transform: rotate(180deg); }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--negative);
  box-shadow: 0 0 8px rgba(230,18,18,.7); animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 50% { opacity: .25; } }
.subject-bar .tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  color: var(--negative); text-transform: uppercase; font-weight: 500;
}
.subject-bar .case {
  flex: 1 1 auto; min-width: 0; text-align: right;
  font-family: var(--mono); font-size: 10px;
  color: var(--text-tertiary); letter-spacing: .1em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.subject-body { padding: 15px 17px 17px; }

.subject-name {
  font-family: var(--display); font-weight: 700; font-size: 28px; line-height: 1;
  letter-spacing: .02em; color: var(--text-accent);
  display: flex; align-items: baseline; gap: 9px;
}
.subject-name small {
  font-family: var(--mono); font-size: 10.5px; font-weight: 400;
  color: var(--blue); letter-spacing: .04em;
}

.stats { margin-top: 16px; display: grid; gap: 1px; background: #15181B; border-radius: 8px; overflow: hidden; }
.stat { background: var(--button-secondary); padding: 11px 13px; }
.stat-k {
  font-family: var(--display); font-size: 11px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--text-tertiary); font-weight: 600;
}
.stat-v {
  margin-top: 4px; font-family: var(--mono); font-size: 14px; color: var(--text-primary);
  display: flex; align-items: baseline; gap: 7px;
}
.stat-v .unit { font-size: 10.5px; color: var(--text-tertiary); }
.stat-v.warn  { color: var(--warning); }
.stat-v.bad   { color: #ff5454; }

/* TODO(severity): the prototype rendered an Impact severity badge
   (.sev / .sev-low/.sev-med/.sev-high) in the Incident Detected stat.
   Severity is NOT implemented yet — it will arrive later from the device's
   crash G-force value. Intentionally omitted; re-add the badge here when the
   feed carries a severity field. */

.crash-stat { position: relative; }
.crash-stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--negative);
}

/* ---------- legend (bottom-left) ---------- */
.legend {
  position: absolute; bottom: calc(var(--bar) + var(--safe-bottom) + 14px); left: calc(18px + var(--safe-left)); z-index: 600;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(31,33,35,.86); backdrop-filter: blur(8px);
  border: 1px solid #2A2D30; border-radius: 10px; padding: 12px 14px;
  font-family: var(--mono); font-size: 11px; color: var(--text-secondary);
}
.legend-row { display: flex; align-items: center; gap: 10px; letter-spacing: .02em; }
.swatch { flex: none; }
.swatch.path { width: 28px; border-top: 3px dashed var(--lava-a); height: 0; }
.swatch.live { width: 13px; height: 13px; border-radius: 50%; background: var(--blue); border: 3px solid var(--text-accent); }
.swatch.crash{ width: 12px; height: 12px; border-radius: 50%; background: var(--negative); border: 2px solid var(--text-accent); }

/* ---------- floating controls (above the bar, bottom-right) ---------- */
.controls {
  position: absolute; right: calc(16px + var(--safe-right)); bottom: calc(var(--bar) + var(--safe-bottom) + 14px); z-index: 600;
  display: flex; flex-direction: column; align-items: flex-end; gap: 11px;
}

/* recenter — "Icon Button Small Primary": dark pill, 36px, rx18, white icon + label */
.btn-recenter {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--body); font-weight: 500; font-size: 13px;
  color: var(--text-accent);
  background: var(--button-secondary); border: none;
  height: 36px; padding: 0 16px 0 13px; border-radius: 18px; cursor: pointer;
  box-shadow: 0 10px 26px -14px rgba(0,0,0,.9);
  transition: filter .15s, transform .14s;
}
.btn-recenter:hover { filter: brightness(1.4); transform: translateY(-1px); }
.btn-recenter svg { width: 16px; height: 16px; color: #fff; }

/* extend — "Button Primary": dark pill (#1A1C1E), 49px tall, rx 24.5, white label */
.btn-extend {
  font-family: var(--body); font-weight: 500; font-size: 16px; letter-spacing: .01em;
  color: var(--text-accent);
  height: 49px; padding: 0 30px;
  border: none; border-radius: 24.5px; cursor: pointer;
  background: var(--button-secondary);
  box-shadow: 0 14px 34px -12px rgba(0,0,0,.95);
  transition: filter .15s, transform .14s;
}
.btn-extend:hover:not(:disabled) { filter: brightness(1.45); transform: translateY(-2px); }
.btn-extend:active:not(:disabled) { transform: translateY(0); }
.btn-extend:disabled {
  color: var(--text-tertiary); cursor: default; box-shadow: none;
  border: 1px solid #2A2D30;
}
.btn-extend.busy { opacity: .7; cursor: progress; }

/* ---------- session bar (very bottom, thin) ---------- */
.session-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 650;
  height: calc(var(--bar) + var(--safe-bottom)); display: flex; align-items: center; gap: 9px;
  padding: 0 calc(16px + var(--safe-right)) var(--safe-bottom) calc(16px + var(--safe-left));
  background: rgba(16,18,20,.94); backdrop-filter: blur(10px);
  border-top: 1px solid #2A2D30;
  font-family: var(--mono); font-size: 12px; color: var(--text-secondary);
}
.session-time { letter-spacing: .04em; }
.session-time b { color: var(--text-accent); font-weight: 500; }
.session-ext { margin-left: auto; color: var(--text-tertiary); letter-spacing: .04em; }

/* toast */
.toast {
  position: absolute; bottom: calc(var(--bar) + var(--safe-bottom) + 62px); right: calc(16px + var(--safe-right)); z-index: 700;
  font-family: var(--mono); font-size: 12px; color: var(--positive);
  background: var(--raised); border: 1px solid rgba(32,221,28,.35);
  padding: 9px 14px; border-radius: 8px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.8);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- full-screen states (loading / error / ended) ---------- */
.screen {
  position: absolute; inset: 0; z-index: 800;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(31,33,35,.55), rgba(6,8,10,.92));
  backdrop-filter: blur(3px);
}
.screen-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--raised); border: 1px solid #2A2D30; border-radius: 16px;
  padding: 30px 26px 28px;
  box-shadow: 0 28px 70px -22px rgba(0,0,0,.95);
}
.screen-kick {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--text-tertiary);
}
.screen-kick.bad { color: var(--negative); }
.screen-title {
  font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.05;
  letter-spacing: .02em; text-transform: uppercase; color: var(--text-accent); margin-top: 12px;
}
.screen-msg { margin-top: 12px; color: var(--text-secondary); font-size: 13.5px; }
.screen-msg b { color: var(--text-primary); font-weight: 600; }
.screen-meta {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid #15181B;
  font-family: var(--mono); font-size: 11px; color: var(--text-tertiary); line-height: 1.7;
}
.spinner {
  width: 34px; height: 34px; margin: 0 auto 4px; border-radius: 50%;
  border: 3px solid #2A2D30; border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .subject { width: calc(100% - 24px); left: 12px; top: 12px; }
  .subject-bar { padding: 7px 12px; }
  .subject-bar .tag, .subject-bar .case { font-size: 9px; }
  .subject-body { padding: 10px 13px 12px; }
  .subject-name { font-size: 20px; }
  .subject-name small { font-size: 9px; }
  /* lay stats out wide & short: two side-by-side, incident spans full width */
  .stats { grid-template-columns: 1fr 1fr; }
  .crash-stat { grid-column: 1 / -1; }
  .stat { padding: 7px 11px; }
  .stat-k { font-size: 9.5px; letter-spacing: .14em; }
  /* keep value + timestamp tidy in a narrow 2-col cell: clock drops to its own line */
  .stat-v { font-size: 12px; flex-wrap: wrap; }
  .stat-v .unit { width: 100%; }
  .legend {
    padding: 8px 10px; gap: 5px; font-size: 9.5px;
    left: calc(10px + var(--safe-left)); bottom: calc(var(--bar) + var(--safe-bottom) + 10px);
  }
  .legend-row { gap: 6px; }
  .leaflet-control-zoom { display: none; } /* pinch-to-zoom on touch */
  .session-label { display: none; }
  .session-bar { padding: 0 12px; gap: 10px; }
  .btn-extend { height: 46px; font-size: 15px; padding: 0 24px; }
}
