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

:root {
  --bg:         #0a0a0f;
  --surface:    #14141e;
  --surface2:   #1e1e2e;
  --border:     #2a2a3e;
  --accent:     #7c6af7;
  --accent2:    #5a4fd4;
  --green:      #3ecf8e;
  --red:        #ff4d6d;
  --yellow:     #f7a83e;
  --text:       #e8e8f0;
  --text-dim:   #6b6b88;
  --radius:     14px;
  --safe-top:   env(safe-area-inset-top);
  --safe-bot:   env(safe-area-inset-bottom);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

#header-text { flex: 1; min-width: 0; }
#app-name { font-size: 17px; font-weight: 600; }

#status {
  font-size: 12px;
  margin-top: 2px;
  transition: color 0.3s;
}
.status-idle        { color: var(--text-dim); }
.status-connecting  { color: var(--yellow); }
.status-listening   { color: var(--green); }
.status-recording   { color: var(--accent); }
.status-transcribing,
.status-thinking    { color: var(--yellow); }
.status-speaking    { color: var(--accent); }
.status-error       { color: var(--red); }

#mic-indicator {
  font-size: 20px;
  transition: color 0.2s, text-shadow 0.2s;
}
.mic-off    { color: var(--text-dim); }
.mic-on     { color: var(--green); text-shadow: 0 0 8px var(--green); }
.mic-record { color: var(--accent); text-shadow: 0 0 10px var(--accent); animation: pulse 0.8s infinite alternate; }

@keyframes pulse {
  from { opacity: 0.7; }
  to   { opacity: 1.0; }
}

/* ── Conversation thread ───────────────────────────────────────────────────── */
#conversation {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
}
.empty-icon { font-size: 48px; }
.empty-text { font-size: 15px; text-align: center; line-height: 1.5; }

.message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 90%;
  animation: slide-in 0.25s ease;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-you   { align-self: flex-end; align-items: flex-end; }
.message-marvin { align-self: flex-start; align-items: flex-start; }

.message .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.message-you   .label { color: var(--accent); }
.message-marvin .label { color: var(--green); }

.message .bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.message-you   .bubble {
  background: var(--accent2);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message-marvin .bubble {
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.message.thinking .bubble {
  color: var(--text-dim);
  font-style: italic;
}

/* ── Controls / footer ─────────────────────────────────────────────────────── */
#controls {
  flex-shrink: 0;
  padding: 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* VAD level bar */
#vad-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
}
#vad-label { font-size: 12px; color: var(--text-dim); width: 72px; flex-shrink: 0; }
#vad-bar {
  flex: 1; height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
#vad-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: 2px;
  transition: width 0.05s linear;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}
.btn-danger {
  background: var(--surface2);
  border: 1px solid var(--red);
  color: var(--red);
}
