/* ─────────────────────────────────────────────────────────────────────────────
   Aeyez — "Lighthouse"
   A camera that narrates what you can't see. The system speaks; the camera
   is the portal. One mint beam against deep ink. Mobile-first.
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  /* Ink palette — warmer than pure black, easier on residual vision */
  --ink:        #0a0e15;
  --ink-2:      #131820;
  --ink-3:      #1c2330;
  --ink-line:   #232b3a;

  /* Paper — warm off-white for text, never pure white */
  --paper:      #f4f1ea;
  --paper-mute: #8b9bb5;
  --paper-dim:  #5e6a82;

  /* The beam — single saturated accent, used sparingly */
  --beam:       #6fffc8;
  --beam-dim:   #4ec9a0;
  --beam-glow:  rgba(111, 255, 200, 0.18);
  --beam-glow-soft: rgba(111, 255, 200, 0.06);

  /* Alerts — only for errors and safe-mode */
  --alert:      #ff6b6b;
  --alert-glow: rgba(255, 107, 107, 0.18);

  /* Geometry */
  --r-sm: 8px;
  --r:    14px;
  --r-lg: 22px;
  --ring: 0 0 0 2px var(--beam);

  /* Typography */
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono:  ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ── Skip link ─────────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: 12px; top: -64px;
  z-index: 1000;
  padding: 12px 18px;
  background: var(--beam);
  color: var(--ink);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: top 140ms ease;
}
.skip-link:focus { top: 12px; outline: none; box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--beam); }

/* ── Splash ────────────────────────────────────────────────────────────────── */
#splash-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at top, #1a2030 0%, var(--ink) 60%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
}
.splash-logo {
  margin: 0;
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(56px, 16vw, 120px);
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: var(--paper);
  animation: splashIn 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.splash-logo::after {
  content: "";
  display: inline-block;
  width: 0.4em; height: 0.08em;
  margin-left: 0.08em;
  background: var(--beam);
  vertical-align: middle;
  animation: beamPulse 1.6s ease-in-out infinite;
}
.splash-sub {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-mute);
  animation: splashIn 600ms 100ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes splashIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes beamPulse {
  0%, 100% { opacity: 1; transform: scaleX(1); }
  50%      { opacity: 0.4; transform: scaleX(0.6); }
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Atmospheric background — subtle beam glow at top, fades down */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, var(--beam-glow-soft), transparent 60%),
    radial-gradient(ellipse 120% 60% at 50% 110%, rgba(28, 35, 48, 0.6), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

main { position: relative; z-index: 1; }

/* ── Layout: mobile-first, single column ───────────────────────────────────── */
#app-view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
#app-view[hidden] { display: none; }

#left-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 18px 0;
}

#right-col {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#right-app, #right-profile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 18px 36px;
}
#right-profile {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 260ms ease, transform 260ms ease;
}

/* ── Header / brand ────────────────────────────────────────────────────────── */
header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
header h1 {
  margin: 0;
  font-family: var(--serif);
  font-variation-settings: "opsz" 96, "SOFT" 30, "WONK" 0;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(38px, 9vw, 56px);
  letter-spacing: -0.035em;
  line-height: 0.92;
  color: var(--paper);
}
header h1::first-letter {
  color: var(--beam);
}
.tagline {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

/* ── Camera viewport — viewfinder portal ───────────────────────────────────── */
#camera-section {
  position: relative;
  height: clamp(280px, 48vh, 520px);
  border-radius: var(--r);
  overflow: hidden;
  background: #000;
  isolation: isolate;
}
#camera-section[hidden] { display: none; }

/* Corner brackets — top-left + bottom-right (asymmetric, viewfinder feel) */
#camera-section::before,
#camera-section::after {
  content: "";
  position: absolute;
  width: 22px; height: 22px;
  border: 2px solid var(--beam);
  z-index: 3;
  pointer-events: none;
  opacity: 0.85;
}
#camera-section::before {
  top: 12px; left: 12px;
  border-right: none; border-bottom: none;
  border-top-left-radius: 2px;
}
#camera-section::after {
  bottom: 12px; right: 12px;
  border-left: none; border-top: none;
  border-bottom-right-radius: 2px;
}

#camera {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

#last-frame {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: min(28vw, 132px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  z-index: 4;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  background: #000;
}
#last-frame[hidden] { display: none; }

/* Subtle vignette over the camera so brackets read against bright scenes */
#camera-section .__vignette,
#camera-section::before, #camera-section::after { filter: drop-shadow(0 0 6px rgba(0,0,0,0.6)); }

/* ── Map section ───────────────────────────────────────────────────────────── */
#map-section {
  height: clamp(280px, 48vh, 520px);
  border-radius: var(--r);
  overflow: hidden;
}
#map-section[hidden] { display: none; }
#map { width: 100%; height: 100%; }

/* ── Tabs (Camera / Map) ───────────────────────────────────────────────────── */
#left-tabs {
  display: flex;
  gap: 4px;
  background: var(--ink-2);
  padding: 4px;
  border-radius: 999px;
  width: fit-content;
}
.left-tab {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--paper-mute);
  padding: 8px 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: color 160ms, background 160ms;
}
.left-tab:hover { color: var(--paper); }
.left-tab.active {
  background: var(--beam);
  color: var(--ink);
}
.left-tab.active:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px var(--beam);
}

footer { display: none; } /* The tagline + footer note are redundant on mobile */

/* ── Status card — the system's voice ──────────────────────────────────────── */
#status-card {
  position: relative;
  background: linear-gradient(180deg, var(--ink-2), var(--ink-3));
  border: 1px solid var(--ink-line);
  border-radius: var(--r);
  padding: 22px 22px 24px;
  /* Glow rises from below — like the camera is illuminating the response */
  box-shadow: 0 -16px 48px -24px var(--beam-glow), 0 24px 48px -24px rgba(0,0,0,0.4);
}
.status-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.status-text {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 500;
  color: var(--paper);
}
.status-text[data-state="listening"]     { color: var(--beam); }
.status-text[data-state="investigating"] { color: var(--beam-dim); }
.status-text[data-state="error"]         { color: var(--alert); }

/* The big response — Fraunces italic, like a literary subtitle */
.response-text {
  margin: 16px 0 0;
  font-family: var(--serif);
  font-variation-settings: "opsz" 36, "SOFT" 60, "WONK" 0;
  font-style: italic;
  font-weight: 350;
  font-size: clamp(20px, 5.4vw, 28px);
  line-height: 1.32;
  letter-spacing: -0.015em;
  color: var(--paper);
  /* Drop cap effect when not empty */
}
.response-text::before {
  content: "";
  display: block;
  width: 28px; height: 2px;
  background: var(--beam);
  margin-bottom: 14px;
  opacity: 0.8;
}
.response-text[hidden] { display: none; }

.summary-text {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--ink-line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  color: var(--paper-mute);
  text-transform: uppercase;
}
.summary-text[hidden] { display: none; }

.latency-chip {
  display: inline-block;
  margin: 14px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--ink);
  border: 1px solid var(--ink-line);
  color: var(--paper-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
button {
  appearance: none;
  border: 1px solid var(--ink-line);
  background: var(--ink-2);
  color: var(--paper);
  padding: 14px 20px;
  border-radius: var(--r-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 140ms, transform 80ms, border-color 140ms;
  min-height: 48px;
}
button:hover:not(:disabled) { background: var(--ink-3); border-color: var(--paper-dim); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button:focus-visible { outline: none; box-shadow: var(--ring); }

button.primary {
  background: var(--beam);
  color: var(--ink);
  border-color: transparent;
  font-weight: 600;
  letter-spacing: -0.005em;
}
button.primary:hover:not(:disabled) { background: #8effd2; }
button.primary[data-state="running"] {
  background: var(--ink-2);
  color: var(--beam);
  border: 1px solid var(--beam);
  box-shadow: inset 0 0 0 1px var(--beam-glow);
}
button.primary[data-state="running"]::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--beam);
  vertical-align: middle;
  animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--beam-glow); }
  50%      { opacity: 0.4; box-shadow: 0 0 0 6px transparent; }
}

button[data-state="safe"] {
  background: var(--alert);
  color: var(--paper);
  border-color: transparent;
  font-weight: 600;
}
button[data-state="safe"]:hover:not(:disabled) { background: #ff8585; }

/* Safe mode: shift the entire UI's beam to red */
body.safe-mode-active {
  --beam: #ff6b6b;
  --beam-dim: #d65555;
  --beam-glow: rgba(255, 107, 107, 0.18);
  --beam-glow-soft: rgba(255, 107, 107, 0.06);
}

/* ── Controls — 2x2 grid on mobile ─────────────────────────────────────────── */
#controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#controls > #auto-btn {
  grid-column: 1 / -1;
  padding: 18px 24px;
  font-size: 15px;
}

/* ── Voice card ────────────────────────────────────────────────────────────── */
#voice-chat-card {
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r);
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#voice-btn {
  width: 100%;
  padding: 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  position: relative;
}
#voice-btn::before {
  content: "◉";
  margin-right: 10px;
  font-size: 12px;
  vertical-align: 1px;
  opacity: 0.6;
}
#voice-btn.recording {
  background: var(--alert);
  color: var(--paper);
  border-color: transparent;
  animation: recordPulse 1.2s ease-in-out infinite;
}
#voice-btn.recording::before {
  content: "●";
  opacity: 1;
  animation: recordDot 0.7s ease-in-out infinite;
}
@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--alert-glow); }
  50%      { box-shadow: 0 0 0 12px transparent; }
}
@keyframes recordDot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}
.transcript-text {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--paper-mute);
  line-height: 1.5;
}

#video-summary-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}
#video-summary-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
#video-upload {
  width: 100%;
  min-width: 0;
  color: var(--paper-mute);
  font: 13px/1.3 var(--sans);
}
#video-upload::file-selector-button {
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-soft);
  color: var(--paper);
  padding: 9px 12px;
  font: 700 12px/1 var(--mono);
  cursor: pointer;
}
#video-summary-output {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-soft);
  color: var(--paper);
  padding: 12px;
  font: 12px/1.5 var(--mono);
}

@media (max-width: 640px) {
  #video-summary-form {
    grid-template-columns: 1fr;
  }
  #video-summary-btn {
    width: 100%;
  }
}

/* ── Section divider (decorative) ──────────────────────────────────────────── */
details > summary {
  position: relative;
  cursor: pointer;
  padding: 14px 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 12px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "";
  width: 18px; height: 1px;
  background: currentColor;
  opacity: 0.4;
}
details > summary::after {
  content: "+";
  margin-left: auto;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 300;
  color: var(--paper-mute);
  transition: transform 200ms ease;
}
details[open] > summary::after { content: "−"; }
details[open] > summary { color: var(--paper); }
details {
  border-top: 1px solid var(--ink-line);
  padding: 0 2px;
}

/* ── History ───────────────────────────────────────────────────────────────── */
#history-filter-bar { padding: 4px 0 12px; }
#history-location-filter {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--paper-mute) 50%),
                    linear-gradient(135deg, var(--paper-mute) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
#history-location-filter:focus { box-shadow: var(--ring); border-color: var(--beam); }

.history-entry {
  padding: 18px 0;
  border-bottom: 1px solid var(--ink-line);
}
.history-entry:last-child { border-bottom: none; }
.history-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.history-thumb {
  flex: 0 0 56px;
  width: 56px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  border: 1px solid var(--ink-line);
}
.history-text { flex: 1; min-width: 0; }
.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.history-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--beam);
}
.history-time {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--paper-dim);
  white-space: nowrap;
}
.history-input {
  margin: 4px 0 6px;
  font-size: 13px;
  color: var(--paper-mute);
  font-style: italic;
}
.history-response {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 350;
  line-height: 1.45;
  color: var(--paper);
}
.history-empty {
  margin: 12px 0;
  color: var(--paper-dim);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Location chip */
.location-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--beam-glow);
  color: var(--beam);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: 2px;
}

/* ── Place suggest banner ──────────────────────────────────────────────────── */
.place-suggest {
  background: linear-gradient(135deg, var(--beam-glow-soft), transparent);
  border: 1px solid var(--beam-dim);
  border-radius: var(--r-sm);
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.place-suggest[hidden] { display: none; }
.place-suggest-text {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  color: var(--paper);
  line-height: 1.4;
}
#place-suggest-count {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-style: normal;
  color: var(--paper-mute);
}
.place-suggest .inline-form { gap: 6px; }
.place-suggest input { flex: 1; }
#place-suggest-dismiss {
  font-size: 12px;
  padding: 8px 12px;
  background: transparent;
  border-color: transparent;
  color: var(--paper-mute);
  min-height: auto;
}

/* ── Calibration panel ─────────────────────────────────────────────────────── */
#calibration-panel { padding-bottom: 14px; }
#calibration-panel .calib-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
#calibration-panel label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper-mute);
  flex: 0 0 auto;
}
#calibration-panel input[type="range"] {
  flex: 1;
  accent-color: var(--beam);
  height: 4px;
}
.calib-readout {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
  color: var(--paper);
}
.calib-meta {
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}
.calib-hint { font-size: 9px; opacity: 0.7; }
#last-diff[data-state="above"] { color: var(--beam); }
#last-diff[data-state="below"] { color: var(--paper-dim); }

/* ── Corner user menu ──────────────────────────────────────────────────────── */
#user-menu-wrap {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 50;
}
#user-menu-wrap[hidden] { display: none; }

.corner-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 160ms, box-shadow 160ms;
  backdrop-filter: blur(8px);
}
.corner-btn:hover { border-color: var(--beam); }
.corner-btn:focus-visible { outline: none; box-shadow: var(--ring); }

#corner-avatar {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  font-weight: 500;
  color: var(--beam);
  line-height: 1;
  user-select: none;
}

#user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-sm);
  padding: 6px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s 180ms;
  pointer-events: none;
}
#user-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s 0s;
  pointer-events: auto;
}
.dropdown-name {
  margin: 0 0 4px;
  padding: 10px 12px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--paper-mute);
  border-bottom: 1px solid var(--ink-line);
}
#user-dropdown button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  border-color: transparent;
  background: transparent;
  font-size: 14px;
  min-height: auto;
}
#user-dropdown button:hover { background: var(--ink-3); }

/* ── Auth overlay ──────────────────────────────────────────────────────────── */
#auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at top, rgba(20, 30, 50, 0.95), rgba(10, 14, 21, 0.98) 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(12px);
  padding: 20px;
}
#auth-overlay[hidden] { display: none; }

#auth-card {
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-lg);
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: cardIn 480ms cubic-bezier(0.16, 1, 0.3, 1) both;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 80px var(--beam-glow-soft);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
#auth-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-variation-settings: "opsz" 96, "SOFT" 50, "WONK" 1;
  font-style: italic;
  font-weight: 400;
  font-size: 44px;
  letter-spacing: -0.035em;
  line-height: 0.95;
  color: var(--paper);
}
#auth-card h2::first-letter { color: var(--beam); }
.auth-tagline {
  margin: -8px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
#auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--ink);
  padding: 4px;
  border-radius: 999px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--paper-mute);
  border-radius: 999px;
  cursor: pointer;
  min-height: auto;
  transition: color 160ms, background 160ms;
}
.auth-tab:hover { color: var(--paper); background: transparent; }
.auth-tab.active {
  background: var(--beam);
  color: var(--ink);
}
.auth-tab.active:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--beam);
}

#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ink-line);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}
#auth-form input:focus { border-color: var(--beam); box-shadow: var(--ring); }
#auth-form input::placeholder { color: var(--paper-dim); }
#auth-submit { width: 100%; padding: 16px; font-size: 14px; }
.auth-error {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--alert);
}

/* ── Profile panel ─────────────────────────────────────────────────────────── */
.back-btn {
  align-self: flex-start;
  background: transparent;
  border-color: transparent;
  color: var(--paper-mute);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 0;
  min-height: auto;
}
.back-btn:hover:not(:disabled) { background: transparent; color: var(--beam); border-color: transparent; }

.profile-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r);
  padding: 22px;
}
.avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--beam);
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  user-select: none;
}
.profile-info h2 {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.02em;
  color: var(--paper);
}
.profile-info p {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--paper-mute);
}

.profile-card {
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.section-heading {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.profile-card input[type="text"],
.profile-card input[type="password"] {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ink-line);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
  width: 100%;
  transition: border-color 160ms, box-shadow 160ms;
}
.profile-card input:focus { border-color: var(--beam); box-shadow: var(--ring); }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; width: auto; min-width: 140px; }

.stack-form { display: flex; flex-direction: column; gap: 10px; }
.stack-form button { align-self: flex-start; }

.form-msg {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.form-msg.success { color: var(--beam); }
.form-msg.error   { color: var(--alert); }

/* Saved locations list */
.locations-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.location-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--ink);
  border-radius: var(--r-sm);
  border: 1px solid var(--ink-line);
}
.location-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  font-weight: 400;
  flex: 1;
  color: var(--paper);
}
.location-address {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--paper-mute);
  margin-top: 2px;
}
.location-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.location-delete {
  background: transparent;
  border-color: transparent;
  color: var(--paper-mute);
  padding: 4px 8px;
  min-height: auto;
  font-size: 14px;
  flex-shrink: 0;
}
.location-delete:hover {
  color: var(--alert);
  background: transparent;
  border-color: transparent;
}

/* ── Desktop refinement ────────────────────────────────────────────────────── */
@media (min-width: 769px) {
  html, body { height: 100%; overflow: hidden; }
  main { height: 100%; overflow: hidden; }

  #app-view {
    display: grid;
    grid-template-columns: 56% 44%;
    height: 100%;
    border-top: 1px solid var(--ink-line);
  }
  #left-col {
    border-right: 1px solid var(--ink-line);
    padding: 32px 24px 28px 36px;
    gap: 22px;
    overflow: hidden;
  }
  #right-col { overflow: hidden; }
  #right-app, #right-profile {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 32px 36px 48px 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-3) transparent;
  }
  #camera-section, #map-section {
    flex: 1;
    height: auto;
    min-height: 0;
  }
  header h1 { font-size: 48px; }

  /* On desktop, controls can flow naturally */
  #controls { grid-template-columns: 1fr 1fr 1fr; }
  #controls > #auto-btn { grid-column: 1 / -1; }
}

/* ── Reduced motion ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .splash-logo, .splash-sub, #auth-card { animation: none !important; }
  #voice-btn.recording { animation: none !important; }
  body::before { display: none; }
}

/* ── High-contrast preference ──────────────────────────────────────────────── */
@media (prefers-contrast: more) {
  :root {
    --paper-mute: #c8d2e0;
    --paper-dim: #9aa8c0;
    --ink-line: #3a4558;
  }
}
