/* ============================================================
   CSS RESET & BASE
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Light Mode (Default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f8fa;
  --bg-tertiary: #f1f3f6;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-navbar: rgba(255,255,255,0.85);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  --sidebar-width: 260px;
  --navbar-height: 56px;
  /* Dynamic color tokens */
  --card-visual-bg: linear-gradient(135deg, #f8fafc, #f1f3f6);
  --dubbing-banner-bg: linear-gradient(135deg, #f1f5f9 0%, #f8fafc 100%);
  --card-hover-border: #d0d5dd;
  --card-tag-hover-bg: #e8eaee;
  --project-selector-hover: #e8eaee;
  --globe-ring-1: #d0d5dd;
  --globe-ring-2: #cbd5e1;
  --globe-ring-3: #94a3b8;
  --download-btn-hover: #e2e8f0;
}

/* Dark Mode */
body.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-navbar: rgba(15,23,42,0.92);
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --border-light: #1e293b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --card-visual-bg: linear-gradient(135deg, #1a2332, #1e293b);
  --dubbing-banner-bg: linear-gradient(135deg, #1a2332 0%, #1e293b 100%);
  --card-hover-border: #475569;
  --card-tag-hover-bg: #334155;
  --project-selector-hover: #334155;
  --globe-ring-1: #475569;
  --globe-ring-2: #334155;
  --globe-ring-3: #64748b;
  --download-btn-hover: #334155;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  transition: background 0.25s ease, color 0.25s ease;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; outline: none; border: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
body {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 0 0 12px;
  transition: background 0.25s ease, border-color 0.25s ease;
  z-index: 50;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 6px; }

/* --- Sidebar Header --- */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-light);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.project-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.project-selector:hover { background: var(--project-selector-hover); }

/* --- Navigation --- */
.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 16px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-blue);
  color: #fff;
}

.nav-item svg { flex-shrink: 0; }

/* --- Pinned Section --- */
.sidebar-pinned {
  flex: 1;
  overflow-y: auto;
}

.sidebar-pinned::-webkit-scrollbar { width: 3px; }
.sidebar-pinned::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 6px; }

.pinned-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px 6px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 450;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  position: relative;
}

.pinned-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.pinned-item svg { flex-shrink: 0; }

.badge-new {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-blue);
  background: rgba(59,130,246,0.1);
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.6;
}

/* --- Search Bar --- */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 16px 0;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: border 0.2s, background 0.25s;
}

.sidebar-search:focus-within {
  border-color: var(--accent-blue);
  background: var(--bg-primary);
}

.sidebar-search input {
  flex: 1;
  background: transparent;
  font-size: 12.5px;
  color: var(--text-primary);
}

.sidebar-search input::placeholder { color: var(--text-muted); font-size: 12.5px; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

/* --- Top Navbar --- */
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: var(--navbar-height);
  min-height: var(--navbar-height);
  background: var(--bg-navbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.nav-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.nav-btn.text-btn {
  width: auto;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.nav-btn.text-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.nav-btn.primary-btn {
  width: auto;
  padding: 0 14px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.nav-btn.primary-btn:hover { background: #2563eb; }

.theme-toggle {
  margin-left: 4px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  margin-left: 6px;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.avatar:hover { transform: scale(1.05); }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard {
  flex: 1;
  padding: 28px 28px 40px;
  max-width: 1200px;
}

/* --- Hero Section --- */
.hero-section {
  margin-bottom: 28px;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: border-color 0.2s;
}

.hero-badge:hover { border-color: var(--accent-blue); }

.hero-badge svg { flex-shrink: 0; }

.badge-divider {
  width: 1px;
  height: 12px;
  background: var(--border-color);
}

.hero-subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ============================================================
   CARDS GRID
   ============================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--card-hover-border);
  transform: translateY(-2px);
}

/* Card Visual */
.card-visual {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-visual-bg);
  position: relative;
  overflow: hidden;
}

/* Wave Visual */
.wave-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 100%;
  padding: 0 16px;
}

.wave-bar {
  width: 4px;
  background: linear-gradient(to top, var(--accent-blue), var(--accent-purple));
  border-radius: 4px;
  opacity: 0.4;
  animation: wavePulse 1.8s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0.0s; }
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }
.wave-bar:nth-child(4) { animation-delay: 0.45s; }
.wave-bar:nth-child(5) { animation-delay: 0.6s; }
.wave-bar:nth-child(6) { animation-delay: 0.75s; }
.wave-bar:nth-child(7) { animation-delay: 0.9s; }
.wave-bar:nth-child(8) { animation-delay: 1.05s; }
.wave-bar:nth-child(9) { animation-delay: 1.2s; }
.wave-bar:nth-child(10) { animation-delay: 1.35s; }
.wave-bar:nth-child(11) { animation-delay: 1.5s; }
.wave-bar:nth-child(12) { animation-delay: 1.65s; }

@keyframes wavePulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

.wave-play-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.25s ease;
}

.card:hover .wave-play-btn {
  opacity: 1;
  transform: scale(1);
}

/* Flow Visual */
.flow-diagram {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px;
}

.flow-node { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.flow-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, var(--accent-blue), var(--accent-purple), var(--accent-amber), var(--accent-green));
  min-width: 16px;
  opacity: 0.6;
}

.flow-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 6px 14px 0;
  position: absolute;
  bottom: 14px;
}

.flow-labels span {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Clone Visual */
.clone-ring {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Card Body */
.card-body {
  padding: 16px 18px 18px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border-radius: 100px;
  transition: background 0.2s;
}

.card:hover .card-tag { background: var(--card-tag-hover-bg); }

/* ============================================================
   DUBBING BANNER
   ============================================================ */
.dubbing-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--dubbing-banner-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  gap: 24px;
  transition: box-shadow 0.2s, background 0.25s, border-color 0.25s;
}

.dubbing-banner:hover {
  box-shadow: var(--shadow-md);
}

.dubbing-text {
  flex: 1;
  min-width: 0;
}

.dubbing-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.alpha-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-blue);
  background: rgba(59,130,246,0.1);
  padding: 2px 8px;
  border-radius: 100px;
  vertical-align: middle;
  margin-left: 4px;
}

.dubbing-desc {
  font-size: 13.5px;
  color: var(--text-tertiary);
}

/* Dubbing Globe */
.dubbing-globe {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.globe-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  animation: globeSpin 12s linear infinite;
}

.globe-ring-1 { width: 100px; height: 100px; border-color: var(--globe-ring-1); }
.globe-ring-2 { width: 70px; height: 70px; border-color: var(--globe-ring-2); animation-duration: 8s; animation-direction: reverse; }
.globe-ring-3 { width: 40px; height: 40px; border-color: var(--globe-ring-3); animation-duration: 6s; }

@keyframes globeSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.globe-center-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue);
  opacity: 0.4;
}

.globe-languages {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.lang-label {
  position: absolute;
  font-size: 8px;
  font-weight: 500;
  color: var(--text-tertiary);
  white-space: nowrap;
  opacity: 0;
  animation: fadeInLang 0.5s ease forwards;
}

.lang-label:nth-child(1) { animation-delay: 0.0s; }
.lang-label:nth-child(2) { animation-delay: 0.1s; }
.lang-label:nth-child(3) { animation-delay: 0.2s; }
.lang-label:nth-child(4) { animation-delay: 0.3s; }
.lang-label:nth-child(5) { animation-delay: 0.4s; }
.lang-label:nth-child(6) { animation-delay: 0.5s; }
.lang-label:nth-child(7) { animation-delay: 0.6s; }
.lang-label:nth-child(8) { animation-delay: 0.7s; }

@keyframes fadeInLang {
  to { opacity: 1; }
}

/* ============================================================
   SIDEBAR TOGGLE BUTTON (Mobile)
   ============================================================ */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: var(--bg-tertiary);
}

/* ============================================================
   RESPONSIVE — TABLETS
   ============================================================ */
@media (max-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dubbing-banner {
    flex-direction: column;
    text-align: center;
    padding: 24px 20px;
  }

  .dubbing-globe {
    width: 100px;
    height: 100px;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  /* Sidebar becomes a slide-in overlay */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease, background 0.25s ease;
    box-shadow: var(--shadow-lg);
    height: 100vh;
    height: 100dvh;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Mobile overlay backdrop */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .main-content {
    width: 100%;
    min-width: 0;
  }

  .top-navbar {
    padding: 0 12px 0 12px;
  }

  .navbar-right {
    gap: 4px;
  }

  .dashboard {
    padding: 16px 14px 32px;
  }

  .hero-title {
    font-size: 20px;
  }

  .hero-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .hero-badge {
    font-size: 10.5px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .card-visual {
    height: 120px;
  }

  /* Hide text-only nav buttons on mobile to prevent overlap */
  .nav-btn.text-btn {
    display: none;
  }

  /* Hide the notification bell on mobile */
  .nav-btn:not(.text-btn):not(.primary-btn):not(.theme-toggle):not(.mobile-menu-btn) {
    display: none;
  }

  /* Make primary btn smaller on mobile */
  .nav-btn.primary-btn {
    padding: 0 10px;
    font-size: 12px;
    height: 30px;
  }

  .theme-toggle {
    margin-left: 2px;
  }

  .avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
    margin-left: 4px;
  }

  .dubbing-banner {
    padding: 20px 16px;
  }

  .dubbing-title {
    font-size: 18px;
  }

  .dubbing-globe {
    width: 80px;
    height: 80px;
  }

  .globe-ring-1 { width: 72px; height: 72px; }
  .globe-ring-2 { width: 50px; height: 50px; }
  .globe-ring-3 { width: 30px; height: 30px; }

  .lang-label {
    font-size: 7px;
  }

  /* Show hamburger menu button on mobile */
  .mobile-menu-btn {
    display: flex;
  }

  /* Coming soon toast adjustments */
  .coming-soon-toast {
    white-space: normal;
    max-width: 90vw;
    text-align: center;
  }
}

/* On very small screens, also hide the Ask button */
@media (max-width: 400px) {
  .nav-btn.primary-btn {
    display: none;
  }

  .top-navbar {
    padding: 0 10px;
  }

  .section-title {
    font-size: 14px;
  }
}

/* ============================================================
   TTS MODAL
   ============================================================ */
.tts-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}

.tts-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.tts-modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.tts-modal.open .tts-modal-content {
  transform: translateY(0) scale(1);
}

.tts-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
}

.tts-modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.tts-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 0.15s;
}

.tts-close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.tts-body {
  padding: 20px 24px 24px;
}

.tts-provider-group {
  margin-bottom: 16px;
}

.tts-provider-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tts-provider-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s, background 0.25s, color 0.25s;
}

.tts-provider-select:focus {
  border-color: var(--accent-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.tts-provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
}

.tts-provider-badge.premium {
  background: linear-gradient(135deg, #f59e0b20, #f59e0b10);
  color: #d97706;
  border: 1px solid #f59e0b30;
}

.tts-provider-badge.standard {
  background: rgba(16,185,129,0.1);
  color: #059669;
  border: 1px solid rgba(16,185,129,0.2);
}

.tts-provider-badge.advanced {
  background: rgba(139,92,246,0.1);
  color: #7c3aed;
  border: 1px solid rgba(139,92,246,0.2);
}

.tts-voice-optgroup.premium {
  color: #d97706;
  font-weight: 600;
}

.tts-voice-optgroup.standard {
  color: #059669;
  font-weight: 600;
}

.tts-voice-optgroup.advanced {
  color: #7c3aed;
  font-weight: 600;
}

.tts-char-limit-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
}

.tts-form-group {
  margin-bottom: 16px;
}

.tts-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tts-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s, background 0.25s, color 0.25s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.tts-select:focus {
  border-color: var(--accent-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.tts-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.6;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  transition: border-color 0.2s, background 0.25s, color 0.25s;
}

.tts-textarea:focus {
  border-color: var(--accent-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.tts-textarea::placeholder {
  color: var(--text-muted);
}

.tts-char-count {
  display: block;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.tts-controls {
  margin-bottom: 12px;
}

.tts-generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 20px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  border: none;
  cursor: pointer;
}

.tts-generate-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.tts-generate-btn:active {
  transform: translateY(0);
}

.tts-generate-btn:disabled {
  cursor: not-allowed;
}

/* --- Status --- */
.tts-status {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.tts-status-success {
  background: rgba(16,185,129,0.1);
  color: #059669;
  border: 1px solid rgba(16,185,129,0.2);
}

.tts-status-error {
  background: rgba(239,68,68,0.08);
  color: #dc2626;
  border: 1px solid rgba(239,68,68,0.15);
}

/* --- Audio Player --- */
.tts-player {
  margin-bottom: 12px;
}

.tts-player audio {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-sm);
}

.tts-player audio::-webkit-media-controls-panel {
  background: var(--bg-tertiary);
}

.tts-player-actions {
  margin-top: 8px;
}

.tts-download-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.tts-download-btn:hover {
  background: var(--download-btn-hover);
  color: var(--text-primary);
}

/* --- Loading spinner --- */
.tts-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.tts-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   COMING SOON TOAST
   ============================================================ */
.coming-soon-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.coming-soon-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   DARK MODE — Element Overrides
   ============================================================ */
body.dark-mode .wave-play-btn circle {
  fill: #f1f5f9;
}

body.dark-mode .clone-ring circle[stroke="#e2e8f0"],
body.dark-mode .clone-ring circle[stroke="#cbd5e1"] {
  stroke: #475569;
}

body.dark-mode .coming-soon-toast {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

body.dark-mode .tts-modal-content {
  box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.2);
}

/* TTS modal adjustments on mobile */
@media (max-width: 768px) {
  .tts-modal {
    padding: 12px;
    align-items: flex-end;
  }

  .tts-modal-content {
    max-height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  .tts-modal.open .tts-modal-content {
    transform: translateY(0);
  }

  .tts-body {
    padding: 16px 18px 20px;
  }

  .tts-modal-header {
    padding: 14px 18px;
  }
}

/* ============================================================
   FLOATING GENERATE BUTTON
   ============================================================ */
.tts-float-generate-btn {
  position: fixed;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  transition: transform 0.15s ease, opacity 0.15s ease;
  z-index: 99999;
  pointer-events: auto;
}

.tts-float-generate-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.tts-float-generate-btn:active {
  transform: scale(0.95);
}

body.dark-mode .tts-float-generate-btn {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
