/* ==========================================================================
   Sonexa — AI Voice Studio
   System-aware theme: dark by default, light when system prefers light
   Claude.ai-inspired elegance
   ========================================================================== */

/* ——— DARK THEME (default) ——— */
:root {
  color-scheme: dark;

  --bg:              #151515;
  --bg-sidebar:      #1a1a1a;
  --surface:         rgba(255, 255, 255, 0.05);
  --surface-hover:   rgba(255, 255, 255, 0.08);
  --surface-muted:   #202020;

  --border:          rgba(255, 255, 255, 0.08);
  --border-strong:   rgba(255, 255, 255, 0.12);
  --border-focus:    rgba(217, 119, 6, 0.50);

  --text-primary:    #f3efe8;
  --text-secondary:  #b4aba1;
  --text-tertiary:   #8c847a;
  --text-inverse:    #1a1612;

  --accent:          #d97706;
  --accent-hover:    #f59e0b;
  --accent-soft:     rgba(217, 119, 6, 0.16);
  --accent-glow:     rgba(245, 158, 11, 0.35);

  --success:         #22c55e;
  --warning:         #f59e0b;
  --error:           #ef4444;

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.28);
  --shadow-lg:  0 12px 40px rgba(0, 0, 0, 0.38);
  --shadow-xl:  0 24px 64px rgba(0, 0, 0, 0.45);

  --transition:       all 180ms cubic-bezier(0.2, 0, 0, 1);
  --transition-slow:  all 320ms cubic-bezier(0.2, 0, 0, 1);

  --radius-sm:  10px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono:  "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w:  260px;
  --header-h:   56px;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

/* ——— LIGHT THEME (system preference, only when no manual override) ——— */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;

    --bg:              #FAFAF8;
    --bg-sidebar:      #F5F3EF;
    --surface:         #FFFFFF;
    --surface-hover:   #F8F6F2;
    --surface-muted:   #F0EDE8;

    --border:          rgba(0, 0, 0, 0.06);
    --border-strong:   rgba(0, 0, 0, 0.10);
    --border-focus:    rgba(204, 120, 50, 0.45);

    --text-primary:    #1A1612;
    --text-secondary:  #746D65;
    --text-tertiary:   #A39E97;
    --text-inverse:    #FFFFFF;

    --accent:          #CC7832;
    --accent-hover:    #B56A28;
    --accent-soft:     rgba(204, 120, 50, 0.10);
    --accent-glow:     rgba(204, 120, 50, 0.20);

    --success:         #2D9C5A;
    --warning:         #CC9A22;
    --error:           #CC4444;

    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg:  0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-xl:  0 24px 64px rgba(0, 0, 0, 0.10);
  }
}

/* ——— LIGHT THEME (manual override) ——— */
:root[data-theme="light"] {
  color-scheme: light;

  --bg:              #FAFAF8;
  --bg-sidebar:      #F5F3EF;
  --surface:         #FFFFFF;
  --surface-hover:   #F8F6F2;
  --surface-muted:   #F0EDE8;

  --border:          rgba(0, 0, 0, 0.06);
  --border-strong:   rgba(0, 0, 0, 0.10);
  --border-focus:    rgba(204, 120, 50, 0.45);

  --text-primary:    #1A1612;
  --text-secondary:  #746D65;
  --text-tertiary:   #A39E97;
  --text-inverse:    #FFFFFF;

  --accent:          #CC7832;
  --accent-hover:    #B56A28;
  --accent-soft:     rgba(204, 120, 50, 0.10);
  --accent-glow:     rgba(204, 120, 50, 0.20);

  --success:         #2D9C5A;
  --warning:         #CC9A22;
  --error:           #CC4444;

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg:  0 12px 40px rgba(0, 0, 0, 0.08);
  --shadow-xl:  0 24px 64px rgba(0, 0, 0, 0.10);
}

/* ——— DARK THEME (manual override, same as default) ——— */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:              #151515;
  --bg-sidebar:      #1a1a1a;
  --surface:         rgba(255, 255, 255, 0.05);
  --surface-hover:   rgba(255, 255, 255, 0.08);
  --surface-muted:   #202020;

  --border:          rgba(255, 255, 255, 0.08);
  --border-strong:   rgba(255, 255, 255, 0.12);
  --border-focus:    rgba(217, 119, 6, 0.50);

  --text-primary:    #f3efe8;
  --text-secondary:  #b4aba1;
  --text-tertiary:   #8c847a;
  --text-inverse:    #1a1612;

  --accent:          #d97706;
  --accent-hover:    #f59e0b;
  --accent-soft:     rgba(217, 119, 6, 0.16);
  --accent-glow:     rgba(245, 158, 11, 0.35);

  --success:         #22c55e;
  --warning:         #f59e0b;
  --error:           #ef4444;

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.28);
  --shadow-lg:  0 12px 40px rgba(0, 0, 0, 0.38);
  --shadow-xl:  0 24px 64px rgba(0, 0, 0, 0.45);
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

img, svg { display: block; max-width: 100%; }

/* ----------------------------- App Container ----------------------------- */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ----------------------------- Top Bar (universal) ----------------------------- */
.top-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  padding-top: var(--sat);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 80;
  flex-shrink: 0;
}

.hamburger-btn {
  width: 44px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  pointer-events: auto;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:active {
  background: var(--surface-hover);
}
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--transition);
  transform-origin: center;
}

/* Animated hamburger → X */
.hamburger-btn.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.is-open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.hamburger-btn.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.top-bar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar-brand .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: var(--text-inverse);
  flex-shrink: 0;
}
.top-bar-brand .logo-mark svg {
  width: 18px;
  height: 18px;
}

.top-bar-brand .brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.top-bar-brand .logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.top-bar-brand .beta-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 6px;
}

.top-bar-spacer {
  flex: 1;
}

/* ----------------------------- App Body (sidebar + main) ----------------------------- */
.app-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  overflow: visible;
}

/* ----------------------------- Sidebar ----------------------------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 280ms cubic-bezier(0.2, 0, 0, 1);
  overflow: hidden;
}

.navbar.is-open {
  transform: translateX(0);
}

.navbar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--sat);
}

.navbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.navbar-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: var(--transition);
}
.navbar-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: var(--text-inverse);
  flex-shrink: 0;
}
.logo-mark svg { width: 18px; height: 18px; }

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.beta-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 6px;
}

/* Nav drawer */
.nav-drawer {
  flex: 1;
  padding: 4px 12px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-group { margin-bottom: 20px; }

.nav-group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  padding: 0 8px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  text-align: left;
  min-height: 44px;
}

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

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  position: relative;
}
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-link.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.nav-link.is-disabled:hover {
  background: transparent;
  color: var(--text-tertiary);
}

.coming-soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  background: var(--surface-muted);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Theme switcher (used on settings page) */
.theme-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: var(--transition);
  min-height: 40px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.theme-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.theme-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.theme-btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.theme-btn-icon svg {
  width: 100%;
  height: 100%;
}

/* Docs page */
.docs-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 0;
}

.docs-header {
  margin-bottom: 32px;
}

.docs-title {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.docs-subtitle {
  max-width: 620px;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.7;
}

.docs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  min-height: 320px;
}

.docs-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  animation: docs-empty-pulse 3s ease-in-out infinite;
}

.docs-empty-icon svg {
  width: 32px;
  height: 32px;
}

@keyframes docs-empty-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.05); opacity: 1; }
}

.docs-empty-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.docs-empty-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-tertiary);
  max-width: 420px;
}

.docs-actions {
  margin-top: 32px;
}

/* Settings page */
.settings-section {
  max-width: 700px;
  margin: 0 auto;
  padding: 48px 0;
}

.settings-header {
  margin-bottom: 32px;
}

.settings-title {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.settings-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.65;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}
.settings-item:hover {
  border-color: var(--border-strong);
}

.settings-item-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.settings-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.settings-item-icon svg {
  width: 20px;
  height: 20px;
}

.settings-item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.settings-item-desc {
  font-size: 13px;
  color: var(--text-tertiary);
}

.settings-item-control {
  flex-shrink: 0;
}

/* Theme preview mini-window */
.theme-preview {
  width: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.theme-preview-bar {
  height: 8px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}

.theme-preview-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-preview-line {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

.settings-actions {
  margin-top: 32px;
}

/* Overlay */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.40);
  z-index: 150;
  opacity: 0;
  transition: opacity 250ms ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay.visible { display: block; }
.overlay.open { opacity: 1; }

/* ----------------------------- Main Content ----------------------------- */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 280ms cubic-bezier(0.2, 0, 0, 1);
}

.page {
  display: none;
  padding: 0 32px;
}
.page.active {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

/* ----------------------------- Welcome Page ----------------------------- */
.welcome-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
}

.welcome-card {
  max-width: 680px;
  width: 100%;
  text-align: center;
  padding: 40px 0;
}

.welcome-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 16px;
}

.welcome-title {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.welcome-title strong { color: var(--accent); }

.welcome-subtitle {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 28px;
}

.welcome-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.welcome-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  transition: var(--transition);
}

.welcome-spoilers {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.spoiler-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  transition: var(--transition);
  cursor: pointer;
}
.spoiler-card summary {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.spoiler-card summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 300;
  color: var(--text-tertiary);
  transition: var(--transition);
}
.spoiler-card[open] summary::after { content: "\2212"; }
.spoiler-card p {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* ----------------------------- Buttons ----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 8px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.btn-secondary:active { transform: translateY(0); }

.btn-large {
  padding: 14px 28px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

.btn-icon-only {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  transition: var(--transition);
}
.btn-icon-only:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* ----------------------------- Icons ----------------------------- */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon svg { width: 100%; height: 100%; }

/* ----------------------------- Form Elements ----------------------------- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.text-input {
  width: 100%;
  min-height: 180px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  resize: vertical;
  transition: var(--transition);
  -webkit-appearance: none;
}
.text-input::placeholder { color: var(--text-tertiary); }
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.voice-select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238c847a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  min-height: 48px;
}
.voice-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.char-count {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: right;
}

/* ----------------------------- Status ----------------------------- */
.status-section { margin-bottom: 16px; }

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.status-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.status.idle .status-icon { background: var(--accent-soft); color: var(--accent); }
.status.busy .status-icon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status.success .status-icon { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.status.error .status-icon { background: rgba(239, 68, 68, 0.15); color: var(--error); }

.status-title { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.status-message { font-size: 13px; color: var(--text-secondary); }

/* ----------------------------- Player ----------------------------- */
.player-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.player-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.audio-player {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  outline: none;
  min-height: 44px;
}

.player-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ----------------------------- Footer ----------------------------- */
.footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.footer p { font-size: 13px; color: var(--text-tertiary); }

/* ----------------------------- About Page ----------------------------- */
.about-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 0;
}

.about-title {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.about-intro {
  max-width: 620px;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.7;
}

.about-header { margin-bottom: 32px; }

.about-content {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}
.about-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.about-card h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}
.about-card p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.about-actions { margin-top: 32px; }

/* ----------------------------- TTS Service Page ----------------------------- */
.service-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 0 48px;
}

.service-head { margin-bottom: 28px; }

.service-kicker {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 8px;
}

.service-title {
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.service-subtitle {
  max-width: 560px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.65;
}

.service-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.service-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
  min-height: 44px;
}
.service-step:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.service-step strong {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
}

.service-step span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* TTS Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

.column, .form-group { min-width: 0; }
.text-input, .voice-select, .btn-large { width: 100%; min-width: 0; }
.text-input { min-height: 220px; resize: vertical; }
.player-section { overflow: hidden; }
.audio-player { width: 100%; max-width: 100%; }
.player-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* Easter egg */
.easter-egg {
  margin-top: 48px;
  text-align: center;
  opacity: 0.15;
  font-size: 12px;
  color: var(--text-tertiary);
  transition: opacity 600ms ease;
  cursor: default;
  user-select: none;
}
.easter-egg:hover {
  opacity: 0.7;
}

/* ----------------------------- Scrollbar ----------------------------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

::selection { background: var(--accent-soft); color: var(--text-primary); }

/* ==========================================================================
   RESPONSIVE — Desktop: sidebar pushes content (drawer)
   ========================================================================== */

/* Desktop: sidebar pushes content — controlled via JS (margin-left on app-body) */
@media (min-width: 769px) {
  .navbar.is-open {
    box-shadow: var(--shadow-xl);
  }

  .service-shell {
    padding-top: 56px;
  }
}

/* ==========================================================================
   RESPONSIVE — Tablet
   ========================================================================== */
@media (max-width: 1024px) {
  .about-content { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   RESPONSIVE — Mobile (< 768px): full-screen overlay menu
   ========================================================================== */
@media (max-width: 768px) {
  .navbar {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 200;
  }

  .page { padding: 0 16px; }

  .welcome-shell { padding: 24px 0 32px; align-items: flex-start; }
  .welcome-card { padding: 20px 0; }
  .welcome-eyebrow { font-size: 12px; margin-bottom: 12px; }
  .welcome-title { font-size: clamp(1.5rem, 7vw, 2rem); margin-bottom: 12px; }
  .welcome-subtitle { font-size: 15px; margin-bottom: 20px; }

  .welcome-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
    margin-bottom: 20px;
  }
  .welcome-actions .btn { width: 100%; justify-content: center; }
  .welcome-pills { gap: 6px; }
  .hero-pill { font-size: 11px; padding: 5px 10px; }
  .welcome-spoilers { margin-top: 24px; }
  .spoiler-card { padding: 12px 14px; }

  /* TTS mobile */
  .service-shell { padding: 24px 0 36px; }
  .service-head { margin-bottom: 20px; }
  .service-kicker { font-size: 11px; }
  .service-title { font-size: clamp(1.5rem, 6vw, 2rem); margin-bottom: 8px; }
  .service-subtitle { font-size: 14px; }
  .service-steps { grid-template-columns: 1fr; gap: 8px; margin-bottom: 20px; }
  .service-step { padding: 12px 14px; }
  .panel { padding: 16px; border-radius: var(--radius-lg); }
  .panel-grid { grid-template-columns: 1fr; gap: 16px; }
  .text-input { min-height: 140px; font-size: 16px; }
  .player-section { border-radius: var(--radius-md); padding: 16px; }
  .player-actions { grid-template-columns: 1fr; }

  /* About mobile */
  .about-section { padding: 24px 0; }

  /* Docs mobile */
  .docs-section { padding: 24px 0; }
  .docs-header { margin-bottom: 20px; }
  .docs-title { font-size: 1.6rem; }
  .docs-subtitle { font-size: 15px; }
  .docs-empty { padding: 40px 16px; min-height: 240px; }
  .docs-empty-icon { width: 52px; height: 52px; }
  .docs-empty-icon svg { width: 26px; height: 26px; }
  .docs-empty-title { font-size: 18px; }
  .docs-empty-text { font-size: 13px; }
  .about-header { margin-bottom: 20px; }
  .about-title { font-size: 1.6rem; }
  .about-intro { font-size: 15px; }
  .about-content { grid-template-columns: 1fr; gap: 12px; }
  .about-card { padding: 18px; }

  /* Settings mobile */
  .settings-section { padding: 24px 0; }
  .settings-header { margin-bottom: 20px; }
  .settings-title { font-size: 1.6rem; }
  .settings-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }
  .settings-item-control { width: 100%; }
  .theme-options { width: 100%; }
  .theme-btn { flex: 1; padding: 8px 10px; font-size: 12px; }
  .theme-preview { width: 100%; }

  .footer {
    padding: 16px;
    padding-bottom: calc(16px + var(--sab));
  }
}

@media (max-width: 400px) {
  .page { padding: 0 12px; }
  .welcome-title { font-size: 1.4rem; }
  .welcome-subtitle { font-size: 14px; }
  .about-title { font-size: 1.5rem; }
}
