/* ECHO shared design tokens and components (used by both the desktop and phone apps).
   No web fonts: a system font stack keeps the apps fast, offline and private. */

:root {
  --bg: #0b1118;
  --bg-raised: #0f171f;
  --panel: #101821;
  --panel-2: #141e28;
  --panel-3: #19252f;
  --line: rgba(222, 235, 246, 0.09);
  --line-strong: rgba(222, 235, 246, 0.18);
  --text: #edf3f7;
  --text-2: #b4c1cb;
  --muted: #82909e;
  --mint: #9af3c6;
  --mint-ink: #0b2118;
  --mint-dim: #1d3a30;
  --blue: #7cb8ff;
  --water: #4fbded;
  --amber: #f2c27b;
  --danger: #ff8f8f;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 18px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  --sans: Inter, 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI Variable', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'Cascadia Mono', Menlo, Consolas, 'Roboto Mono', monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon { flex: none; display: block; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

.eyebrow, .section-label { font: 500 10px var(--mono); letter-spacing: 1.2px; text-transform: uppercase; color: #81909d; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.05s; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--panel-3); border-color: rgba(222, 235, 246, 0.3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--mint); border-color: #b5f9d8; color: var(--mint-ink); font-weight: 800; }
.btn-primary:hover { background: #b2f7d4; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn-danger { color: var(--danger); border-color: rgba(255, 143, 143, 0.35); background: rgba(255, 143, 143, 0.08); }
.btn-danger:hover { background: rgba(255, 143, 143, 0.16); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }

/* ---------- chips, pills ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.chip[aria-pressed='true'], .chip.active { background: var(--mint-dim); border-color: #3f7a63; color: #d7ffe9; }
.pill { display: inline-block; padding: 3px 8px; border-radius: 6px; border: 1px solid #3b5b4e; background: #172a23; color: #a4d7be; font: 9px var(--mono); letter-spacing: 0.7px; text-transform: uppercase; }
.pill-amber { border-color: #6b5a33; background: #2a2314; color: var(--amber); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px rgba(154, 243, 198, 0.55); }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 10px; border: 1px solid #344751; background: #0d171f; color: var(--text); font-size: 14px; outline: none; }
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: #81c4a4; box-shadow: 0 0 0 3px rgba(154, 243, 198, 0.12); }
.field-error { color: var(--danger); font-size: 12px; min-height: 16px; }
.range { width: 100%; accent-color: var(--mint); }

/* toggle switch: <label class="switch-row"><input type="checkbox"><span class="switch"></span>…</label> */
.switch-row { position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.switch-row > input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch { position: relative; flex: none; width: 36px; height: 20px; border-radius: 20px; background: #35414a; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #9ba7b0; transition: left 0.15s, background 0.15s; }
.switch-row > input:checked ~ .switch { background: #3e8268; }
.switch-row > input:checked ~ .switch::after { left: 19px; background: #d5ffeb; }
.switch-row > input:focus-visible ~ .switch { outline: 2px solid var(--mint); outline-offset: 2px; }
.switch-row .switch { order: 3; margin-left: auto; }

/* ---------- cards, lists ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--panel); }
.evidence-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.evidence-row .badge { flex: none; min-width: 38px; height: 30px; display: grid; place-items: center; padding: 0 6px; border-radius: 8px; background: #243445; color: #b7d5ff; font: 500 10px var(--mono); }
.evidence-row .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.evidence-row strong { font-size: 13px; font-weight: 600; }
.evidence-row small { font-size: 11px; color: var(--muted); line-height: 1.4; }
.evidence-row:hover strong { color: var(--mint); }
.step-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.step-row .num { font: 11px var(--mono); color: #8fe2bd; padding-top: 2px; }
.step-row .body { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.step-row strong { font-size: 13px; font-weight: 600; }
.step-row small { font-size: 12px; color: var(--muted); line-height: 1.5; }
.callout { display: flex; gap: 12px; padding: 14px; border-radius: 12px; border: 1px solid #2b5147; background: linear-gradient(135deg, #142b27, #142029); }
.callout .mark { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #28483d; color: var(--mint); }
.callout strong { font-size: 13px; }
.callout p { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: #a9bcc1; }
.confidence { display: flex; gap: 10px; margin-top: 12px; }
.confidence i { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.confidence .observed { background: var(--mint); } .confidence .inferred { background: var(--amber); } .confidence .unknown { background: #758592; }
.confidence strong { font-size: 12px; } .confidence small { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.note { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.note p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.note footer { display: flex; align-items: center; gap: 8px; font: 10px var(--mono); color: var(--muted); }
.note footer .spacer { flex: 1; }
.terrain-art { display: block; width: 100%; height: 100%; }

/* ---------- chat ---------- */
.msg { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; }
.msg .avatar { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: #28463a; color: var(--mint); }
.msg .bubble { border: 1px solid #2b3d44; background: #16232b; padding: 11px 13px; border-radius: 4px 12px 12px 12px; max-width: 100%; }
.msg .bubble strong { font-size: 12px; }
.msg .bubble p { margin: 6px 0 0; font-size: 13px; line-height: 1.65; color: #b6c5cc; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .links { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.msg .links a { font-size: 12px; color: var(--mint); text-decoration: none; }
.msg .links a:hover { text-decoration: underline; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: #234a3c; border-color: #36634f; border-radius: 12px 4px 12px 12px; color: #dcf6e8; max-width: 88%; }
.msg.user .bubble p { color: inherit; margin: 0; }
.msg.thinking .bubble { opacity: 0.8; }
.mode-note { font-size: 11px; color: var(--muted); line-height: 1.5; }
.mode-note.live { color: #8fd8b3; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; z-index: 9000; max-width: min(520px, calc(100vw - 32px)); padding: 11px 16px; border-radius: 10px; border: 1px solid #3b5a4c; background: #152b23; color: #d3f6e4; font-size: 13px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); transition: opacity 0.22s, transform 0.22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: #6b3b3b; background: #2b1717; color: #ffd0d0; }

/* ---------- map (Leaflet) ---------- */
.leaflet-container { font-family: var(--sans); background: #0e1a20; outline: none; -webkit-tap-highlight-color: transparent; }
/* Only the basemap is toned down. NASA imagery keeps its true colours. */
.echo-basemap { filter: brightness(0.82) saturate(0.82); }
.leaflet-control-attribution { background: rgba(8, 15, 20, 0.7) !important; color: #8d9ba2 !important; font-size: 10px !important; padding: 2px 6px !important; border-radius: 6px 0 0 0; backdrop-filter: blur(6px); }
.leaflet-control-attribution a { color: #c3d2d9 !important; }
.echo-pin-wrap { background: none; border: 0; }
.echo-pin { display: block; width: 10px; height: 10px; margin: 4px; border-radius: 50%; background: #dcebf0; border: 1px solid #14232a; box-shadow: 0 0 0 4px rgba(165, 237, 207, 0.15), 0 0 14px rgba(154, 243, 198, 0.55); }
.echo-pin-primary { background: #b9f8d8; width: 12px; height: 12px; margin: 3px; }
.echo-note-pin { display: block; width: 14px; height: 14px; margin: 3px; border-radius: 4px 4px 4px 0; transform: rotate(-45deg); background: var(--amber); border: 1.5px solid #2a2314; box-shadow: 0 0 12px rgba(242, 194, 123, 0.6); }
.echo-note-draft { border-style: dashed; animation: echo-bob 1.4s ease-in-out infinite; }
@keyframes echo-bob { 50% { transform: rotate(-45deg) scale(1.18); } }
.echo-popup .leaflet-popup-content-wrapper { background: #14212a; color: #eaf2f5; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.echo-popup .leaflet-popup-tip { background: #14212a; }
.echo-popup .leaflet-popup-content { margin: 10px 12px; }
.echo-popup-body { display: flex; flex-direction: column; gap: 4px; font-size: 12px; max-width: 220px; }
.echo-popup-body span { color: #a9bcc4; line-height: 1.45; overflow-wrap: anywhere; }
.echo-popup-body small { color: #8eeac1; font: 10px var(--mono); }
.echo-tooltip { background: #14212a; color: #eaf2f5; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 8px; font-size: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.echo-tooltip::before { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
