/* ==========================================================================
   VCF TRANSLATOR PRO — RESPONSIVE DESIGN SYSTEM (MOBILE-FIRST)
   ========================================================================== */

:root {
  --bg-main: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-card: #ffffff;
  --bg-inset: #f1f5f9;
  --border-light: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --accent-primary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  --accent-blue: #2563eb;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #0ea5e9;
  --info-bg: #f0f9ff;

  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-card: 0 0 0 1px rgba(0,0,0,0.06), 0 4px 20px -2px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.06), 0 8px 10px -6px rgba(0,0,0,0.03);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Background Grid ── */
.bg-grid-overlay {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 50% 0%, rgba(124,58,237,0.04) 0%, transparent 60%),
    linear-gradient(to right, rgba(226,232,240,0.4) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(226,232,240,0.4) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.app-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Container ── */
.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}
@media (max-width: 768px)  { .container { padding: 0 16px; } }
@media (max-width: 480px)  { .container { padding: 0 12px; } }

/* ==========================================================================
   HEADER & NAVBAR
   ========================================================================== */
.main-header {
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 8px 0;
  gap: 12px;
  flex-wrap: nowrap;
}

/* Brand */
.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 0;
}

.brand-icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text h1 {
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.2;
}

.brand-badge {
  font-size: 0.6rem;
  background: #f3e8ff;
  color: var(--accent-primary);
  border: 1px solid #d8b4fe;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .brand-text p { display: none; }
  .brand-icon-box { width: 36px; height: 36px; font-size: 1rem; }
}

/* Nav actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.engine-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .engine-status-badge .full-label { display: none; }
  .engine-status-badge .short-label { display: inline; }
}
@media (min-width: 641px) {
  .engine-status-badge .short-label { display: none; }
}

.btn-header {
  padding: 7px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-header:hover { background: var(--bg-subtle); border-color: #cbd5e1; }

/* Hide speed label on small screens */
@media (max-width: 520px) {
  .speed-label { display: none; }
}

/* ==========================================================================
   FEATURE TABS BAR
   ========================================================================== */
.feature-tabs-bar {
  padding: 14px 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border-light);
}
.feature-tabs-bar::-webkit-scrollbar { display: none; }

.feature-tabs-wrapper {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-inset);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  min-width: max-content;
}

.tab-btn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { background: #fff; color: var(--accent-primary); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */
.main-content {
  flex: 1;
  padding: 20px 0 60px;
}

.tab-panel { display: none; animation: fadeInUp 0.28s ease; }
.tab-panel.active { display: block; }

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

/* ==========================================================================
   TONE SELECTOR STRIP
   ========================================================================== */
.tone-selector-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.tone-selector-strip::-webkit-scrollbar { display: none; }

.tone-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.tone-pill-btn {
  padding: 5px 12px;
  background: #fff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.tone-pill-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.tone-pill-btn.active { background: #f3e8ff; border-color: var(--accent-primary); color: var(--accent-primary); }

/* ==========================================================================
   TRANSLATION STUDIO GRID (TWO CARDS SIDE BY SIDE)
   ========================================================================== */
.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

/* Stack vertically on tablet and mobile */
@media (max-width: 860px) {
  .studio-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* Translation Cards */
.trans-box-card {
  background: #fff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 380px;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.trans-box-card:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

/* Card Header */
.trans-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle);
  gap: 8px;
  flex-wrap: nowrap;
  min-height: 52px;
}

.lang-select-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
}
.lang-select-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-select-pill:hover { border-color: var(--accent-primary); background: #faf5ff; }

.flag-ico {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.clear-btn {
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.clear-btn:hover { border-color: var(--danger); color: var(--danger); }

.detected-badge {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent-primary);
  background: #f3e8ff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Main textarea */
.trans-textarea {
  flex: 1;
  width: 100%;
  padding: 16px;
  border: none;
  outline: none;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  font-family: var(--font-sans);
  color: var(--text-main);
  background: transparent;
  resize: none;
  min-height: 200px;
  line-height: 1.7;
}
.trans-textarea::placeholder { color: var(--text-dim); }

/* Output box */
.trans-output-box {
  flex: 1;
  padding: 16px;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  line-height: 1.7;
  color: var(--text-main);
  min-height: 200px;
  word-break: break-word;
  white-space: pre-wrap;
  user-select: text;
  overflow-y: auto;
}

/* Microscope words */
.micro-word {
  display: inline-block;
  padding: 0 2px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.micro-word:hover { background: #ede9fe; color: #6d28d9; text-decoration: underline; }

/* Card Footer */
.trans-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  background: #fff;
  gap: 8px;
  flex-wrap: nowrap;
  min-height: 52px;
}

.footer-actions-left,
.footer-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-action-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.icon-action-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); background: #faf5ff; }
.icon-action-btn.active {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: pulseRed 1.5s infinite;
}

@keyframes pulseRed {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.stats-text {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================================
   CULTURAL NUANCES CARD (BELOW STUDIO)
   ========================================================================== */
.nuances-card {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
}

@media (max-width: 640px) {
  .nuances-card { padding: 14px 16px; }
}

.nuances-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.nuances-card-header h3 {
  font-size: clamp(0.9rem, 2vw, 1rem);
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ==========================================================================
   MULTI-LANGUAGE MATRIX (TAB 2)
   ========================================================================== */
.panel-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

@media (max-width: 640px) { .panel-card { padding: 16px 14px; } }

.panel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.panel-card-header h2 {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-card-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.matrix-trans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .matrix-trans-grid { grid-template-columns: 1fr; }
}

.matrix-trans-card {
  background: #fff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}
.matrix-trans-card:hover { border-color: var(--accent-primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.matrix-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.matrix-lang-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  min-width: 0;
  flex: 1;
}

.matrix-card-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.matrix-trans-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-main);
  word-break: break-word;
}

/* ==========================================================================
   SUBTITLE / FILE TRANSLATOR (TAB 3)
   ========================================================================== */
.file-dropzone-box {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-xl);
  padding: 36px 20px;
  text-align: center;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
}
.file-dropzone-box:hover { border-color: var(--accent-primary); background: #faf5ff; }

.file-previews-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

@media (max-width: 640px) {
  .file-previews-grid { grid-template-columns: 1fr; }
}

.file-preview-textarea {
  width: 100%;
  height: 180px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-subtle);
  resize: vertical;
  min-height: 120px;
}

.file-preview-textarea.output { background: #fff; }

/* ==========================================================================
   CONVERSATION FACE-À-FACE (TAB 4)
   ========================================================================== */
.conversation-arena-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 700px) {
  .conversation-arena-grid { grid-template-columns: 1fr; gap: 14px; }
}

.speaker-deck-card {
  background: #fff;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 480px) { .speaker-deck-card { padding: 14px; } }

.speaker-deck-card.speaker-a { border-top: 5px solid #2563eb; }
.speaker-deck-card.speaker-b { border-top: 5px solid #10b981; }

.speaker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.speaker-header-title {
  font-weight: 800;
  font-size: clamp(0.9rem, 2vw, 1.05rem);
}

.speaker-speech-bubble {
  width: 100%;
  height: 130px;
  padding: 14px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  font-family: var(--font-sans);
  font-size: 1rem;
  resize: none;
  transition: border-color 0.2s ease;
}
.speaker-speech-bubble:focus { outline: none; border-color: var(--accent-primary); }

.big-mic-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.speaker-a .big-mic-btn { background: #2563eb; }
.speaker-b .big-mic-btn { background: #10b981; }
.big-mic-btn:hover { transform: scale(1.1); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }

/* ==========================================================================
   PHRASEBOOK (TAB 5)
   ========================================================================== */
.phrasebook-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  gap: 12px;
  flex-wrap: nowrap;
}

@media (max-width: 520px) {
  .phrasebook-entry { flex-wrap: wrap; }
}

.phrasebook-entry-text { min-width: 0; flex: 1; }
.phrasebook-src { font-weight: 700; color: var(--text-main); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phrasebook-tgt { font-size: 0.95rem; color: var(--accent-primary); font-weight: 800; margin-top: 2px; }
.phrasebook-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* ==========================================================================
   LANGUAGE PICKER MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: flex-end;  /* Bottom sheet on mobile */
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 20px; }
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #fff;
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

@media (min-width: 600px) {
  .modal-dialog {
    border-radius: var(--radius-xl);
    animation: modalPop 0.3s cubic-bezier(0.34,1.56,0.64,1);
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes modalPop {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-search-box {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

.modal-search-input {
  width: 100%;
  padding: 10px 16px 10px 38px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  outline: none;
  background: #fff;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>');
  background-repeat: no-repeat;
  background-position: 12px center;
  font-family: var(--font-sans);
  transition: border-color 0.2s ease;
}
.modal-search-input:focus { border-color: var(--accent-primary); }

.modal-lang-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px;
  align-content: start;
}

@media (max-width: 480px) {
  .modal-lang-list { grid-template-columns: repeat(2, 1fr); }
}

.lang-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.12s ease;
  border: 1px solid transparent;
}
.lang-list-item:hover { background: var(--bg-inset); }
.lang-list-item.selected { background: #f3e8ff; border-color: #d8b4fe; }

.lang-item-name {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-item-native { font-size: 0.72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   MICROSCOPE RESULT BOX
   ========================================================================== */
.microscope-box {
  background: #faf5ff;
  border: 1.5px solid #d8b4fe;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-top: 14px;
  animation: fadeInUp 0.25s ease;
}

@media (max-width: 640px) { .microscope-box { padding: 12px 14px; } }

/* ==========================================================================
   UTILITIES
   ========================================================================== */
.btn-primary {
  padding: 9px 18px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(124,58,237,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(124,58,237,0.3); }

/* Spinning loader */
.spinner-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  gap: 10px;
  text-align: center;
}

/* Print */
@media print {
  .main-header, .feature-tabs-bar, .nav-actions { display: none !important; }
}


/* ==========================================================================
   VOICE PERSONA CHIPS BAR & INTERACTIVE PREVIEW
   ========================================================================== */
.persona-chips-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fdfcff;
  border-bottom: 1px dashed var(--border-light);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.persona-chips-bar::-webkit-scrollbar { display: none; }

.persona-bar-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.persona-chips-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.persona-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.persona-chip-btn:hover {
  border-color: var(--accent-primary);
  background: #faf5ff;
  transform: translateY(-1px);
}

.persona-chip-btn.active {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.persona-avatar {
  font-size: 0.95rem;
}

.persona-name {
  font-weight: 800;
}

.persona-gender {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--bg-inset);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

.persona-chip-btn.active .persona-gender {
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-primary);
}

.icon-action-btn.playing {
  background: #7c3aed !important;
  color: #ffffff !important;
  border-color: #7c3aed !important;
  animation: pulsePurple 1.5s infinite;
}

@keyframes pulsePurple {
  0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(124, 58, 237, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}
