/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d0d1a;
  --surface:      #16162a;
  --surface-2:    #1e1e35;
  --accent:       #6c63ff;
  --accent-light: #8b84ff;
  --success:      #3ecf8e;
  --warning:      #f0a500;
  --error:        #e05c5c;
  --text:         #e8e8f4;
  --text-muted:   #7777aa;
  --border:       rgba(255,255,255,0.07);
  --radius-lg:    16px;
  --radius-md:    12px;
  --radius-sm:    8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ── App shell ───────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
}
.title { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; color: var(--accent-light); }
.status-bar   { font-size: 12px; }
.status-ok    { color: var(--success); }
.status-warn  { color: var(--warning); }
.status-error { color: var(--error); }

/* ── Main (scrollable) ───────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px 16px 4px;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

/* ── Account pills ───────────────────────────────────────────────────────── */
.accounts { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.account-pill { font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 500; }
.account-pill.connected    { background: rgba(62,207,142,.12); color: var(--success); border: 1px solid rgba(62,207,142,.25); }
.account-pill.disconnected { background: rgba(224,92,92,.12);  color: var(--error);   border: 1px solid rgba(224,92,92,.25); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}
.empty-state.hidden { display: none; }
.empty-icon  { font-size: 36px; opacity: .5; }
.empty-state p { font-size: 15px; line-height: 1.5; }
.empty-hint  { font-size: 12px; opacity: .6; }

/* ── Conversation cards ──────────────────────────────────────────────────── */
.conversation { display: flex; flex-direction: column; gap: 8px; }

.turn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}

.turn-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.turn-header:active { background: var(--surface-2); }

.turn-you-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent-light);
  flex-shrink: 0;
}
.turn-you-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turn-chevron {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.turn-body {
  padding: 10px 14px 14px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
}

/* Collapsed: hide body, rotate chevron */
.turn-card.collapsed .turn-body    { display: none; }
.turn-card.collapsed .turn-chevron { transform: rotate(-90deg); }

/* ── State bar ───────────────────────────────────────────────────────────── */
.state-bar {
  flex-shrink: 0;
  text-align: center;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 28px;
}

/* ── Footer + mic button ─────────────────────────────────────────────────── */
.footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 20px 20px;
  gap: 10px;
}
.hint-text { font-size: 12px; color: var(--text-muted); }

.mic-btn {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}
.mic-btn:active, .mic-btn.recording { transform: scale(0.93); background: #7c75ff; }
.mic-btn.processing { background: var(--warning); }
.mic-btn.speaking   { background: var(--success); }
.mic-btn.error      { background: var(--error); }
.mic-icon { width: 28px; height: 28px; position: relative; z-index: 1; }

/* ── Pulse ring ──────────────────────────────────────────────────────────── */
.pulse-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.pulse-ring.active   { opacity: 1; animation: pulse 1s ease-out infinite; }
.pulse-ring.speaking { opacity: 1; border-color: var(--success); animation: pulse-slow 1.5s ease-out infinite; }

@keyframes pulse      { 0% { transform: scale(1);    opacity: .8; } 100% { transform: scale(1.5);  opacity: 0; } }
@keyframes pulse-slow { 0% { transform: scale(1);    opacity: .6; } 100% { transform: scale(1.35); opacity: 0; } }

.hint-commands { font-size: 11px; color: var(--text-muted); text-align: center; line-height: 1.6; opacity: .6; }

.turn-response-text { margin-bottom: 10px; }
.turn-response-text.pending { color: var(--text-muted); font-style: italic; }

.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(108,99,255,.15);
  color: var(--accent-light);
  border: 1px solid rgba(108,99,255,.3);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.play-btn:active { background: rgba(108,99,255,.3); }
.play-btn:disabled { opacity: .5; cursor: default; }

/* ── Lock screen ──────────────────────────────────────────────────────────── */
.lock-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 24px;
}

.lock-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.lock-icon   { font-size: 36px; }
.lock-title  { font-size: 22px; font-weight: 700; color: var(--accent-light); }
.lock-subtitle { font-size: 14px; color: var(--text-muted); text-align: center; }

.lock-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  outline: none;
  text-align: center;
  letter-spacing: 3px;
}
.lock-input:focus { border-color: var(--accent); }

.lock-error {
  font-size: 13px;
  color: var(--error);
  text-align: center;
}

.lock-btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lock-btn:active  { background: var(--accent-light); }
.lock-btn:disabled { opacity: .5; cursor: default; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
