/* Camera HUD stays dark to remain readable over live video in either theme. */
.ar-view {
  --hud-bg: #0e0f11;
  --hud-surface: #16181b;
  --hud-ink: #ecedef;
  --hud-muted: #9ba0a8;
  --hud-line: rgba(236, 237, 239, .2);
  --ar-space-1: 4px; --ar-space-2: 8px; --ar-space-3: 12px;
  --ar-space-4: 16px; --ar-space-5: 20px; --ar-space-6: 24px; --ar-space-8: 32px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-width: 320px;
  color: var(--hud-ink);
  background: var(--nv-accent-ink);
  font-family: var(--nv-font);
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--nv-accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- page shell ---------- */
.ar-view {
  position: relative;
  height: calc(100dvh - var(--nv-bar-h));
  width: 100%;
  overflow: hidden;
  background: var(--hud-bg);
}

.ar-camera { position: absolute; inset: 0; background: var(--hud-bg); }
.ar-camera-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ar-contrast-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, rgb(14 15 17 / 0.55) 0%, rgb(14 15 17 / 0) 18%, rgb(14 15 17 / 0) 72%, rgb(14 15 17 / 0.6) 100%);
}
@media (prefers-reduced-transparency: reduce) {
  .ar-contrast-scrim { background: rgb(14 15 17 / 0.35); }
}

.ar-overlay-layer { position: absolute; inset: 0; display: none; }
.ar-view--live .ar-overlay-layer,
.ar-view--empty .ar-overlay-layer,
.ar-view--calibrating .ar-overlay-layer,
.ar-view--loading-data .ar-overlay-layer { display: block; }

/* ---------- top bar ---------- */
.ar-topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--ar-space-3);
  padding: max(env(safe-area-inset-top), 12px) 12px 8px;
  z-index: 30;
}
.ar-heading-readout {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--hud-ink);
}
.ar-heading-readout .ar-confidence-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--nv-warn); }
.ar-heading-readout[data-confidence="ready"] .ar-confidence-dot { background: var(--nv-accent); }
.ar-heading-readout[data-confidence="unstable"] .ar-confidence-dot { background: var(--nv-warn); }
.ar-exit-button {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink); font-size: 16px;
}
.ar-freshness {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
  padding: 4px 10px; border-radius: var(--nv-r);
  background: var(--hud-surface); color: var(--hud-muted);
  font-size: 12px; font-weight: 600; z-index: 29; white-space: nowrap;
}
.ar-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(12px);
  max-width: 84vw; padding: 10px 16px; border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink);
  font-size: 13px; font-weight: 600; text-align: center; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 0.18s var(--nv-ease), transform 0.18s var(--nv-ease);
}
.ar-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.ar-toast:empty { display: none; }

/* ---------- horizon guide ---------- */
.ar-horizon-guide {
  position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--hud-line);
  z-index: 5; pointer-events: none;
  transition: top 0.15s linear;
}
.ar-horizon-guide::before, .ar-horizon-guide::after {
  content: ""; position: absolute; top: -4px; width: 1px; height: 9px; background: var(--hud-line);
}
.ar-horizon-guide::before { left: 50%; } .ar-horizon-guide::after { left: 50%; display: none; }

/* ---------- marker field ---------- */
.ar-marker-field { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.ar-marker {
  position: absolute; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; background: none; border: 0; padding: 0;
  transition: left 0.12s linear, top 0.12s linear, transform 0.25s var(--nv-ease), opacity 0.16s var(--nv-ease);
}
.ar-marker-label {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 8px 6px; border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line);
  min-width: 54px; max-width: 120px;
}
.ar-vessel-glyph { width: 14px; height: 14px; position: relative; margin-bottom: 1px; }
.ar-vessel-glyph i { position: absolute; inset: 0; display: block; box-shadow: none; }
.ar-marker--triangle .ar-vessel-glyph i { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 14px solid var(--glyph-color, var(--nv-accent)); background: transparent; box-shadow: none; }
.ar-marker--circle .ar-vessel-glyph i { border-radius: 50%; border: 2px solid var(--hud-ink); background: var(--glyph-color, var(--nv-accent)); }
.ar-marker--square .ar-vessel-glyph i { border-radius: var(--nv-r); border: 2px solid var(--hud-ink); background: var(--glyph-color, var(--nv-accent)); }
.ar-marker--diamond .ar-vessel-glyph i { border-radius: var(--nv-r); border: 2px solid var(--hud-ink); background: var(--glyph-color, var(--nv-accent)); transform: rotate(45deg); }
.ar-marker--dot .ar-vessel-glyph i { border-radius: 50%; border: 2px solid var(--hud-ink); background: var(--glyph-color, var(--nv-accent)); inset: 2px; }
.ar-marker--stopped { --glyph-color: var(--hud-muted); }
.ar-marker--slow { --glyph-color: var(--nv-warn); }
.ar-marker--fast { --glyph-color: var(--nv-ok); }
.ar-marker-name { font-size: 12px; font-weight: 700; line-height: 1.2; color: var(--hud-ink); max-width: 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-marker-distance { padding: 2px 5px; border-radius: var(--nv-r); color: var(--nv-accent-ink); background: var(--nv-accent); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.ar-marker--stale .ar-marker-label { opacity: 0.62; }
.ar-marker--selected .ar-marker-label { outline: 2px solid var(--nv-accent); background: var(--hud-surface); }
.ar-marker--closest .ar-marker-label::before {
  content: "Closest"; position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 700; letter-spacing: 0.02em; color: var(--nv-accent-ink);
  background: var(--nv-accent); padding: 1px 6px; border-radius: var(--nv-r); white-space: nowrap;
}
.ar-marker--label-hidden .ar-marker-name, .ar-marker--label-hidden .ar-marker-distance { display: none; }
.ar-marker--label-hidden .ar-marker-label { padding: 6px; min-width: 26px; }
.ar-marker-trajectory { position: absolute; top: 50%; left: 50%; width: 2px; transform-origin: top center; background: linear-gradient(to bottom, var(--glyph-color, var(--nv-accent)), transparent); opacity: 0.55; pointer-events: none; z-index: 9; }

/* ---------- edge indicators ---------- */
.ar-edge-indicator {
  position: absolute; top: 50%; width: 60px; height: 52px; margin-top: -26px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: var(--nv-r); background: var(--hud-surface); border: 1px solid var(--hud-line);
  color: var(--hud-ink); pointer-events: auto; z-index: 20;
}
.ar-edge-indicator--left { left: 12px; }
.ar-edge-indicator--right { right: 12px; }
.ar-edge-indicator .ar-edge-chevron { font-size: 14px; line-height: 1; color: var(--hud-muted); }
.ar-edge-indicator .ar-edge-distance { color: var(--nv-accent); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ar-edge-overflow {
  position: absolute; top: 50%; width: 36px; height: 36px; margin-top: -18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--hud-surface); border: 1px solid var(--hud-line);
  color: var(--hud-ink); font-size: 11px; font-weight: 700; z-index: 20;
}
.ar-edge-overflow--left { left: 20px; } .ar-edge-overflow--right { right: 20px; }

/* ---------- radar ---------- */
.ar-radar {
  position: absolute; top: 64px; right: 12px; width: 104px; height: 104px; border-radius: 50%;
  background: var(--hud-surface); border: 1px solid var(--hud-line); z-index: 25;
  display: none;
}
.ar-view--radar-on .ar-radar { display: block; }
.ar-radar-ring { position: absolute; border: 1px solid var(--hud-line); border-radius: 50%; }
.ar-radar-facing-wedge {
  position: absolute; top: 50%; left: 50%; width: 0; height: 0;
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 34px solid var(--hud-line);
  transform-origin: bottom center; margin: -34px 0 0 -9px;
}
.ar-radar-vessel { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--glyph-color, var(--nv-accent)); margin: -2.5px 0 0 -2.5px; }
.ar-radar-toggle {
  position: absolute; height: 40px; min-width: 40px; padding: 0 12px; border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; z-index: 26; pointer-events: auto;
}

/* ---------- insight stack ---------- */
.ar-insight-stack { position: absolute; left: 12px; bottom: 148px; display: flex; flex-direction: column; gap: 8px; z-index: 22; max-width: 62vw; }
.ar-insight-card {
  display: flex; align-items: center; gap: 8px; min-height: 48px; height: auto; padding: 7px 12px; border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink);
  pointer-events: auto; text-align: left;
}
.ar-insight-card strong { display: block; font-size: 13px; font-weight: 700; line-height: 1.2; max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-insight-card span { display: block; font-size: 12px; font-weight: 700; color: var(--nv-accent); text-transform: none; }

/* ---------- filter bar ---------- */
.ar-filter-bar {
  position: absolute; left: 0; right: 0; bottom: 92px; z-index: 22;
  display: flex; gap: 8px; padding: 0 12px; overflow-x: auto; scroll-snap-type: x proximity;
  -ms-overflow-style: none; scrollbar-width: none;
}
.ar-filter-bar::-webkit-scrollbar { display: none; }
.ar-filter-chip {
  flex: 0 0 auto; scroll-snap-align: start; min-height: 40px; padding: 0 16px; border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink);
  font-size: 14px; font-weight: 600;
}
.ar-filter-chip--active { background: var(--nv-accent); border-color: var(--nv-accent); color: var(--nv-accent-ink); }

/* ---------- bottom controls ---------- */
.ar-bottom-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 22;
  display: flex; align-items: center; gap: 8px; overflow-x: auto;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  -ms-overflow-style: none; scrollbar-width: none;
}
.ar-bottom-controls::-webkit-scrollbar { display: none; }
.ar-control-button {
  height: 44px; flex: 0 0 auto; padding: 0 16px; border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink);
  font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px;
}

/* ---------- state panels (intro / permission / unsupported / loading / empty / calibration / error) ---------- */
.ar-state-panel { position: absolute; inset: 0; z-index: 40; display: none; overflow-y: auto; }
.ar-view--intro .ar-intro,
.ar-view--requesting .ar-intro,
.ar-view--denied .ar-permission-state,
.ar-view--unsupported .ar-unsupported-state,
.ar-view--data-error .ar-data-error { display: flex; }

.ar-intro, .ar-permission-state, .ar-unsupported-state, .ar-data-error {
  min-height: 100%; flex-direction: column; justify-content: center; gap: var(--ar-space-6);
  padding: max(env(safe-area-inset-top), 24px) 24px max(env(safe-area-inset-bottom), 24px);
  background: var(--hud-bg);
}
.ar-eyebrow { font-size: 13px; font-weight: 700; color: var(--nv-accent); }
.ar-state-panel h1 { margin: 0; font-size: 30px; line-height: 34px; font-weight: 700; color: var(--hud-ink); max-width: 22ch; }
.ar-state-panel h2 { margin: 0; font-size: 22px; line-height: 27px; font-weight: 700; color: var(--hud-ink); }
.ar-state-panel p { margin: 0; font-size: 16px; line-height: 23px; color: var(--hud-muted); max-width: 40ch; }
.ar-requirement-list { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 0; padding: 0; list-style: none; }
.ar-requirement-list li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--hud-muted); }
.ar-requirement-list i { width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--nv-r); background: var(--hud-line); display: flex; align-items: center; justify-content: center; color: var(--nv-accent); font-size: 15px; }
.ar-requirement-list b { color: var(--hud-ink); }
.ar-primary-cta {
  display: inline-flex; align-items: center; justify-content: center; width: fit-content; min-height: 52px; padding: 0 24px;
  border: 0; border-radius: var(--nv-r); background: var(--nv-accent); color: var(--nv-accent-ink);
  font-size: 16px; font-weight: 700; text-decoration: none; white-space: nowrap; align-self: flex-start;
}
.ar-primary-cta:active { transform: translateY(1px) scale(0.97); }
.ar-primary-cta[disabled] { opacity: 0.6; }
.ar-enable-cta {
  position: relative;
  min-width: min(100%, 244px);
  overflow: hidden;
}
.ar-enable-cta-label { position: relative; z-index: 1; }
.ar-enable-progress {
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  overflow: hidden;
  background: var(--hud-surface);
}
.ar-enable-progress-bar {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--nv-ink);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 180ms var(--nv-ease);
}
.ar-secondary-link { font-size: 14px; font-weight: 600; color: var(--nv-accent); text-decoration: underline; align-self: flex-start; background: none; border: 0; padding: 0; }
.ar-fine-print { font-size: 12px; line-height: 16px; color: var(--hud-muted); max-width: 40ch; }
.ar-error-notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--nv-r);
  color: var(--hud-ink);
  background: var(--hud-line);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  max-width: 40ch;
}
.ar-debug-badge {
  position: fixed; left: 0; bottom: 0; z-index: 95; pointer-events: none;
  margin: 0; padding: 3px 8px max(env(safe-area-inset-bottom), 3px) 8px;
  font-size: 10px; line-height: 14px; font-family: var(--nv-mono);
  color: var(--hud-line); background: rgb(0 0 0 / 0.55); max-width: 100vw;
  overflow-wrap: break-word; white-space: pre-line;
}
.ar-debug-badge:empty { display: none; }
.ar-permission-actions, .ar-error-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- calibration prompt ---------- */
.ar-calibration-prompt {
  position: absolute; left: 16px; right: 16px; bottom: 96px; z-index: 45; display: none;
  padding: var(--ar-space-5); border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink);
}
.ar-view--calibrating .ar-calibration-prompt { display: block; }
.ar-calibration-glyph { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--nv-accent); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; font-size: 16px; }
.ar-calibration-prompt h2 { font-size: 18px; margin: 0 0 6px; }
.ar-calibration-prompt p { font-size: 14px; line-height: 20px; color: var(--hud-muted); margin: 0 0 14px; max-width: 44ch; }
.ar-calibration-actions { display: flex; gap: 12px; }
.ar-calibration-actions button { height: 40px; padding: 0 16px; border-radius: var(--nv-r); font-size: 13px; font-weight: 700; border: 1px solid var(--hud-line); background: transparent; color: var(--hud-ink); }
.ar-calibration-actions button:first-child { background: var(--nv-accent); color: var(--nv-accent-ink); border-color: transparent; }

/* ---------- loading + empty states (float over live camera) ---------- */
.ar-loading-state, .ar-empty-state {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 15;
  width: min(260px, 72vw); padding: var(--ar-space-5); border-radius: var(--nv-r);
  background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink); text-align: center;
  display: none;
}
.ar-view--loading-data .ar-loading-state { display: block; }
.ar-view--empty .ar-empty-state { display: block; }
.ar-loading-state strong, .ar-empty-state strong { display: block; font-size: 16px; margin-bottom: 6px; }
.ar-empty-state p { margin: 0; font-size: 13px; line-height: 18px; color: var(--hud-muted); }
.ar-loading-skeleton { height: 8px; border-radius: var(--nv-r); margin: 8px auto 0; background: var(--hud-surface); }
.ar-loading-skeleton:nth-child(1) { width: 70%; }
.ar-loading-skeleton:nth-child(2) { width: 92%; }
.ar-loading-skeleton:nth-child(3) { width: 55%; }

/* ---------- vessel detail sheet ---------- */
.ar-sheet-scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 2049; opacity: 0; pointer-events: none; transition: opacity 0.16s var(--nv-ease); }
.ar-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2050;
  max-height: 62dvh; overflow-y: auto; border-radius: var(--nv-r);
  background: var(--nv-raised); color: var(--nv-ink);
  padding: 8px 20px max(20px, env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.22s var(--nv-ease);
}
.ar-sheet-scrim.is-open { opacity: 1; pointer-events: auto; }
.ar-sheet.is-open { transform: translateY(0); }
.ar-sheet-handle { width: 36px; height: 4px; border-radius: var(--nv-r); background: var(--nv-line); margin: 8px auto 12px; }
.ar-sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ar-sheet-title { display: flex; align-items: center; gap: 10px; }
.ar-sheet-title h2 { margin: 0; font-size: 22px; line-height: 27px; font-weight: 700; }
.ar-sheet-subtitle { margin: 2px 0 0; font-size: 13px; color: var(--nv-muted); font-weight: 600; }
.ar-sheet-close { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--nv-line); background: var(--nv-raised); color: var(--nv-ink); font-size: 16px; flex-shrink: 0; }
.ar-sheet-readout { font-size: 18px; font-weight: 700; color: var(--nv-ink); margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.ar-sheet-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0 0 14px; padding: 0; }
.ar-sheet-facts dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--nv-muted); margin: 0; }
.ar-sheet-facts dd { font-size: 14px; font-weight: 600; color: var(--nv-ink); margin: 2px 0 0; }
.ar-sheet-section-label { font-size: 12px; font-weight: 700; color: var(--nv-muted); margin: 14px 0 6px; }
.ar-sheet-movements { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.ar-sheet-movements li { font-size: 13px; line-height: 18px; color: var(--nv-ink); border-bottom: 1px solid var(--nv-line); padding-bottom: 6px; }
.ar-sheet-movements li span { display: block; color: var(--nv-muted); font-size: 11px; }
.ar-sheet-record-link {
  display: block; width: 100%; height: 48px; border-radius: var(--nv-r); border: 1px solid var(--nv-ink);
  background: transparent; color: var(--nv-ink); font-size: 14px; font-weight: 700; text-align: center; line-height: 46px; text-decoration: none;
}
.ar-sheet-align-button {
  display: block; width: 100%; height: 44px; margin: 0 0 10px; border-radius: var(--nv-r);
  border: 1px dashed var(--nv-line); background: transparent; color: var(--nv-ink);
  font-size: 13px; font-weight: 700; text-align: center;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ar-marker, .ar-sheet, .ar-sheet-scrim, .ar-primary-cta, .ar-calibration-glyph { transition-duration: 0.08s !important; animation: none !important; }
}

/* ---------- landscape ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .ar-horizon-guide { top: 48%; }
  .ar-insight-stack { bottom: 90px; left: 12px; max-width: 46vw; }
  .ar-filter-bar { bottom: 12px; left: 12px; right: auto; max-width: 40vw; flex-wrap: wrap; }
  .ar-bottom-controls { left: auto; right: 12px; bottom: 12px; width: auto; flex-direction: column; align-items: flex-end; }
  .ar-sheet { top: 0; bottom: 0; left: auto; right: 0; width: min(420px, 42vw); max-height: none; border-radius: var(--nv-r); transform: translateX(100%); }
  .ar-sheet.is-open { transform: translateX(0); }
}

@media (min-width: 720px) {
  .ar-intro, .ar-permission-state, .ar-data-error { max-width: 480px; margin: 0 auto; }
  .ar-unsupported-state {
    max-width: none;
    margin: 0;
    padding-inline: clamp(48px, 18vw, 280px);
    background: var(--hud-bg);
  }
}

/* Compact instrumentation, not a second navigation header. */
.ar-view { color: var(--hud-ink); line-height: 1.4; }
.ar-topbar { justify-content: space-between; }
.ar-heading-readout, .ar-marker-distance { font-family: var(--nv-mono); }
.ar-heading-readout[data-confidence="ready"] .ar-confidence-dot { background: var(--nv-ok); }
.ar-state-panel { padding-bottom: 48px; }
.ar-state-panel h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.12; letter-spacing: -.04em; }
.ar-state-panel .ar-primary-cta { background: var(--nv-accent); color: var(--nv-accent-ink); max-width: 100%; white-space: normal; text-align: center; }
.ar-primary-cta, .ar-control-button, .ar-filter-chip, .ar-calibration-actions button, .ar-sheet button, .ar-sheet a { transition: background 180ms var(--nv-ease), transform 180ms var(--nv-ease); }
.ar-primary-cta:hover { filter: brightness(1.08); }
.ar-control-button:hover, .ar-filter-chip:hover { background: var(--hud-bg); }
.ar-control-button:active, .ar-filter-chip:active, .ar-sheet button:active { transform: scale(.97); }
.ar-sheet { border: 1px solid var(--nv-line); }
.ar-sheet-title { min-width: 0; }
.ar-sheet-title h2, .ar-sheet-facts dd { overflow-wrap: anywhere; }
.ar-sheet-record-link, .ar-sheet-align-button { color: var(--nv-ink); border-color: var(--nv-line); }
.ar-calibration-actions { flex-wrap: wrap; }
.ar-calibration-actions button { min-height: 44px; height: auto; }
.ar-bottom-controls { bottom: 28px; }
.ar-filter-bar { bottom: 112px; }
.ar-insight-stack { bottom: 168px; }
.ar-filter-chip { min-height: 44px; }
.ar-attribution { position: absolute; z-index: 46; bottom: 0; left: 0; right: 0; padding: 6px 12px; color: var(--hud-muted); background: var(--hud-bg); border-top: 1px solid var(--hud-line); font-size: 11px; }
.ar-attribution summary { cursor: pointer; min-height: 20px; }
.ar-attribution p { margin: 8px 0; max-width: 80ch; line-height: 1.5; }
.ar-attribution a { color: var(--hud-ink); text-decoration: underline; }
.ar-noscript { position: fixed; inset: var(--nv-bar-h) 0 0; z-index: 100; padding: 2rem; color: var(--nv-ink); background: var(--nv-bg); }
.ar-noscript a { color: inherit; text-decoration: underline; }
@media (max-height: 740px) { .ar-state-panel { gap: 16px; justify-content: flex-start; } }
@media (prefers-reduced-motion: reduce) { .ar-view *, .ar-view *::before, .ar-view *::after { transition-duration: .01ms !important; animation: none !important; } }

/* QR hand-off: only for devices with a mouse, i.e. desktop. */
.ar-qr { display: none; align-items: center; gap: 16px; }
.ar-qr-svg { width: 148px; height: 148px; flex: none; border-radius: var(--nv-r, 6px); background: #fff; }
.ar-state-panel .ar-qr-caption { max-width: 28ch; font-size: 14px; line-height: 20px; }
@media (hover: hover) and (pointer: fine) { .ar-qr { display: flex; } }

/* Camera HUD keeps permissions, freshness and actions legible at every width. */
.sea-spot { --nv-accent:#e9b83a; --nv-r:6px; overflow-x:hidden; }
.ar-view * { box-sizing:border-box; }
.ar-state-panel { width:100%; min-width:0; }
.ar-requirement-list svg,.ar-sheet-close svg,.ar-exit-button svg { width:22px; height:22px; }
.ar-calibration-glyph svg { width:36px; height:36px; }
.ar-step-status { display:block; margin-top:3px; color:var(--nv-accent); font-size:12px; }
.ar-permission-steps { font-size:13px; line-height:1.8; color:var(--hud-muted); }
.ar-accuracy-hint { position:absolute; z-index:29; top:84px; left:12px; right:12px; margin:0 auto; max-width:360px; padding:7px 10px; background:var(--hud-surface); border:1px solid var(--hud-line); border-radius:var(--nv-r); font-size:12px; text-align:center; color:var(--hud-muted); pointer-events:none; }
.ar-freshness { max-width:calc(100% - 24px); white-space:normal; text-align:center; }
.ar-freshness[data-stale=true] { color:var(--nv-accent); border:1px solid var(--nv-accent); }
.ar-locate { display:none; position:absolute; z-index:2051; right:12px; bottom:164px; min-height:44px; max-width:160px; }
.ar-view--live .ar-locate,.ar-view--empty .ar-locate,.ar-view--calibrating .ar-locate { display:flex; }
.ar-sheet { background:var(--hud-bg); color:var(--hud-ink); border-color:var(--hud-line); }
.ar-sheet h2,.ar-sheet-facts dd,.ar-sheet-close,.ar-sheet-record-link,.ar-sheet-align-button { color:var(--hud-ink); }
.ar-sheet-close,.ar-sheet-align-button { background:var(--hud-surface); border-color:var(--hud-line); }
.ar-sheet-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin:12px 0; }
.ar-sheet-actions button { min-height:44px; background:var(--hud-surface); border:1px solid var(--hud-line); border-radius:var(--nv-r); color:var(--hud-ink); font:inherit; }
.ar-sheet-actions button[aria-pressed=true] { background:var(--nv-accent); color:var(--nv-accent-ink); }
.ar-detail-skeleton { height:64px; margin:12px 0; background:var(--hud-line); border-radius:var(--nv-r); }
.ar-exit-button,.ar-sheet-close { min-width:44px; min-height:44px; display:grid; place-items:center; }
.ar-control-button { flex-shrink:1; height:auto; min-height:44px; white-space:normal; }
.ar-qr { flex-wrap:wrap; max-width:100%; }
.ar-qr-svg { max-width:100%; }
.ar-attribution summary { min-height:44px; display:flex; align-items:center; }
.ar-bottom-controls { bottom:64px; }
.ar-filter-bar { bottom:120px; }
.ar-insight-stack { bottom:224px; }
.ar-marker { min-width:44px; min-height:44px; }
.ar-sheet a { min-height:44px; display:flex; align-items:center; }
.ar-sheet button:focus-visible,.ar-view a:focus-visible,.ar-view button:focus-visible { outline:2px solid var(--nv-accent); outline-offset:3px; }
@media(min-width:720px) and (orientation:landscape) { .ar-locate { bottom:220px; } .ar-bottom-controls { bottom:64px; } }
@media(max-width:540px) { .ar-bottom-controls { gap:5px; } .ar-control-button { padding:8px; font-size:12px; } .ar-state-panel { padding-inline:20px; } .ar-qr-svg { width:128px; height:128px; } }
.ar-sheet-readout,.ar-sheet-movements li { color:var(--hud-ink); }
.ar-sheet-subtitle,.ar-sheet-facts dt,.ar-sheet-section-label,.ar-sheet-movements li span { color:var(--hud-muted); }
.ar-sheet-close { border-radius:var(--nv-r); }
.ar-sheet-record-link { justify-content:center; line-height:1.4; height:auto; padding:10px; border-color:var(--hud-line); }
.ar-sheet-align-button { height:auto; min-height:44px; padding:10px; line-height:1.4; }
.ar-sheet-movements li { position:relative; padding:0 0 12px 16px; margin-left:4px; border-bottom:0; border-left:1px solid var(--hud-line); }
.ar-sheet-movements li::before { content:""; position:absolute; top:5px; left:-4px; width:7px; height:7px; border-radius:50%; background:var(--nv-accent); }
.ar-state-panel .ar-eyebrow { color:var(--nv-accent); }
.ar-unsupported-state { align-items:flex-start; }
.ar-state-panel .ar-qr { padding-top:16px; border-top:1px solid var(--hud-line); }
.ar-state-panel .ar-qr-caption { color:var(--hud-muted); }
@media(min-width:720px) { .ar-unsupported-state { padding-inline:max(24px,calc((100vw - 640px) / 2)); } }
.ar-about { max-width: 40ch; font-size: 14px; line-height: 20px; color: var(--hud-muted); }
.ar-about summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--nv-accent); text-decoration: underline; }
.ar-about p, .ar-state-panel .ar-about p { margin: 0 0 8px; font-size: 14px; line-height: 20px; }
.ar-about h3 { margin: 12px 0 2px; font-size: 14px; line-height: 20px; color: var(--hud-ink); }

/* Owner B pass: the camera tool is dark, so the shared bar uses a page-scoped dark set of the same tokens (AA: #f2f3f5 and #b4bac4 on #0e0f11). */
.nv-bar { --nv-bg: #0e0f11; --nv-surface: #1b1d20; --nv-raised: #1b1d20; --nv-ink: #f2f3f5; --nv-muted: #b4bac4; --nv-line: rgba(255, 255, 255, .18); color-scheme: dark; }
.ar-step-status { color: var(--hud-muted); }
.ar-attribution { color: #b4bac4; font-size: 12px; }
.ar-state-panel .ar-h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.12; letter-spacing: -.04em; font-weight: 700; color: var(--hud-ink); max-width: 22ch; }

/* ---------- Sea Spot: calmer HUD, label rows, reticle, list, calibration, snapshot ---------- */
[hidden] { display: none !important; }

/* Intro explainer */
.ar-howto { margin: 0; padding-left: 20px; display: grid; gap: 6px; max-width: 40ch; color: var(--hud-muted); font-size: 14px; line-height: 20px; }
.ar-state-panel .ar-secondary-link { min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; }

/* Top bar: heading on the left, snapshot and exit on the right */
.ar-topbar-actions { display: flex; align-items: center; gap: 8px; }
.ar-icon-button { width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--hud-surface); border: 1px solid var(--hud-line); color: var(--hud-ink); }
.ar-icon-button svg { width: 22px; height: 22px; }
#arSnapButton, .ar-icon-button.ar-locate { display: none; }
.ar-view--live #arSnapButton, .ar-view--empty #arSnapButton { display: grid; }
.ar-view--live .ar-icon-button.ar-locate, .ar-view--empty .ar-icon-button.ar-locate, .ar-view--calibrating .ar-icon-button.ar-locate { display: grid; }
.ar-intro { justify-content: flex-start; }
.ar-locate { width: 44px; max-width: none; padding: 0; justify-content: center; right: 12px; bottom: calc(168px + env(safe-area-inset-bottom)); }
.ar-view--listonly .ar-topbar, .ar-view--listonly .ar-freshness, .ar-view--listonly .ar-accuracy-hint { display: none; }

/* Quieter status text: one muted line, accuracy hint only when it matters */
.ar-freshness { top: 58px; padding: 3px 10px; font-weight: 500; background: rgb(22 24 27 / .78); }
.ar-freshness[data-stale=true] { font-weight: 700; }
.ar-accuracy-hint { top: 84px; }

/* Bottom controls and attribution bar: compact, state shown by border */
.ar-attribution { padding: 0 12px env(safe-area-inset-bottom); font-size: 12px; }
.ar-attribution summary { min-height: 32px; position: relative; }
.ar-attribution summary::after { content: ""; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; }
.ar-bottom-controls { bottom: calc(36px + env(safe-area-inset-bottom)); padding-bottom: 8px; }
.ar-filter-bar { bottom: calc(100px + env(safe-area-inset-bottom)); }
.ar-insight-stack { bottom: calc(112px + env(safe-area-inset-bottom)); }
.ar-control-button[aria-pressed="true"], .ar-control-button[aria-expanded="true"] { border-color: var(--nv-accent); color: var(--nv-accent); }

/* Radar dial: on by default, small, never blocks taps */
.ar-radar { top: 96px; right: 12px; width: 92px; height: 92px; pointer-events: none; }
.ar-radar-n { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font-size: 11px; line-height: 1; font-weight: 700; color: var(--hud-muted); }
.ar-radar-vessel--far { opacity: .5; }
.ar-radar-vessel[hidden] { display: none; }

/* Markers: positioned by transform from JS; labels lifted into rows, sized by distance */
.ar-horizon-guide::before { display: none; }
.ar-marker { left: 0; top: 0; transition: opacity .16s var(--nv-ease); will-change: transform; }
.ar-marker-label { gap: 2px; padding: 4px 8px 5px; min-width: 54px; max-width: 132px; flex: none; transform: scale(var(--ls, 1)); transform-origin: 50% 50%; }
.ar-marker-head { display: flex; align-items: center; gap: 5px; max-width: 100%; min-width: 0; }
.ar-marker-head .ar-vessel-glyph { margin: 0; flex: none; }
.ar-marker-name { font-size: 13px; line-height: 16px; max-width: 104px; }
.ar-marker-distance { font-size: 12px; line-height: 14px; padding: 1px 5px; }
.ar-marker::after { content: ""; position: absolute; left: 50%; top: calc(50% + 22px * var(--ls, 1)); width: 1px; height: calc(var(--stem, 0) * 1px); background: var(--hud-ink); opacity: .55; pointer-events: none; }
.ar-marker--closest .ar-marker-label::before { content: none; }
.ar-marker--closest .ar-marker-label { border-color: var(--hud-ink); }
.ar-marker--aimed .ar-marker-label { border-color: var(--nv-accent); }
.ar-marker--cal .ar-marker-label { outline: 2px dashed var(--nv-accent); outline-offset: 2px; }
.ar-marker--label-hidden::after { display: none; }
.ar-marker-trajectory { background: var(--glyph-color, var(--nv-accent)); }

/* Centre reticle and the ship it names */
.ar-reticle { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 1px solid var(--hud-ink); border-radius: 50%; opacity: .7; pointer-events: none; z-index: 6; }
.ar-reticle[data-locked="true"] { border-color: var(--nv-accent); opacity: 1; }
.ar-aimed { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); max-width: 46vw; min-height: 44px; padding: 0 14px; border: 1px solid var(--nv-accent); border-radius: var(--nv-r); background: var(--hud-surface); color: var(--hud-ink); font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 26; pointer-events: auto; }

/* Smart empty state */
.ar-empty-state { width: min(300px, 82vw); }
.ar-empty-state p + p { margin-top: 8px; }
.ar-empty-viewpoint a { color: var(--nv-accent); text-decoration: underline; display: inline-flex; align-items: center; min-height: 44px; }
.ar-empty-list { min-height: 44px; margin-top: 8px; padding: 0 16px; border: 1px solid var(--hud-line); border-radius: var(--nv-r); background: var(--hud-bg); color: var(--hud-ink); font-weight: 700; }

/* Two-ship calibration overlay */
.ar-fovcal { position: absolute; inset: 0; z-index: 55; }
.ar-fovcal-pad { position: absolute; inset: 0; z-index: 1; cursor: crosshair; touch-action: none; }
.ar-fovcal-card { position: absolute; z-index: 2; bottom: calc(100px + env(safe-area-inset-bottom)); left: 12px; right: 12px; display: grid; gap: 8px; padding: 12px; border: 1px solid var(--nv-accent); border-radius: var(--nv-r); background: var(--hud-surface); color: var(--hud-ink); }
.ar-fovcal-card p { margin: 0; font-size: 14px; line-height: 20px; }
.ar-fovcal-step { font-weight: 700; }
.ar-fovcal-hint { color: var(--hud-muted); }
.ar-fovcal-card button { min-height: 44px; justify-self: start; padding: 0 16px; border: 1px solid var(--hud-line); border-radius: var(--nv-r); background: transparent; color: var(--hud-ink); font-weight: 700; }

/* Detail sheet additions */
.ar-sheet-map-link { justify-content: center; margin: 0 0 12px; border: 1px solid var(--hud-line); border-radius: var(--nv-r); color: var(--hud-ink); font-size: 14px; font-weight: 700; text-decoration: none; }
.ar-list-note { margin: 8px 0; font-size: 12px; line-height: 18px; color: var(--hud-muted); }
.ar-sheet .ar-list-note { margin-top: 0; }

/* Ships near me sheet (bottom sheet over the camera, full panel when there is no camera) */
.ar-list-scrim { position: absolute; inset: 0; z-index: 2039; background: rgb(0 0 0 / .45); opacity: 0; pointer-events: none; transition: opacity .16s var(--nv-ease); }
.ar-list-scrim.is-open { opacity: 1; pointer-events: auto; }
.ar-list-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2040; max-height: 78%; overflow-y: auto;
  padding: 8px 16px max(16px, env(safe-area-inset-bottom)); background: var(--hud-bg); color: var(--hud-ink);
  border: 1px solid var(--hud-line); border-radius: var(--nv-r);
  transform: translateY(100%); visibility: hidden; transition: transform .22s var(--nv-ease), visibility 0s linear .22s;
}
.ar-list-sheet.is-open { transform: translateY(0); visibility: visible; transition: transform .22s var(--nv-ease); }
.ar-list-sheet h2 { margin: 0; font-size: 22px; line-height: 27px; font-weight: 700; color: var(--hud-ink); }
.ar-list-sheet .ar-sheet-header > div:first-child { min-width: 0; }
.ar-list-sheet .ar-sheet-subtitle { color: var(--hud-muted); }
.ar-list-sheet .ar-sheet-close { background: var(--hud-surface); border-color: var(--hud-line); color: var(--hud-ink); }
.ar-view--listonly .ar-list-sheet { top: 0; bottom: calc(32px + env(safe-area-inset-bottom)); max-height: none; border-width: 0 0 1px; border-radius: 0; padding-top: max(8px, env(safe-area-inset-top)); }
.ar-view--listonly .ar-attribution { z-index: 2041; }
.ar-tabs { display: flex; gap: 8px; margin: 0 0 8px; }
.ar-tabs button { flex: 1; min-height: 44px; border: 1px solid var(--hud-line); border-radius: var(--nv-r); background: var(--hud-surface); color: var(--hud-ink); font-size: 14px; font-weight: 700; }
.ar-tabs button[aria-selected="true"] { background: var(--nv-accent); border-color: var(--nv-accent); color: var(--nv-accent-ink); }
.ar-list { list-style: none; margin: 0; padding: 0; }
.ar-list-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 6px 4px; border: 0; border-bottom: 1px solid var(--hud-line); background: transparent; color: var(--hud-ink); text-align: left; }
.ar-list-arrow { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--hud-line); border-radius: 50%; color: var(--nv-accent); transition: transform .15s linear; }
.ar-list-arrow svg { width: 20px; height: 20px; }
.ar-list-main { flex: 1; min-width: 0; display: grid; }
.ar-list-main strong { font-size: 15px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-list small { font-size: 12px; line-height: 16px; color: var(--hud-muted); }
.ar-list-dist { flex: none; display: grid; text-align: right; font-family: var(--nv-mono); font-size: 14px; font-weight: 700; }
.ar-spotted-row { display: grid; padding: 10px 4px; border-bottom: 1px solid var(--hud-line); }
.ar-spotted-row strong { font-size: 15px; }
.ar-list-empty { padding: 12px 4px; font-size: 14px; color: var(--hud-muted); }
.ar-list-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 4px 0 8px; }
.ar-list-actions .ar-primary-cta { min-height: 44px; padding: 0 16px; font-size: 14px; }
.ar-switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; font-weight: 600; }
.ar-switch input { width: 24px; height: 24px; accent-color: var(--nv-accent); }

/* Snapshot preview (the image is composed on this device) */
.ar-snap-scrim { position: fixed; inset: 0; z-index: 2059; background: rgb(0 0 0 / .6); opacity: 0; pointer-events: none; transition: opacity .16s var(--nv-ease); }
.ar-snap-scrim.is-open { opacity: 1; pointer-events: auto; }
.ar-snap { position: fixed; z-index: 2060; left: 12px; right: 12px; top: 50%; max-width: 420px; max-height: calc(100dvh - 24px); overflow-y: auto; margin: 0 auto; transform: translateY(-50%); display: none; gap: 12px; padding: 16px; border: 1px solid var(--hud-line); border-radius: var(--nv-r); background: var(--hud-bg); color: var(--hud-ink); }
.ar-snap.is-open { display: grid; }
.ar-snap h2 { margin: 0; font-size: 20px; line-height: 26px; color: var(--hud-ink); }
.ar-snap .ar-list-note { margin: 0; font-size: 13px; }
.ar-snap-img { width: 100%; max-height: 50dvh; object-fit: contain; border: 1px solid var(--hud-line); border-radius: var(--nv-r); background: #000; }
.ar-snap .ar-sheet-actions { margin: 0; }

@media (orientation: landscape) and (max-height: 500px) {
  .ar-bottom-controls { bottom: 36px; }
  .ar-filter-bar { bottom: 36px; }
  .ar-insight-stack { bottom: 36px; }
  .ar-locate { bottom: 100px; }
  .ar-radar { top: 64px; }
  .ar-aimed { top: 64px; }
}
.is-list-open .ar-locate { display: none !important; }
