/* گوینده — استودیوی تبدیل متن به گفتار (تم تیره، RTL) */
:root {
  --bg: #0f1117;
  --bg-soft: #161a23;
  --card: #1b2030;
  --card-2: #202637;
  --border: #2c3348;
  --text: #e8eaf2;
  --text-dim: #9aa3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --accent: #f59e0b;
  --ok: #34d399;
  --err: #f87171;
  --radius: 14px;
}

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

body {
  font-family: "Vazirmatn", "Segoe UI", Tahoma, Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(900px 420px at 10% -10%, rgba(245, 158, 11, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

main { max-width: 880px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- هدر ---------- */
.topbar {
  max-width: 880px; margin: 0 auto; padding: 20px 20px 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, #312e81, #4338ca); color: #c7d2fe;
  box-shadow: 0 6px 18px rgba(67, 56, 202, 0.35);
}
.brand h1 { font-size: 20px; font-weight: 800; }
.brand p { font-size: 12px; color: var(--text-dim); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ghost-link { color: var(--text-dim); font-size: 12.5px; text-decoration: none; }
.ghost-link:hover { color: var(--primary-hover); }
.proxy-toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--text-dim); cursor: pointer; user-select: none;
}
.proxy-toggle input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary, #2d7ff9); }
.proxy-toggle:hover { color: var(--primary-hover); }

/* ---------- کارت‌ها ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
}
.card h2 { font-size: 15px; font-weight: 700; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hint-link { font-size: 12px; color: var(--primary-hover); text-decoration: none; }
.hint-inline { font-size: 11.5px; color: var(--text-dim); }

/* ---------- تب‌های داخل پنل (به سبک yt-ask) ---------- */
.app-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0a0c12;
}
.app-tab {
  flex: 1; min-width: 0;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 11px 8px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  transition: background .15s, color .15s;
}
.app-tab + .app-tab { border-inline-start: 1px solid var(--border); }
.app-tab:hover:not(.active) { background: var(--card-2); color: var(--primary-hover); }
.app-tab.active { background: var(--primary); color: #fff; font-weight: 700; }
.app-tab:focus-visible { outline: 2px solid var(--primary-hover); outline-offset: -2px; }
.app-tabpane { display: flex; flex-direction: column; gap: 16px; }

/* ---------- بنر ---------- */
.banner {
  max-width: 880px; margin: 10px auto 0; padding: 10px 16px;
  background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 12px; color: #fcd34d; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.banner a { color: #fde68a; }

/* ---------- کلید API ---------- */
.key-row { display: flex; gap: 8px; }
.key-row input {
  flex: 1; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; outline: none;
}
.key-row input:focus { border-color: var(--primary); }
.key-status { font-size: 12.5px; min-height: 16px; }
.key-status.ok { color: var(--ok); }
.key-status.err { color: var(--err); }

/* ---------- دکمه‌ها ---------- */
.btn {
  background: var(--card-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #272e44; border-color: #3a4361; }
.btn.primary { background: var(--primary); border-color: transparent; font-weight: 700; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.chip { padding: 5px 11px; border-radius: 999px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.vsep { width: 1px; height: 22px; background: var(--border); display: inline-block; }
.btn.ai { background: linear-gradient(135deg, #7c3aed33, #6366f144); border-color: #7c3aed88; color: #c4b5fd; font-weight: 700; }
.btn.ai:hover { background: linear-gradient(135deg, #7c3aed55, #6366f166); border-color: #a78bfa; }
.hint-alt { font-size: 11.5px; color: var(--text-dim); user-select: none; }
.hint-alt kbd {
  background: var(--card-2); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 6px; font-size: 10.5px; font-family: inherit;
}

/* ---------- ادیتور ---------- */
.editor-head { display: flex; align-items: baseline; justify-content: space-between; }
.editor-tools { display: flex; align-items: center; gap: 10px; }
.char-count { font-size: 11.5px; color: var(--text-dim); }
.tagbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
}
.tagbar label { font-size: 12.5px; color: var(--text-dim); }
.tagbar select { min-width: 180px; }
textarea {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; line-height: 1.9; resize: vertical;
  font-family: inherit; outline: none; min-height: 120px;
}
textarea:focus { border-color: var(--primary); }
.hint { font-size: 11.5px; color: var(--text-dim); line-height: 1.8; }
.hint code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; font-size: 11px; direction: ltr; display: inline-block; }

/* ---------- فرم‌ها ---------- */
select {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-family: inherit; outline: none; width: 100%;
}
select:focus { border-color: var(--primary); }
/* صدای من (کلون/طراحی) داخل دراپ‌داون صداها — پس‌زمینهٔ متمایز */
#voiceSelect option.voice-custom-opt {
  background: #3a2d6e; color: #ddd6fe; font-weight: 700;
}
#voiceSelect option.voice-custom-opt:checked {
  background: #4c3a8f; color: #fff;
}
/* صدای کتابخانه در دراپ‌داون صداها — پس‌زمینهٔ متمایز (آبی) */
#voiceSelect option.voice-lib-opt {
  background: #1e3a5f; color: #bfdbfe; font-weight: 700;
}
#voiceSelect option.voice-lib-opt:checked {
  background: #2b4f7d; color: #fff;
}
#voiceSelect option.voice-sep-opt {
  background: var(--bg); color: var(--text-dim); font-size: 11px;
}
/* برچسب «فقط ۳.۸+» و کنترل‌های مخصوص همین نسخه */
.badge38 {
  display: inline-block; font-size: 10px; font-weight: 700; line-height: 1;
  color: #34d399; background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.45); border-radius: 999px;
  padding: 3px 7px; margin-inline-start: 4px; vertical-align: middle; white-space: nowrap;
}
.modern-only.modern-disabled { opacity: 0.55; }
.modern-only.modern-disabled label { cursor: not-allowed; }
.field input[type="text"] {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-family: inherit; outline: none; width: 100%;
}
.field input[type="text"]:focus { border-color: var(--primary); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.field-hint { font-size: 11px; color: var(--text-dim); min-height: 14px; line-height: 1.7; }
.model-row { display: flex; align-items: stretch; gap: 8px; }
.model-row select { flex: 1; min-width: 0; }
.model-row .btn.small { white-space: nowrap; }
.model-row .btn.spin { opacity: 0.6; pointer-events: none; }
.model-row .btn.spin::before { content: "⏳"; margin-inline-end: 4px; }
.temp-row { display: flex; align-items: center; gap: 10px; }
.temp-row input[type="range"] { flex: 1; accent-color: var(--primary); cursor: pointer; }
.temp-value {
  min-width: 48px; text-align: center; font-size: 12.5px; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px;
}

.segmented { display: flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented button {
  flex: 1; background: transparent; border: none; color: var(--text-dim); padding: 9px 0;
  font-size: 13.5px; cursor: pointer; font-family: inherit; font-weight: 600; transition: all 0.15s;
}
.segmented button.active { background: var(--primary); color: #fff; }

.preset-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- دکمه تولید ---------- */
.generate {
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border: none;
  border-radius: 14px; padding: 15px; font-size: 16.5px; font-weight: 800; cursor: pointer;
  font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35); transition: transform 0.1s, filter 0.15s;
}
.generate:hover { filter: brightness(1.1); }
.generate:active { transform: scale(0.99); }
.generate:disabled { filter: saturate(0.4) brightness(0.7); cursor: wait; }
.spinner {
  width: 18px; height: 18px; border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- وضعیت ---------- */
.status {
  padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.9;
  background: var(--bg-soft); border: 1px solid var(--border);
}
.status.ok { border-color: rgba(52, 211, 153, 0.45); color: var(--ok); }
.status.err { border-color: rgba(248, 113, 113, 0.45); color: var(--err); }
.status.info { color: var(--text-dim); }

/* ---------- خروجی ---------- */
.result audio { width: 100%; }
.speed-row { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); flex-wrap: wrap; }
.speed-row .chip.active { background: var(--primary); border-color: transparent; color: #fff; }
.result-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.result-meta { font-size: 12px; color: var(--text-dim); }

footer {
  max-width: 880px; margin: 0 auto; padding: 12px 20px 28px; text-align: center;
  font-size: 11px; color: #5b6478;
}

/* ---------- پاپ‌آپ احساسات (Alt+کلیک) ---------- */
.emotion-popup {
  position: fixed; z-index: 1000; width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--card); border: 1px solid #3d4670; border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55); padding: 10px 12px 12px;
}
.emotion-popup .pp-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-dim); padding: 2px 2px 8px; position: sticky; top: -10px;
  background: var(--card); margin: -2px -4px 4px; padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.emotion-popup .pp-close {
  background: transparent; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; padding: 2px 6px; border-radius: 6px; font-family: inherit;
}
.emotion-popup .pp-close:hover { color: var(--text); background: var(--card-2); }
.emotion-popup .pp-group { font-size: 10.5px; color: #8b93a9; margin: 10px 2px 6px; font-weight: 700; }
.emotion-popup .pp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.emotion-popup .pp-chip {
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 4px 10px; font-size: 11.5px; cursor: pointer; font-family: inherit;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.emotion-popup .pp-chip:hover { background: var(--primary); border-color: transparent; color: #fff; }
.emotion-popup .pp-chip:active { transform: scale(0.95); }

/* ---------- سنجهٔ توکن ---------- */
.token-meter {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; display: flex; flex-direction: column; gap: 6px;
}
.tm-nums { font-size: 11.5px; color: var(--text-dim); line-height: 1.9; }
.tm-nums b { color: var(--text); }
.tm-bar { height: 5px; background: #2a3147; border-radius: 999px; overflow: hidden; }
.tm-bar i { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width 0.3s; }
.tm-bar i.warn { background: var(--accent); }
.tm-bar i.err { background: var(--err); }
.tm-verdict { font-size: 12px; line-height: 1.8; }
.tm-verdict.ok { color: var(--ok); }
.tm-verdict.warn { color: #fcd34d; }
.tm-verdict.err { color: var(--err); }
.tm-wait { font-size: 11.5px; color: var(--text-dim); }

.chunk-row {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  color: var(--text-dim); cursor: pointer; padding: 0 4px; user-select: none;
}
.chunk-row input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }

/* ---------- پاک کردن متن (تأیید شناور) ---------- */
.textarea-wrap { position: relative; }
.textarea-wrap textarea { display: block; } /* حذف شکاف baseline تا پوشش دقیقاً هم‌اندازهٔ باکس شود */
.clear-confirm {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(13, 15, 21, 0.78); backdrop-filter: blur(2px);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.clear-box {
  background: var(--card); border: 1px solid #3d4670; border-radius: 12px;
  padding: 16px 22px; text-align: center; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.clear-box p { font-size: 13.5px; margin-bottom: 12px; }
.clear-actions { display: flex; gap: 8px; justify-content: center; }

/* ---------- هشدار پرامپت سراسری ---------- */
.tone-warn {
  font-size: 11.5px; color: #fcd34d; background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 8px; padding: 6px 10px; line-height: 1.8;
}

.hidden { display: none !important; }

/* ---------- صدای من (کلون/طراحی) ---------- */
#voiceLabCard input[type="text"] {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-family: inherit; outline: none; width: 100%;
}
#voiceLabCard input[type="text"]:focus { border-color: var(--primary); }
.vc-tabs { margin-bottom: 4px; }
.vc-panel { display: flex; flex-direction: column; gap: 12px; }
.vc-panel > .hint { line-height: 2; }
.vc-tips {
  font-size: 12px; line-height: 1.9; color: #fcd34d;
  background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px; padding: 10px 12px;
}
.vc-tips ul { margin: 6px 0 0; padding-inline-start: 18px; }
.vc-tips li { margin-bottom: 3px; }
.consent-box {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.consent-text { font-size: 13px; line-height: 1.9; color: var(--text); }
.vc-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.vc-slot {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.vc-slot-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.vc-badge {
  font-size: 10.5px; font-weight: 600; color: var(--text-dim);
  background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px;
}
.vc-badge.ok { color: #86efac; border-color: rgba(134, 239, 172, 0.4); }
.vc-badge.rec { color: #fca5a5; border-color: rgba(252, 165, 165, 0.5); }
.vc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filebtn { display: inline-flex; align-items: center; cursor: pointer; }
.vc-slot audio { width: 100%; height: 34px; }
.vc-info { font-size: 11px; color: var(--text-dim); min-height: 14px; }
.vc-form { display: flex; flex-direction: column; gap: 8px; }
.vc-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.vc-check input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }
.vc-status { font-size: 12.5px; line-height: 1.9; border-radius: 8px; padding: 8px 12px; }
.vc-status.ok { color: #86efac; background: rgba(134, 239, 172, 0.1); border: 1px solid rgba(134, 239, 172, 0.35); }
.vc-status.err { color: #fca5a5; background: rgba(252, 165, 165, 0.1); border: 1px solid rgba(252, 165, 165, 0.35); }
.vc-status.info { color: #93c5fd; background: rgba(147, 197, 253, 0.1); border: 1px solid rgba(147, 197, 253, 0.35); }
.vc-details { margin-top: 8px; }
.vc-details summary { cursor: pointer; font-size: 12px; color: var(--text-dim); }
.vc-json {
  margin-top: 6px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: #0b1020; border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-family: Consolas, "Courier New", monospace; font-size: 11px; line-height: 1.6; color: #cbd5e1; direction: ltr; text-align: left;
}
.vc-details .btn.small { margin-top: 6px; }
.vc-manage { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.vc-manage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vc-manage-head h3 { font-size: 13.5px; }
.vc-list { display: flex; flex-direction: column; gap: 8px; }
.vc-item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
.vc-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vc-item-name { font-size: 13px; font-weight: 600; }
.vc-item-meta { font-size: 10.5px; color: var(--text-dim); direction: ltr; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
