:root {
  --bg: #090d16;
  --surface: #111827;
  --surface-2: #192234;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --danger: #fb7185;
  --ok: #34d399;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top right, #16213e 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0; }
.small { font-size: 0.8rem; }
.error-text { color: var(--danger); font-size: 0.9rem; margin-top: 0.5rem; }

/* Auth */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.auth-badge { font-size: 2.5rem; margin-bottom: 0.5rem; }
.auth-card h1 { margin: 0.2rem 0; font-size: 1.4rem; }
.auth-card input[type="password"] {
  width: 100%;
  margin: 1rem 0 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
}
.remember-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* Shell */
.app-shell {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent);
}
.brand-title { font-weight: 700; font-size: 1.05rem; }
.brand-sub { font-size: 0.75rem; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.mode-switch {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
}
.mode-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06101f;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.85rem 0;
  overflow-x: auto;
}
.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
}
.tab-btn.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
}

.content { flex: 1; display: flex; flex-direction: column; }
.tab-panel { display: none; flex-direction: column; gap: 1rem; flex: 1; }
.tab-panel.active { display: flex; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.card h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.card h3 { margin: 0 0 0.25rem; font-size: 0.98rem; }

.hero-card {
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.1), rgba(129, 140, 248, 0.08)), var(--surface);
}
.hero-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.hero-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06101f;
  border: 0;
}
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: rgba(251, 113, 133, 0.15); color: var(--danger); border-color: rgba(251, 113, 133, 0.4); }
.btn.full { width: 100%; }

.audio-player { width: 100%; margin-top: 0.85rem; height: 40px; }
.script-wrap { margin-top: 0.75rem; }
.script-wrap summary { cursor: pointer; color: var(--accent); font-size: 0.88rem; font-weight: 600; }
.script-text { line-height: 1.55; color: #cbd5e1; white-space: pre-wrap; margin-top: 0.5rem; }

/* Chat log */
.chat-log {
  flex: 1;
  min-height: 180px;
  max-height: 44vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.25rem 0;
}
.msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 0.93rem;
}
.msg.user {
  align-self: flex-end;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
}
.action-pill {
  display: inline-block;
  margin-top: 0.4rem;
  margin-right: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(52, 211, 153, 0.14);
  color: var(--ok);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

/* Dock */
.dock {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.85rem;
}
.live-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  color: var(--ok);
}
.pulse-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

.dock-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(129, 140, 248, 0.18));
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.mic-btn.recording {
  background: linear-gradient(135deg, rgba(251, 113, 133, 0.3), rgba(244, 63, 94, 0.25));
  border-color: var(--danger);
  animation: pulse 1.2s infinite;
}
.text-form { display: flex; gap: 0.5rem; }
.text-form input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

/* Voice tab */
.status-box {
  margin: 0.75rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.voice-steps { display: grid; gap: 0.9rem; margin: 1rem 0; }
.voice-step {
  padding: 0.9rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.quote {
  font-style: italic;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.step-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }
.voice-submit-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Memory & Sources */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.oauth-details { margin: 0.75rem 0; }
.oauth-details summary { cursor: pointer; color: var(--accent); font-size: 0.88rem; }
.oauth-details textarea {
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: monospace;
  font-size: 0.78rem;
}
.google-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.sources-list { display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.9rem; }
.mem-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
.learning-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.85rem 0; }
.learning-form input {
  flex: 1; min-width: 200px;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.learning-form select {
  padding: 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.learnings-list { display: flex; flex-direction: column; gap: 0.5rem; }
.learning-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.learning-cat {
  font-size: 0.72rem;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(129, 140, 248, 0.18);
  color: var(--accent-2);
  margin-right: 0.5rem;
}
