/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --bg:         #060B14;
  --card:       rgba(6, 11, 20, 0.90);
  --border:     rgba(255,255,255,0.10);
  --text:       #EFF6FF;
  --muted:      #6E88A8;
  --accent:     #00D4A8;
  --accent-dim: rgba(0,212,168,0.15);
  --blue:       #4B9CF8;
  --warn:       #F59E0B;
  --header-h:   56px;
  --radius:     14px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input  { font: inherit; color: inherit; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  height: var(--header-h);
  padding: 0 16px;
  background: rgba(6,11,20,0.96);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  z-index: 20;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: #020F0B;
  font-size: 17px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: -0.3px; }

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}
.tagline {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.conn-status { display: flex; align-items: center; gap: 6px; }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); transition: background 0.3s;
}
.conn-dot--on  { background: var(--accent); }
.conn-dot--off { background: #EF4444; }
.conn-label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* TTS button in header */
.tts-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent);
  border: none;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  flex-shrink: 0;
}
.tts-btn:hover { opacity: 0.85; }
.tts-btn--off  { background: #EF4444; opacity: 1; }

/* ── Camera stage ────────────────────────────────────────────────────────── */
.camera-stage {
  flex: 1;
  display: flex;
  align-items: stretch;
  background: #000;
  overflow: hidden;
  position: relative;
}

.camera-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#webcam {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

#serverFeed {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ── Live badge ──────────────────────────────────────────────────────────── */
.live-badge {
  position: absolute;
  top: 12px; right: 12px;
  display: flex; align-items: center; gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 700;
  backdrop-filter: blur(8px);
  z-index: 10;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); transition: background 0.3s;
}
.live-dot--active { background: var(--accent); animation: blink 2s infinite; }
.live-dot--server { background: var(--warn); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.35} }

/* ── Detection chips row (top of bottom panel) ───────────────────────────── */
.chips-row {
  position: absolute;
  left: 14px; right: 14px;
  bottom: calc(var(--panel-h, 220px) + 10px);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 10;
}

.det-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px; font-weight: 700;
  backdrop-filter: blur(8px);
}
.det-chip--match      { border-color: var(--accent); color: var(--accent); }
.det-chip--gesture    { border-color: rgba(0,212,168,0.35); }
.det-chip--expression { }
.det-chip-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.det-chip-icon { font-size: 15px; line-height: 1; }
.det-chip-conf { color: var(--muted); font-weight: 500; font-size: 13px; }

/* ── Bottom panel ────────────────────────────────────────────────────────── */
.bottom-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 10;
  background: linear-gradient(to top, rgba(6,11,20,0.97) 70%, transparent);
  padding: 16px 14px 14px;
}

/* ── Guidance card ───────────────────────────────────────────────────────── */
.guidance-card {
  padding: 16px 18px 14px;
  border-top: 1px solid var(--border);
}
.guidance-card--warn { border-top-color: rgba(245,159,11,0.5); }

.guidance-text {
  font-size: 32px; font-weight: 800; line-height: 1.25;
  margin-bottom: 8px;
}
.guidance-sub  { font-size: 16px; color: var(--muted); margin-bottom: 12px; }

.guidance-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ── Action buttons ──────────────────────────────────────────────────────── */
.action-btn {
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #020F0B;
  font-size: 15px; font-weight: 800;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.action-btn:hover { opacity: 0.85; }
.action-btn--muted {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--muted);
}
.action-btn--muted:hover { color: var(--text); }

/* ── OCR card ────────────────────────────────────────────────────────────── */
.ocr-card {
  background: rgba(0,212,168,0.06);
  border: 1px solid rgba(0,212,168,0.25);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.ocr-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  flex-wrap: wrap;
}
.ocr-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.ocr-label {
  font-size: 10px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; flex: 1;
}
.ocr-text { font-size: 20px; font-weight: 700; line-height: 1.4; word-break: break-word; }
.ocr-text--empty { font-size: 15px; font-weight: 400; color: var(--muted); }

/* ── Find row ────────────────────────────────────────────────────────────── */
.find-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
  height: 44px;
  margin-top: 10px;
}
.find-icon { color: var(--accent); font-size: 14px; flex-shrink: 0; }
.find-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 16px; font-weight: 500; color: var(--text);
}
.find-input::placeholder { color: var(--muted); }
.find-mic   { color: var(--accent); font-size: 16px; padding: 3px 6px; flex-shrink: 0; }
.find-mic:hover { opacity: 0.75; }
.find-clear { color: var(--muted); font-size: 13px; padding: 3px 6px; flex-shrink: 0; }
.find-clear:hover { color: var(--text); }

/* ── Gesture teach panel ─────────────────────────────────────────────────── */
.teach-panel {
  position: absolute;
  inset: 0;
  background: rgba(6,11,20,0.92);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.teach-inner {
  background: rgba(20,30,50,0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: min(90vw, 360px);
  display: flex; flex-direction: column; gap: 14px;
}
.teach-title  { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.teach-gesture { font-size: 26px; font-weight: 800; color: var(--accent); }
.teach-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px; color: var(--text);
  outline: none; width: 100%;
}
.teach-input:focus { border-color: var(--accent); }
.teach-actions { display: flex; gap: 10px; }

/* ── Learned gesture chip ────────────────────────────────────────────────── */
.det-chip--learned { border-color: #F59E0B; color: #F59E0B; }

/* ── Camera loader ───────────────────────────────────────────────────────── */
.camera-loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(6,11,20,0.9);
  z-index: 15;
}
.loader-ring {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { color: var(--muted); font-size: 14px; font-weight: 600; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { font-size: 16px; }
  .conn-label { display: none; }
  .tagline    { display: none; }
  .guidance-text { font-size: 30px; }
  .guidance-sub  { font-size: 15px; }
  .det-chip { font-size: 15px; padding: 8px 15px; }
  .det-chip-conf { font-size: 14px; }
  .action-btn { font-size: 17px; padding: 13px 24px; }
  .find-row { height: 52px; }
  .find-input { font-size: 17px; }
  .ocr-text { font-size: 23px; }
  .tts-btn { width: 44px; height: 44px; font-size: 22px; }
}
