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

/* ── Dark theme (default) ──────────────────── */
:root,
[data-theme="dark"],
[data-theme="system"] {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface-hover: #1a1a24;
  --text: #e8e8ed;
  --text-dim: #7a7a8a;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --accent-bg: rgba(99, 102, 241, 0.1);
  --user-bubble: #1e1e2e;
  --assistant-bubble: #1a1a2a;
  --recording: #ef4444;
  --recording-glow: rgba(239, 68, 68, 0.4);
  --thinking: #f59e0b;
  --speaking: #22c55e;
  --speaking-glow: rgba(34, 197, 94, 0.4);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --success-bg: rgba(34, 197, 94, 0.1);
  --error-bg: rgba(239, 68, 68, 0.1);
  --info-bg: rgba(99, 102, 241, 0.1);
  --scrollbar: #333;
  --input-bg: var(--bg);
  --modal-backdrop: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.4);
}

/* ── Light theme ───────────────────────────── */
[data-theme="light"],
[data-resolved-theme="light"][data-theme="system"] {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-hover: #f0f0f4;
  --text: #1a1a2e;
  --text-dim: #6b6b7b;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --accent: #5558e6;
  --accent-glow: rgba(85, 88, 230, 0.3);
  --accent-bg: rgba(85, 88, 230, 0.08);
  --user-bubble: #eeeef4;
  --assistant-bubble: #f0f0fa;
  --recording: #dc2626;
  --recording-glow: rgba(220, 38, 38, 0.3);
  --thinking: #d97706;
  --speaking: #16a34a;
  --speaking-glow: rgba(22, 163, 74, 0.3);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --success-bg: rgba(22, 163, 74, 0.08);
  --error-bg: rgba(220, 38, 38, 0.08);
  --info-bg: rgba(85, 88, 230, 0.06);
  --scrollbar: #c0c0c8;
  --input-bg: #f5f5f7;
  --modal-backdrop: rgba(0, 0, 0, 0.3);
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background 0.2s, color 0.2s;
  padding-bottom: 30px;
}

/* ── Navigation ─────────────────────────────── */

.top-nav {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-logo {
  flex-shrink: 0;
}

.nav-logo-img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.settings-logo-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.top-nav .nav-links {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.top-nav .nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.35rem 1rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--border-hover);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  font-size: 1.1rem;
}

.btn-icon:hover {
  color: var(--text);
  background: var(--border-hover);
}

/* ── App layout (Voice Agent) ──────────────── */

#app {
  width: 100%;
  max-width: 600px;
  min-height: calc(100vh - 78px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header .subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ── Provider toggles ────────────────────────── */

#provider-toggles {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  justify-content: center;
}

#provider-toggles.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
}

.toggle-label {
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toggle-value {
  color: var(--text);
  min-width: 42px;
  font-size: 0.75rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--scrollbar);
  border-radius: 20px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* ── Voice Sample Section ─────────────────────── */

.voice-sample-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.voice-sample-section.hidden {
  display: none !important;
}

.voice-record-btn,
.voice-upload-btn,
.voice-clear-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.voice-record-btn:hover,
.voice-upload-btn:hover,
.voice-clear-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.voice-record-btn.recording {
  background: var(--error-bg);
  border-color: var(--recording);
  color: var(--recording);
}

.voice-clear-btn {
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.voice-status {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.voice-status.ready {
  color: var(--speaking);
}

.voice-countdown {
  font-variant-numeric: tabular-nums;
}

/* ── Orb ─────────────────────────────────────── */

#orb-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 3rem 0 2rem;
  position: relative;
}

#orb {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16162a 100%);
  border: 2px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  z-index: 2;
  outline: none;
}

#orb:hover {
  transform: scale(1.04);
  border-color: var(--accent);
  box-shadow: 0 0 40px var(--accent-glow);
}

#orb:active {
  transform: scale(0.97);
}

#orb-glow {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  filter: blur(30px);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}

#orb-inner {
  width: 50px;
  height: 50px;
  color: var(--accent);
  transition: color 0.3s ease;
}

#mic-icon {
  width: 100%;
  height: 100%;
}

#orb-label {
  margin-top: 1.2rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: color 0.3s ease;
}

/* Pulse rings */
.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid transparent;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── States ───────────────────────────────────── */

.state-ready #orb {
  animation: orb-breathe 3s ease-in-out infinite;
}
.state-ready #orb-glow {
  opacity: 0.5;
}
.state-ready .pulse-ring {
  border-color: var(--accent);
  animation: pulse-expand 4s ease-out infinite;
  opacity: 0.2;
}
.state-ready .ring-2 { animation-delay: 1.3s; }
.state-ready .ring-3 { animation-delay: 2.6s; }

.state-recording #orb {
  border-color: var(--recording);
  box-shadow: 0 0 50px var(--recording-glow);
  animation: orb-breathe 1.5s ease-in-out infinite;
}
.state-recording #orb-glow {
  opacity: 0.8;
  background: radial-gradient(circle, var(--recording-glow) 0%, transparent 70%);
}
.state-recording #orb-inner {
  color: var(--recording);
}
.state-recording .pulse-ring {
  border-color: var(--recording);
  animation: pulse-expand 2s ease-out infinite;
}
.state-recording .ring-2 { animation-delay: 0.5s; }
.state-recording .ring-3 { animation-delay: 1s; }

.state-transcribing #orb,
.state-thinking #orb {
  border-color: var(--thinking);
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.3);
  animation: orb-spin-glow 2s linear infinite;
}
.state-transcribing #orb-glow,
.state-thinking #orb-glow {
  opacity: 0.6;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.3) 0%, transparent 70%);
}
.state-transcribing #orb-inner,
.state-thinking #orb-inner {
  color: var(--thinking);
}

.state-speaking #orb {
  border-color: var(--speaking);
  box-shadow: 0 0 50px var(--speaking-glow);
  animation: orb-breathe 1s ease-in-out infinite;
}
.state-speaking #orb-glow {
  opacity: 0.7;
  background: radial-gradient(circle, var(--speaking-glow) 0%, transparent 70%);
}
.state-speaking #orb-inner {
  color: var(--speaking);
}
.state-speaking .pulse-ring {
  border-color: var(--speaking);
  animation: pulse-expand 1.5s ease-out infinite;
}
.state-speaking .ring-2 { animation-delay: 0.4s; }
.state-speaking .ring-3 { animation-delay: 0.8s; }

/* ── Animations ───────────────────────────────── */

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes orb-spin-glow {
  0% { box-shadow: 0 0 30px rgba(245, 158, 11, 0.2), inset 0 0 20px rgba(245, 158, 11, 0.05); }
  50% { box-shadow: 0 0 50px rgba(245, 158, 11, 0.4), inset 0 0 30px rgba(245, 158, 11, 0.1); }
  100% { box-shadow: 0 0 30px rgba(245, 158, 11, 0.2), inset 0 0 20px rgba(245, 158, 11, 0.05); }
}

@keyframes pulse-expand {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

/* ── Status bar ───────────────────────────────── */

#status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  transition: background 0.3s ease;
}

.state-ready #status-dot { background: var(--accent); }
.state-recording #status-dot { background: var(--recording); animation: dot-blink 1s infinite; }
.state-transcribing #status-dot,
.state-thinking #status-dot { background: var(--thinking); animation: dot-blink 0.6s infinite; }
.state-speaking #status-dot { background: var(--speaking); }

@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Transcript (Voice Agent) ─────────────────── */

#transcript-container {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 2rem;
}

#transcript-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.transcript-item {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 90%;
  animation: fade-in 0.3s ease;
}

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

.transcript-item.assistant {
  background: var(--assistant-bubble);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border-left: 2px solid var(--accent);
}

.transcript-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ────────────────────────────────── */

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 2px;
}

/* ═════════════════════════════════════════════════
   TRANSCRIPTION PAGE
   ═════════════════════════════════════════════════ */

/* ── Two-column layout ─────────────────────────── */

.app-layout {
  display: flex;
  width: 100%;
  min-height: calc(100vh - 78px);
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.sidebar-empty {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
  padding: 2rem 1rem;
}

.session-item {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 0.25rem;
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--surface-hover);
}

.session-item.active {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.session-item-title {
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  display: flex;
  gap: 0.5rem;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer .btn {
  width: 100%;
}

/* ── Main content area ─────────────────────────── */

.main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 960px;
}

.main-content h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.main-content .subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* ── Mode tabs ─────────────────────────────────── */

.mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.mode-tab {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.mode-tab:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.mode-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}

/* ── Upload area ───────────────────────────────── */

.upload-area {
  border: 2px dashed var(--border-hover);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 1rem;
}

.upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.upload-area p {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.upload-area .upload-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
}

.upload-area input[type="file"] {
  display: none;
}

/* ── Buttons ───────────────────────────────────── */

.btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #5558e6;
}

.btn-danger {
  background: var(--recording);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-warning:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
}

/* ── Live controls (enhanced) ──────────────────── */

.live-controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}

.live-controls-enhanced {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.session-timer {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 50px;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.btn-mute {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-mute:hover {
  border-color: var(--border-hover);
}

.btn-mute.muted {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
}

/* ── Status indicator ──────────────────────────── */

.transcribe-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.transcribe-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}

.transcribe-status .status-dot.active {
  background: var(--accent);
  animation: dot-blink 1s infinite;
}

.transcribe-status .status-dot.recording {
  background: var(--recording);
  animation: dot-blink 0.6s infinite;
}

.transcribe-status .status-dot.complete {
  background: var(--speaking);
}

/* ── Transcript display ────────────────────────── */

.transcript-display {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
  min-height: 200px;
  max-height: 500px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.transcript-display .empty {
  color: var(--text-dim);
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.85rem;
}

.transcript-segment {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  animation: fade-in 0.3s ease;
}

.transcript-segment:last-child {
  border-bottom: none;
}

.segment-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.speaker-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.speaker-label.pending {
  color: var(--text-dim);
  font-style: italic;
}

.segment-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.segment-text {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ── Result tabs ───────────────────────────────── */

.result-tabs-container {
  margin-bottom: 1rem;
}

.result-tabs-header {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.result-tab {
  padding: 0.55rem 1.2rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.result-tab:hover {
  color: var(--text);
}

.result-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.result-panel {
  display: none;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: var(--surface);
  padding: 1rem;
  min-height: 120px;
}

.result-panel.active {
  display: block;
}

/* ── Speaker name editor ───────────────────────── */

.speaker-editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
  margin-bottom: 1rem;
}

.speaker-editor h3 {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#speaker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.speaker-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}

.speaker-card-header {
  margin-bottom: 0.5rem;
}

.speaker-card-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.speaker-audio-wrap {
  margin-bottom: 0.5rem;
}

.speaker-audio-wrap audio {
  width: 100%;
  height: 32px;
  border-radius: 6px;
}

.speaker-audio-caption {
  display: block;
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.speaker-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speaker-name-row label {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.speaker-name-row input {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.speaker-name-row input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Export buttons ─────────────────────────────── */

.export-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ── YouTube input ─────────────────────────────── */

.youtube-input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.text-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.text-input::placeholder {
  color: var(--text-dim);
}

/* ── Utility classes ───────────────────────────── */

.section-hidden {
  display: none;
}

.hidden {
  display: none !important;
}

/* ── Modal system ──────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-backdrop);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-fade-in 0.15s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--shadow);
  animation: modal-slide-in 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--border-hover);
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-slide-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Settings tabs ─────────────────────────────── */

.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.settings-tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row label {
  font-size: 0.85rem;
  color: var(--text);
}

.settings-row select {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
}

.settings-row select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Toast notifications ───────────────────────── */

.toast-container {
  position: fixed;
  top: 60px;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.82rem;
  max-width: 360px;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 20px var(--shadow);
  border: 1px solid var(--border);
}

.toast.success {
  background: var(--success-bg);
  border-color: var(--speaking);
  color: var(--speaking);
}

.toast.error {
  background: var(--error-bg);
  border-color: var(--recording);
  color: var(--recording);
}

.toast.info {
  background: var(--info-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.toast.dismissing {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ── MOM / Action Items panels ─────────────────── */

.mom-content {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}

.mom-content h2 {
  font-size: 1.1rem;
  margin: 1rem 0 0.4rem;
}

.mom-content h3 {
  font-size: 0.95rem;
  margin: 0.8rem 0 0.3rem;
}

.mom-content h4 {
  font-size: 0.88rem;
  margin: 0.6rem 0 0.2rem;
}

.mom-content ul {
  padding-left: 1.4rem;
  margin: 0.3rem 0;
}

.mom-content li {
  margin-bottom: 0.15rem;
}

.mom-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.75rem 0;
}

.mom-content table {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.mom-content td {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.mom-content strong {
  font-weight: 600;
}

.mom-content em {
  font-style: italic;
  color: var(--text-dim);
}

.mom-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mom-controls select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
}

.action-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.action-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.action-item-desc {
  font-size: 0.88rem;
  line-height: 1.5;
}

.priority-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.priority-badge.high {
  background: var(--error-bg);
  color: var(--recording);
}

.priority-badge.medium {
  background: var(--warning-bg);
  color: var(--warning);
}

.priority-badge.low {
  background: var(--success-bg);
  color: var(--speaking);
}

.action-item-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* ── Loading spinner ───────────────────────────── */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-placeholder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 2rem 1rem;
  justify-content: center;
}

/* ── Disconnect button ─────────────────────────── */

#disconnect-btn {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

/* ── Markdown in assistant messages ────────────── */

.transcript-item.assistant strong {
  font-weight: 600;
  color: var(--text);
}

.transcript-item.assistant em {
  font-style: italic;
  color: var(--text);
}

.transcript-item.assistant ul {
  margin: 0.25rem 0;
  padding-left: 1.2rem;
}

.transcript-item.assistant li {
  margin-bottom: 0.15rem;
}

/* ── Bottom Status Bar ─────────────────────────── */

.bottom-status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  z-index: 200;
  gap: 0;
}

.bottom-status-bar .bar-section {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.6rem;
  white-space: nowrap;
}

.bottom-status-bar .bar-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  flex-shrink: 0;
}

.bottom-status-bar .bar-spacer {
  flex: 1;
}

.ws-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--recording);
  flex-shrink: 0;
  transition: background 0.3s;
}

.ws-dot.connected {
  background: var(--speaking);
}

.audio-meter {
  width: 70px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.audio-meter-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.05s linear;
}

.audio-meter-fill.level-warning {
  background: var(--warning);
}

.audio-meter-fill.level-high {
  background: var(--recording);
}

/* ── Confidence Badge ─────────────────────────── */

.confidence-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.confidence-badge.high {
  background: var(--success-bg);
  color: var(--speaking);
}

.confidence-badge.medium {
  background: var(--warning-bg);
  color: var(--warning);
}

.confidence-badge.low {
  background: var(--error-bg);
  color: var(--recording);
}

/* ── Enhanced Settings ────────────────────────── */

.settings-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.15rem;
}

.settings-row .toggle-switch input:disabled + .toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-row .settings-label-group {
  display: flex;
  flex-direction: column;
}

.settings-row .settings-label-group label {
  font-size: 0.85rem;
  color: var(--text);
}

/* ── Pre-Meeting Modal ─────────────────────────── */

.pre-meeting-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.pre-meeting-section-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.meeting-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.meeting-type-btn {
  padding: 0.55rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.meeting-type-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.meeting-type-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.template-upload-area {
  border: 2px dashed var(--border-hover);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.template-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.template-upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.template-sections {
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.template-sections div {
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--border);
}

.template-sections div:last-child {
  border-bottom: none;
}

/* ── Saved Templates (Settings + Pre-meeting) ───── */

.saved-templates-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
}

.saved-templates-empty {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  padding: 1rem 0;
}

.saved-template-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  cursor: default;
  transition: all 0.15s;
}

.saved-template-item:last-child {
  margin-bottom: 0;
}

.saved-template-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.saved-template-item .template-item-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.saved-template-item .template-item-info {
  flex: 1;
  min-width: 0;
}

.saved-template-item .template-item-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-template-item .template-item-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.saved-template-item .template-item-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.saved-template-item .template-item-actions button {
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.saved-template-item .template-item-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.saved-template-item .template-item-actions button.delete-btn:hover {
  border-color: var(--recording);
  color: var(--recording);
}

/* Custom template list in pre-meeting popup */
.custom-saved-templates {
  max-height: 180px;
  overflow-y: auto;
}

.custom-template-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: all 0.15s;
}

.custom-template-option:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.custom-template-option.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.custom-template-option .template-option-name {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text);
}

.custom-template-option .template-option-sections {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.custom-template-option .template-option-check {
  font-size: 0.9rem;
  color: var(--accent);
  display: none;
}

.custom-template-option.selected .template-option-check {
  display: inline;
}

/* ── Enrollment Rows ──────────────────────────── */

.enrollment-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.enrollment-row:last-child {
  border-bottom: none;
}

.enrollment-photo-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px dashed var(--border-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 1.1rem;
  transition: border-color 0.15s;
}

.enrollment-photo-placeholder:hover {
  border-color: var(--accent);
}

.enrollment-photo-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.enrollment-name-input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
}

.enrollment-name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.enrollment-audio-group {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.enrollment-audio-btn {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.enrollment-audio-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.enrollment-record-btn.recording {
  border-color: var(--danger, #f44336);
  color: var(--danger, #f44336);
  animation: enrollment-pulse 1s ease-in-out infinite;
}

@keyframes enrollment-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.enrollment-audio-status {
  font-size: 0.72rem;
  white-space: nowrap;
}

.enrollment-audio-status.ready {
  color: var(--success, #4caf50);
}

.enrollment-audio-status.processing {
  color: var(--warning, #ff9800);
}

.enrollment-audio-status.error {
  color: var(--danger, #f44336);
}

.enrollment-remove-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.enrollment-remove-btn:hover {
  color: var(--danger, #f44336);
  background: rgba(244, 67, 54, 0.1);
}

/* ── Speaker Photos in Transcript ─────────────── */

.speaker-photo-inline {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 0.3rem;
}

.speaker-avatar-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-dim);
  font-size: 0.6rem;
  vertical-align: middle;
  margin-right: 0.3rem;
}

.speaker-card-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.speaker-card-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-dim);
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ── Voice Profiles Page ──────────────────────── */

.profile-form-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
}

.profile-form-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.profile-form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.profile-form-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.profile-form-fields {
  flex: 1;
  min-width: 0;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  background: var(--surface);
  transition: border-color 0.15s;
}

.profile-card:hover {
  border-color: var(--border-hover);
}

.profile-card-photo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--text-dim);
  font-size: 1.2rem;
  font-weight: 600;
}

.profile-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-card-info {
  flex: 1;
  min-width: 0;
}

.profile-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.profile-card-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.profile-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    padding: 1rem;
  }

  .bottom-status-bar {
    font-size: 0.65rem;
  }

  .bottom-status-bar .bar-section {
    padding: 0 0.35rem;
  }

  .audio-meter {
    width: 50px;
  }

  .meeting-type-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .enrollment-row {
    flex-wrap: wrap;
  }
}
