/* ASR v3 - ağ/qara, monospace interfeys.
   Şrift yığını opencode.ai-dəki ilə eynidir: Berkeley Mono lisenziyalıdır, ona
   görə real yüklənən IBM Plex Mono-dur (latin + latin-ext, `ə ğ ı ş ö ü ç` daxil). */

@import url("fonts/plex-mono.css");

:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --raised: #f2f2f2;
  --border: #e2e2e2;
  --border-strong: #c9c9c9;
  --text: #111111;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --invert-bg: #111111;
  --invert-text: #ffffff;
  /* Loqo mətndən bir az kontrastlıdır - nişan solğun görünməsin */
  --logo-color: #000000;
  --font: "Berkeley Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --radius: 2px;
  /* Mətn sahələrində seçim rəngi: sahənin fonundan fərqli boz (ağ/qara tərs yox) */
  --select-bg: #c9d4e3;
  color-scheme: light;
}

:root[data-theme="dark"] {
  /* Brauzerin öz elementləri (avtomatik doldurma, scrollbar, select) də tünd olsun */
  color-scheme: dark;
  --select-bg: #3d4a5c;
  --bg: #0b0b0b;
  --panel: #111111;
  --raised: #191919;
  --border: #262626;
  --border-strong: #3d3d3d;
  --text: #e8e8e8;
  --muted: #8c8c8c;
  --faint: #5f5f5f;
  --invert-bg: #ffffff;
  --invert-text: #0b0b0b;
  --logo-color: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

::selection { background: var(--invert-bg); color: var(--invert-text); }

/* ---------- ümumi elementlər ---------- */

.label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

button, .btn {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

button:hover, .btn:hover { background: var(--raised); }

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button:disabled:hover { background: transparent; }

.btn-primary {
  background: var(--invert-bg);
  color: var(--invert-text);
  border-color: var(--invert-bg);
}

.btn-primary:hover { opacity: 0.85; background: var(--invert-bg); }

.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

.btn-sm { padding: 3px 8px; font-size: 11px; }

input, textarea, select {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  width: 100%;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
}

input::placeholder { color: var(--faint); }

/* Seçilmiş mətn sahənin içində görünsün: ümumi ::selection (ağ/qara tərs) qara
   mövzuda ağ fon verirdi və brauzerin ağ "avtomatik doldurma" fonu ilə birləşib
   seçim görünmürdü (login-də istifadəçi adı). */
input::selection, textarea::selection { background: var(--select-bg); color: var(--text); }

/* Brauzer yadda saxlanmış login-i dolduranda sahəni öz rəngi ilə (ağ/sarı) boyayır -
   qara mövzuda ağ sahə alınırdı. Fon mövzunun rənginə qaytarılır. */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  box-shadow: 0 0 0 1000px var(--bg) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-out 0s;
}
input:autofill { background: var(--bg); color: var(--text); }

hr { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ---------- karkas ---------- */

.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Heç bir iç element səhifəni eninə genişləndirməsin - lazım olanda
     öz daxilində scroll olunur (cədvəl: .table-wrap) */
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 19px;
  font-weight: 600;
  /* Marka kiçik hərflərlə yazılır ("milligram"); monospace-də sıx aralıq daha səliqəli görünür */
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-top: 2px;
}

/* Loqo SVG-si maska kimi işlədilir: rəngi `currentColor`-dan alır, ona görə
   eyni fayl həm ağ, həm qara mövzuda düzgün görünür. */
/* 64 px-lik başlıq zolağında ~60% hündürlük: yazı ilə tarazdır, zolağı doldurmur */
.brand .logo {
  width: 34px;
  height: 34px;
  flex: none;
  background: var(--logo-color);
  /* Loqo dəyişəndə `?v=` artırılır - nginx statikanı 7 gün keşləyir, yoxsa
     istifadəçidə köhnə nişan qalır. */
  -webkit-mask: url("logo.svg?v=6") center / contain no-repeat;
  mask: url("logo.svg?v=6") center / contain no-repeat;
}

.brand .logo.lg { width: 64px; height: 64px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.chip {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 8px;
  white-space: nowrap;
}

.body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---------- sol panel ---------- */

.sidebar {
  width: 280px;
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  transition: width 0.18s ease;
}

/* ☰ ilə bağlanmış panel: əsas sahə tam enliyə keçir */
body.sb-collapsed .sidebar {
  width: 0;
  border-right: none;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* seçim rejimi */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--raised);
}

.bulk-bar .danger,
.btn.danger {
  color: var(--danger, #e5484d);
}

.file-item { display: flex; align-items: center; gap: 8px; }

.file-item.selected { background: var(--raised); box-shadow: inset 2px 0 0 var(--accent, currentColor); }

.file-check {
  flex: none;
  width: 15px;
  height: 15px;
  accent-color: var(--accent, #4f8cff);
  cursor: pointer;
}

.file-name { flex: 1; min-width: 0; }

#selectBtn.on {
  background: var(--accent, #4f8cff);
  color: #fff;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.file-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.file-item {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: block;
  position: relative;
}

.file-item:hover { background: var(--raised); }

/* Silmə düyməsi yalnız kursor sətrin üstündə olanda görünür */
.file-del {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  background: var(--raised);
}

.file-item:hover .file-del { opacity: 1; }

/* Sağ kənarda yer yoxdur - ipucu sola açılır.
   İki sinif birlikdə yazılıb ki, faylda sonra gələn `.hint::after` qaydası
   `left`-i geri qaytarmasın: eyni çəkidə olsaydı, `left` və `right` birlikdə
   təyin olunub ipucunun eni sıfıra düşürdü. */
.hint.hint-left::after {
  left: auto;
  right: calc(100% + 8px);
}

.file-item.active {
  background: var(--raised);
  box-shadow: inset 2px 0 0 var(--text);
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.file-meta {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--faint);
  margin-top: 2px;
}

.dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  vertical-align: middle;
}

.dot.live { background: var(--text); animation: pulse 1s infinite; }
.dot.err { background: var(--text); opacity: 0.5; }

@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- əsas sahə ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.main-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

/* Panel düyməsi alətlər sətrinin ən solunda, sabit ölçüdə */
.main-head #sidebarToggle { flex: none; }

/* Ox panelin vəziyyətini göstərir: AÇIQ -> sola (bağla), BAĞLI -> sağa (aç).
   SVG-nin özü sola baxır, bağlı vəziyyətdə 180° çevrilir. */
.sb-toggle {
  padding: 4px 7px;
  line-height: 0;
}

.sb-toggle svg {
  width: 13px;
  height: 13px;
  display: block;
  transition: transform 0.18s ease;
}

body.sb-collapsed .sb-toggle svg { transform: rotate(180deg); }

.main-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 24px 20px 32px;
}

.center {
  max-width: 760px;
  margin: 0 auto;
}

/* ---------- giriş paneli ---------- */

.dropzone {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
}

.dropzone:hover, .dropzone.over {
  border-color: var(--text);
  color: var(--text);
  background: var(--panel);
}

.dropzone .big { font-size: 14px; color: var(--text); margin-bottom: 6px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.row { display: flex; gap: 8px; }

/* .row içindəki mətn sahələri 100% eni məcbur etmir - düymə ilə birlikdə
   sığaraq üfüqi scroll yaratmır */
.row > input:not([type="checkbox"]):not([type="radio"]) {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.notice {
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 14px 0;
  font-size: 12px;
  background: var(--panel);
}

/* ---------- transkript ---------- */

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 14px;
  min-height: 18px;
}

.progress {
  flex: 1;
  height: 2px;
  background: var(--border);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.25s;
}

.transcript {
  font-size: 15px;
  line-height: 2.05;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Sətir: solda alət sütunu (redaktə düymələri), sağda vaxt + mətn */
.cue {
  margin-bottom: 14px;
  position: relative;
  padding-left: 30px;
}

.cue-tools {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}

/* Yalnız kursor sətrin üstündə olanda görünür - mətn təmiz qalsın */
.cue:hover .cue-tools,
.cue.editing .cue-tools { opacity: 1; }

.icon-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  justify-content: center;
  border-color: transparent;
  color: var(--faint);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-btn svg { width: 13px; height: 13px; display: block; }

.cue-time {
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.06em;
  cursor: pointer;
  user-select: none;
}

.cue-time:hover { color: var(--text); }

/* İpucu: sağ tərəfdə açılır, çünki sol kənarda yer yoxdur və yuxarıda
   sürüşən sahə onu kəsir. */
.hint::after {
  content: attr(data-hint);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--invert-bg);
  color: var(--invert-text);
  font-size: 10px;
  line-height: 1.5;
  padding: 3px 7px;
  border-radius: var(--radius);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 20;
}

.hint:hover::after { opacity: 1; }

.w {
  cursor: pointer;
  border-radius: var(--radius);
  padding: 1px 1px;
  transition: background 0.08s;
}

.w:hover {
  background: var(--raised);
  box-shadow: 0 1px 0 var(--text);
}

.w.on {
  background: var(--invert-bg);
  color: var(--invert-text);
}

.transcript.raw { color: var(--muted); }

/* Redaktə rejimi sətir-sətirdir: yalnız seçilmiş sətir dəyişdirilə bilir,
   sözlərin vaxt möhürləri isə yerində qalır. */
.cue.editing .cue-line {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 10px;
  outline: none;
  background: var(--panel);
}

.cue.editing .w { cursor: text; }

.cue.editing .w:hover {
  background: transparent;
  box-shadow: none;
}

.cue.editing .w.on {
  background: transparent;
  color: inherit;
}

.cue.editing .cue-time {
  pointer-events: none;
  opacity: 0.45;
}

.empty {
  color: var(--faint);
  text-align: center;
  padding: 60px 0;
  font-size: 12px;
}

/* ---------- pleyer ---------- */

.player {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.player audio { width: 100%; height: 32px; }

.player .time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- modal ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.modal h3 { margin: 0 0 14px; font-size: 13px; font-weight: 600; }

.dialog-text {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.modal input { margin-top: 12px; }

.kv {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.kv span:first-child { color: var(--muted); }

/* API sənəd səhifəsi: mətn sütunu mərkəzdə, uzun kod blokları öz içində sürüşür.

   `display: block` VACİBDİR: bu element həm də `.main`-dir, ora isə
   `display: flex; flex-direction: column` verilib. Flex sütununda məzmun
   hündürlüyü aşanda uşaqlar sıxılır - cədvəl qutuları 0 hündürlüyə düşüb
   məzmunu bir-birinin üstünə salırdı. */
.api-page {
  display: block;
  width: 100%;
  /* Sürüşən qutu TAM enlidir: şaquli scroll pəncərənin sağ kənarında olur.
     Əvvəl `max-width: 900px` burada idi və scroll zolağı səhifənin ortasında,
     mətn sütununun kənarında görünürdü. */
  overflow-y: auto;
  min-width: 0;
}

/* Mətn sütunu sürüşən qutunun içində mərkəzləşir */
.api-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

.api-page p { margin: 0 0 10px; line-height: 1.75; }
.api-page code { font-size: 11px; }

.api-h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; }
.api-page .lead { color: var(--muted); margin-bottom: 4px; }

/* Nömrələnmiş addım başlıqları - sənəd sıra ilə oxunur */
.api-h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  margin: 44px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.step-num {
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 50%;
  background: var(--invert-bg);
  color: var(--invert-text);
}

.api-page h3 { font-size: 12px; margin: 26px 0 8px; color: var(--muted); }

/* Vurğulanan qeyd */
.note {
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 12px;
  line-height: 1.7;
}

/* Python / curl keçidi */
.code-tabs { margin-top: 10px; }

.tabs-row { display: flex; gap: 2px; }

.tabs-row .tab {
  border: none;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius);
}

.tabs-row .tab:hover { color: var(--text); background: transparent; }

.tabs-row .tab.on {
  color: var(--invert-text);
  background: var(--invert-bg);
}

.code-tabs .api-code {
  margin-top: 0;
  border-radius: 0 0 8px 8px;
}

.api-key-list {
  margin-top: 12px;
  max-height: 40vh;
  overflow-y: auto;
  /* İçəridəki ipucu qutuları sətrin sağına daşıb səhifəni genişlətməsin */
  overflow-x: hidden;
}

.api-key-list code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  opacity: 0.85;
}

.api-code {
  background: var(--bg-soft, rgba(128, 128, 128, 0.12));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}

.code-block { margin-top: 8px; }

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--raised);
  font-size: 11px;
  color: var(--muted);
}

.code-block .api-code {
  margin-top: 0;
  border-radius: 0 0 8px 8px;
}

/* Kod sətirləri səhifəni genişləndirməsin - uzun sətirlər alt sətirə keçir */
.api-code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: hidden;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

/* Dar ekranlarda cədvəl səhifəni deyil, özünü genişləndirir.
   `min-width: 0` olmasa flex valideyn içində qutu daralmır və cədvəl kəsilir. */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
}

/* Cədvəl sətirləri dar ekranda əzilməsin - qutu sürüşsün */
.table-wrap > table { min-width: 520px; }

.api-table th, .api-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.api-table th {
  font-weight: 600;
  color: var(--muted);
}

.api-table code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
}

.modal .dialog-text code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-soft, rgba(128, 128, 128, 0.15));
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Çat: "paylaş" pəncərəsi - link sahəsi və kopyala düyməsi bir sətirdə */
.share-modal { max-width: 480px; }
.share-link { display: flex; gap: 8px; margin-top: 12px; }
.share-link input { margin-top: 0; flex: 1; min-width: 0; font-size: 12px; }
.share-link .btn { flex: none; }
.share-modal .modal-actions { flex-wrap: wrap; }

/* Yükləmə göstəricisi. Faylda faiz bilinir, linkdə isə bilinmir - o halda
   zolaq gedər-gəlməz hərəkət edir ki, gözləmə donmuş görünməsin. */
.bar {
  height: 2px;
  background: var(--border);
  margin-top: 16px;
  overflow: hidden;
  position: relative;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.15s linear;
}

.bar.indeterminate > i {
  width: 35%;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

.bar-label {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}

/* ---------- auth / admin ---------- */

.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  background: var(--panel);
}

.auth-card h1 {
  font-size: 15px;
  margin: 0 0 4px;
  letter-spacing: 0.06em;
}

.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 5px; }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; }

.tabs button { flex: 1; justify-content: center; }

.tabs button.on {
  background: var(--invert-bg);
  color: var(--invert-text);
  border-color: var(--invert-bg);
}

table { width: 100%; border-collapse: collapse; font-size: 12px; }

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 400;
}

tbody tr:hover { background: var(--panel); }

.err {
  font-size: 11px;
  border: 1px solid var(--border-strong);
  padding: 8px 10px;
  margin-bottom: 12px;
  border-radius: var(--radius);
}

.hidden { display: none !important; }
/* Səhifə yenilənəndə açıq iş serverdən gələnə qədər boş forma/başlıq görünməsin
   (templates: head skripti, JS bərpadan sonra "restoring"-i götürür) */
.restoring .restore-hide { visibility: hidden; }

/* ---------- mobil ---------- */

/* Fon örtüyü və bağlama düyməsi yalnız mobil çekmecədə lazımdır */
.sb-backdrop { display: none; }
.sb-close { display: none; }

@media (max-width: 860px) {
  /* Panel məzmunu aşağı itələmir: üstünə sürüşən çekmecə kimi açılır.
     Əvvəl `position: static` idi və fayl siyahısı ekranın üçdə birini tutub
     transkripti aşağı salırdı. */
  .sidebar {
    position: fixed;
    z-index: 45;
    top: 0;
    left: 0;
    bottom: 0;
    width: 86%;
    max-width: 320px;
    max-height: none;
    border-right: 1px solid var(--border);
    border-bottom: none;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  }

  body:not(.sb-collapsed) .sidebar { transform: none; }

  /* Bağlı vəziyyətdə eni saxlanılır (masaüstündəki `width: 0` mobil üçün
     lazım deyil) - yalnız ekrandan kənara sürüşür */
  body.sb-collapsed .sidebar { width: 86%; }

  .sb-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 44;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body:not(.sb-collapsed) .sb-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sb-close { display: inline-flex; }

  .main-body { padding: 16px 14px 24px; }
  .topbar { padding: 0 12px; }
  .topbar-right .hide-sm { display: none; }
}

/* ---------- ASR / TTS keçidi ---------- */

.mode-switch {
  display: inline-flex;
  flex: none;
  margin-left: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.mode-switch a {
  padding: 3px 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--muted);
}

/* ASR | TTS | AI | Banx arasında nazik, solğun xətt */
.mode-switch a + a { border-left: 1px solid var(--border); }

.mode-switch a:hover { color: var(--text); background: var(--raised); }

.mode-switch a.on {
  background: var(--invert-bg);
  color: var(--invert-text);
}

/* ---------- TTS ---------- */

.tts-form { display: flex; flex-direction: column; gap: 18px; }

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.check input { width: auto; margin: 0; accent-color: var(--text); }

.dropzone.compact { padding: 22px 16px; }

.dropzone.has-file {
  border-style: solid;
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.dropzone.has-file .big {
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.ref-preview { margin-top: 8px; width: 100%; height: 32px; }

textarea { resize: vertical; line-height: 1.7; min-height: 70px; }

textarea:disabled { opacity: 0.6; }

.counter { font-size: 10px; color: var(--faint); letter-spacing: 0.06em; }
.counter.over { color: var(--text); font-weight: 600; }

details.adv summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  list-style: none;
}

details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: "+ "; }
details.adv[open] summary::before { content: "− "; }

.adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.adv-grid .label { display: block; margin-bottom: 5px; }

.gen-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gen-row .btn-primary { padding: 9px 22px; font-size: 13px; }
.gen-row .muted, .muted { color: var(--muted); font-size: 11px; }

/* Nəticə: dalğa forması + idarə */
.tts-out {
  margin-top: 26px;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 14px 16px;
}

.tts-out .status-line { margin-bottom: 0; }
.tts-out.has-audio .status-line { margin-bottom: 12px; }

.wave-wrap { position: relative; height: 48px; cursor: pointer; }
.wave-wrap canvas { width: 100%; height: 100%; display: block; }

.wave-ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.wave-ctrl .play { min-width: 64px; justify-content: center; }
.wave-ctrl .spacer { flex: 1; }

.progress.indeterminate > i {
  width: 30%;
  animation: slide 1.1s ease-in-out infinite;
}

.tts-text-preview {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 7.5em;
  overflow: hidden;
}


/* ---------- TTS: səs bazası ---------- */

.voice-current {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--panel);
}

.vinfo { flex: 1; min-width: 0; }

.vname {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vmeta {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: 1px;
}

.icon-btn.vplay {
  flex: none;
  width: 28px;
  height: 28px;
  border-color: var(--border-strong);
  color: var(--text);
}

.icon-btn.vplay.on { background: var(--invert-bg); color: var(--invert-text); }

.voice-lib {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.voice-lib-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.voice-lib:not(.open) .voice-lib-head { border-bottom: none; }

.lib-toggle {
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
  gap: 8px;
  border: none;
  padding: 2px 0;
  background: transparent;
}

.lib-toggle:hover { background: transparent; }
.lib-toggle:hover .label { color: var(--text); }
.lib-toggle .label { white-space: nowrap; }

.lib-toggle svg {
  width: 12px;
  height: 12px;
  flex: none;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.voice-lib.open .lib-toggle svg { transform: rotate(90deg); }
.voice-lib-head input { width: 160px; padding: 4px 8px; font-size: 12px; }

.voice-list { max-height: 264px; overflow-y: auto; }

.voice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.voice-item:last-child { border-bottom: none; }
.voice-item:hover { background: var(--raised); }
.voice-item.active { background: var(--raised); box-shadow: inset 2px 0 0 var(--text); }

.voice-item .vdur { font-size: 11px; color: var(--faint); flex: none; }

.vactions { display: flex; gap: 2px; flex: none; opacity: 0; transition: opacity 0.12s; }
.voice-item:hover .vactions, .voice-item:focus-within .vactions { opacity: 1; }
.vactions .icon-btn.on { color: var(--text); border-color: var(--border-strong); }

.voice-list .empty { padding: 22px 0; }

@media (max-width: 860px) {
  .vactions { opacity: 1; }
}

@media (max-width: 600px) {
  .voice-lib-head input { width: 110px; }
  .voice-item .vdur { display: none; }
}

.dropzone.busy { opacity: 0.7; pointer-events: none; }
.dropzone.busy .big { animation: pulse 1s infinite; }

/* ---------- Conversational AI (çat) ---------- */

.chat-empty { text-align: center; padding: 72px 0 24px; }
.chat-empty .muted { max-width: 48ch; margin: 0 auto; line-height: 1.7; }
/* AI-da alt sətir qısadır - bir sətirdə qalsın ("köməkçisi" ayrıca düşməsin) */
.chat-page:not(.banx) .chat-empty .muted { max-width: 64ch; }
.chat-empty-title { font-size: 18px; font-weight: 600; margin-bottom: 10px; }

.suggest {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 26px;
}

.suggest .btn { font-size: 12px; color: var(--muted); }
.suggest .btn:hover { color: var(--text); }

.chat-thread { padding-bottom: 8px; }

.msg { margin: 0 0 22px; }

.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.msg.user .bubble {
  max-width: 85%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-note { font-size: 10px; letter-spacing: 0.08em; color: var(--faint); margin-top: 4px; }

.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}

.msg.ai:hover .msg-actions, .msg.ai:last-child .msg-actions { opacity: 1; }
.msg-actions .btn { padding: 2px 6px; font-size: 10px; }

/* Cavab hələ yazılır: son elementin sonunda yanıb-sönən kursor */
/* Üç nöqtə (gözləmə) ilə yanaşı kursor görünməsin - kursor yalnız mətn yazılanda */
.msg.ai.streaming .md > :last-child:not(.typing)::after {
  content: "▍";
  margin-left: 1px;
  animation: pulse 1s infinite;
}

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1s infinite;
}

.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }

/* Markdown */
.md { font-size: 14px; line-height: 1.75; word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 18px 0 8px; line-height: 1.4; font-weight: 600; }
.md h1 { font-size: 17px; }
.md h2 { font-size: 16px; }
.md h3, .md h4, .md h5, .md h6 { font-size: 14px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md hr { margin: 14px 0; }

.md blockquote {
  margin: 0 0 10px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}

.md code {
  font-family: var(--font);
  font-size: 12px;
  background: var(--raised);
  border-radius: var(--radius);
  padding: 1px 5px;
}

.md pre {
  position: relative;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.6;
}

.md pre code { background: none; padding: 0; white-space: pre; }

.md-lang {
  display: block;
  margin-bottom: 6px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.md-table { overflow-x: auto; margin: 0 0 12px; }
.md table { width: auto; min-width: 50%; }
.md th, .md td { padding: 6px 10px; border: 1px solid var(--border); }
.md th { font-size: 11px; letter-spacing: 0.04em; text-transform: none; color: var(--muted); font-weight: 600; }

/* Yazı sahəsi */
.composer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 12px 20px 8px;
}

.composer-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer textarea {
  flex: 1;
  width: 100%;
  min-height: 42px;
  max-height: 220px;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
}

.composer .btn { height: 42px; flex: none; justify-content: center; min-width: 92px; }

/* "AI səhv edə bilər" xəbərdarlığı - mobildə də görünür */
.composer-hint {
  max-width: 760px;
  margin: 5px auto 0;
  font-size: 10px;
  color: var(--faint);
  text-align: center;
}

/* Boş söhbət (body.chat-start, chat.js showEmpty): klassik AI çatları kimi başlıq və yazı
   qutusu ortada, ilk mesajdan sonra qutu aşağı düşür. Açıq söhbət bərpa olunarkən
   (.restoring) tətbiq olunmur - qutu ortadan aşağı tullanmasın. Telefonda qutu aşağıda qalır. */
@media (min-width: 601px) {
  html:not(.restoring) .chat-start .main-body { flex: 0 1 auto; margin-top: auto; padding-bottom: 12px; }
  html:not(.restoring) .chat-start .chat-empty { padding-top: 0; }
  html:not(.restoring) .chat-start .composer { margin-bottom: auto; padding-bottom: 12vh;
    border-top: none; background: transparent; }
}

@media (max-width: 600px) {
  .composer { padding: 10px 10px 6px; }
  .msg.user .bubble { max-width: 92%; }
  .msg-actions { opacity: 1; }
}

/* ---------- çat: səs və mikrofon ---------- */

.icon-tool {
  height: 42px;
  min-width: 42px;
  padding: 0 10px;
  justify-content: center;
  flex: none;
  color: var(--muted);
}

.icon-tool svg { width: 18px; height: 18px; display: block; }
.icon-tool:hover { color: var(--text); }


/* Mikrofon: dəyirmi düymə. Yazarkən ikon gizlənir, yerində ekvalayzer
   zolaqları səsin tezliklərinə görə böyüyüb-kiçilir (JS --h dəyişənini verir). */
#micBtn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  flex: none;
}

#micBtn.rec {
  background: var(--invert-bg);
  color: var(--invert-text);
  border-color: var(--invert-bg);
}

#micBtn .eq { display: none; align-items: center; justify-content: center; gap: 2.5px; height: 22px; }
#micBtn.rec .mic-icon { display: none; }
#micBtn.rec .eq { display: flex; }

#micBtn .eq i {
  --h: 0;
  width: 3px;
  height: calc(3px + var(--h) * 19px);
  border-radius: 2px;
  background: currentColor;
  transition: height 60ms linear;
}

#micBtn.busy { opacity: 0.5; pointer-events: none; }

.msg.ai.speaking .msg-actions { opacity: 1; }
.msg-actions .audio-btn { padding: 2px 6px; }
.msg-actions .audio-btn svg { width: 13px; height: 13px; display: block; }
.msg-actions .audio-btn.on { color: var(--text); border-color: var(--border-strong); }
.composer .icon-tool { min-width: 42px; padding: 0 10px; }
#micBtn.unavail { opacity: 0.45; }

.msg-sources { font-size: 12.5px; line-height: 1.6; color: var(--faint); margin-top: 8px; letter-spacing: 0.01em; }
.msg-sources a { color: var(--muted); }
.msg-sources a:hover { color: var(--text); }

/* Yazı qutusu: [mikrofon | mətn | fayl] bir çərçivədə. Düymələr kvadratdır, mətndən
   xətt ilə ayrılır; mətn uzananda ikonlar aşağıda (son sətrin yanında) qalır.
   Səslə yazılmış mətni silən × mətn sahəsinin sağ yuxarı küncündədir. */
.input-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.input-wrap:focus-within { border-color: var(--text); }
.input-field { position: relative; flex: 1; display: flex; min-width: 0; }
.composer .input-field textarea { flex: 1; width: 100%; min-height: 52px; padding: 14px 12px; border: none; background: transparent; }
.input-wrap.has-clear textarea { padding-right: 32px; }
/* Uzun yer tutucu (Banx) dar ekranda ikinci sətrə düşüb kəsilməsin */
.composer .input-field textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.composer .input-wrap .icon-tool,
.composer .input-wrap #micBtn {
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: auto;
  min-height: 52px;
  padding: 0 0 17px;
  border: none;
  border-radius: 0;
  background: transparent;
}

.composer .input-wrap #micBtn { border-right: 1px solid var(--border); }
.composer .input-wrap #attachBtn { border-left: 1px solid var(--border); }
.composer .input-wrap .icon-tool:hover { background: var(--raised); }
.composer .input-wrap #micBtn .eq { height: 20px; }
.composer .input-wrap #micBtn.rec { background: var(--invert-bg); color: var(--invert-text); }

.clear-btn {
  position: absolute;
  top: 15px;
  right: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--raised);
  color: var(--muted);
}

.clear-btn:hover { color: var(--text); background: var(--border); }
.clear-btn svg { width: 11px; height: 11px; display: block; }

/* Agent alət işlədərkən üç nöqtənin yanında status */
.tool-status { margin-left: 10px; font-size: 11px; color: var(--muted); animation: pulse 1.4s infinite; }

/* Cavabın altındakı ikon düymələr (kopyala, yenidən, səs) və onların ipucu */
.msg-actions .icon-act { padding: 4px 6px; position: relative; }
.msg-actions .icon-act svg { width: 15px; height: 15px; display: block; }
.msg-actions [data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;                      /* sola hizalı - ilk düymədə panelin kənarından kəsilməsin */
  bottom: calc(100% + 6px);
  transform: translateY(2px);
  white-space: nowrap;
  padding: 4px 8px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--invert-text);
  background: var(--invert-bg);
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
  z-index: 20;
}
.msg-actions [data-tip]:hover::after,
.msg-actions [data-tip]:focus-visible::after { opacity: 1; transform: translateY(0); }
/* toxunma ekranında ipucu ilişib qalmasın */
@media (hover: none) { .msg-actions [data-tip]::after { display: none; } }

/* ---------- mikrofon yazısı (ASR girişi və TTS referansı) ---------- */

.rec-box {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.rec-box.on { border-style: solid; border-color: var(--text); background: var(--panel); }
.rec-info { flex: 1; min-width: 0; }
.rec-title { font-size: 14px; color: var(--text); }
.rec-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.rec-time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text); min-width: 42px; text-align: right; }

.rec-btn {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.rec-btn:hover { border-color: var(--text); }
.rec-btn svg { width: 20px; height: 20px; display: block; }
.rec-btn .stop-icon { display: none; }
.rec-btn.unavail { opacity: 0.45; }
.on > .rec-btn, .rec-btn.on { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.on > .rec-btn .mic-icon, .rec-btn.on .mic-icon { display: none; }
.on > .rec-btn .stop-icon, .rec-btn.on .stop-icon { display: block; }
.rec-btn:disabled { opacity: 0.5; cursor: default; }

.rec-eq { display: inline-flex; align-items: center; gap: 3px; height: 24px; }
.rec-eq i {
  --h: 0;
  width: 3px;
  height: calc(3px + var(--h) * 21px);
  border-radius: 2px;
  background: var(--text);
  transition: height 60ms linear;
}

/* TTS: oxunacaq cümlə */
.rec-panel {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rec-sentence {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--raised);
}
.rec-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rec-row .spacer { flex: 1; }
.rec-row audio { height: 36px; max-width: 100%; flex: 1 1 220px; }
.mic-link {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mic-link svg { width: 15px; height: 15px; }

@media (max-width: 560px) {
  .rec-box { flex-wrap: wrap; }
  .rec-sentence { font-size: 16px; }
}

/* ---------- sol panel siyahıları (çat, ASR, TTS): vaxt qrupları + üç nöqtəli menyu (ui.js) ---------- */

.list-group {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px 6px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-align: left;
  cursor: pointer;
}
.list-group:hover { color: var(--text); }
.list-group svg { width: 12px; height: 12px; flex: none; transition: transform 0.15s; }
.list-group.open svg { transform: rotate(90deg); }         /* ox aşağı dönür */
.list-group.pinned { cursor: default; }
.list-group.pinned svg { transform: none; }
.list-group .list-count { margin-left: auto; color: var(--faint); font-size: 10px; }

.list-item { padding-right: 34px; }
.draft-item .file-meta { font-style: italic; }
.draft-item .row-more { position: absolute; font-size: 16px; line-height: 1; }

.row-more {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}
.row-more svg { width: 14px; height: 14px; }
.list-item:hover .row-more, .row-more.on, .row-more:focus-visible { opacity: 1; }
.row-more:hover, .row-more.on { color: var(--text); border-color: var(--border-strong); background: var(--bg); }
@media (hover: none) { .row-more { opacity: 1; } }

.row-menu {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.row-menu-item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.row-menu-item:hover { background: var(--raised); }
/* Bəndlər arasında nazik xətt - "adını dəyiş / sancaqla / sil" bir-birinə qarışmasın */
.row-menu-item + .row-menu-item {
  border-top: 1px solid var(--border);
  border-radius: 0;
}
.row-menu-item.danger { color: var(--danger, #e5484d); }

/* ---------- çat: fayl və şəkil (yalnız AI) ---------- */

.attach-tray {
  max-width: 760px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attach-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  height: 46px;
  padding: 4px 28px 4px 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.attach-chip.busy { opacity: 0.7; }
.attach-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: var(--radius); flex: none; }
.attach-chip .file-icon { width: 36px; height: 36px; }

.attach-x {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 20px;
  cursor: pointer;
}

.attach-x:hover { background: var(--raised); color: var(--text); }

.file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--raised);
  border-radius: var(--radius);
  color: var(--muted);
}

.file-icon svg { width: 18px; height: 18px; }
.file-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.file-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 10px; color: var(--faint); white-space: nowrap; }

/* Mesajdakı fayllar (istifadəçi mesajının üstündə, sağda) */
.msg-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 85%; }

.file-thumb {
  display: block;
  width: 148px;
  height: 148px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--raised);
}

.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 6px 12px 6px 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.file-card:hover { border-color: var(--border-strong); }
.file-card .file-icon { width: 34px; height: 34px; }

/* Faylı çat sahəsinə sürükləyəndə yazı sahəsi işıqlanır */
.composer.drop { outline: 2px dashed var(--border-strong); outline-offset: -6px; }

@media (max-width: 600px) {
  .file-thumb { width: 112px; height: 112px; }
  .attach-chip { max-width: 100%; }
  .msg-files { max-width: 92%; }
}

/* ---------- daxili izah səhifəsi (/docs/banx) ---------- */
/* Sxemlər HTML qutularıdır (SVG yox): ekran daralanda öz-özünə alt-alta düzülür, rənglər
   mövzu dəyişənlərindən gəlir. Yaxşı/pis üçün yalnız iki rəng (--doc-good / --doc-bad). */

:root { --doc-good: #1f8a4c; --doc-bad: #c4473a; --doc-hl: rgba(255, 196, 0, 0.28); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --doc-good: #4cc382; --doc-bad: #ef6b5e; --doc-hl: rgba(255, 196, 0, 0.22); }
}
:root[data-theme="dark"] { --doc-good: #4cc382; --doc-bad: #ef6b5e; --doc-hl: rgba(255, 196, 0, 0.22); }

.doc-scroll { overflow-y: auto; }
.doc-loading, .doc-denied { max-width: 760px; margin: 60px auto; padding: 0 16px; color: var(--muted); font-size: 13px; text-align: center; }
.doc-denied { color: var(--text); border: 1px solid var(--border); padding: 24px 16px; }

.doc { max-width: 920px; margin: 0 auto; padding: 32px 16px 64px; font-size: 14px; line-height: 1.7; }
.doc b { font-weight: 600; }
.doc p { margin: 0 0 12px; }

.doc-head { border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 20px; }
.doc-kicker { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.doc h1 { font-size: 30px; line-height: 1.2; margin: 6px 0 10px; font-weight: 600; }
.doc-lead { font-size: 16px; color: var(--muted); max-width: 680px; }
.doc-meta { font-size: 11px; color: var(--faint); margin: 0; }

.doc-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 36px; }
.doc-toc a {
  font-size: 12px; color: var(--muted); text-decoration: none; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.doc-toc a:hover { color: var(--text); border-color: var(--border-strong); }

.doc-sec { margin: 0 0 48px; scroll-margin-top: 16px; }
.doc h2 { display: flex; align-items: center; gap: 12px; font-size: 20px; line-height: 1.3; margin: 0 0 14px; font-weight: 600; }
.doc-num {
  flex: none; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--invert-bg); color: var(--invert-text); font-size: 14px; border-radius: var(--radius);
}
.doc-note { font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--border-strong); padding-left: 12px; margin-top: 16px; }

/* qutular */
.doc-box { border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius); padding: 14px 16px; }
.doc-box p { margin: 0; font-size: 13px; color: var(--muted); }
.doc-box-t { font-weight: 600; margin-bottom: 6px; }
.doc-trio { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 10px; margin: 18px 0 4px; }
.doc-arrow { display: flex; align-items: center; color: var(--faint); font-size: 20px; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.doc-q {
  border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0 16px;
  font-size: 14px; background: var(--bg);
}
.doc-q::before { content: "sual: "; color: var(--faint); }

/* addımlar: sol - nə edilir, sağ - misalda nə olur; aralarda ox */
.doc-steps { list-style: none; counter-reset: st; margin: 0; padding: 0; }
.doc-steps li {
  counter-increment: st; position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 14px 58px; margin-bottom: 26px;
  background: var(--panel);
}
.doc-steps li::before {
  content: counter(st); position: absolute; left: 14px; top: 14px; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong);
  border-radius: 50%; font-size: 13px; font-weight: 600; background: var(--bg);
}
.doc-steps li:not(:last-child)::after {
  content: "↓"; position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%);
  color: var(--faint); font-size: 16px; line-height: 20px;
}
.doc-step-what b { display: block; margin-bottom: 2px; }
.doc-step-what span { font-size: 13px; color: var(--muted); }
.doc-step-ex {
  font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; align-self: start; word-break: break-word;
}
.doc-step-ex::before { content: "misalda"; display: block; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 2px; }
.doc-src { color: var(--faint); font-size: 11.5px; }

/* əvvəl / indi */
.doc-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0 8px; }
.doc-col { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.doc-col > p { font-size: 13px; color: var(--muted); }
.doc-col-h { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 12px; }
.doc-col-h.bad { color: var(--doc-bad); }
.doc-col-h.good { color: var(--doc-good); }
.doc-facts { margin: 12px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }

/* kartlar */
.doc-cardrow { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-card {
  display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg); padding: 8px; font-size: 12px; box-shadow: 2px 2px 0 var(--border);
}
.doc-card i { font-style: normal; padding: 1px 5px; border-radius: var(--radius); background: var(--raised); }
.doc-card i.hl, .doc-leaf.hl { background: var(--doc-hl); outline: 1px solid rgba(255, 196, 0, 0.6); }
.doc-cardrow.big .doc-card { flex: 1 1 140px; }
.doc-cardrow.small .doc-card { flex: 0 1 auto; min-width: 74px; }
.doc-card.dots { justify-content: center; align-items: center; color: var(--faint); box-shadow: none; border-style: dashed; }
.doc-card.wide { width: 100%; }
.doc-card.wide i { padding: 3px 6px; line-height: 1.5; }
.doc-parent {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: var(--radius);
  background: var(--invert-bg); color: var(--invert-text);
}
.doc-parent.block { display: block; font-weight: 500; line-height: 1.5; padding: 3px 6px; }

.doc-meter { height: 8px; border: 1px solid var(--border); border-radius: var(--radius); margin-top: 12px; overflow: hidden; }
.doc-meter span { display: block; height: 100%; background: var(--text); opacity: 0.55; }
.doc-meter-l { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }

.doc-answer { font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: var(--radius); border: 1px solid; }
.doc-answer.bad { color: var(--doc-bad); border-color: var(--doc-bad); }
.doc-answer.good { color: var(--doc-good); border-color: var(--doc-good); }

/* qanun ağacı: üst bənd -> alt bənd */
.doc-tree { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0 8px; }
.doc-branch { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--panel); }
.doc-branch-h { font-size: 12.5px; padding-bottom: 8px; border-bottom: 1px dashed var(--border-strong); }
.doc-leaf { font-size: 12.5px; margin: 8px 0 0 18px; position: relative; padding: 4px 8px; border-radius: var(--radius); background: var(--bg); }
.doc-leaf::before { content: "└"; position: absolute; left: -16px; top: 3px; color: var(--faint); }

/* nəticə zolaqları */
.doc-bars { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.doc-bar { display: grid; grid-template-columns: 260px 1fr 64px; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 12.5px; }
.doc-bar-l { color: var(--muted); }
.doc-bar-t { height: 18px; background: var(--raised); border-radius: var(--radius); overflow: hidden; }
.doc-bar-t span { display: block; height: 100%; background: var(--border-strong); }
.doc-bar.now .doc-bar-t span { background: var(--doc-good); }
.doc-bar.now .doc-bar-l, .doc-bar.now b { color: var(--text); }
.doc-bar b { text-align: right; }
.doc-bars-axis { font-size: 11px; color: var(--faint); margin: 4px 0 0; }

.doc-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.doc-kpi { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.doc-kpi b { display: block; font-size: 24px; line-height: 1.2; margin-bottom: 4px; }
.doc-kpi span { font-size: 12px; color: var(--muted); }

.doc-table-wrap { overflow-x: auto; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-table th, .doc-table td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.doc-table th { font-size: 11px; color: var(--muted); font-weight: 600; }
.doc-table tr.now td { background: var(--panel); }

.doc-list { padding-left: 18px; }
.doc-list li { margin-bottom: 8px; }
.doc-foot { border-top: 1px solid var(--border); padding-top: 16px; font-size: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .doc { padding-top: 20px; }
  .doc h1 { font-size: 24px; }
  .doc-trio { grid-template-columns: 1fr; }
  .doc-arrow { justify-content: center; transform: rotate(90deg); }
  .doc-grid, .doc-compare, .doc-tree, .doc-kpis { grid-template-columns: 1fr; }
  .doc-steps li { grid-template-columns: 1fr; padding-left: 52px; }
  .doc-bar { grid-template-columns: 1fr 52px; }
  .doc-bar-l { grid-column: 1 / -1; }
}

/* izah səhifəsi: 3-4-cü bölmələrin əlavə elementləri */
.doc-h3 { font-size: 15px; font-weight: 600; margin: 26px 0 8px; }
.doc-analogy { border: 1px solid var(--border); border-left: 3px solid var(--text); background: var(--panel);
  border-radius: var(--radius); padding: 12px 14px; margin: 10px 0 16px; font-size: 13.5px; }
.doc-takeaway { border: 1px solid var(--doc-good); border-radius: var(--radius); padding: 12px 14px; margin-top: 16px; font-size: 13.5px; }
.doc-eg { margin-top: 8px !important; font-style: italic; }
.doc-eg::before { content: "Misal: "; font-style: normal; color: var(--faint); }
.doc-chain { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; gap: 8px; align-items: stretch; margin: 6px 0 8px; }
.doc-chain-step { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px; background: var(--bg); text-align: center; }
.doc-chain-step b { display: block; font-size: 13px; }
.doc-chain-step span { font-size: 11.5px; color: var(--muted); }
.doc-chain-arr, .doc-addr-arr { display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 18px; }
.doc-addr { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 8px; margin: 8px 0; }
.doc-addr > div:not(.doc-addr-arr) { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--panel); }
.doc-addr b { display: block; font-size: 18px; }
.doc-addr span { font-size: 12.5px; }
.doc-addr small { color: var(--muted); font-size: 11.5px; }
.doc-why { padding-left: 20px; font-size: 13px; margin: 10px 0 12px; }
.doc-why li { margin-bottom: 4px; }
.doc-meter.inline { display: inline-block; width: 70px; height: 8px; margin: 0 4px; vertical-align: middle; }

@media (max-width: 760px) {
  .doc-chain, .doc-addr { grid-template-columns: 1fr; }
  .doc-chain-arr, .doc-addr-arr { transform: rotate(90deg); }
}

/* Cavabın səs menyusu (⋮): danışan və sürət */
.voice-menu { min-width: 200px; }
.voice-menu-head {
  padding: 6px 10px 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.voice-menu-head + .row-menu-item { border-top: 0; }
.voice-menu .voice-speeds + .voice-menu-head,
.voice-menu .row-menu-item + .voice-menu-head { margin-top: 4px; border-top: 1px solid var(--border); }
.voice-menu .voice-item { display: flex; align-items: center; gap: 6px; }
.voice-check { width: 14px; height: 14px; flex: none; }
.voice-check svg { width: 14px; height: 14px; display: block; }
.voice-menu .voice-item.on { font-weight: 600; }
.voice-speeds { display: flex; gap: 4px; padding: 2px 6px 6px; }
.voice-speed {
  flex: 1;
  padding: 5px 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.voice-speed:hover { color: var(--text); border-color: var(--border-strong); }
.voice-speed.on { color: var(--text); border-color: var(--text); font-weight: 600; }
.msg-actions .voice-more.on { color: var(--text); }
.voice-name { flex: 1; }
.voice-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted);
}
.voice-play svg { width: 11px; height: 11px; display: block; }
.voice-play:hover, .voice-play.on { color: var(--text); border-color: var(--border-strong); }
.voice-play.busy { animation: pulse 1.4s infinite; }

/* ---------- TTS: səs klonlama paneli və hazır səslər ---------- */
.clone-panel { border: 1px solid var(--border); border-radius: var(--radius); }
.clone-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: var(--panel);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.clone-toggle:hover .label { color: var(--text); }
.clone-toggle svg { width: 12px; height: 12px; flex: none; color: var(--muted); transition: transform 0.15s ease; }
.clone-panel.open .clone-toggle svg { transform: rotate(90deg); }
.clone-panel.open .clone-toggle { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.clone-note { margin-left: auto; font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clone-body { display: flex; flex-direction: column; gap: 18px; padding: 14px 12px 12px; }

.preset-list { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.preset-item:hover { color: var(--text); border-color: var(--border-strong); }
.preset-item.on { color: var(--text); border-color: var(--text); font-weight: 600; }
.preset-item .voice-check { width: 14px; height: 14px; flex: none; }
.preset-item .voice-check svg { width: 14px; height: 14px; display: block; }
.preset-item .icon-btn.vplay { width: 24px; height: 24px; }
#presetBox.off .preset-list { opacity: 0.45; }

/* ---------- çat: sualın altında kopyala / redaktə et ---------- */
.msg.user .user-actions { margin-top: -2px; }
.msg.user:hover .user-actions, .msg.user:focus-within .user-actions { opacity: 1; }
/* ipucu sağa hizalı - sağ kənardan kəsilməsin */
.msg-actions.user-actions [data-tip]::after { left: auto; right: 0; }
.msg.user.editing .bubble, .msg.user.editing .user-actions { display: none; }
.edit-box { width: 85%; display: flex; flex-direction: column; gap: 8px; }
.edit-box textarea {
  width: 100%;
  min-height: 44px;
  resize: none;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.edit-actions { display: flex; justify-content: flex-end; gap: 6px; }
@media (max-width: 600px) { .edit-box { width: 92%; } }
@media (hover: none) { .msg.user .user-actions { opacity: 1; } }

/* TTS: düymələrdə ikon (səs yarat, oxut, endir) */
.btn .btn-ico { width: 14px; height: 14px; flex: none; display: block; }
#genBtn, #playBtn, #dlBtn { display: inline-flex; align-items: center; gap: 7px; }
#playBtn .btn-ico, #dlBtn .btn-ico { width: 12px; height: 12px; }

/* Ümumi ipucu: düymənin üstündə dərhal çıxır (data-tip). tip-left - sağ kənardakı
   düymələr üçün sağa hizalı; tip-below - yuxarı zolaqdakı düymələr üçün aşağıda */
.tip { position: relative; }
/* özü absolute yerləşən düymələr yerində qalsın */
.clear-btn.tip { position: absolute; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translate(-50%, 2px);
  white-space: nowrap;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.4;
  text-transform: none;
  color: var(--invert-text);
  background: var(--invert-bg);
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
  z-index: 30;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.tip.tip-left::after { left: auto; right: 0; transform: translateY(2px); }
.tip.tip-left:hover::after, .tip.tip-left:focus-visible::after { transform: translateY(0); }
.tip.tip-below::after { bottom: auto; top: calc(100% + 6px); }
/* hazır səsin ▶ düyməsinə gələndə yalnız onun ipucu görünsün */
.preset-item:has(.vplay:hover)::after { opacity: 0; }
@media (hover: none) { .tip::after { display: none; } }

/* ---------- çat: kod bloku (md.js codeBlock) - başlıq, kopyala, rəngləmə ---------- */
:root { --tk-k: #8a3ffc; --tk-s: #198038; --tk-n: #b45309; --tk-c: #8d8d8d; --code-bg: #f6f6f6; }
:root[data-theme="dark"] { --tk-k: #c39bff; --tk-s: #7ed99a; --tk-n: #f2b56b; --tk-c: #7a7a7a; --code-bg: #0b0b0b; }
.md .code-block {
  margin: 0 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--code-bg);
}
.md .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px 4px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.md .code-lang { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.md .code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.md .code-copy svg { width: 13px; height: 13px; display: block; }
.md .code-copy:hover, .md .code-copy.done { color: var(--text); border-color: var(--border-strong); }
.md .code-block pre { margin: 0; border: none; border-radius: 0; background: transparent; padding: 12px 14px; }
.md .tk-k { color: var(--tk-k); }
.md .tk-s { color: var(--tk-s); }
.md .tk-n { color: var(--tk-n); }
.md .tk-c { color: var(--tk-c); font-style: italic; }
@media print { .md .code-copy { display: none; } }

/* ---------- çat: göndər düyməsi - kvadrat ikon, mesaj qutusundan az aralı ---------- */
.composer-inner { gap: 6px; }
.send-btn {
  flex: none;
  width: 54px;
  height: 54px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--invert-bg);
  border-radius: var(--radius);
  background: var(--invert-bg);
  color: var(--invert-text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, opacity 0.12s;
}
.send-btn svg { width: 18px; height: 18px; display: block; }
.send-btn .stop-icon { display: none; }
/* Ümumi "button:hover" fonu boz edirdi (aktiv düymə qaralır / ağ temada ağarırdı) -
   göndərdə rəng yalnız bir ton dəyişir (fona doğru 12%) */
.send-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--invert-bg) 88%, var(--bg));
  border-color: color-mix(in srgb, var(--invert-bg) 88%, var(--bg));
}
/* sönük halda üzərinə gələndə ox fayl ikonu kimi parlaqlaşır */
.send-btn:disabled:hover { background: var(--bg); color: var(--text); }
/* qutu boşdur - sönük */
.send-btn:disabled {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--muted);      /* fayl ikonunun rəngi (.icon-tool) */
  cursor: default;
  opacity: 1;              /* ümumi button:disabled 0.4 edirdi - xətt qutununkundan tutqun görünürdü */
}
/* cavab yazılır: içində ağ dairə, basanda dayanır */
.send-btn.streaming { background: var(--bg); border-color: var(--border-strong); color: var(--text); }
.send-btn.streaming .send-icon { display: none; }
.send-btn.streaming .stop-icon { display: block; }
.send-btn.streaming:hover { background: color-mix(in srgb, var(--bg) 88%, var(--text)); border-color: var(--border-strong); }

/* ---------- OCR səhifəsi (ocr.html) ---------- */

.ocr-page { --bad: #c4372c; --good: #2f8f4e; --scan: #e53935; }
:root[data-theme="dark"] .ocr-page { --bad: #e8695e; --good: #5cbf7c; --scan: #ff4d4d; }
.ocr-wrap { max-width: 1180px; margin: 0 auto; }
.ocr-head h1 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.ocr-head p { margin: 0 0 20px; max-width: 760px; line-height: 1.6; }
.ocr-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
.ocr-col { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
/* iki sütunda şəkil paneli yerində qalır - cədvəlin aşağısına düşəndə də şəkil görünür */
.ocr-grid > .ocr-col:first-child { position: sticky; top: 0; }

/* şəkil + skan xətti: xətt şəklin öz enində/hündürlüyündə gedib-gəlir */
.ocr-preview { border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius); }
.ocr-img { position: relative; display: flex; flex-direction: column; align-items: center; background: var(--raised); }
.ocr-img img, .ocr-more img { cursor: zoom-in; }
.ocr-preview.scanning .ocr-img img { cursor: default; }
/* lupa düyməsi - şəklin sağ yuxarı küncündə */
.ocr-zoom { position: absolute; top: 8px; right: 8px; z-index: 2; width: 32px; height: 32px; padding: 0;
            display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong);
            border-radius: var(--radius); background: color-mix(in srgb, var(--bg) 82%, transparent);
            color: var(--text); cursor: pointer; }
.ocr-zoom svg { width: 16px; height: 16px; }
.ocr-zoom:hover { background: var(--bg); border-color: var(--text); }
.ocr-zoom.tip { position: absolute; }

/* böyüdücü (zoom.js): şəkil panelinin içində (cədvəl yanında) və ya tam ekran */
body.zoom-open { overflow: hidden; }
.zooming > :not(.zoom-back) { display: none !important; }
.zoom-back.zoom-inline { position: relative; inset: auto; z-index: 1; width: 100%;
                         height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 380px;
                         border-radius: var(--radius); }
.zoom-inline .zoom-bar { top: 8px; }
.zoom-back { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, 0.9); }
.zoom-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: zoom-in; }
.zoom-stage.pannable { cursor: grab; }
.zoom-stage.pannable:active { cursor: grabbing; }
.zoom-img { position: absolute; top: 0; left: 0; max-width: none; max-height: none; transform-origin: 0 0;
            user-select: none; -webkit-user-select: none; background: #fff; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5); }
.zoom-bar { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: flex; align-items: center;
            gap: 4px; padding: 5px; border: 1px solid #3d3d3d; border-radius: var(--radius); background: #111;
            color: #e8e8e8; font-size: 12px; max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; }
.zoom-btn { width: 34px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;
            border: 1px solid transparent; border-radius: var(--radius); background: none; color: #e8e8e8; cursor: pointer; }
.zoom-btn svg { width: 16px; height: 16px; }
.zoom-btn:hover:not(:disabled) { border-color: #5f5f5f; background: #1d1d1d; }
.zoom-btn:disabled { opacity: 0.35; cursor: default; }
.zoom-pct, .zoom-page { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; color: #bdbdbd; }
/* PDF scan-dan əvvəl brauzerdə göstərilmir - yer tutan lövhə (skan xətti onun üzərində gedir) */
.ocr-pdf { display: flex; align-items: center; justify-content: center; width: 220px; height: 290px;
           margin: 18px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--muted);
           font-size: 22px; letter-spacing: 0.2em; line-height: 1; }
.ocr-pdf.hidden { display: none; }
/* PDF-in 2-ci və sonrakı səhifələri */
.ocr-more { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.ocr-more:not(:empty) { padding: 8px 0; border-top: 1px solid var(--border); }
.ocr-more img { display: block; max-width: 100%; max-height: 72vh; }
.ocr-img-in { position: relative; display: inline-block; max-width: 100%; line-height: 0; overflow: hidden; }
.ocr-img-in img { display: block; max-width: 100%; max-height: 72vh; width: auto; height: auto; }
.scan-line { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--scan);
             box-shadow: 0 0 12px 3px color-mix(in srgb, var(--scan) 65%, transparent); display: none; }
.ocr-preview.scanning .scan-line { display: block; animation: ocr-scan 2.2s ease-in-out infinite alternate; }
@keyframes ocr-scan { from { top: 0; } to { top: calc(100% - 2px); } }
.ocr-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px;
                   border-top: 1px solid var(--border); flex-wrap: wrap; }
#scanBtn, #removeBtn, #exportBtn { display: inline-flex; align-items: center; gap: 6px; }
#removeBtn .btn-ico, #exportBtn .btn-ico { width: 12px; height: 12px; }

.ocr-section { display: flex; flex-direction: column; gap: 10px; }
.ocr-time { font-size: 11px; }
.ocr-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: 12px;
            line-height: 1.6; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
            background: var(--panel); max-height: 420px; overflow-y: auto; }
.ocr-check { font-size: 12px; padding: 8px 10px; border: 1px solid var(--border-strong); border-left-width: 3px;
             border-radius: var(--radius); background: var(--panel); line-height: 1.5; }
.ocr-check.ok { border-left-color: var(--good); }
.ocr-check.bad { border-left-color: var(--bad); }

.ocr-meta, .ocr-items { width: 100%; border-collapse: collapse; font-size: 12px; }
.ocr-meta th, .ocr-meta td, .ocr-items th, .ocr-items td { padding: 6px 8px; border-bottom: 1px solid var(--border);
                                                           text-align: left; vertical-align: middle; }
.ocr-meta th { width: 30%; color: var(--muted); font-weight: 400; }
.ocr-meta td.empty { color: var(--faint); }
.ocr-totals { margin-top: 4px; }
.ocr-totals td { text-align: right; font-variant-numeric: tabular-nums; }
.ocr-totals tr[data-key="total"] th, .ocr-totals tr[data-key="total"] td { color: var(--text); font-weight: 600; }
.ocr-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.ocr-items th { color: var(--muted); font-weight: 400; background: var(--panel); white-space: nowrap; }
.ocr-items td { overflow-wrap: break-word; }
.ocr-items td:nth-child(2) { min-width: 140px; }
.ocr-items .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ocr-items .idx { color: var(--faint); width: 1%; }
.ocr-items .mark { width: 1%; text-align: center; color: var(--good); padding-left: 2px; padding-right: 2px; }
.ocr-items tr:last-child td { border-bottom: 0; }
.ocr-items tr.bad td, .ocr-totals tr.bad th, .ocr-totals tr.bad td { color: var(--bad); }
.ocr-items tr.bad .mark { color: var(--bad); cursor: help; }

/* redaktə: ✎ sətrin üzərinə gələndə görünür; redaktədə ✓ ✕ 🗑 */
.ocr-page td.act { width: 1%; white-space: nowrap; text-align: right; padding: 2px 4px; }
.ocr-ico { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
           border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--muted);
           cursor: pointer; vertical-align: middle; }
.ocr-ico svg { width: 13px; height: 13px; }
.ocr-ico:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg); }
.ocr-ico.danger:hover { color: var(--bad); }
.ocr-page tr:not(.editing) td.act .ocr-ico { opacity: 0; }
.ocr-page tr:hover td.act .ocr-ico, .ocr-page td.act .ocr-ico:focus-visible { opacity: 1; }
@media (hover: none) { .ocr-page tr:not(.editing) td.act .ocr-ico { opacity: 1; } }
.ocr-page tr.editing td { background: var(--panel); }
.ocr-input { width: 100%; min-width: 0; padding: 4px 6px; font-size: 12px; font-family: var(--font); }
.ocr-input.num { text-align: right; width: 72px; }
.ocr-input.unit { width: 56px; }
.ocr-items td.unit { color: var(--muted); white-space: nowrap; }
.ocr-items tr.editing td.num { width: 1%; }
.ocr-items tr.editing td:nth-child(2) { width: 100%; }
.ocr-input.invalid { border-color: var(--bad); }
.ocr-add { align-self: flex-start; }
.ocr-sub { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.ocr-extra th { width: 38%; }
.ocr-extra tr.editing th { padding-right: 4px; }
.ocr-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; border: 0; background: none;
              color: var(--muted); cursor: pointer; font-family: var(--font); }
.ocr-toggle:hover, .ocr-toggle:hover .label { color: var(--text); }
.ocr-toggle svg { width: 11px; height: 11px; transition: transform 0.15s; }
.ocr-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

/* sol panel açıq olanda iş sahəsi daralır - ekranın yox, sahənin enindən asılı olaraq
   şəkil cədvəlin üstünə keçir */
.ocr-page .main-body { container-type: inline-size; }
@container (max-width: 940px) {
  .ocr-grid { grid-template-columns: 1fr; }
  .ocr-grid > .ocr-col:first-child { position: static; }
  .zoom-back.zoom-inline { height: 70vh; }
  .ocr-img-in img { max-height: 46vh; }
}
@media (max-width: 860px) {
  .ocr-grid { grid-template-columns: 1fr; }
  .ocr-grid > .ocr-col:first-child { position: static; }
  .ocr-img-in img { max-height: 50vh; }
}

/* Heç bir tab açıq olmayan istifadəçi (ui.js -> guardTabs) */
.no-tabs { margin: 18vh auto 0; max-width: 46ch; padding: 0 16px; text-align: center; color: var(--muted); line-height: 1.6; }

/* Admin: istifadəçinin tabları (admin.html modalı) */
.tab-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tab-picks .tab-pick { display: inline-flex; margin: 0; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: 13px; user-select: none; }
.tab-picks .tab-pick input { width: auto; margin: 0; }
.tab-pick:has(input:checked) { border-color: var(--text); }
.tab-pick:has(input:disabled) { opacity: .55; cursor: default; }
.tab-picks-note { font-size: 12px; margin-top: 6px; }

/* =====================================================================
   ASR redaktoru (asr_editor.js): Sənəd və Studiya görünüşləri
   ===================================================================== */

/* ---------- giriş ekranı ---------- */
.input-view { max-width: 820px; padding-top: 12px; }
.input-head { margin-bottom: 18px; }
.input-head h1 { font-size: 18px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.input-head p { margin: 0; color: var(--muted); font-size: 12px; }
.input-view .dropzone { padding: 48px 20px 40px; background: var(--panel); }
.input-view .dropzone:hover, .input-view .dropzone.over { background: var(--raised); }
.dz-icon { width: 30px; height: 30px; display: block; margin: 0 auto 12px; color: var(--muted); }
.dropzone:hover .dz-icon, .dropzone.over .dz-icon { color: var(--text); }
.src-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.src-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--bg); }
.src-card.rec-box { border-style: solid; border-color: var(--border); }
.src-card.rec-box.on { border-color: var(--text); }
.src-title { font-size: 13px; font-weight: 600; }
.src-sub { font-size: 11px; color: var(--muted); margin: 2px 0 10px; }

/* ---------- alətlər sətri ---------- */
.doc-toolbar {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: 6px 20px; border-bottom: 1px solid var(--border); min-height: 41px;
}
.tb-group { display: flex; align-items: center; gap: 2px; flex: none; }
.tb-btn {
  width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  color: var(--muted); cursor: pointer; flex: none;
}
.tb-btn:hover { color: var(--text); background: var(--raised); }
.tb-btn.on { color: var(--text); border-color: var(--border-strong); }
.tb-btn svg { width: 15px; height: 15px; display: block; }
.tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }
.doc-toolbar .status-line { flex: 1; min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; }
.save-state { font-size: 11px; color: var(--faint); white-space: nowrap; flex: none; }
.save-state[data-kind="saved"]::before { content: "✓ "; }
.save-state[data-kind="dirty"], .save-state[data-kind="saving"] { color: var(--muted); }
.save-state[data-kind="error"] { color: #d14343; cursor: pointer; text-decoration: underline; }

.seg { display: inline-flex; flex: none; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.seg button {
  font-family: var(--font); font-size: 11px; letter-spacing: 0.04em; padding: 3px 10px;
  background: transparent; color: var(--muted); border: 0; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { color: var(--text); background: var(--raised); }
.seg button.on { background: var(--invert-bg); color: var(--invert-text); }

/* ---------- mətn ---------- */
.transcript.doc {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.75; white-space: pre-wrap; word-break: break-word;
  outline: none; min-height: 40vh; caret-color: var(--text);
}
.transcript.doc.raw { color: var(--muted); }
.transcript.doc p.para { margin: 0 0 1.05em; position: relative; padding-left: 66px; }
.transcript.doc p.para::before {
  content: attr(data-time); position: absolute; left: 0; top: 0.42em;
  font-family: var(--font); font-size: 11px; line-height: 1; letter-spacing: 0.04em;
  color: var(--faint); cursor: pointer; user-select: none;
}
.transcript.doc p.para:hover::before { color: var(--text); }
.transcript.doc .w { cursor: text; padding: 0; border-radius: 2px; transition: background 0.1s; }
.transcript.doc .w:hover { background: transparent; box-shadow: none; }
.transcript.doc:not([contenteditable="true"]) .w { cursor: pointer; }
.transcript.doc .w.on { background: var(--select-bg); color: inherit; box-shadow: none; }
::highlight(asr-find) { background-color: rgba(250, 199, 117, 0.55); }
::highlight(asr-find-cur) { background-color: rgba(239, 159, 39, 0.95); color: #111; }

/* ---------- Sənəd: vərəq ---------- */
.main-body:has(> .doc-view:not(.hidden)) { background: var(--panel); }
.doc-view { max-width: 1240px; margin: 0 auto; }
.layout-doc .doc-view .sheet {
  max-width: 860px; margin: 0 auto; background: var(--bg);
  border: 1px solid var(--border); padding: 56px 64px 80px; min-height: 70vh;
}
.layout-doc .studio-panel { display: none; }

/* ---------- Studiya: mətn + yan panel ---------- */
.layout-studio .doc-view {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start;
}
.layout-studio .doc-view.hidden { display: none; }
.layout-studio .doc-view .sheet {
  background: var(--bg); border: 1px solid var(--border); padding: 32px 36px 60px; min-height: 70vh;
}
.studio-panel {
  position: sticky; top: 0; display: flex; flex-direction: column; gap: 18px;
  background: var(--bg); border: 1px solid var(--border); padding: 16px;
  /* Hündürlük görünən sahəyə bərabərdir (app.js fitStudioPanel); bu, JS-siz ehtiyat həddir */
  max-height: calc(100vh - 210px); overflow: hidden;
}
/* Yuxarı bölmələr (dalğa, axtarış, məlumat) sıxılmır; yalnız "Abzaslar" qalan yeri tutur və
   öz içində sürüşür. Əvvəl uzun videoda (yüzlərlə abzas) siyahı bütün bölmələri sıxırdı və
   onlar bir-birinin üstünə düşürdü. */
.sp-sec { min-height: 0; flex: none; }
.sp-grow { flex: 1 1 0; min-height: 120px; display: flex; flex-direction: column; }
.sp-label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.wave { width: 100%; height: 64px; display: block; cursor: pointer; }
.sp-stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 12px; }
.sp-stats dt { color: var(--muted); }
.sp-stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.outline { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 0; min-height: 0; }
.outline li {
  display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 6px; padding: 5px 6px;
  font-size: 11px; line-height: 1.45; cursor: pointer; border-left: 2px solid transparent; color: var(--muted);
}
.outline li:hover { background: var(--raised); color: var(--text); }
.outline li.on { border-left-color: var(--text); color: var(--text); background: var(--raised); }
.ol-time { color: var(--faint); font-variant-numeric: tabular-nums; }
.ol-text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- axtar / əvəz et ---------- */
.find-bar { display: flex; flex-direction: column; gap: 6px; }
.layout-doc .find-bar {
  max-width: 860px; margin: 0 auto 10px; padding: 8px 10px; background: var(--bg);
  border: 1px solid var(--border-strong); position: sticky; top: -24px; z-index: 5;
}
.layout-studio .find-close { display: none; }
.find-row { display: flex; align-items: center; gap: 6px; }
.find-row input { padding: 5px 8px; font-size: 12px; flex: 1; min-width: 0; width: auto; }
.find-count { font-size: 11px; color: var(--muted); min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.find-count:empty { min-width: 0; }
.find-row .btn { white-space: nowrap; }

/* ---------- pleyer ---------- */
.player { gap: 10px; padding: 8px 20px; }
.player .time { font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
.pl-btn {
  font-family: var(--font); font-size: 11px; background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 3px 7px; cursor: pointer; flex: none;
}
.pl-btn:hover { color: var(--text); border-color: var(--border-strong); }
.pl-play {
  width: 36px; height: 36px; border-radius: 50%; border: 0; flex: none; cursor: pointer; padding: 0;
  background: var(--invert-bg); color: var(--invert-text); display: inline-flex; align-items: center; justify-content: center;
}
/* Ümumi button:hover fonu boz edir - burada düymə öz rəngində qalır, yalnız bir az solur */
.pl-play:hover { background: var(--invert-bg); opacity: 0.82; }
.pl-play svg { width: 20px; height: 20px; display: block; }
.pl-play .i-pause, .player.playing .pl-play .i-play { display: none; }
.player.playing .pl-play .i-pause { display: block; }
.player .seek { flex: 1; min-width: 60px; padding: 0; border: 0; background: transparent; accent-color: var(--text); height: 18px; }
.player .speed { width: auto; flex: none; padding: 3px 6px; font-size: 11px; }

@media (max-width: 1100px) {
  .layout-studio .doc-view { grid-template-columns: minmax(0, 1fr) 250px; }
}

/* Dar ekran: həmişə Sənəd, vərəq kənarsız; vaxt abzasın üstündə */
@media (max-width: 860px) {
  #layoutSwitch { display: none; }
  .layout-studio .doc-view { display: block; }
  .studio-panel { display: none; }
  .layout-studio .find-close { display: inline-flex; }
  .layout-doc .doc-view .sheet, .layout-studio .doc-view .sheet { padding: 20px 16px 48px; border: 0; }
  .main-body:has(> .doc-view:not(.hidden)) { background: var(--bg); }
  .transcript.doc p.para { padding-left: 0; }
  .transcript.doc p.para::before { position: static; display: block; margin-bottom: 4px; }
  .doc-toolbar { padding: 6px 12px; gap: 8px; }
  .src-grid { grid-template-columns: minmax(0, 1fr); }
  .player { padding: 8px 12px; gap: 6px; }
  .player .speed { display: none; }
}

/* ---------- seçilmiş hissənin paneli (mətndə seçim olanda) ---------- */
.sel-bar {
  position: fixed; z-index: 60; display: flex; align-items: center; gap: 4px; padding: 4px;
  background: var(--invert-bg); color: var(--invert-text); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28); font-size: 11px; user-select: none;
}
.sel-bar.hidden { display: none; }
.sel-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border: 0;
  border-radius: 4px; background: transparent; color: inherit; font-family: var(--font); font-size: 11px; cursor: pointer;
}
.sel-btn:hover { background: rgba(127, 127, 127, 0.28); }
.sel-btn:disabled { opacity: 0.5; cursor: progress; }
.sel-btn svg { width: 14px; height: 14px; display: block; }
.sel-play { width: 28px; padding: 0; justify-content: center; }
.sel-play svg { width: 15px; height: 15px; }
.sel-play .i-pause, .sel-bar.playing .sel-play .i-play { display: none; }
.sel-bar.playing .sel-play .i-pause { display: block; }
.sel-time { padding: 0 6px 0 2px; opacity: 0.75; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sel-sep { width: 1px; height: 16px; background: currentColor; opacity: 0.25; margin: 0 2px; }
.sel-bar .hidden { display: none; }

/* ---------- format alətləri (alətlər sətrində) ---------- */
.doc-toolbar .tb-group { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.doc-toolbar .tb-group::-webkit-scrollbar { display: none; }
.tb-fmt { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.tb-txt { font-size: 13px; line-height: 1; color: var(--muted); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.tb-txt b, .tb-txt i, .tb-txt u { font-size: 14px; }
.tb-punct { font-size: 17px; font-weight: 700; padding-bottom: 3px; width: 24px; }
.tb-btn .hl-line { stroke: #e0b43a; }
.doc-toolbar .tb-btn.on { color: var(--invert-text); background: var(--invert-bg); border-color: var(--invert-bg); }

/* Söz formatları (redaktor) */
.transcript.doc .w.b { font-weight: 650; }
.transcript.doc .w.i { font-style: italic; }
.transcript.doc .w.u { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.transcript.doc .w.hl { background: #fff1a8; color: #111; box-shadow: 0 0 0 1px #fff1a8; }
:root[data-theme="dark"] .transcript.doc .w.hl { background: rgba(255, 214, 90, 0.32); color: inherit; box-shadow: 0 0 0 1px rgba(255, 214, 90, 0.32); }
.transcript.doc .w.hl.on { background: var(--select-bg); }

@media (max-width: 860px) {
  .doc-toolbar .status-line { display: none; }
}

/* ---------- ASR-in qeydi: musiqi / başqa dil / nitq yoxdur ---------- */
.asr-note.hidden { display: none; }
.asr-note.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 72px 16px 56px; gap: 12px; color: var(--muted);
}
.dn-icon {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; color: var(--text);
}
.dn-icon svg { width: 24px; height: 24px; }
.dn-tag {
  font-family: var(--font); font-size: 15px; letter-spacing: 0.04em; color: var(--text);
  padding: 4px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel);
}
.dn-text { max-width: 46ch; font-size: 13px; line-height: 1.6; }
.asr-note.banner {
  display: flex; align-items: flex-start; gap: 10px; margin: 0 0 22px; padding: 10px 12px;
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: 0;
  background: var(--panel); color: var(--muted); font-size: 12px; line-height: 1.55;
}
.asr-note.banner svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--text); }
.transcript.hidden { display: none; }

/* ---------- uğursuz transkripsiya ----------
   Siyahıda: sol kənarda qırmızı xətt və "⚠ uğursuz"; sənəddə: izah + "yenidən cəhd et" */
.file-item.failed { box-shadow: inset 2px 0 0 var(--danger, #e5484d); }
.file-item.failed.active { box-shadow: inset 3px 0 0 var(--danger, #e5484d); }
.file-item.failed .file-name { color: var(--muted); }
.file-item.failed .dot { display: none; }
.fail-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--danger, #e5484d); }
.fail-tag svg { width: 11px; height: 11px; flex: none; }
.asr-note.failed .dn-icon { border-color: var(--danger, #e5484d); color: var(--danger, #e5484d); }
.asr-note.failed .btn { margin-top: 4px; }
.asr-note.failed .dn-warn { min-height: 1em; font-size: 12px; color: var(--danger, #e5484d); }
.asr-note.failed .dn-warn:empty { display: none; }

/* ---------- başlıq: hesab menyusu (_account_menu.html, ui.js → accountMenu) ----------
   Ana səhifə, balans, API, admin, tema, çıxış bir düymənin arxasındadır. Masaüstündə
   sağ yuxarıda açılan kart, mobildə (≤600px) sağdan sürüşən çekmecə. */

.menu-btn {
  height: 36px;
  padding: 3px 10px 3px 3px;
  gap: 8px;
  border-radius: 999px;
  border-color: var(--border-strong);
  background: var(--bg);
}
.menu-btn:hover { background: var(--raised); }
.menu-btn[aria-expanded="true"] { border-color: var(--text); }

.avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--invert-bg);
  color: var(--invert-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}
.avatar.lg { width: 42px; height: 42px; font-size: 18px; }

.menu-ico, .um-item svg, .um-close svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.um-item svg .fill { fill: currentColor; stroke: none; }

.tb-balance { font-size: 11px; color: var(--muted); }

.um-backdrop {
  position: fixed;
  inset: 0;
  z-index: 59;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
body.um-open .um-backdrop { pointer-events: auto; }

.user-menu {
  position: fixed;
  z-index: 60;
  top: 58px;
  right: 14px;
  width: 300px;
  max-height: calc(100% - 72px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
}
body.um-open .user-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.um-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}
.um-id { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.um-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.um-user {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.um-close {
  display: none;
  border: none;
  padding: 8px;
  color: var(--muted);
  border-radius: 6px;
}
.um-close:hover { color: var(--text); }

.um-balance {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 12px 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.um-balance-val { font-size: 16px; font-weight: 600; }

.um-list { display: flex; flex-direction: column; padding: 6px; }
.um-foot { padding: 6px; border-top: 1px solid var(--border); }

.um-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  justify-content: flex-start;
}
.um-item:hover, .um-item:focus-visible { background: var(--raised); outline: none; }
.um-item svg { color: var(--muted); }
.um-theme-val { margin-left: auto; color: var(--muted); font-size: 12px; }
.um-theme-val::after { content: "ağ"; }
:root[data-theme="dark"] .um-theme-val::after { content: "qara"; }
.um-logout, .um-logout svg { color: var(--muted); }
.um-logout:hover, .um-logout:hover svg { color: var(--text); }

/* ---------- mobil başlıq (≤600px) ----------
   1-ci sətir: loqo + "milligram" ... menyu düyməsi. 2-ci sətir: xidmət tabları ekran eni
   boyunca (yalnız bir tab varsa gizlənir). Əvvəl düymələr ikinci sətrə düşür, marka sığmırdı. */
@media (max-width: 600px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    gap: 0 10px;
    padding: 0 12px;
  }
  .topbar-left { display: contents; }
  .brand { order: 1; flex: 1 1 auto; min-width: 0; height: 54px; gap: 10px; }
  .brand .logo { width: 30px; height: 30px; }
  .brand-name { font-size: 18px; }
  .brand-sub { display: none; }
  .topbar-right { order: 2; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .tb-balance { display: none !important; }

  .mode-switch {
    order: 3;
    flex: 1 1 100%;
    display: flex;
    margin: 0 0 10px;
    border-radius: 8px;
    overflow: hidden;
  }
  .mode-switch a {
    flex: 1;
    text-align: center;
    padding: 7px 0;
    font-size: 12px;
  }
  .mode-switch.single { display: none; }

  .user-menu {
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 330px);
    max-height: none;
    border-radius: 0;
    border-width: 0 0 0 1px;
    opacity: 1;
    transform: translateX(100%);
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.um-open .user-menu { transform: none; transition: transform 0.22s ease; }
  .um-backdrop { background: rgba(0, 0, 0, 0.5); }
  body.um-open .um-backdrop { opacity: 1; }
  .um-close { display: inline-flex; }
  .um-head { padding: 18px 12px 18px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
  .um-list { flex: 1; }
  .um-item { padding: 13px 12px; font-size: 14px; }
}

/* Tema düyməsinin ikonu (◐ simvolu monospace şriftdə yoxdur, kiçik üçbucaq kimi görünürdü) */
.theme-ico { width: 14px; height: 14px; display: block; }
.theme-ico circle { fill: none; stroke: currentColor; stroke-width: 2; }
.theme-ico path { fill: currentColor; }
#themeBtn:has(.theme-ico) { padding-left: 7px; padding-right: 7px; }

/* API sənədi: sol menyu + bir anda bir bölmə (api.js → docNav) */
.api-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 8px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
}
.api-layout .api-inner { margin: 0; padding-left: 24px; padding-right: 0; min-width: 0; }
.api-side {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 12px 24px 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.api-side-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin: 4px 10px 10px;
}
.api-side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}
.api-side-link .n {
  flex: none;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
}
.api-side-link:hover { color: var(--text); background: var(--raised); }
.api-side-link.active { color: var(--text); background: var(--raised); font-weight: 600; }
.api-side-link.active .n { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.api-side-sub { display: none; flex-direction: column; margin: 2px 0 6px 19px; border-left: 1px solid var(--border); }
.api-side-sub.open { display: flex; }
.api-side-sub a {
  font-size: 11.5px;
  padding: 5px 10px 5px 18px;
  color: var(--muted);
  text-decoration: none;
  margin-left: -1px;
  border-left: 1px solid transparent;
}
.api-side-sub a:hover { color: var(--text); }
.api-side-sub a.active { color: var(--text); border-left-color: var(--text); }

.api-sec:not(.active) { display: none; }
.api-sec > .api-h2:first-child { margin-top: 28px; }
.api-page h3[id] { scroll-margin-top: 16px; }

.api-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 40px;
}
.api-pager-link {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
}
.api-pager-link small { font-size: 10.5px; color: var(--muted); }
.api-pager-link.next { text-align: right; grid-column: 2; }
.api-pager-link:hover { background: var(--raised); }

/* Mobil: menyu yuxarıda üfüqi sürüşən zolaq olur, alt başlıqlar gizlənir */
@media (max-width: 860px) {
  .api-layout { display: block; padding: 0; }
  .api-layout .api-inner { padding: 18px 16px 56px; }
  .api-side {
    flex-direction: row;
    gap: 6px;
    z-index: 5;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    scrollbar-width: none;
  }
  .api-side::-webkit-scrollbar { display: none; }
  .api-side-title, .api-side-sub, .api-side-sub.open { display: none; }
  .api-side-link { flex: none; white-space: nowrap; padding: 6px 11px; border: 1px solid var(--border-strong); border-radius: 999px; }
  .api-side-link .n { display: none; }
  .api-side-link.active { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
  .api-sec > .api-h2:first-child { margin-top: 20px; }
  .api-page h3[id] { scroll-margin-top: 64px; }
  .api-pager-link { padding: 10px 12px; font-size: 12px; }
}
.api-page .api-h2 { scroll-margin-top: 12px; }
.api-list { margin: 8px 0 12px; padding-left: 18px; line-height: 1.8; }
.api-table th[scope], .api-table tr > th:first-child:not(:only-child) { white-space: nowrap; }

/* TTS: model seçimi (main-head-in sağında) - milligram tts pro / fast */
.model-pick { position: relative; flex: none; }
.model-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.model-btn:hover, .model-btn[aria-expanded="true"] { background: var(--raised); }
.model-btn .model-name { color: var(--muted); }
.model-btn .model-name b { color: var(--text); font-weight: 600; }
.model-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.model-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.model-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  width: 290px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.model-opt {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.model-opt:hover { background: var(--raised); }
.model-opt.on { background: var(--raised); }
.model-pick .model-opt { align-items: stretch; justify-content: flex-start; text-align: left; }
.mo-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.mo-desc { text-align: left; }
.mo-name { font-size: 12.5px; font-weight: 600; }
.mo-desc { font-size: 11px; color: var(--muted); line-height: 1.45; }
.mo-check { width: 14px; height: 14px; }
.mo-check svg { width: 14px; height: 14px; display: block; }
/* Fast modeldə klonlama və ətraflı (sürət, seed) yoxdur */
.engine-fast #clonePanel, .engine-fast #advBox { display: none; }
/* Fast tempo slayderi (yalnız fast-da) */
.tempo-box { display: none; }
.engine-fast .tempo-box { display: block; }
.tempo-row { display: flex; align-items: center; gap: 10px; }
.tempo-row input[type=range] { flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; accent-color: var(--text); height: 22px; }
.tempo-end { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tempo-val { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; }
.tempo-val.changed { color: var(--text); font-weight: 600; }
@media (max-width: 600px) {
  .model-btn { padding: 0 8px 0 10px; font-size: 11.5px; }
  .model-btn .mn-pre { display: none; }
  .model-menu { width: min(290px, calc(100vw - 24px)); }
}

/* TTS: səsləndiriləcək mətn üçün daha hündür sahə (mobil ekranda bir az az) */
#genText { min-height: 320px; }
@media (max-width: 600px) { #genText { min-height: 240px; } }

/* ---------- iş gedir: mətn hələ gəlməyib ---------- */
.doc-wait {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 46vh; gap: 14px; color: var(--muted);
}
.doc-wait.hidden { display: none; }
.sheet:has(> .doc-wait:not(.hidden)) > .transcript { display: none; }
.dw-spin {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--text);
  animation: dw-spin 0.9s linear infinite;
}
@keyframes dw-spin { to { transform: rotate(360deg); } }
.dw-text { font-family: var(--font); font-size: 14px; letter-spacing: 0.04em; color: var(--text); }
.dw-bar { width: min(260px, 70%); height: 2px; background: var(--border); overflow: hidden; }
.dw-bar.hidden { display: none; }
.dw-bar > i { display: block; height: 100%; width: 0; background: var(--text); transition: width 0.25s; }
.dw-hint { font-size: 12px; color: var(--faint); }
@media (prefers-reduced-motion: reduce) { .dw-spin { animation-duration: 3s; } }
