:root {
  --bg: #0a0c10;
  --bg-elevated: #11141a;
  --bg-soft: #171b23;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eef2f7;
  --text-muted: #9aa4b2;
  --text-subtle: #6b7280;
  --primary: #14b8a6;
  --primary-strong: #0d9488;
  --primary-soft: rgba(20, 184, 166, 0.12);
  --accent: #38bdf8;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-lg: 18px;
  --font: "Vazirmatn", Tahoma, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --container: 1180px;
  --transition: 180ms ease;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(20, 184, 166, 0.08), transparent 28%),
    linear-gradient(180deg, #0d1016 0%, var(--bg) 100%);
  line-height: 1.7;
}

a { color: inherit; text-decoration: none; }

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

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.container {
  width: min(var(--container), calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.88);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  min-height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.22);
}

.brand-mark:has(.brand-logo-img),
.brand-mark .brand-logo-img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.22);
}

.brand-mark:has(.brand-logo-img) {
  background: transparent;
  box-shadow: none;
}

.brand-copy h1 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-copy p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.nav-link {
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: var(--transition);
}

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

.nav-link.is-active {
  color: var(--text);
  background: var(--bg-elevated);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.nav-link--studio.is-active {
  color: #5eead4;
  background: rgba(20, 184, 166, 0.12);
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.toolbar-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

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

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 120px;
  padding: 0.22rem 0.55rem 0.22rem 0.28rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.user-badge-initial {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  flex-shrink: 0;
}

.user-badge-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit-panel { overflow: visible; }

.credit-panel .panel-body,
.credit-panel { padding: 0; border: none; background: transparent; box-shadow: none; }

.credit-card {
  padding: 1.1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.08), transparent 42%),
    var(--bg-elevated);
  box-shadow: var(--shadow);
}

.credit-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.credit-card-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.credit-card-badge {
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.credit-ring-wrap {
  position: relative;
  width: 148px;
  height: 148px;
  margin: 0 auto 0.9rem;
}

.credit-ring {
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.credit-ring-track,
.credit-ring-progress {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
}

.credit-ring-track {
  stroke: rgba(255, 255, 255, 0.07);
}

html[data-theme="light"] .credit-ring-track {
  stroke: rgba(15, 23, 42, 0.08);
}

.credit-ring-progress {
  stroke-dasharray: 326.73;
  transition: stroke-dashoffset 0.45s ease, stroke 0.3s ease;
}

.credit-card--good .credit-ring-progress { stroke: #14b8a6; }

.credit-card--warning .credit-ring-progress { stroke: #f59e0b; }
.credit-card--critical .credit-ring-progress { stroke: #ef4444; }

.credit-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.credit-ring-center strong {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.credit-ring-center span {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.credit-meter {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-bottom: 0.85rem;
}

html[data-theme="light"] .credit-meter {
  background: rgba(15, 23, 42, 0.08);
}

.credit-meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #38bdf8);
  transition: width 0.45s ease;
}

.credit-card--warning .credit-meter-fill {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.credit-card--critical .credit-meter-fill {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.credit-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.credit-stat {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.credit-stat span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.credit-stat strong {
  font-size: 0.95rem;
  font-weight: 700;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.preset-chip {
  min-width: 44px;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.preset-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.preset-chip.active {
  color: #042f2e;
  border-color: transparent;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
}

.field-chars #max-chars-custom {
  margin-top: 0.15rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.user-chip {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 0.82rem;
  font-weight: 600;
}

.credit-widget {
  display: none;
}

main.page-main {
  flex: 1;
  padding: 1.5rem 0 2.5rem;
}

.page-head {
  margin-bottom: 1.25rem;
}

.page-head h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
}

.page-head p {
  margin: 0;
  color: var(--text-muted);
}

.panel-studio-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(20, 184, 166, 0.28);
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.12), rgba(20, 184, 166, 0.04));
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

.panel-studio-link:hover {
  border-color: rgba(20, 184, 166, 0.45);
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), rgba(20, 184, 166, 0.06));
  transform: translateY(-1px);
}

.panel-studio-link-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(20, 184, 166, 0.18);
  color: #5eead4;
  flex-shrink: 0;
}

.panel-studio-link-copy {
  display: grid;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.panel-studio-link-copy strong {
  font-size: 0.92rem;
}

.panel-studio-link-copy small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.panel-studio-link-arrow {
  color: #5eead4;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.layout-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 1rem;
}

.stack { display: grid; gap: 1rem; }

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.panel-subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.panel-body { padding: 1.1rem; }

.account-panel-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.account-subscription-banner {
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(45, 212, 191, 0.22);
  background: rgba(45, 212, 191, 0.08);
  color: var(--text);
  font-size: 0.92rem;
}

.account-subscription-banner strong {
  color: var(--primary);
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.account-form + .account-form {
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.account-form-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stat-card {
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.stat-card span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}

.stat-card strong {
  font-size: 1.35rem;
  font-weight: 700;
}

.steps {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 0.76rem;
  font-weight: 600;
}

.step-pill.active {
  color: #ccfbf1;
  border-color: rgba(20, 184, 166, 0.35);
  background: var(--primary-soft);
}

.step-pill.done {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.08);
}

.step-index {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.06);
}

.dropzone {
  position: relative;
  min-height: 210px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.5rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: var(--transition);
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
  border-color: rgba(20, 184, 166, 0.55);
  background: var(--primary-soft);
  outline: none;
}

.dropzone.has-file { min-height: 130px; cursor: default; }

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone.has-file input[type="file"] { pointer-events: none; }

.transcribe-form.is-locked {
  position: relative;
}

.transcribe-form.is-locked .dropzone,
.transcribe-form.is-locked .field,
.transcribe-form.is-locked .options-grid,
.transcribe-form.is-locked .toggle-row,
.transcribe-form.is-locked .actions {
  opacity: 0.55;
  filter: grayscale(0.35);
}

.transcribe-form.is-locked .dropzone {
  cursor: not-allowed;
  border-style: solid;
}

.transcribe-form.is-locked .dropzone:hover,
.transcribe-form.is-locked .dropzone:focus-visible {
  border-color: var(--border-strong);
  background: transparent;
}

.transcribe-form.is-locked input[type="file"] {
  cursor: not-allowed;
}

.dropzone-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.85rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
}

.dropzone h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.dropzone p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.dropzone .hint {
  margin-top: 0.65rem;
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.file-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  max-width: 520px;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.file-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}

.file-meta { flex: 1; min-width: 0; text-align: start; }

.file-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta span {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.options-grid,
.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.admin-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.field { display: grid; gap: 0.4rem; }

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field select,
.field input[type="text"],
.field input[type="password"],
.field input[type="number"] {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.field select:focus-visible,
.field input:focus-visible {
  outline: none;
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.lang-picker {
  position: relative;
}

.lang-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.72rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  text-align: right;
}

.lang-picker-trigger:hover,
.lang-picker-trigger[aria-expanded="true"] {
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.lang-picker-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.lang-picker-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
}

.lang-picker-panel {
  position: absolute;
  z-index: 30;
  inset-inline: 0;
  top: calc(100% + 0.35rem);
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.lang-picker-panel input[type="search"] {
  width: 100%;
  margin-bottom: 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.lang-picker-list {
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.lang-picker-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: right;
}

.lang-picker-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.lang-picker-item.selected {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.35);
}

.lang-picker-item-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.lang-picker-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.lang-picker-empty,
.lang-picker-count {
  padding: 0.65rem 0.35rem 0.15rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.toggle-row p {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.toggle-row small {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-subtle);
  font-weight: 400;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #334155;
  cursor: pointer;
  transition: var(--transition);
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  right: 3px;
  border-radius: 50%;
  background: white;
  transition: var(--transition);
}

.switch input:checked + .switch-slider { background: var(--primary); }

.switch input:checked + .switch-slider::before { transform: translateX(-20px); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.72rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn-secondary {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--border);
}

.btn-secondary.is-active,
.btn-secondary:hover:not(:disabled) {
  border-color: rgba(20, 184, 166, 0.35);
  background: var(--primary-soft);
}

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

.btn-ghost:hover:not(:disabled) { color: var(--text); }

.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.8rem; }

.btn-block { width: 100%; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.processing {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(20, 184, 166, 0.25);
  background: var(--primary-soft);
}

.processing.active { display: block; }

.processing-body {
  display: grid;
  gap: 0.65rem;
}

.processing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.processing-head strong {
  font-size: 0.92rem;
}

.processing-head span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.processing-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.processing-bar-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #5eead4);
  transition: width 0.25s ease;
}

.processing-detail {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.results-panel { display: none; }
.results-panel.visible { display: block; }

.result-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  margin-bottom: 0.85rem;
  overflow-x: auto;
}

.tab {
  padding: 0.5rem 0.8rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.tab.active {
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.18);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.subtitle-list {
  display: grid;
  gap: 0.65rem;
  max-height: 380px;
  overflow: auto;
}

.subtitle-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.subtitle-index {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--accent);
}

.subtitle-time {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-subtle);
  margin-bottom: 0.25rem;
}

.subtitle-text { margin: 0; font-size: 0.92rem; }

.code-block,
.transcript-block {
  margin: 0;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0d1117;
  max-height: 380px;
  overflow: auto;
}

.code-block {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.transcript-block { line-height: 1.8; }

.table-wrap { overflow: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: middle;
}

.data-table th {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.empty-cell {
  text-align: center !important;
  color: var(--text-subtle);
  padding: 1.5rem !important;
}

.bug-report-cell {
  max-width: 22rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.88rem;
}

.bug-report-list {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem;
}

.bug-report-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}

.bug-report-card[open] {
  border-color: rgba(45, 212, 191, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.bug-report-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  list-style: none;
}

.bug-report-summary::-webkit-details-marker { display: none; }
.bug-report-summary:hover { background: rgba(45, 212, 191, 0.04); }

.bug-report-chevron {
  color: var(--text-subtle);
  font-size: 1.4rem;
  line-height: 1;
  transform: rotate(0);
  transition: transform 160ms ease;
}

.bug-report-card[open] .bug-report-chevron { transform: rotate(-90deg); }

.bug-report-main {
  display: grid;
  min-width: 0;
  gap: 0.35rem;
}

.bug-report-message {
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bug-report-meta,
.bug-report-badges,
.bug-http-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
}

.bug-report-meta {
  color: var(--text-subtle);
  font-size: 0.74rem;
}

.bug-report-meta span:not(:last-child)::after {
  margin-inline-start: 0.75rem;
  color: var(--border);
  content: "•";
}

.bug-report-badges { justify-content: flex-end; }
.tag-info { color: #bfdbfe; background: rgba(59, 130, 246, 0.14); }
.tag-system { color: #ddd6fe; background: rgba(139, 92, 246, 0.14); }

.bug-report-details {
  display: grid;
  gap: 0.75rem;
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.bug-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding-top: 0.9rem;
}

.bug-detail-block {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}

.bug-detail-block h4 {
  margin: 0 0 0.65rem;
  color: var(--accent);
  font-size: 0.78rem;
}

.bug-detail-wide { width: 100%; }

.bug-kv {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.bug-kv > div {
  display: grid;
  grid-template-columns: minmax(5.5rem, 0.35fr) minmax(0, 1fr);
  gap: 0.65rem;
}

.bug-kv dt {
  color: var(--text-subtle);
  font-size: 0.72rem;
}

.bug-kv dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.78rem;
}

.bug-http-row {
  direction: ltr;
  justify-content: flex-start;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.bug-code {
  max-height: 260px;
  margin: 0.7rem 0 0;
  padding: 0.8rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1117;
  color: #d1d5db;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.65;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.bug-raw {
  padding: 0.2rem 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.bug-raw > summary {
  width: fit-content;
  cursor: pointer;
}

.bug-raw-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.bug-raw-json { max-height: 420px; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
}

.pagination-info {
  color: var(--text-muted);
  font-size: 0.82rem;
  min-width: 6.5rem;
  text-align: center;
}

.pagination-bar .is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.tag-success { color: #bbf7d0; background: rgba(34, 197, 94, 0.12); }
.tag-danger { color: #fecaca; background: rgba(239, 68, 68, 0.12); }
.tag-admin { color: #bae6fd; background: rgba(56, 189, 248, 0.12); margin-inline-start: 0.35rem; }

.limit-input {
  width: 84px;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.info-list {
  display: grid;
  gap: 0.65rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 0.86rem;
}

.info-item span { color: var(--text-muted); }

.site-footer {
  padding: 1rem 0 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 0.78rem;
  text-align: center;
}

.toast-stack {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: grid;
  gap: 0.55rem;
  width: min(360px, calc(100vw - 2rem));
}

.toast {
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(17, 20, 26, 0.96);
  box-shadow: var(--shadow);
}

.toast.success { border-color: rgba(34, 197, 94, 0.3); }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }

.toast strong {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.86rem;
}

.toast span {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.hidden { display: none !important; }

.login-shell { place-content: center; }

.login-back {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.86rem;
}

.login-back a { color: var(--primary); }

.login-container { max-width: 420px; padding: 2rem 0; }

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.login-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-form { display: grid; gap: 0.9rem; }

.account-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding: 0.25rem;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.account-tab {
  display: block;
  text-align: center;
  padding: 0.55rem 0.75rem;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}

.account-tab.is-active {
  color: var(--text);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.account-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.credit-buy-btn { margin-top: 0.85rem; }

.credit-empty-state {
  text-align: center;
  padding: 1rem 0.5rem 0.25rem;
}

.credit-empty-state strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.credit-empty-state p {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.credit-empty-state--compact {
  padding: 0.65rem 0.25rem 0.15rem;
}

.quota-hint {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.55;
  border: 1px solid rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.08);
  color: var(--text);
}

.quota-hint.is-error {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.08);
}

.quota-hint a, .quota-hint button.linkish {
  color: var(--primary);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

body.subscription-modal-open { overflow: hidden; }

.subscription-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.subscription-modal.hidden { display: none; }

.subscription-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}

.subscription-modal-card {
  position: relative;
  width: min(100%, 380px);
  padding: 1.35rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  text-align: center;
}

.subscription-modal-close {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.subscription-modal-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.85rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--primary);
  background: rgba(20, 184, 166, 0.12);
}

.subscription-modal-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.subscription-modal-lead,
.subscription-modal-phone {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.subscription-modal-phone a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.alert {
  padding: 0.85rem;
  border-radius: 10px;
  margin-bottom: 0.85rem;
  font-size: 0.86rem;
}

.alert-error {
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.1);
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .layout-grid,
  .stat-grid,
  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .bug-report-summary {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .bug-report-badges {
    grid-column: 2;
    justify-content: flex-start;
  }

  .bug-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
  }
  .topbar {
    width: 100%;
    justify-content: space-between;
  }
  .user-badge-name { display: none; }
  .options-grid { grid-template-columns: 1fr; }
  .actions .btn,
  .result-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Light theme */
html[data-theme="light"] {
  --bg: #eef1f6;
  --bg-elevated: #ffffff;
  --bg-soft: #f5f7fb;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-soft: rgba(13, 148, 136, 0.1);
  --accent: #0284c7;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at top, rgba(13, 148, 136, 0.06), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
}

html[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .alert-error {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.08);
}

.theme-toggle {
  padding: 0;
}

.theme-icon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-dark { display: block; }
html[data-theme="light"] .theme-toggle .theme-icon-light { display: block; }

.tag-viewer {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.12);
}

html[data-theme="light"] .tag-viewer {
  color: #6d28d9;
  background: rgba(139, 92, 246, 0.1);
}

.tag-user {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-soft);
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-subtle);
  font-size: 0.78rem;
}

.log-original {
  display: block;
  color: var(--text-subtle);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.info-note strong {
  color: var(--primary);
  font-size: 0.88rem;
}

.text-muted {
  color: var(--text-muted);
}

.smart-cut-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.smart-cut-session-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.smart-cut-session-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.smart-cut-session-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.smart-cut-scenario-list {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.smart-cut-scenario-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.015);
}

.smart-cut-scenario-item summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
}

.smart-cut-scenario-item summary::-webkit-details-marker {
  display: none;
}

.smart-cut-scenario-hook,
.smart-cut-scenario-rationale,
.smart-cut-scenario-ending {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.smart-cut-scenario-ending {
  color: var(--primary);
  opacity: 0.9;
}

.smart-cut-scenario-rationale {
  font-style: italic;
  opacity: 0.92;
}

.smart-cut-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--primary);
  background: rgba(var(--primary-rgb, 99, 102, 241), 0.12);
  border: 1px solid rgba(var(--primary-rgb, 99, 102, 241), 0.25);
}

.smart-cut-segment-list {
  margin: 0.5rem 0 0;
  padding-right: 1.1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.smart-cut-segment-list .seg-time {
  color: var(--primary);
  margin-left: 0.35rem;
}

/* —— Telegram glass panel (account) —— */
.telegram-glass-panel {
  margin-top: 1.25rem;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.03) 45%,
    rgba(99, 102, 241, 0.08) 100%
  );
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.telegram-glass-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.telegram-glass-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(125, 211, 252, 0.25);
}

.telegram-glass-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.telegram-status-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.telegram-glass-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.telegram-hint {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.85;
}

.telegram-bot-handle {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #7dd3fc;
  text-decoration: none;
}

.telegram-bot-handle:hover {
  opacity: 0.9;
}

.panel-telegram-link-icon {
  color: #38bdf8;
}

.panel-telegram-link--muted {
  opacity: 0.92;
}

.telegram-notify-default {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  cursor: pointer;
}

.telegram-notify-default input {
  margin-top: 0.2rem;
}

[data-theme="light"] .telegram-glass-panel {
  border-color: rgba(15, 23, 42, 0.08);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(248, 250, 252, 0.88) 100%
  );
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

/* Caption history panel */
.history-caption-panel .history-caption-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-telegram-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
}

.history-caption-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-caption-card {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft, rgba(148, 163, 184, 0.06));
}

.history-caption-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
}

.history-caption-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  color: var(--text-muted, #94a3b8);
  font-size: 0.82rem;
}

.history-caption-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.history-caption-empty,
.history-caption-empty-state {
  color: var(--text-muted, #94a3b8);
  font-size: 0.9rem;
}

.history-view-card {
  width: min(100%, 640px) !important;
}

.history-view-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0.75rem 0 0.6rem;
}

.history-view-body {
  max-height: min(50vh, 420px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft, rgba(2, 6, 23, 0.35));
  font-size: 0.88rem;
  line-height: 1.7;
}

.history-view-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

@media (max-width: 720px) {
  .history-caption-card {
    flex-direction: column;
  }
  .history-caption-actions {
    width: 100%;
  }
  .history-caption-actions .btn {
    flex: 1 1 calc(50% - 0.4rem);
  }
}
