/* ═══════════════════════════════════════════════════════════════════════
   ba2ki speech studio — themed on the ba2ki.com design system
   (tokens copied from /var/www/ba2ki-pixazo/app/globals.css)
   ═══════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #0a0a0f;
  --foreground: #e9ecf2;
  --card: #12121a;
  --card-hover: #191924;
  --border: #272736;
  --muted: #8b93a3;
  --accent: #2b8fff;
  --accent-hover: #5cabff;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;

  /* aliases used by the studio widgets */
  --text: var(--foreground);
  --text-dim: var(--muted);
  --panel: var(--card);
  --panel-border: var(--border);
  --danger: var(--red);
  --input-bg: var(--card-hover);
}

[data-theme="light"] {
  color-scheme: light;
  --background: #f5f6fa;
  --foreground: #14161d;
  --card: #ffffff;
  --card-hover: #eef1f7;
  --border: #dfe3ec;
  --muted: #646c7c;
  --accent: #0a67e0;
  --accent-hover: #2b8fff;
}

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

html { background: var(--background); }
html, body { min-height: 100%; }

body {
  font-family: Geist, "Vazirmatn", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.7;
  /* the site's electric-blue halo at the top of every page */
  background-image: radial-gradient(1100px 480px at 50% -200px,
    rgb(43 143 255 / 0.09), transparent 65%);
  background-repeat: no-repeat;
}
[data-theme="light"] body {
  background-image: radial-gradient(1100px 480px at 50% -200px,
    rgb(10 103 224 / 0.06), transparent 65%);
}

/* ───────────────────────────── header */
.topnav { display: flex; gap: 8px; align-items: center; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 42px; padding: 6px 14px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 10px; color: var(--foreground);
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 85%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-family: Orbitron, Geist, sans-serif;
  font-weight: 700; font-size: 1.15rem; letter-spacing: 0.2em;
  color: var(--foreground);
}
.divider { width: 1px; height: 22px; background: var(--border); }
.title { font-size: 1rem; font-weight: 600; }
.badge {
  font-size: 0.68rem; padding: 2px 10px; border-radius: 999px;
  border: 1px color-mix(in srgb, var(--amber) 40%, transparent);
  color: var(--amber);
  font-weight: 600;
}
.top-actions { display: flex; gap: 8px; }

/* ───────────────────────────── layout */
.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
  max-width: 1280px;
  margin: 22px auto;
  padding: 0 20px;
  align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 14px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 10px;
}
.panel-head h2 {
  font-size: 0.78rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* ───────────────────────────── buttons & inputs */
.btn {
  border: none; cursor: pointer; font-family: inherit;
  border-radius: 10px; font-weight: 600; font-size: 0.88rem;
  padding: 9px 18px;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent; color: var(--foreground);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; border-radius: 8px; }
.btn-icon {
  width: 42px; height: 42px; padding: 0; font-size: 1rem;
  background: var(--accent); color: #fff; border-radius: 50%;
}
.icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--foreground); border-radius: 9px; padding: 5px 12px;
  cursor: pointer; font-weight: 700; font-family: inherit; font-size: 0.8rem;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

textarea {
  width: 100%; resize: vertical; min-height: 140px;
  background: var(--card-hover); color: var(--foreground);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 15px; font-family: inherit; font-size: 0.95rem; line-height: 2;
  transition: border-color 0.2s;
}
textarea:focus { outline: none; border-color: var(--accent); }

.char-count { font-size: 0.72rem; color: var(--muted); }

/* chips / samples — the site's pill style */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.chip {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 999px; padding: 3px 13px;
  font-family: inherit; font-size: 0.78rem; cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { color: var(--foreground); border-color: var(--accent); }

/* controls row */
.controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.grow { flex: 1; }
.ctrl label { font-size: 0.78rem; color: var(--muted); display: flex; gap: 8px; }
.ctrl b { color: var(--foreground); }
input[type="range"] { accent-color: var(--accent); width: 150px; }

.seg {
  display: inline-flex; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.seg-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 7px 15px; font-family: inherit; font-size: 0.78rem;
  cursor: pointer; font-weight: 600; transition: all 0.15s;
}
.seg-btn.active { background: var(--accent); color: #fff; }

/* status line */
.status {
  min-height: 22px; font-size: 0.78rem; color: var(--muted);
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
}
.status.err { color: var(--red); }
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ───────────────────────────── voices */
.voices-panel { position: sticky; top: 80px; }
@media (max-width: 960px) { .voices-panel { position: static; } }
.voice-list { display: grid; gap: 9px; max-height: 46vh; overflow-y: auto; padding-inline-end: 4px; }
.voice-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 13px; cursor: pointer; position: relative;
  transition: all 0.15s;
  background: var(--card);
}
.voice-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  transform: translateY(-2px); background: var(--card-hover); }
.voice-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.vc-top { display: flex; align-items: center; gap: 10px; }
.vc-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.vc-name { font-weight: 600; font-size: 0.9rem; }
.vc-desc { font-size: 0.73rem; color: var(--muted); }
.vc-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.vc-tag {
  font-size: 0.65rem; padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); font-weight: 500;
}
.vc-tag.en { color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.vc-tag.tmp { color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.vc-del {
  position: absolute; top: 8px; inset-inline-end: 8px;
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.85rem; padding: 4px;
}
.vc-del:hover { color: var(--red); }

.dropzone {
  margin-top: 12px; border: 2px dashed var(--border);
  border-radius: 12px; padding: 20px; text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone.drag {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.dz-icon { font-size: 1.7rem; margin-bottom: 6px; }
.dz-inner p { font-size: 0.84rem; }
.dz-sub { font-size: 0.71rem; color: var(--muted); }
.dz-or {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 8px;
  color: var(--muted); font-size: 0.73rem;
}
.dz-or::before, .dz-or::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.btn-rec { width: 100%; padding: 12px; }
.btn-rec.recording { background: var(--red); }
.rec-ui { margin-top: 12px; }
.rec-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.92rem;
}
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--red);
  animation: pulse 1s infinite;
}
.rec-meter {
  height: 6px; border-radius: 999px; background: var(--card-hover);
  overflow: hidden; margin: 8px 0;
}
.rec-level {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}
.rec-level.hot { background: var(--red); }
.rec-sentence { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.rec-read {
  font-size: 0.95rem; line-height: 2.1; font-weight: 500;
  padding: 10px 12px; border-radius: 10px;
  background: var(--card-hover); border: 1px solid var(--border);
}
.dz-bar { height: 6px; border-radius: 999px; background: var(--card-hover); overflow: hidden; margin: 10px 0; }
.dz-bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s; }

.hint { font-size: 0.71rem; color: var(--muted); margin-top: 12px; line-height: 1.9; }

.smart-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.78rem; color: var(--muted); cursor: pointer;
  min-height: 42px; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.smart-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.smart-toggle:has(input:checked) { color: var(--accent); }

/* ───────────────────────────── player */
.player-actions { display: flex; align-items: center; gap: 12px; flex: 1; }
.time { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wave-wrap {
  position: relative; height: 116px;
  background: var(--card-hover); border-radius: 12px;
  border: 1px solid var(--border); overflow: hidden;
}
#waveform { width: 100%; height: 100%; display: block; cursor: pointer; }
.wave-progress::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0;
  width: 2px; background: var(--accent);
}

/* ───────────────────────────── history */
.history-list { display: grid; gap: 8px; max-height: 300px; overflow-y: auto; }
.hist-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; font-size: 0.8rem; background: var(--card);
}
.hist-text {
  flex: 1; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; direction: auto; text-align: start;
}
.hist-meta { color: var(--muted); font-size: 0.7rem; white-space: nowrap; }
.hist-item button {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 0.73rem;
  font-family: inherit;
}
.hist-item button:hover { color: var(--accent); border-color: var(--accent); }

/* ───────────────────────────── footer / toasts */
.footer {
  text-align: center; padding: 24px 12px 32px;
  color: var(--muted); font-size: 0.7rem;
}
.toasts {
  position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 50;
  display: grid; gap: 8px;
}
.toast {
  background: var(--card); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: 10px; padding: 10px 18px; font-size: 0.8rem;
  animation: slideIn 0.25s ease; max-width: 340px;
}
.toast.err { border-inline-start-color: var(--red); }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } }

.btn-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* mobile: touch targets, no zoom-on-tap */
@media (max-width: 640px) {
  .layout { padding: 0 12px; margin: 14px auto; gap: 12px; }
  .panel { padding: 14px; border-radius: 12px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .title, .topbar .badge, .topbar .divider { display: none; }
  .brand { gap: 0; }
  .topnav { order: 2; margin-inline-start: auto; }
  .nav-btn { padding: 6px 10px; font-size: 0.78rem; }
  .btn { min-height: 46px; min-width: 46px; }
  .btn-sm { min-height: 38px; }
  .icon-btn { min-height: 40px; min-width: 44px; }
  textarea { font-size: 16px; }          /* stops iOS auto-zoom on focus */
  input[type="range"] { width: 100%; }
  .pace-ctrl { width: 100%; }
  .controls { gap: 10px; }
  .wave-wrap { height: 96px; }
  .voice-list { max-height: none; }
  button, .chip, .seg-btn, .voice-card {
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
}
