/* ── CSS Variables ─────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0a0a;
  --bg-subtitle:  #111111;
  --bg-panel:     #1a1a1a;
  --bg-card:      #222222;
  --text-primary: #ffffff;
  --text-muted:   #666666;
  --text-sub:     #444444;
  --accent:       #4ecdc4;
  --accent-dim:   #2a7a76;
  --border:       #2a2a2a;
  --topbar-h:     52px;
  --bottom-h:     56px;

  /* CEFR badge colors */
  --a1: #4ade80;
  --a2: #60a5fa;
  --b1: #fbbf24;
  --b2: #fb923c;
  --c1: #f87171;
  --c2: #c084fc;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg:           #f5f5f5;
  --bg-subtitle:  #ececec;
  --bg-panel:     #e2e2e2;
  --bg-card:      #d8d8d8;
  --text-primary: #111111;
  --text-muted:   #888888;
  --text-sub:     #aaaaaa;
  --border:       #cccccc;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, select { font: inherit; color: inherit; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%23666'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }

/* ── Top Bar ───────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
}

/* ── Mode Selector (compact dropdown) ─────────────────────────────────── */
.mode-selector {
  position: relative;
}

.mode-current {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s var(--ease);
  cursor: pointer;
}

.mode-current:hover {
  border-color: var(--accent-dim);
}

.mode-selector.open .mode-current {
  border-color: var(--accent);
}

.mode-icon {
  font-size: 0.9rem;
}

.mode-label {
  font-weight: 600;
}

.mode-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s var(--ease);
}

.mode-selector.open .mode-arrow {
  transform: rotate(180deg);
}

.mode-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  min-width: 160px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
}

.mode-selector.open .mode-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s var(--ease);
}

.mode-option:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.mode-option.active {
  background: rgba(78, 205, 196, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.mode-opt-icon {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
}

.topbar-right { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-card); color: var(--text-primary); }

/* ── Settings Drawer ───────────────────────────────────────────────────── */
.settings-drawer {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 300px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 0 12px;
  padding: 0;
  z-index: 90;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s var(--ease), padding 0.35s var(--ease);
}

.settings-drawer.open {
  max-height: 400px;
  padding: 16px 20px 20px;
}

.settings-inner h3 {
  margin-bottom: 16px;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.settings-label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.settings-label select,
.settings-label input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 6px;
}

.difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.difficulty-row input[type="range"] { flex: 1; }

.cefr-label { font-size: 0.75rem; font-weight: 700; }
.cefr-label.a1 { color: var(--a1); }
.cefr-label.c2 { color: var(--c2); }

.difficulty-value {
  display: inline-block;
  margin-top: 4px;
  font-weight: 700;
  color: var(--accent);
}

/* ── Main Content Layout ───────────────────────────────────────────────── */
.main-content {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  overflow: hidden;
  transition: bottom 0.2s var(--ease);
}

/* When bottom bar is visible, shrink main content */
.main-content.has-player {
  bottom: var(--bottom-h);
}

.subtitle-section {
  flex: 1;
  position: relative;
  background: var(--bg-subtitle);
  overflow: hidden;
}

/* ── Status / Overlays ─────────────────────────────────────────────────── */
.realtime-overlay {
  position: absolute;
  top: 16px; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

/* ── Mic Controls ────────────────────────────────────────────────────── */
.mic-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.mic-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}
.mic-btn:hover { border-color: var(--accent); }
.mic-btn.active {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.15);
}
.mic-btn.muted {
  border-color: #f87171;
  opacity: 0.6;
}

.mic-select {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 6px 12px;
  max-width: 180px;
  outline: none;
}
.mic-select:focus { border-color: var(--accent); }

/* ── Record Controls ─────────────────────────────────────────────────── */
.record-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.record-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease);
}
.record-btn:hover { border-color: #f87171; }
.record-btn.recording {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.2);
  animation: record-pulse 1.2s ease-in-out infinite;
}
.record-btn.paused {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
}

@keyframes record-pulse {
  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); }
}

.record-stop-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s var(--ease);
}
.record-stop-btn:hover { border-color: var(--accent); background: rgba(78, 205, 196, 0.15); }

.record-timer {
  font-size: 0.8rem;
  color: #f87171;
  font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 10px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-sub);
}
.pulse-dot.active {
  background: #4ade80;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.3); }
}

/* File upload overlay */
.upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtitle);
  z-index: 20;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 60px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  text-align: center;
  color: var(--text-muted);
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(78, 205, 196, 0.06);
}

.drop-icon { font-size: 2.5rem; color: var(--text-sub); }
.drop-sub  { font-size: 0.85rem; }

.file-pick-btn {
  display: inline-block;
  padding: 8px 22px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.file-pick-btn:hover { opacity: 0.85; }

/* Progress overlay */
.progress-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtitle);
  z-index: 20;
}

.progress-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 320px;
}

.progress-box p { font-size: 0.9rem; color: var(--text-muted); }

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s var(--ease);
}

#progress-pct { font-size: 0.85rem; color: var(--text-muted); }

/* ── Bottom Bar ────────────────────────────────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
}

/* Player controls */
.player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.bottom-bar-extras {
  display: none;
  margin-left: 8px;
}

.play-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.play-btn:hover { opacity: 0.85; }
.play-btn.playing::before { content: "⏸"; }
.play-btn:not(.playing)::before { content: "▶"; }
.play-btn { font-size: 0; } /* hide original text, use ::before */

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.progress-played {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
}

.progress-thumb {
  position: absolute;
  top: 50%; left: 0%;
  transform: translate(-50%, -50%);
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  transition: transform 0.1s;
}

.progress-track:hover .progress-thumb {
  transform: translate(-50%, -50%) scale(1.4);
}

.time-display {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Vocab toggle — only visible on mobile */
.vocab-toggle-btn {
  display: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  background: transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.vocab-toggle-btn:hover { background: rgba(78, 205, 196, 0.1); }
.vocab-toggle-btn.open { background: rgba(78, 205, 196, 0.12); }

/* Translate toggle */
.translate-toggle-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.translate-toggle-btn:hover { background: rgba(78, 205, 196, 0.1); }
.translate-toggle-btn.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(78, 205, 196, 0.12);
}

/* ── Range Input Styling ───────────────────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  border: none;
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.3); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* ── Responsive — mobile ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --topbar-h: 46px;
    --bottom-h: 48px;
  }

  .main-content { flex-direction: column; }

  .subtitle-section { flex: 1; min-height: 0; }

  /* Top bar compact */
  .topbar { padding: 0 12px; }
  .logo { font-size: 0.95rem; }
  .mode-current { padding: 5px 10px; font-size: 0.8rem; }
  .mode-label { display: none; }
  .topbar-right { gap: 4px; }
  .icon-btn { width: 32px; height: 32px; font-size: 1rem; }

  /* Settings drawer full-width on mobile */
  .settings-drawer { width: 100%; border-left: none; border-radius: 0 0 12px 12px; }

  /* Mic + record controls compact */
  .mic-controls { gap: 6px; }
  .mic-btn { width: 38px; height: 38px; font-size: 1rem; }
  .mic-select { font-size: 0.7rem; max-width: 140px; padding: 5px 10px; }
  .record-controls { gap: 4px; }
  .record-btn { width: 38px; height: 38px; font-size: 1rem; }
  .record-stop-btn { width: 30px; height: 30px; font-size: 0.85rem; }
  .record-timer { font-size: 0.72rem; padding: 3px 8px; }
  .status-indicator { font-size: 0.72rem; padding: 4px 10px; }

  /* Bottom bar compact */
  .bottom-bar { padding: 0 12px; }

  /* Show vocab toggle + bottom extras on mobile */
  .bottom-bar-extras { display: flex; }
  .vocab-toggle-btn { display: inline-flex; }

  /* Vocab panel: bottom sheet with drag handle */
  .vocab-panel {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    height: 0;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    transition: height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), bottom 0.2s var(--ease);
    z-index: 50;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
  }

  /* When player is active, push vocab panel above bottom bar */
  .main-content.has-player .vocab-panel {
    bottom: var(--bottom-h);
  }

  .vocab-panel.open { height: 42vh; }

  /* Upload overlay compact */
  .drop-zone { padding: 32px 28px; gap: 8px; }
  .drop-icon { font-size: 2rem; }
  .file-pick-btn { padding: 7px 18px; font-size: 0.8rem; }

  /* Progress box compact */
  .progress-box { width: 260px; }
}

/* ── Conversation Mode ────────────────────────────────────────────────── */

/* Split layout: lyrics 60% left, suggestions 40% right */
.main-content.convo-layout .subtitle-section { flex: 0 0 60%; }
.main-content.convo-layout .suggestions-panel { display: flex; }
.main-content.convo-layout .vocab-panel { display: none; }

.conversation-overlay {
  position: absolute;
  top: 12px; left: 0; right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.convo-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 16px;
}

.speaker-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-card);
  border-radius: 6px;
  padding: 2px;
}

.speaker-btn {
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}

.speaker-btn.active[data-speaker="other"] {
  background: #fbbf24;
  color: #000;
}

.speaker-btn.active[data-speaker="me"] {
  background: var(--accent);
  color: #000;
}

.ask-btn {
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--accent);
  color: #000;
  transition: opacity 0.15s;
}
.ask-btn:hover { opacity: 0.85; }
.ask-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

.convo-save-btn {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  background: transparent;
  transition: all 0.15s;
}
.convo-save-btn:hover { background: rgba(78, 205, 196, 0.1); }
.convo-save-btn:disabled { opacity: 0.5; pointer-events: none; }

/* Speaker badge on lyrics lines */
.speaker-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.speaker-badge.me {
  background: rgba(78, 205, 196, 0.2);
  color: var(--accent);
}
.speaker-badge.other {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

/* Suggestion indicator on lyrics lines */
.sug-indicator {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(78, 205, 196, 0.12);
  color: var(--accent-dim);
  opacity: 0.5;
  transition: opacity 0.3s, background 0.3s, color 0.3s;
  pointer-events: none;
}
.sug-indicator.latest {
  opacity: 1;
  background: rgba(78, 205, 196, 0.2);
  color: var(--accent);
  animation: sug-indicator-pulse 1.5s ease-out;
}
@keyframes sug-indicator-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.4); }
  70%  { box-shadow: 0 0 0 6px rgba(78, 205, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0); }
}

/* ── Suggestions Panel ────────────────────────────────────────────────── */
.suggestions-panel {
  display: none;
  flex-direction: column;
  width: 40%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.suggestions-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.suggestions-panel .panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.copy-sug-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  background: transparent;
  transition: background 0.15s;
}
.copy-sug-btn:hover { background: rgba(78, 205, 196, 0.1); }

.sug-placeholder {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 40px 20px;
}
.sug-placeholder kbd {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.78rem;
}

.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  animation: sug-fade-in 0.3s var(--ease);
}

.suggestion-card.streaming .sug-content::after {
  content: '|';
  animation: sug-cursor 0.6s steps(2) infinite;
  color: var(--accent);
  font-weight: 700;
}

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

@keyframes sug-cursor {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

.sug-content {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.sug-content p { margin-bottom: 8px; }
.sug-content p:last-child { margin-bottom: 0; }
.sug-content strong { color: var(--accent); }

/* ── Conversation responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content.convo-layout { flex-direction: column; }
  .main-content.convo-layout .subtitle-section { flex: 1; }
  .main-content.convo-layout .suggestions-panel {
    width: 100%;
    max-height: 35vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .convo-controls { gap: 6px; padding: 5px 10px; }
  .speaker-btn { padding: 3px 8px; font-size: 0.72rem; }
  .ask-btn { padding: 5px 12px; font-size: 0.72rem; }
}

/* ── AI Settings Overlay ──────────────────────────────────────────────── */
.ais-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.ais-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.ais-dialog {
  width: min(760px, 95vw);
  max-height: 85vh;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  transform: scale(0.96);
  transition: transform 0.2s var(--ease);
}
.ais-overlay.open .ais-dialog {
  transform: scale(1);
}

/* Header */
.ais-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 4px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ais-tabs {
  display: flex;
  gap: 2px;
}
.ais-tab {
  padding: 14px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s var(--ease);
}
.ais-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.ais-tab:hover:not(.active) { color: var(--text-primary); }
.ais-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.ais-close:hover { background: var(--bg-card); color: var(--text-primary); }

/* Panels */
.ais-panel { display: none; flex: 1; overflow-y: auto; }
.ais-panel.active { display: flex; flex-direction: column; }

/* Prompts panel */
.ais-prompt-section {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ais-prompt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ais-prompt-top label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
}
.ais-prompt-top select {
  font-size: 0.84rem;
  padding: 5px 28px 5px 10px;
}
.ais-prompt-status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}
.ais-prompt-status.default {
  background: var(--bg-card);
  color: var(--text-muted);
}
.ais-prompt-status.custom {
  background: rgba(78, 205, 196, 0.15);
  color: var(--accent);
}
.ais-textarea-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
}
.ais-textarea-label textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text-primary);
  resize: vertical;
  min-height: 140px;
  transition: border-color 0.15s;
}
.ais-textarea-label textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}
.ais-prompt-actions {
  display: flex;
  gap: 10px;
}
.ais-btn {
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}
.ais-btn:hover { border-color: var(--accent-dim); color: var(--text-primary); }
.ais-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.ais-btn.primary:hover { opacity: 0.85; }

/* Format details */
.ais-format-details {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.ais-format-details summary {
  cursor: pointer;
  padding: 6px 0;
  font-weight: 500;
}
.ais-format-text {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-muted);
}

/* Knowledge Base panel */
.ais-kb-section {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.ais-kb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ais-kb-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}
.ais-upload-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.ais-kb-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.ais-kb-empty {
  color: var(--text-muted);
  font-size: 0.84rem;
  padding: 24px 0;
  text-align: center;
}
.ais-kb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
}
.ais-kb-row:hover { border-color: var(--accent-dim); }
.ais-kb-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.ais-kb-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}
.ais-kb-name:hover { text-decoration-color: var(--accent); }
.ais-kb-size {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ais-kb-del {
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.ais-kb-del:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* Preview */
.ais-kb-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  max-height: 200px;
  display: flex;
  flex-direction: column;
}
.ais-kb-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.ais-kb-preview-close {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.ais-kb-preview-close:hover { background: var(--bg-panel); color: var(--text-primary); }
.ais-kb-preview-content {
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-y: auto;
  color: var(--text-primary);
  background: var(--bg);
}

/* Mobile */
@media (max-width: 768px) {
  .ais-dialog { max-height: 92vh; border-radius: 12px 12px 0 0; align-self: flex-end; width: 100%; }
  .ais-prompt-section, .ais-kb-section { padding: 14px; }
  .ais-kb-name { max-width: 180px; }
}
