/* ═══════════════════════════════════════════════════════════
   VivaVoxx — Clean rebuild 2026-03-24
   Dark theme, purple accent, mobile-first
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --border: #1e1e2e;
  --text: #e4e4eb;
  --muted: #6b6b7b;
  --accent: #a78bfa;
  --accent-dim: rgba(167, 139, 250, 0.15);
  --success: #34d399;
  --error: #f87171;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100%; }

/* ═══════════════════════════════════════════════════════════
   PIN SCREEN
   ═══════════════════════════════════════════════════════════ */

#auth-screen {
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px calc(40px + var(--safe-bottom));
  padding-top: calc(40px + var(--safe-top));
}

.pin-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pin-logo h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 1px;
}

#auth-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
  text-align: center;
}

.auth-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  font-size: 16px;
  outline: none;
  text-align: center;
  letter-spacing: 1px;
}

.auth-form input:focus { border-color: var(--accent); }
.auth-form input::placeholder { color: var(--muted); letter-spacing: 0; }

.auth-submit {
  height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.auth-submit:active { opacity: 0.8; }
.auth-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.auth-hint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
  min-height: 16px;
}

.auth-error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  min-height: 20px;
}

.auth-form.shake { animation: shake 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.auth-lockout {
  color: var(--error);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  margin-top: 12px;
}

/* ═══════════════════════════════════════════════════════════
   MAIN APP LAYOUT
   ═══════════════════════════════════════════════════════════ */

#main-app {
  height: 100%;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header h1 { font-size: 18px; font-weight: 600; letter-spacing: 0.5px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.token-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
}
.token-badge.warning { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.token-badge.empty { background: rgba(248, 113, 113, 0.15); color: var(--error); }
.header-status { font-size: 12px; color: var(--muted); }

.stop-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--error);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-stop 1.5s ease infinite;
}

@keyframes pulse-stop {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
}

/* Status bar */
.status-bar {
  display: none;
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
  flex-shrink: 0;
}

.status-bar.load { background: var(--accent-dim); color: var(--accent); }
.status-bar.ok { background: rgba(52, 211, 153, 0.1); color: var(--success); }
.status-bar.err { background: rgba(248, 113, 113, 0.1); color: var(--error); }

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════
   INPUT AREA
   ═══════════════════════════════════════════════════════════ */

.input-area {
  padding: 8px 12px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.transcript-preview {
  font-size: 13px;
  color: var(--accent);
  min-height: 0;
  padding: 0 4px;
  max-height: 40px;
  overflow: hidden;
}

.transcript-preview:not(:empty) { margin-bottom: 8px; }

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mic-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.mic-btn svg { width: 22px; height: 22px; }

.mic-btn.listening {
  background: var(--accent);
  color: var(--bg);
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(167, 139, 250, 0); }
}

.input-row input {
  flex: 1;
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  font-size: 15px;
  outline: none;
}

.input-row input:focus { border-color: var(--accent); }
.input-row input::placeholder { color: var(--muted); }

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   TAB NAVIGATION
   ═══════════════════════════════════════════════════════════ */

.tab-nav {
  display: flex;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  transition: color 0.15s;
}

.tab-btn.active { color: var(--accent); }
.tab-btn svg { opacity: 0.6; }
.tab-btn.active svg { opacity: 1; stroke: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   HOME TAB
   ═══════════════════════════════════════════════════════════ */

.greeting {
  text-align: center;
  padding: 20px 0 16px;
}

.greeting h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

/* Chat */
.chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  -webkit-user-select: text;
  user-select: text;
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble-text {
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.copy-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  display: block;
  opacity: 0.5;
}

.bubble.user .copy-hint { color: rgba(10, 10, 15, 0.5); }

/* ═══════════════════════════════════════════════════════════
   BRIEFING TAB
   ═══════════════════════════════════════════════════════════ */

.brief-head {
  margin-bottom: 16px;
}

.brief-head h2 { font-size: 20px; }
.brief-date { font-size: 13px; color: var(--muted); }

.brief-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.btn-play {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 24px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-play:active { opacity: 0.8; }

.brief-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}

.brief-body h2, .brief-body h3, .brief-body h4 {
  margin: 16px 0 8px;
  color: var(--text);
}

.brief-body h2 { font-size: 18px; }
.brief-body h3 { font-size: 16px; }
.brief-body h4 { font-size: 14px; font-weight: 600; }
.brief-body code { background: var(--surface); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.brief-body strong { color: var(--accent); }
.brief-body li { margin-left: 8px; margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════════════
   NOTES TAB
   ═══════════════════════════════════════════════════════════ */

.notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.notes-head h2 { font-size: 20px; }

.btn-accent {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-accent:active { opacity: 0.8; }

.btn-ghost {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

#note-form {
  margin-bottom: 16px;
}

#note-form textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

#note-form textarea:focus { border-color: var(--accent); }

.note-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.note-date { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.note-body {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 8px;
  -webkit-user-select: text;
  user-select: text;
}

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

.note-actions button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.note-actions button:active { background: var(--accent-dim); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   CO-BUILDER TAB
   ═══════════════════════════════════════════════════════════ */

.cb-head { margin-bottom: 16px; }
.cb-head h2 { font-size: 20px; }

.cb-section { margin-bottom: 20px; }
.cb-section h3 { font-size: 15px; color: var(--muted); margin-bottom: 8px; }

.brief-summary {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  cursor: pointer;
  -webkit-user-select: text;
  user-select: text;
}

.agent-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 8px;
}

.agent-name { font-size: 14px; font-weight: 500; }

.agent-st {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

.agent-st.running { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.agent-st.complete { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.agent-st.failed { background: rgba(248, 113, 113, 0.15); color: var(--error); }

.cb-commands {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cmd-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.cmd-btn:active { background: var(--accent-dim); border-color: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   SHARED COMPONENTS
   ═══════════════════════════════════════════════════════════ */

.center-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  color: var(--muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }
