/* Omnistant — mobile-first, calm, light.
 *
 * There is no dark mode by design: high contrast is fatiguing for the people
 * this is built for. Tokens, sizes and motion are from the design handoff.
 */

:root {
  --bg: #F8F9FB;
  --surface: #FFFFFF;
  --primary: #4A90E2;
  --primary-hover: #3F81CE;
  --primary-text: #357ABD;
  --primary-tint: #F2F7FD;
  --secondary: #7ED321;
  --secondary-hover: #72C119;
  --activity: #BD10E0;
  --item: #34A853;
  --warning: #FBBC04;
  --error: #EA4335;
  --text: #2C3E50;
  --muted: #7F8C8D;
  --border: #E8EAED;
  --ring: #DDE4EC;
  --dot-off: #C7CDD4;

  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-pill: 999px;
  --sh-card: 0 2px 10px rgba(44,62,80,.06);
  --sh-resp: 0 2px 12px rgba(44,62,80,.07);
  --sh-row:  0 2px 8px  rgba(44,62,80,.05);
  --sh-btn:  0 4px 12px rgba(74,144,226,.24);
  --sh-mic:  0 4px 12px rgba(44,62,80,.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Montserrat, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: .3px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; letter-spacing: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }

/* ───────── header ───────── */
.header {
  position: sticky; top: 0; z-index: 20;
  height: 56px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
  height: calc(56px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--item); flex: none; }
.brand h1 { font-size: 18px; font-weight: 600; }
.agent-status { font-size: 12px; color: var(--muted); }

/* ───────── layout ───────── */
main {
  padding: 4px 20px 28px;
  display: flex; flex-direction: column; gap: 20px;
  max-width: 560px; margin: 0 auto;
  padding-bottom: calc(200px + env(safe-area-inset-bottom));
}
.card {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 16px; box-shadow: var(--sh-card);
  display: flex; flex-direction: column; gap: 8px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 16px; font-weight: 600; }

.ghost-btn {
  min-height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--primary);
  font-size: 12px; font-weight: 600; transition: background .3s ease, border-color .3s ease;
}
.ghost-btn:hover { background: var(--primary-tint); border-color: var(--primary); }

/* ───────── globe ───────── */
.globe-wrap { position: relative; display: flex; justify-content: center; }
#globe { touch-action: none; max-width: 100%; height: auto; }
.globe-dot { cursor: pointer; transition: r .3s ease; }
.globe-ring { animation: softPulse 2s ease-in-out infinite; }
.globe-tooltip {
  position: absolute; transform: translate(-50%, -125%);
  background: var(--text); color: #fff;
  font-size: 12px; line-height: 1.4;
  padding: 8px 10px; border-radius: var(--r-sm);
  max-width: 220px; pointer-events: none;
  opacity: 0; transition: opacity .3s ease;
}
.globe-empty {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  margin: 0; max-width: 190px; text-align: center;
  font-size: 12px; color: var(--muted);
}
.legend { display: flex; justify-content: center; gap: 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ───────── watch / camera ───────── */
.watch-state { font-size: 12px; color: var(--muted); }
.watch-state.live { color: var(--item); font-weight: 600; }
.viewport {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  border-radius: 10px; overflow: hidden;
  background: linear-gradient(180deg, #EEF3F8, #E4EBF3);
}
.viewport video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewport-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center; padding: 20px; color: var(--muted);
}
/* The HTML `hidden` attribute sets display:none from the UA stylesheet, which an
   author `display: flex` silently outranks — that is why the "Camera off" panel
   used to sit on top of a live picture. Restate it at author specificity. */
.viewport-placeholder[hidden] { display: none; }
.viewport-placeholder p { margin: 0; font-weight: 600; color: var(--text); font-size: 16px; }
.viewport-placeholder small { max-width: 30ch; font-size: 12px; }

.watch-badge {
  position: absolute; top: 10px; left: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.92); color: var(--text);
  font-size: 12px; font-weight: 600; box-shadow: var(--sh-row);
}
.watch-badge[hidden] { display: none; }
.watch-pip { width: 8px; height: 8px; border-radius: 50%; background: var(--item); animation: softPulse 2s ease-in-out infinite; }
.seen-line { margin: 0; font-size: 12px; color: var(--muted); min-height: 18px; }

/* ───────── buttons ───────── */
.btn-row { display: flex; gap: 8px; }
.btn-primary, .btn-secondary, .btn-got-it, .quick-btn, .btn-send {
  min-height: 48px; border-radius: var(--r-md);
  font-size: 16px; font-weight: 600; transition: background .3s ease, border-color .3s ease, color .3s ease;
}
.btn-primary:active, .btn-secondary:active, .btn-got-it:active,
.quick-btn:active, .mic:active { transform: scale(.98); }
.btn-primary {
  flex: 1; background: var(--primary); color: #fff; border: none;
  box-shadow: var(--sh-btn); min-height: 56px;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary.stop { background: var(--surface); color: var(--primary-text); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary {
  background: var(--surface); color: var(--primary-text);
  border: 1px solid var(--border); padding: 0 16px;
}
.btn-secondary:hover { border-color: var(--primary); }
.btn-secondary[hidden] { display: none; }
.btn-got-it { flex: 1; background: var(--secondary); color: var(--text); border: none; }
.btn-got-it:hover { background: var(--secondary-hover); }

/* ───────── workflow ───────── */
.workflow { text-align: center; display: flex; flex-direction: column; gap: 8px; animation: riseIn .4s ease-out; }
.workflow-title { font-size: 20px; font-weight: 600; }
.workflow-sub { margin: 0; font-size: 16px; color: var(--muted); }
.workflow[hidden] { display: none; }

/* ───────── response ───────── */
.response { box-shadow: var(--sh-resp); padding: 20px; gap: 16px; animation: riseIn .4s ease-out; }
.response[hidden] { display: none; }
.answer { margin: 0; font-size: 24px; font-weight: 500; line-height: 1.5; min-height: 72px; }
.details { background: var(--bg); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.details[hidden] { display: none; }
.details-row { display: flex; justify-content: space-between; gap: 12px; }
.details-row .k { font-size: 12px; color: var(--muted); }
.details-row .v { font-size: 12px; font-weight: 500; text-align: right; }

/* ───────── globe details ───────── */
.globe-details { display: flex; flex-direction: column; gap: 12px; animation: riseIn .4s ease-out; }
.globe-details[hidden] { display: none; }
.globe-details h2 { font-size: 18px; font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  transition: background .3s ease, color .3s ease, border-color .3s ease;
}
.pill.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.obs-list { display: flex; flex-direction: column; gap: 8px; }
.obs-row {
  width: 100%; min-height: 48px; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--sh-row);
  display: flex; align-items: center; gap: 10px; transition: border-color .3s ease;
}
.obs-row:hover { border-color: var(--primary); }
.obs-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.obs-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.obs-label { font-size: 16px; font-weight: 500; }
.obs-meta { font-size: 12px; color: var(--muted); }
.obs-conf { font-size: 12px; color: var(--muted); flex: none; }
.empty-note { font-size: 12px; color: var(--muted); margin: 0; }

/* ───────── quick actions ───────── */
.quick { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.quick-label { font-size: 12px; color: var(--muted); }
.quick-btn {
  text-align: left; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.quick-btn.active { background: var(--primary-tint); border-color: var(--primary); color: var(--primary-text); }

/* ───────── voice bar ───────── */
.voicebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.mic-row { display: flex; align-items: center; gap: 12px; max-width: 520px; margin: 0 auto; width: 100%; }
.mic-holder { position: relative; width: 56px; height: 56px; flex: none; }
.mic {
  position: relative; z-index: 1;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; box-shadow: var(--sh-mic);
  transition: background .3s ease, transform .3s ease;
}
.mic.listening { background: var(--item); }
.mic.busy { background: var(--muted); }
.mic:disabled { opacity: .5; }
.mic-halo {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--primary); opacity: 0; pointer-events: none;
}
.mic-halo.on { opacity: .3; animation: haloPulse 2s ease-in-out infinite; }
.mic-halo.listening { background: var(--item); }
.voice-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.voice-status { font-size: 12px; font-weight: 600; color: var(--muted); }
.voice-status.listening { color: var(--item); }
.voice-status.busy { color: var(--primary); }
.voice-transcript { font-size: 16px; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; }
.speak-bars { display: flex; gap: 3px; align-items: center; flex: none; }
.speak-bars[hidden] { display: none; }
.speak-bars i { width: 4px; height: 20px; border-radius: 2px; background: var(--primary); animation: speakBar 1.2s ease-in-out infinite; }
.speak-bars i:nth-child(2) { animation-delay: .2s; }
.speak-bars i:nth-child(3) { animation-delay: .4s; }

.composer { display: flex; gap: 8px; max-width: 520px; margin: 0 auto; width: 100%; }
.composer input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 16px; font-family: inherit; color: var(--text); background: var(--bg);
}
.btn-send { padding: 0 18px; background: var(--primary); color: #fff; border: none; }
.btn-send:hover { background: var(--primary-hover); }
.btn-send:disabled { opacity: .5; }

/* ───────── motion ───────── */
@keyframes riseIn    { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes popIn     { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: scale(1); } }
@keyframes softPulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes haloPulse { 0%,100% { transform: scale(1); opacity: .35; } 50% { transform: scale(1.18); opacity: .12; } }
@keyframes speakBar  { 0%,100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }

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

/* ───────── wide screens ───────── */
@media (min-width: 800px) {
  main { max-width: 1040px; display: grid; grid-template-columns: 400px 1fr; gap: 20px; align-items: start; }
  .globe-card { grid-row: span 2; }
  .quick { grid-column: 1 / -1; }
}

/* ───────── daily timeline ───────── */
.timeline-card { border: 1px solid var(--border); padding: 20px 16px; gap: 16px; animation: riseIn .4s ease-out; }
.timeline-card[hidden] { display: none; }
.tl-count { font-size: 12px; color: var(--muted); }
.tl-track { position: relative; height: 56px; }
.tl-rail {
  position: absolute; top: 14px; left: 6px; right: 6px;
  height: 6px; border-radius: var(--r-pill); background: var(--border);
}
.tl-event {
  position: absolute; top: 0; width: 48px; height: 56px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; padding: 0;
}
.tl-dot {
  width: 16px; height: 16px; border-radius: 50%; margin-top: 9px;
  box-shadow: 0 0 0 4px rgba(232,234,237,.9);
  transition: box-shadow .3s ease;
}
.tl-event.selected .tl-dot { box-shadow: 0 0 0 4px rgba(74,144,226,.22); }
.tl-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tl-detail { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.tl-title { font-size: 16px; font-weight: 500; }
.tl-meta { font-size: 12px; color: var(--muted); }

/* ───────── wake word ───────── */
.wake-pill {
  min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 8px; align-self: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; font-weight: 600;
  transition: background .3s ease, border-color .3s ease, color .3s ease;
}
.wake-pill[aria-pressed="true"] { background: var(--primary-tint); border-color: var(--primary); color: var(--primary-text); }
.wake-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot-off); flex: none; transition: background .3s ease; }
.wake-pill[aria-pressed="true"] .wake-dot { background: var(--item); }
.wake-note { font-size: 12px; color: var(--muted); text-align: center; margin: 0; max-width: 44ch; align-self: center; }
.wake-note[hidden] { display: none; }
.mic-halo.standby { opacity: .3; animation: haloPulse 4s ease-in-out infinite; }
