:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-2: #eef3fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #d8e2ef;
  --line-strong: #c3cede;
  --text: #142033;
  --soft-text: #344054;
  --muted: #68758b;
  --accent: #7c3aed;
  --accent-2: #6d28d9;
  --blue: #1570ef;
  --ok: #039855;
  --warn: #dc8a00;
  --err: #d92d20;
  --violet: #7c3aed;
  --shadow: 0 18px 50px rgba(29, 41, 57, .10);
  --shadow-soft: 0 8px 22px rgba(29, 41, 57, .07);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 0%, rgba(124, 58, 237, .10), transparent 32%),
    radial-gradient(circle at 88% 14%, rgba(21, 112, 239, .10), transparent 28%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
}

a { color: inherit; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.app-topbar, .panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.app-topbar {
  flex: 0 0 auto;
  padding: 14px;
  backdrop-filter: blur(14px);
}

.toprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, rgba(124, 58, 237, .14), rgba(21, 112, 239, .12));
  border: 1px solid rgba(124, 58, 237, .22);
  box-shadow: var(--shadow-soft);
}
.brand h1 { margin: 0; font-size: 19px; line-height: 1.1; color: var(--text); }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-status, .top-actions, .preview-actions, .download-row, .progress-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.top-actions { justify-content: flex-end; }
.top-status {
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.top-status strong {
  color: var(--text);
  font-size: 13px;
  margin-left: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f7f9fd;
  border: 1px solid var(--line);
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.btn, button, .download-all, .single-download, .result-actions a, .history-actions a, .ghost-link {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #24364f;
  border-radius: 14px;
  padding: 9px 13px;
  font-weight: 850;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: .15s transform, .15s background, .15s border-color, .15s box-shadow;
  box-shadow: 0 2px 7px rgba(29, 41, 57, .04);
}
.btn:hover, button:hover, .download-all:hover, .result-actions a:hover, .history-actions a:hover, .ghost-link:hover {
  background: #f8fafc;
  border-color: #aebcd0;
  box-shadow: 0 6px 18px rgba(29, 41, 57, .08);
}
.btn:active, button:active { transform: scale(.98); }
button:disabled, .btn:disabled { opacity: .65; cursor: wait; }
.primary, .btn.primary {
  border-color: rgba(124, 58, 237, .82);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 12px 26px rgba(124, 58, 237, .22);
}
.primary:hover, .btn.primary:hover { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.danger, .btn.danger {
  border-color: rgba(217, 45, 32, .25);
  background: #fff5f4;
  color: var(--err);
}
.danger:hover, .btn.danger:hover { background: #ffeceb; border-color: rgba(217, 45, 32, .38); }
.warning, .btn.warning {
  border-color: rgba(220, 138, 0, .28);
  background: #fff8eb;
  color: #875100;
}
.wide { width: 100%; }

.control-grid {
  display: grid;
  grid-template-columns: minmax(185px, 1fr) minmax(150px, .85fr) minmax(132px, .6fr) minmax(140px, .62fr) minmax(140px, .62fr) minmax(205px, 1fr) minmax(150px, .68fr) auto auto;
  gap: 8px;
  margin-top: 12px;
  align-items: stretch;
}
.control-box {
  min-height: 44px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 15px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 850;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(29, 41, 57, .04);
}
.control-box > span, .control-box summary span {
  color: var(--muted);
  font-weight: 800;
  flex: 0 0 auto;
}
.file-box { position: relative; }
.file-box input[type="file"] {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--soft-text);
  padding: 0;
  font-weight: 750;
}
.select-box select, .template-select, .control-box select {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  font-weight: 850;
}
.toggle-box { justify-content: flex-start; }
.switch-line { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 850; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.manual-text-trigger {
  border: 1px solid var(--line);
  text-align: left;
}
.manual-text-trigger b {
  min-width: 64px;
  color: var(--accent);
  font-size: 13px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(8px);
}
.modal-card {
  width: min(760px, 100%);
  max-height: min(76vh, 680px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(15, 23, 42, .22);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}
.modal-head h2 { margin: 0; font-size: 22px; }
.modal-head p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; font-weight: 700; }
.modal-close {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  font-weight: 600;
}
.manual-text-modal textarea {
  min-height: 300px;
  flex: 1;
  margin: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  resize: none;
  padding: 14px 15px;
  outline: none;
  color: var(--text);
  background: #fbfdff;
  line-height: 1.55;
  font-weight: 700;
}
.manual-text-modal textarea:focus, .search-input:focus {
  border-color: rgba(124, 58, 237, .55);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, .10);
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 16px;
  color: var(--muted);
  font-weight: 850;
}
.modal-actions { display: flex; gap: 8px; }

.top-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.status { margin: 0; color: var(--muted); font-size: 13px; font-weight: 750; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.mini-calculator {
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  gap: 7px;
  min-width: min(650px, 58vw);
}
.mini-calculator div {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 14px;
  padding: 7px 9px;
}
.mini-calculator span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 950; letter-spacing: .04em; }
.mini-calculator strong { display: block; margin-top: 3px; color: var(--text); font-size: 15px; line-height: 1; }

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 14px;
}
.left-column, .right-column {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel { min-height: 0; overflow: hidden; }
.panel-head, .preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbfdff);
}
.panel h2, .preview-head h2 { margin: 0; font-size: 18px; line-height: 1.15; color: var(--text); }
.panel p, .preview-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; font-weight: 700; }

.progress-panel { flex: 0 0 auto; max-height: 58%; display: flex; flex-direction: column; }
.language-panel { flex: 1; display: flex; flex-direction: column; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px 15px 6px; }
.stat-card {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 16px;
  padding: 9px 10px;
  min-width: 0;
  box-shadow: 0 2px 8px rgba(29, 41, 57, .04);
}
.stat-card span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 950; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card strong { display: block; margin-top: 5px; font-size: 20px; line-height: 1; }
.green { color: var(--ok); }
.amber { color: var(--warn); }
.red { color: var(--err); }
.violet { color: var(--violet); }
.blue { color: var(--blue); }

.progress-track { height: 10px; border-radius: 999px; background: #e9eef7; border: 1px solid var(--line); overflow: hidden; margin: 8px 15px 12px; }
.progress-fill { width: 0%; height: 100%; background: linear-gradient(90deg, var(--violet), var(--blue), var(--ok)); border-radius: 999px; transition: width .25s ease; }

.result-tools { padding: 0 15px 12px; display: flex; flex-direction: column; gap: 9px; }
.filter-tabs { display: flex; gap: 7px; overflow: auto; padding-bottom: 2px; }
.filter-tabs button {
  min-height: 34px;
  flex: 0 0 auto;
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 950;
}
.filter-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.search-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 0 12px;
  outline: none;
  font-weight: 750;
}
.results {
  min-height: 0;
  overflow: auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-row, .history-row {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 18px;
  padding: 10px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  box-shadow: 0 2px 9px rgba(29, 41, 57, .04);
}
.result-row:hover, .history-row:hover { background: #fbfdff; border-color: #b7c5d8; }
.result-row.active { background: #f4efff; border-color: rgba(124, 58, 237, .72); }
.result-row.done { border-color: rgba(3, 152, 85, .30); }
.result-row.needs_review { border-color: rgba(220, 138, 0, .38); }
.result-row.error { border-color: rgba(217, 45, 32, .35); }
.result-row.audio-error { border-color: rgba(220, 138, 0, .38); }
.lang-flag, .lang-flag-emoji, .result-flag {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #f4f7fb;
  border: 1px solid var(--line);
  font-size: 24px;
  flex: 0 0 auto;
}
.lang-flag-img { width: 24px; height: 18px; object-fit: cover; border-radius: 4px; box-shadow: 0 0 0 1px rgba(29, 41, 57, .10); }
.result-main, .history-main { min-width: 0; }
.result-main strong, .history-main strong { display: block; color: var(--text); font-size: 14px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-main span, .history-main span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error-text { display: block; margin-top: 5px; color: var(--warn); font-size: 12px; line-height: 1.35; white-space: normal; word-break: break-word; }
.result-actions, .history-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.result-actions button, .result-actions a, .history-actions button, .history-actions a { min-height: 32px; padding: 6px 9px; border-radius: 10px; font-size: 12px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  border: 1px solid currentColor;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
  background: #fff;
}

.language-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}
.language-toolbar button, .language-toolbar select { min-height: 36px; border-radius: 12px; padding: 7px 10px; font-size: 12px; }
.template-select { min-width: 150px; border: 1px solid var(--line-strong); background: #fff; color: var(--text); font-weight: 850; }
.languages {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 8px;
  align-content: start;
}
.lang, .language-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 9px 10px;
  background: #ffffff;
  min-height: 48px;
  box-shadow: 0 2px 8px rgba(29, 41, 57, .04);
  cursor: pointer;
}
.lang:hover, .language-choice:hover { background: #fbfdff; border-color: #b7c5d8; }
.lang input, .language-choice input { position: absolute; opacity: 0; pointer-events: none; }
.lang:has(input:checked), .language-choice:has(input:checked) { background: #f4efff; border-color: rgba(124, 58, 237, .65); }
.language-info { min-width: 0; }
.language-info strong { display: block; color: var(--text); font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.language-info span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 850; }

.right-column { overflow: hidden; }
.global-downloads {
  flex: 0 0 auto;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.download-info strong { display: block; color: var(--text); font-size: 14px; }
.download-info span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 750; }

.preview-empty {
  flex: 0 0 auto;
  min-height: 240px;
  padding: 36px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.preview-empty h2 { margin: 0; font-size: 24px; }
.preview-empty p { max-width: 620px; color: var(--muted); line-height: 1.55; }
.download-row { justify-content: center; margin-top: 12px; }
.download-all { background: #ecfdf3; border-color: rgba(3, 152, 85, .24); color: #027a48; }
.download-all.disabled { pointer-events: none; opacity: .48; filter: grayscale(.3); }
.preview-panel { flex: 1; display: flex; flex-direction: column; }
.preview-head { flex: 0 0 auto; }
.preview-panel pre {
  min-height: 0;
  flex: 1;
  margin: 0;
  padding: 18px;
  overflow: auto;
  background: #ffffff;
  color: #182230;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 0;
}
.history-panel { flex: 1; display: flex; flex-direction: column; }
.history-list { min-height: 0; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: #f8fbff; }
.history-row { grid-template-columns: minmax(0, 1fr) auto; }
.history-main strong { font-size: 13px; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.auth-card {
  width: min(430px, 100%);
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}
.logo-badge {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  letter-spacing: .04em;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff;
  box-shadow: 0 10px 26px rgba(124, 58, 237, .24);
}
.auth-card h1 { margin: 0; font-size: 28px; }
.auth-sub, .auth-error { margin: 0; color: var(--muted); line-height: 1.5; }
.auth-error { min-height: 18px; color: var(--err); }
.contact-link { text-align: center; color: var(--accent); text-decoration: none; font-weight: 850; font-size: 14px; }
.auth-button { text-decoration: none; }

@media (max-width: 1280px) {
  .control-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 390px minmax(0, 1fr); }
  .top-chips { display: none; }
}

@media (max-width: 1020px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; overflow: visible; }
  .workspace { grid-template-columns: 1fr; overflow: visible; }
  .left-column, .right-column, .progress-panel, .language-panel, .history-panel, .preview-panel { min-height: 420px; max-height: none; }
  .control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-calculator { min-width: 100%; }
  .top-footer, .toprow { align-items: stretch; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .brand { min-width: 0; }
}

@media (max-width: 640px) {
  .app-shell { padding: 8px; gap: 8px; }
  .app-topbar, .panel { border-radius: 18px; }
  .control-grid { grid-template-columns: 1fr; }
  .stat-grid, .mini-calculator { grid-template-columns: repeat(2, 1fr); }
  .result-row { grid-template-columns: 42px minmax(0, 1fr); }
  .result-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .history-row { grid-template-columns: 1fr; }
  .history-actions { justify-content: flex-start; }
}

.result-flag .lang-flag-emoji { width: auto; height: auto; border: 0; background: transparent; font-size: 24px; }
.empty-results { margin: 10px; color: var(--muted); font-size: 13px; font-weight: 750; }

/* UI stage 1.1 — calm compact fix */
:root {
  --bg: #f3f5f8;
  --bg-2: #edf1f6;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --line: #d7dfeb;
  --line-strong: #bdc8d8;
  --text: #172033;
  --soft-text: #344054;
  --muted: #667085;
  --accent: #5b5ce2;
  --accent-2: #4f46e5;
  --blue: #2563eb;
  --ok: #078a52;
  --warn: #b86e00;
  --err: #c3362b;
  --violet: #5b5ce2;
  --shadow: 0 10px 28px rgba(15, 23, 42, .07);
  --shadow-soft: 0 4px 14px rgba(15, 23, 42, .055);
}

html, body {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
body {
  background: linear-gradient(180deg, #f5f7fa 0%, #edf1f6 100%);
}

.app-shell {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  gap: 10px;
  padding: 10px;
}

.app-topbar, .panel {
  box-shadow: var(--shadow);
}

.app-topbar {
  padding: 12px;
}

.brand-logo {
  background: #edf3ff;
  border-color: #c9d7f2;
  color: var(--accent);
}

.control-grid {
  grid-template-columns: minmax(205px, 1.05fr) minmax(160px, .86fr) minmax(130px, .58fr) minmax(150px, .62fr) minmax(210px, 1fr) minmax(145px, .66fr) auto auto;
  gap: 7px;
  margin-top: 10px;
}
.control-box {
  min-height: 40px;
  padding: 7px 11px;
  border-radius: 14px;
  box-shadow: none;
}
.btn, button, .download-all, .single-download, .result-actions a, .history-actions a, .ghost-link {
  min-height: 38px;
  border-radius: 13px;
  box-shadow: none;
}
.primary, .btn.primary {
  background: linear-gradient(135deg, #6264e8, #5147d8);
  border-color: rgba(91, 92, 226, .75);
  box-shadow: 0 8px 18px rgba(91, 92, 226, .18);
}

.top-footer {
  margin-top: 8px;
}
.mini-calculator div {
  padding: 7px 10px;
  box-shadow: none;
}

.workspace {
  min-height: 0;
  overflow: hidden;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 10px;
}
.left-column, .right-column {
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  gap: 10px;
}

.panel-head, .preview-head {
  padding: 12px 14px;
  background: #fff;
}
.panel h2, .preview-head h2 {
  font-size: 17px;
}
.panel p, .preview-head p {
  font-size: 12px;
  line-height: 1.35;
}

.progress-panel {
  flex: 0 0 auto;
  max-height: min(44%, 340px);
}
.language-panel {
  min-height: 0;
  flex: 1 1 auto;
}
.language-head {
  align-items: flex-start;
  gap: 8px;
}
.language-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: -3px;
  flex: 0 0 auto;
}
.language-count {
  flex: 0 0 auto;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #344054;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}
.language-toolbar {
  padding: 10px 12px;
  gap: 7px;
  background: #f8fafc;
}
.language-toolbar button, .language-toolbar select {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

.languages {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  padding: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  background: #f8fafc;
}
.lang, .language-choice {
  min-width: 0;
  min-height: 50px;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 9px;
  border-radius: 14px;
  box-shadow: none;
  overflow: hidden;
}
.lang:has(input:checked), .language-choice:has(input:checked) {
  background: #eef2ff;
  border-color: #a8b2ff;
}
.lang-flag, .lang-flag-emoji, .result-flag {
  width: 34px;
  height: 34px;
  min-width: 34px;
  max-width: 34px;
  border-radius: 11px;
  font-size: 20px;
  overflow: hidden;
  justify-self: center;
  align-self: center;
  background: #f1f5f9;
}
.lang-flag-img {
  width: 28px;
  height: 21px;
  display: block;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .08);
}
.result-flag .lang-flag-img {
  width: 28px;
  height: 21px;
}
.result-flag .lang-flag-emoji {
  width: auto;
  height: auto;
  min-width: 0;
  max-width: none;
  border: 0;
  background: transparent;
  font-size: 20px;
}
.language-info strong {
  font-size: 12.5px;
}
.language-info span {
  margin-top: 2px;
  font-size: 10.5px;
}

.global-downloads {
  flex: 0 0 auto;
  min-height: 64px;
  padding: 10px 14px;
}
.preview-empty, .preview-panel {
  flex: 1 1 auto;
  min-height: 0;
}
.preview-empty {
  padding: 24px 20px;
}
.preview-empty h2 {
  font-size: 22px;
}
.history-panel {
  flex: 0 0 180px;
  min-height: 150px;
  max-height: 210px;
}
.history-list {
  background: #f8fafc;
}
.preview-panel pre {
  background: #fff;
  color: #172033;
}

/* Hide full-page scrollbars caused by nested panels; scroll only inside language/results/history/text areas. */
.right-column > .panel,
.left-column > .panel {
  min-height: 0;
}
.results,
.languages,
.history-list,
.preview-panel pre {
  scrollbar-width: thin;
  scrollbar-color: #a7b1c2 transparent;
}

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 400px minmax(0, 1fr); }
  .control-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1020px) {
  html, body { overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; overflow: visible; }
  .workspace { overflow: visible; }
  .left-column, .right-column { overflow: visible; }
  .history-panel { flex-basis: auto; max-height: none; }
}

/* UI stage 1.2 — hard scroll and language-card fix */
html,
body {
  width: 100% !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

body {
  background: #f2f4f7 !important;
}

.app-shell:not(.hidden) {
  position: fixed !important;
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  gap: 10px !important;
  padding: 10px !important;
}

.app-topbar {
  min-height: 0 !important;
}

.workspace {
  min-height: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
  grid-template-columns: minmax(390px, 420px) minmax(0, 1fr) !important;
  gap: 10px !important;
}

.left-column,
.right-column {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

.left-column {
  display: flex !important;
  flex-direction: column !important;
}

.right-column {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) minmax(132px, 172px) !important;
}

.progress-panel.hidden + .language-panel,
.language-panel {
  min-height: 0 !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
}

.progress-panel {
  max-height: 320px !important;
  overflow: hidden !important;
}

.languages,
.results,
.history-list,
.preview-panel pre {
  min-height: 0 !important;
  overflow: auto !important;
  overscroll-behavior: contain !important;
}

.languages {
  height: auto !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  padding: 8px !important;
  gap: 7px !important;
}

.language-choice {
  position: relative !important;
  min-width: 0 !important;
  overflow: hidden !important;
  grid-template-columns: 34px minmax(0, 1fr) !important;
  align-items: center !important;
}

.language-choice input[type="checkbox"] {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
}

.lang-flag,
.lang-flag-emoji,
.result-flag {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  border-radius: 10px !important;
  overflow: hidden !important;
}

.lang-flag-img {
  width: 27px !important;
  height: 20px !important;
  max-width: 27px !important;
  max-height: 20px !important;
  object-fit: cover !important;
  display: block !important;
}

.language-info {
  min-width: 0 !important;
  overflow: hidden !important;
}

.language-info strong,
.language-info span {
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.preview-empty,
.preview-panel,
.history-panel {
  min-height: 0 !important;
  max-height: none !important;
}

.preview-empty {
  height: 100% !important;
}

.history-panel {
  height: auto !important;
}

@media (max-width: 1280px) {
  .workspace { grid-template-columns: minmax(370px, 400px) minmax(0, 1fr) !important; }
}

@media (max-width: 1020px) {
  html, body { overflow: hidden !important; }
  .app-shell:not(.hidden) {
    position: fixed !important;
    inset: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  .workspace {
    grid-template-columns: 1fr !important;
    overflow: hidden !important;
  }
  .left-column,
  .right-column {
    overflow: hidden !important;
  }
}


/* UI stage 1.3 — calmer light background + day/night theme switch */
:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #e9eef5;
  --bg-2: #e4eaf2;
  --panel: #fbfcfe;
  --panel-soft: #f3f6fa;
  --line: #cfd8e6;
  --line-strong: #b5c1d1;
  --text: #172033;
  --soft-text: #344054;
  --muted: #667085;
  --accent: #5558d9;
  --accent-2: #473fc8;
  --blue: #2464d6;
  --ok: #047b4b;
  --warn: #a36200;
  --err: #bd3027;
  --violet: #5558d9;
}

html[data-theme="light"] body,
body[data-theme="light"] {
  background: linear-gradient(180deg, #e9eef5 0%, #e3e9f2 100%) !important;
}

.theme-toggle {
  min-width: 94px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --bg-2: #0f172a;
  --panel: #182235;
  --panel-soft: #1e293b;
  --line: #344154;
  --line-strong: #475569;
  --text: #f1f5f9;
  --soft-text: #d7dee9;
  --muted: #9aa8ba;
  --accent: #8b7cf6;
  --accent-2: #6d5df0;
  --blue: #60a5fa;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;
  --violet: #a78bfa;
  --shadow: 0 14px 34px rgba(0, 0, 0, .26);
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, .20);
}

html[data-theme="dark"] body,
body[data-theme="dark"] {
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .app-topbar,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .auth-card {
  background: rgba(24, 34, 53, .96) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .panel-head,
html[data-theme="dark"] .preview-head,
html[data-theme="dark"] .global-downloads,
html[data-theme="dark"] .footer-actions,
html[data-theme="dark"] .stats {
  background: #182235 !important;
  border-color: var(--line) !important;
}

html[data-theme="dark"] .languages,
html[data-theme="dark"] .results,
html[data-theme="dark"] .history-list,
html[data-theme="dark"] .language-toolbar,
html[data-theme="dark"] .text-area {
  background: #111827 !important;
}

html[data-theme="dark"] .control-box,
html[data-theme="dark"] .selectbox,
html[data-theme="dark"] .uploadbox,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .mini-calculator div,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .filter,
html[data-theme="dark"] .row,
html[data-theme="dark"] .result-row,
html[data-theme="dark"] .history-row,
html[data-theme="dark"] .lang,
html[data-theme="dark"] .language-choice,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] .manual-text-modal textarea,
html[data-theme="dark"] .modal-close,
html[data-theme="dark"] .template-select,
html[data-theme="dark"] .btn,
html[data-theme="dark"] button,
html[data-theme="dark"] .download-all,
html[data-theme="dark"] .single-download,
html[data-theme="dark"] .result-actions a,
html[data-theme="dark"] .history-actions a,
html[data-theme="dark"] .ghost-link,
html[data-theme="dark"] .badge {
  background: #202b3d !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] button:hover,
html[data-theme="dark"] .download-all:hover,
html[data-theme="dark"] .result-actions a:hover,
html[data-theme="dark"] .history-actions a:hover,
html[data-theme="dark"] .ghost-link:hover,
html[data-theme="dark"] .lang:hover,
html[data-theme="dark"] .language-choice:hover,
html[data-theme="dark"] .result-row:hover,
html[data-theme="dark"] .history-row:hover {
  background: #263449 !important;
  border-color: #5b6b80 !important;
}

html[data-theme="dark"] .primary,
html[data-theme="dark"] .btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  border-color: rgba(167, 139, 250, .72) !important;
  color: #fff !important;
  box-shadow: 0 10px 22px rgba(109, 93, 240, .22) !important;
}

html[data-theme="dark"] .danger,
html[data-theme="dark"] .btn.danger {
  background: rgba(251, 113, 133, .12) !important;
  border-color: rgba(251, 113, 133, .35) !important;
  color: #fecdd3 !important;
}

html[data-theme="dark"] .warning,
html[data-theme="dark"] .btn.warning,
html[data-theme="dark"] .notice {
  background: rgba(251, 191, 36, .12) !important;
  border-color: rgba(251, 191, 36, .36) !important;
  color: #fde68a !important;
}

html[data-theme="dark"] .download-all {
  background: rgba(52, 211, 153, .12) !important;
  border-color: rgba(52, 211, 153, .34) !important;
  color: #a7f3d0 !important;
}

html[data-theme="dark"] .download-all.disabled {
  opacity: .45 !important;
}

html[data-theme="dark"] .brand h1,
html[data-theme="dark"] .panel h2,
html[data-theme="dark"] .preview-head h2,
html[data-theme="dark"] .preview-empty h2,
html[data-theme="dark"] .auth-card h1,
html[data-theme="dark"] .download-info strong,
html[data-theme="dark"] .result-main strong,
html[data-theme="dark"] .history-main strong,
html[data-theme="dark"] .language-info strong,
html[data-theme="dark"] .mini-calculator strong,
html[data-theme="dark"] .select-box select,
html[data-theme="dark"] .template-select,
html[data-theme="dark"] .control-box select,
html[data-theme="dark"] .file-box input[type="file"] {
  color: var(--text) !important;
}

html[data-theme="dark"] .brand p,
html[data-theme="dark"] .status,
html[data-theme="dark"] .panel p,
html[data-theme="dark"] .preview-head p,
html[data-theme="dark"] .download-info span,
html[data-theme="dark"] .result-main span,
html[data-theme="dark"] .history-main span,
html[data-theme="dark"] .language-info span,
html[data-theme="dark"] .control-box > span,
html[data-theme="dark"] .control-box summary span,
html[data-theme="dark"] .mini-calculator span,
html[data-theme="dark"] .stat-card span,
html[data-theme="dark"] .auth-sub,
html[data-theme="dark"] .empty-results {
  color: var(--muted) !important;
}

html[data-theme="dark"] .brand-logo,
html[data-theme="dark"] .lang-flag,
html[data-theme="dark"] .lang-flag-emoji,
html[data-theme="dark"] .result-flag,
html[data-theme="dark"] .flag,
html[data-theme="dark"] .bigflag {
  background: #273449 !important;
  border-color: var(--line) !important;
}

html[data-theme="dark"] .lang:has(input:checked),
html[data-theme="dark"] .language-choice:has(input:checked),
html[data-theme="dark"] .result-row.active,
html[data-theme="dark"] .row.active {
  background: rgba(139, 124, 246, .18) !important;
  border-color: rgba(167, 139, 250, .70) !important;
}

html[data-theme="dark"] .progress-track,
html[data-theme="dark"] .bar {
  background: #101827 !important;
  border-color: var(--line) !important;
}

html[data-theme="dark"] .preview-panel pre,
html[data-theme="dark"] .text-box {
  background: #101827 !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

html[data-theme="dark"] .preview-empty {
  background: #182235 !important;
}
html[data-theme="dark"] .modal-backdrop {
  background: rgba(2, 6, 23, .62) !important;
}

html[data-theme="dark"] .modal-card {
  background: var(--panel) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .modal-head {
  background: #182235 !important;
  border-color: var(--line) !important;
}


html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #7f8da3 !important;
}

html[data-theme="dark"] option {
  background: #202b3d;
  color: var(--text);
}

html[data-theme="dark"] .green { color: var(--ok) !important; }
html[data-theme="dark"] .amber { color: var(--warn) !important; }
html[data-theme="dark"] .red { color: var(--err) !important; }
html[data-theme="dark"] .violet { color: var(--violet) !important; }
html[data-theme="dark"] .blue { color: var(--blue) !important; }

html[data-theme="dark"] .results,
html[data-theme="dark"] .languages,
html[data-theme="dark"] .history-list,
html[data-theme="dark"] .preview-panel pre {
  scrollbar-color: #64748b transparent;
}

[data-theme="dark"] .top-status {
  background: var(--panel-soft);
  border-color: var(--line);
}
[data-theme="dark"] .top-status strong { color: var(--text); }

/* UI stage 1.6 — progressive intake flow + drag/drop */
:root,
html[data-theme="light"] {
  --bg: #e6ebf2;
  --bg-2: #dde5ef;
  --panel: #f8fafc;
  --panel-soft: #eef3f8;
}
html[data-theme="light"] body,
body[data-theme="light"] {
  background: linear-gradient(180deg, #e5ebf3 0%, #dfe7f0 100%) !important;
}
.app-topbar {
  padding: 12px !important;
}
.control-grid {
  grid-template-columns: minmax(330px, 1.35fr) minmax(270px, 1.05fr) repeat(5, minmax(148px, .72fr)) auto auto !important;
  align-items: stretch !important;
  gap: 10px !important;
}
.control-box.intake-box {
  min-height: 76px !important;
  align-items: flex-start !important;
  justify-content: center !important;
  flex-direction: column !important;
  gap: 4px !important;
  padding: 12px 16px !important;
  border-radius: 20px !important;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9fd 100%) !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 8px 24px rgba(29, 41, 57, .06) !important;
  cursor: pointer;
}
.control-box.intake-box:hover {
  border-color: rgba(85, 88, 217, .45) !important;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5ff 100%) !important;
  box-shadow: 0 12px 32px rgba(85, 88, 217, .10) !important;
}
.file-box {
  border-style: dashed !important;
  border-width: 2px !important;
  position: relative !important;
}
.file-box::after {
  content: 'drop';
  position: absolute;
  right: 14px;
  top: 13px;
  min-width: 44px;
  text-align: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(85, 88, 217, .10);
  color: var(--accent);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.file-box.drag-over {
  border-color: var(--accent) !important;
  background: #eef2ff !important;
  transform: translateY(-1px);
}
.file-box.has-file {
  border-style: solid !important;
  border-color: rgba(4, 123, 75, .42) !important;
  background: #f0fdf7 !important;
}
.file-box.has-file::after {
  content: 'ready';
  background: rgba(4, 123, 75, .12);
  color: var(--ok);
}
.file-box input[type="file"] {
  position: absolute !important;
  inset: 0 !important;
  opacity: 0 !important;
  cursor: pointer !important;
  width: 100% !important;
  height: 100% !important;
}
.control-kicker {
  display: block;
  color: var(--muted) !important;
  font-size: 11px !important;
  line-height: 1 !important;
  font-weight: 950 !important;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.intake-main {
  display: block;
  max-width: 100%;
  color: var(--text);
  font-size: 15px;
  line-height: 1.15;
  font-weight: 1000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intake-sub {
  display: block;
  max-width: 100%;
  color: var(--muted) !important;
  font-size: 12px !important;
  line-height: 1.2;
  font-weight: 800 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.manual-text-trigger .intake-sub.has-text {
  color: var(--ok) !important;
}
.progressive-control {
  opacity: 0;
  transform: translateX(18px) scale(.98);
  pointer-events: none;
  max-width: 0;
  min-width: 0;
  padding-left: 0 !important;
  padding-right: 0 !important;
  border-width: 0 !important;
  overflow: hidden !important;
  transition: opacity .22s ease, transform .22s ease, max-width .24s ease, padding .22s ease, border-width .22s ease;
}
.control-grid.has-content .mode-control,
.control-grid.has-content .quality-control,
.control-grid.has-mode .voice-control,
.control-grid.has-mode .text-telegram-control,
.control-grid.has-mode .run-control,
.control-grid.has-voice .voice-dependent {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
  max-width: 520px;
  min-width: 0;
  padding: 8px 12px !important;
  border-width: 1px !important;
  animation: stageIn .24s ease both;
}
.control-grid.has-content .intake-box {
  min-height: 58px !important;
  padding-top: 9px !important;
  padding-bottom: 9px !important;
}
.control-grid.has-content .file-box::after { display: none; }
@keyframes stageIn {
  from { opacity: 0; transform: translateX(18px) scale(.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
.mode-control select:invalid,
.mode-control select option[value=""] {
  color: var(--muted);
}
.tooltip-control { position: relative; }
.tooltip-control:hover::after {
  content: attr(data-tooltip);
  position: fixed;
  z-index: 10000;
  left: min(var(--tooltip-x, 50vw), calc(100vw - 360px));
  top: calc(var(--tooltip-y, 0px) + 18px);
  width: min(340px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, .12);
  background: #172033;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 750;
  white-space: normal;
  box-shadow: 0 16px 42px rgba(15, 23, 42, .24);
}
.ios-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  margin-left: auto;
  color: var(--text);
  font-weight: 950;
}
.ios-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ios-track {
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: #f97066;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .10);
  transition: background .18s ease;
  position: relative;
  flex: 0 0 auto;
}
.ios-knob {
  position: absolute;
  width: 24px;
  height: 24px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .25);
  transition: transform .18s ease;
}
.ios-switch input:checked + .ios-track {
  background: #12b76a;
}
.ios-switch input:checked + .ios-track .ios-knob {
  transform: translateX(22px);
}
.ios-label {
  min-width: 24px;
  font-size: 13px;
  color: var(--soft-text);
}
.compact-switch {
  margin-left: auto;
  gap: 7px;
}
.top-footer {
  margin-top: 8px !important;
}
.status {
  display: none;
  min-height: 0;
}
.status.status-visible {
  display: block;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .60);
  border: 1px solid var(--line);
}
.mini-calculator {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease;
}
.control-grid.has-content + .top-footer .mini-calculator,
.top-footer.has-content .mini-calculator {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
html[data-theme="dark"] .control-box.intake-box {
  background: #202b3d !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] .control-box.intake-box:hover,
html[data-theme="dark"] .file-box.drag-over {
  background: #263449 !important;
  border-color: rgba(167, 139, 250, .55) !important;
}
html[data-theme="dark"] .file-box.has-file {
  background: rgba(18, 183, 106, .12) !important;
  border-color: rgba(52, 211, 153, .42) !important;
}
html[data-theme="dark"] .tooltip-control:hover::after {
  background: #f8fafc;
  color: #172033;
  border-color: rgba(255,255,255,.20);
}
html[data-theme="dark"] .ios-label,
html[data-theme="dark"] .intake-main { color: var(--text) !important; }
html[data-theme="dark"] .status.status-visible { background: #202b3d; }

@media (max-width: 1480px) {
  .control-grid {
    grid-template-columns: minmax(280px, 1.1fr) minmax(235px, .95fr) repeat(3, minmax(150px, .7fr)) auto !important;
  }
}
@media (max-width: 1280px) {
  .control-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 1020px) {
  .control-grid { grid-template-columns: 1fr 1fr !important; }
  .control-box.intake-box { min-height: 68px !important; }
}

/* reliability override: hidden steps should not reserve grid columns */
.progressive-control {
  display: none !important;
  opacity: 0;
  transform: translateX(16px);
}
.control-grid.has-content .mode-control,
.control-grid.has-content .quality-control,
.control-grid.has-mode .voice-control,
.control-grid.has-mode .text-telegram-control,
.control-grid.has-mode .run-control,
.control-grid.has-voice .voice-dependent {
  display: flex !important;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  max-width: none;
  border-width: 1px !important;
}
.control-grid.has-mode .run-control {
  display: inline-flex !important;
}

/* UI stage 1.8 — full progress workspace + new task reset */
.new-task-box {
  display: none !important;
  border-color: rgba(195, 54, 43, .34) !important;
  background: linear-gradient(180deg, #fff5f4 0%, #ffe7e4 100%) !important;
  color: var(--err) !important;
  box-shadow: 0 10px 26px rgba(195, 54, 43, .12) !important;
}
.new-task-box .control-kicker,
.new-task-box .intake-sub {
  color: rgba(195, 54, 43, .76) !important;
}
.new-task-box .intake-main {
  color: var(--err) !important;
  font-size: 17px !important;
}
.new-task-box:hover {
  border-color: rgba(195, 54, 43, .56) !important;
  background: linear-gradient(180deg, #fff1ef 0%, #ffd9d4 100%) !important;
  box-shadow: 0 14px 34px rgba(195, 54, 43, .18) !important;
}

.app-shell.job-final .file-box {
  display: none !important;
}
.app-shell.job-final .new-task-box {
  display: flex !important;
}
.app-shell.job-final .run-control {
  display: none !important;
}

.app-shell.job-active .language-panel {
  display: none !important;
}
.app-shell.job-active .left-column {
  display: flex !important;
  min-height: 0 !important;
}
.app-shell.job-active .progress-panel {
  flex: 1 1 auto !important;
  max-height: none !important;
  min-height: 0 !important;
  display: grid !important;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) !important;
  overflow: hidden !important;
}
.app-shell.job-active .progress-panel.hidden {
  display: none !important;
}
.app-shell.job-active .progress-panel .panel-head {
  padding: 18px 18px 14px !important;
}
.app-shell.job-active .progress-panel .panel-head h2 {
  font-size: 24px !important;
}
.app-shell.job-active .progress-panel .panel-head p {
  font-size: 15px !important;
  font-weight: 850 !important;
}
.app-shell.job-active .progress-panel .stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px !important;
  padding: 14px 18px 8px !important;
}
.app-shell.job-active .progress-panel .stat-card {
  min-height: 82px !important;
  border-radius: 18px !important;
  padding: 14px !important;
}
.app-shell.job-active .progress-panel .stat-card span {
  font-size: 12px !important;
}
.app-shell.job-active .progress-panel .stat-card strong {
  font-size: 31px !important;
  margin-top: 8px !important;
}
.app-shell.job-active .progress-track {
  height: 15px !important;
  margin: 12px 18px 16px !important;
}
.app-shell.job-active .result-tools {
  padding: 0 18px 14px !important;
}
.app-shell.job-active .filter-tabs button {
  min-height: 39px !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
}
.app-shell.job-active .search-input {
  min-height: 46px !important;
  font-size: 14px !important;
}
.app-shell.job-active .results {
  min-height: 0 !important;
  padding: 0 14px 14px !important;
  gap: 10px !important;
}
.app-shell.job-active .result-row {
  min-height: 66px !important;
  border-radius: 18px !important;
  padding: 12px !important;
}

html[data-theme="dark"] .new-task-box {
  background: rgba(251, 113, 133, .13) !important;
  border-color: rgba(251, 113, 133, .40) !important;
  color: #fecdd3 !important;
}
html[data-theme="dark"] .new-task-box .control-kicker,
html[data-theme="dark"] .new-task-box .intake-sub {
  color: #fda4af !important;
}
html[data-theme="dark"] .new-task-box .intake-main {
  color: #fecdd3 !important;
}
html[data-theme="dark"] .new-task-box:hover {
  background: rgba(251, 113, 133, .20) !important;
  border-color: rgba(251, 113, 133, .55) !important;
}

@media (max-width: 1020px) {
  .app-shell.job-active .progress-panel .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* UI stage 2.0 — readable progress workspace width fix */
.app-shell.job-active .workspace,
.app-shell.job-final .workspace {
  grid-template-columns: minmax(560px, 46vw) minmax(0, 1fr) !important;
}

.app-shell.job-active .progress-panel,
.app-shell.job-final .progress-panel {
  width: 100% !important;
  max-width: 100% !important;
}

.app-shell.job-active .progress-panel .stat-grid,
.app-shell.job-final .progress-panel .stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.app-shell.job-active .progress-panel .stat-card,
.app-shell.job-final .progress-panel .stat-card {
  min-width: 0 !important;
}

.app-shell.job-active .result-row,
.app-shell.job-final .result-row {
  grid-template-columns: 42px minmax(150px, 1fr) max-content !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

.app-shell.job-active .result-actions,
.app-shell.job-final .result-actions {
  min-width: max-content !important;
  max-width: 100% !important;
  flex-wrap: nowrap !important;
  overflow: visible !important;
}

.app-shell.job-active .result-actions button,
.app-shell.job-active .result-actions a,
.app-shell.job-final .result-actions button,
.app-shell.job-final .result-actions a {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

.app-shell.job-active .filter-tabs,
.app-shell.job-final .filter-tabs {
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  scrollbar-width: thin !important;
}

@media (max-width: 1280px) {
  .app-shell.job-active .workspace,
  .app-shell.job-final .workspace {
    grid-template-columns: minmax(520px, 50vw) minmax(0, 1fr) !important;
  }
  .app-shell.job-active .progress-panel .stat-grid,
  .app-shell.job-final .progress-panel .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1020px) {
  .app-shell.job-active .workspace,
  .app-shell.job-final .workspace {
    grid-template-columns: 1fr !important;
  }
  .app-shell.job-active .right-column,
  .app-shell.job-final .right-column {
    min-height: 420px !important;
  }
}

/* UI stage 2.1 — keep progress exactly in the original Languages column */
.app-shell.job-active .workspace,
.app-shell.job-final .workspace {
  grid-template-columns: 420px minmax(0, 1fr) !important;
}

.app-shell.job-active .left-column,
.app-shell.job-final .left-column {
  width: 100% !important;
  max-width: 420px !important;
  min-width: 0 !important;
}

.app-shell.job-active .progress-panel,
.app-shell.job-final .progress-panel {
  width: 100% !important;
  max-width: 100% !important;
}

.app-shell.job-active .progress-panel .stat-grid,
.app-shell.job-final .progress-panel .stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.app-shell.job-active .result-row,
.app-shell.job-final .result-row {
  grid-template-columns: 42px minmax(0, 1fr) auto !important;
}

@media (max-width: 1020px) {
  .app-shell.job-active .workspace,
  .app-shell.job-final .workspace {
    grid-template-columns: 1fr !important;
  }

  .app-shell.job-active .left-column,
  .app-shell.job-final .left-column {
    width: 100% !important;
    max-width: none !important;
  }
}

/* UI stage 2.2 — compact progress rows inside the original Languages column */
.app-shell.job-active .progress-panel .panel-head,
.app-shell.job-final .progress-panel .panel-head {
  padding: 12px 14px 10px !important;
}

.app-shell.job-active .progress-panel .panel-head h2,
.app-shell.job-final .progress-panel .panel-head h2 {
  font-size: 20px !important;
}

.app-shell.job-active .progress-panel .panel-head p,
.app-shell.job-final .progress-panel .panel-head p {
  font-size: 13px !important;
}

.app-shell.job-active .progress-panel .stat-grid,
.app-shell.job-final .progress-panel .stat-grid {
  gap: 8px !important;
  padding: 10px 12px 6px !important;
}

.app-shell.job-active .progress-panel .stat-card,
.app-shell.job-final .progress-panel .stat-card {
  min-height: 0 !important;
  border-radius: 15px !important;
  padding: 9px 10px !important;
}

.app-shell.job-active .progress-panel .stat-card span,
.app-shell.job-final .progress-panel .stat-card span {
  font-size: 10px !important;
  letter-spacing: .03em !important;
}

.app-shell.job-active .progress-panel .stat-card strong,
.app-shell.job-final .progress-panel .stat-card strong {
  font-size: 24px !important;
  margin-top: 4px !important;
}

.app-shell.job-active .progress-track,
.app-shell.job-final .progress-track {
  height: 10px !important;
  margin: 8px 12px 10px !important;
}

.app-shell.job-active .result-tools,
.app-shell.job-final .result-tools {
  padding: 0 12px 10px !important;
  gap: 8px !important;
}

.app-shell.job-active .filter-tabs,
.app-shell.job-final .filter-tabs {
  gap: 6px !important;
}

.app-shell.job-active .filter-tabs button,
.app-shell.job-final .filter-tabs button {
  min-height: 32px !important;
  padding: 6px 9px !important;
  border-radius: 11px !important;
  font-size: 12px !important;
}

.app-shell.job-active .search-input,
.app-shell.job-final .search-input {
  min-height: 38px !important;
  border-radius: 13px !important;
  font-size: 13px !important;
}

.app-shell.job-active .results,
.app-shell.job-final .results {
  padding: 0 9px 9px !important;
  gap: 7px !important;
}

.app-shell.job-active .result-row,
.app-shell.job-final .result-row {
  grid-template-columns: 34px minmax(0, 1fr) max-content !important;
  gap: 7px !important;
  min-height: 54px !important;
  padding: 7px 8px !important;
  border-radius: 15px !important;
}

.app-shell.job-active .result-flag,
.app-shell.job-final .result-flag {
  width: 34px !important;
  height: 34px !important;
  border-radius: 12px !important;
  font-size: 20px !important;
}

.app-shell.job-active .result-flag .lang-flag-img,
.app-shell.job-final .result-flag .lang-flag-img {
  width: 23px !important;
  height: 17px !important;
  border-radius: 4px !important;
}

.app-shell.job-active .result-main strong,
.app-shell.job-final .result-main strong {
  font-size: 13px !important;
  line-height: 1.15 !important;
}

.app-shell.job-active .result-main span,
.app-shell.job-final .result-main span {
  margin-top: 3px !important;
  font-size: 11px !important;
}

.app-shell.job-active .result-actions,
.app-shell.job-final .result-actions {
  gap: 5px !important;
  flex-wrap: nowrap !important;
}

/* The status pill duplicated the status line and caused clipping in the compact column. */
.app-shell.job-active .result-actions .badge,
.app-shell.job-final .result-actions .badge {
  display: none !important;
}

.app-shell.job-active .result-actions button,
.app-shell.job-active .result-actions a,
.app-shell.job-final .result-actions button,
.app-shell.job-final .result-actions a {
  min-height: 28px !important;
  padding: 5px 7px !important;
  border-radius: 9px !important;
  font-size: 11px !important;
  line-height: 1 !important;
}

@media (max-width: 460px) {
  .app-shell.job-active .result-row,
  .app-shell.job-final .result-row {
    grid-template-columns: 32px minmax(0, 1fr) max-content !important;
  }
  .app-shell.job-active .result-actions button,
  .app-shell.job-active .result-actions a,
  .app-shell.job-final .result-actions button,
  .app-shell.job-final .result-actions a {
    padding: 5px 6px !important;
    font-size: 10px !important;
  }
}

/* UI stage 2.3 — viewport scale for 2K/1K monitors
   Keep the same geometry, but shrink the whole app on smaller desktop widths. */
:root {
  --ui-scale: 1;
}

@media (max-width: 2200px) { :root { --ui-scale: .96; } }
@media (max-width: 1960px) { :root { --ui-scale: .90; } }
@media (max-width: 1760px) { :root { --ui-scale: .84; } }
@media (max-width: 1500px) { :root { --ui-scale: .78; } }

@media (min-width: 1021px) {
  html,
  body {
    width: 100vw !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }

  .app-shell:not(.hidden) {
    transform: scale(var(--ui-scale)) !important;
    transform-origin: top left !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: calc(100vw / var(--ui-scale)) !important;
    height: calc(100dvh / var(--ui-scale)) !important;
    max-width: none !important;
    max-height: none !important;
  }

  /* On scaled desktops we keep the wide desktop control geometry,
     otherwise media queries were forcing 3-4 columns and breaking the flow. */
  .control-grid {
    grid-template-columns:
      minmax(300px, 1.15fr)
      minmax(240px, .90fr)
      minmax(112px, .44fr)
      minmax(118px, .46fr)
      minmax(112px, .42fr)
      minmax(150px, .58fr)
      minmax(104px, .40fr)
      minmax(96px, .36fr)
      minmax(92px, .34fr)
      auto !important;
  }

  .control-box,
  .btn,
  button,
  .download-all,
  .single-download,
  .result-actions a,
  .history-actions a,
  .ghost-link {
    white-space: nowrap !important;
  }

  .template-select,
  .control-box select {
    min-width: 0 !important;
  }

  .toprow {
    gap: 10px !important;
  }

  .brand {
    min-width: 250px !important;
  }
}

@media (max-width: 1500px) and (min-width: 1021px) {
  .brand p {
    max-width: 230px !important;
  }
  .top-status {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* UI stage 2.4 — compact control blocks + real cursor tooltips */
@media (min-width: 1021px) {
  .control-grid {
    gap: 7px !important;
    grid-template-columns:
      minmax(250px, .95fr)
      minmax(200px, .74fr)
      minmax(96px, .36fr)
      minmax(104px, .39fr)
      minmax(96px, .36fr)
      minmax(134px, .50fr)
      minmax(88px, .32fr)
      minmax(82px, .30fr)
      minmax(78px, .28fr)
      minmax(106px, .40fr)
      auto !important;
  }

  .control-box {
    min-height: 52px !important;
    padding: 7px 10px !important;
    border-radius: 15px !important;
    gap: 4px !important;
  }

  .control-box.intake-box {
    min-height: 58px !important;
    padding: 9px 12px !important;
    border-radius: 17px !important;
  }

  .control-grid.has-content .intake-box {
    min-height: 50px !important;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
  }

  .control-box > span,
  .control-box summary span,
  .control-kicker {
    font-size: 10px !important;
    letter-spacing: .035em !important;
    line-height: 1 !important;
  }

  .intake-main {
    font-size: 13px !important;
    line-height: 1.05 !important;
  }

  .intake-sub {
    font-size: 10.5px !important;
    line-height: 1.1 !important;
  }

  .select-box select,
  .template-select,
  .control-box select {
    font-size: 12px !important;
    line-height: 1.15 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding-right: 18px !important;
  }

  .toggle-box {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  .ios-switch {
    gap: 5px !important;
    margin-left: 6px !important;
    flex: 0 0 auto !important;
  }

  .ios-track {
    width: 40px !important;
    height: 23px !important;
  }

  .ios-knob {
    width: 19px !important;
    height: 19px !important;
  }

  .ios-switch input:checked + .ios-track .ios-knob {
    transform: translateX(17px) !important;
  }

  .ios-label {
    min-width: 18px !important;
    font-size: 11px !important;
    line-height: 1 !important;
  }

  .compact-switch {
    font-size: 12px !important;
    gap: 5px !important;
    margin-left: 6px !important;
  }

  .run-control,
  .btn.primary.run-control {
    min-height: 52px !important;
    padding: 0 14px !important;
    border-radius: 15px !important;
    font-size: 14px !important;
  }

  .top-actions .btn,
  .theme-toggle,
  .ghost-link {
    min-height: 38px !important;
    padding: 8px 12px !important;
    border-radius: 14px !important;
    font-size: 13px !important;
  }

  .brand {
    min-width: 230px !important;
  }

  .brand h1 {
    font-size: 17px !important;
  }

  .brand p {
    font-size: 12px !important;
    max-width: 245px !important;
  }

  .top-status {
    min-height: 34px !important;
    padding: 6px 11px !important;
    font-size: 12px !important;
  }
}

@media (max-width: 1760px) and (min-width: 1021px) {
  .control-grid {
    grid-template-columns:
      minmax(230px, .88fr)
      minmax(178px, .66fr)
      minmax(82px, .31fr)
      minmax(90px, .34fr)
      minmax(82px, .31fr)
      minmax(112px, .42fr)
      minmax(74px, .28fr)
      minmax(72px, .27fr)
      minmax(68px, .25fr)
      minmax(96px, .36fr)
      auto !important;
  }

  .control-box {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .run-control,
  .btn.primary.run-control {
    font-size: 13px !important;
    padding-left: 11px !important;
    padding-right: 11px !important;
  }
}

/* Disable the old pseudo-tooltip. It was clipped by compact blocks and transformed layout. */
.tooltip-control:hover::after {
  content: none !important;
  display: none !important;
}

.cursor-tooltip {
  position: fixed;
  z-index: 999999;
  max-width: 320px;
  padding: 9px 11px;
  border-radius: 13px;
  border: 1px solid rgba(15, 23, 42, .14);
  background: #162033;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 750;
  box-shadow: 0 16px 42px rgba(15, 23, 42, .24);
  pointer-events: none;
  opacity: 0;
  transform: translate(12px, 14px) scale(.98);
  transition: opacity .08s ease, transform .08s ease;
}

.cursor-tooltip.visible {
  opacity: 1;
  transform: translate(12px, 14px) scale(1);
}

html[data-theme="dark"] .cursor-tooltip {
  background: #f8fafc;
  color: #172033;
  border-color: rgba(255, 255, 255, .22);
}

.history-countdown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin-top: 5px !important;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #cfd9e8;
  background: #f3f7fc;
  color: #516174 !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  line-height: 1.1;
}
.history-countdown::before { content: '⏳'; }
.history-countdown.urgent {
  border-color: rgba(220, 138, 0, .35);
  background: #fff7e6;
  color: #9a5b00 !important;
}
.history-countdown.expired {
  border-color: rgba(217, 45, 32, .28);
  background: #fff1f0;
  color: #b42318 !important;
}
html[data-theme="dark"] .history-countdown {
  border-color: #354760;
  background: #172235;
  color: #c8d5e8 !important;
}
html[data-theme="dark"] .history-countdown.urgent {
  border-color: rgba(253, 176, 34, .38);
  background: rgba(253, 176, 34, .13);
  color: #ffd58a !important;
}
html[data-theme="dark"] .history-countdown.expired {
  border-color: rgba(249, 112, 102, .35);
  background: rgba(249, 112, 102, .12);
  color: #ffb4ad !important;
}


.ui-language-select {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #24364f;
  border-radius: 14px;
  padding: 8px 10px;
  font-weight: 850;
  box-shadow: 0 2px 7px rgba(29, 41, 57, .04);
}
:root[data-theme="dark"] .ui-language-select {
  background: var(--panel-soft);
  color: var(--text);
  border-color: var(--line-strong);
}
html[dir="rtl"] .toprow,
html[dir="rtl"] .control-grid,
html[dir="rtl"] .workspace {
  direction: rtl;
}
html[dir="rtl"] .brand-text,
html[dir="rtl"] .preview-panel,
html[dir="rtl"] .history-row,
html[dir="rtl"] .result-row,
html[dir="rtl"] .language-choice {
  text-align: right;
}
html[dir="rtl"] pre,
html[dir="rtl"] textarea {
  direction: rtl;
  text-align: right;
}


/* UI stage 3 — compact clickable history grid + auth language picker */
.auth-language-select {
  width: 100%;
  max-width: 220px;
  margin: 8px auto 12px;
  display: block;
  text-align: center;
}

.history-list {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  align-content: start !important;
  gap: 8px !important;
  padding: 10px !important;
  overflow: auto !important;
}

.history-card,
.history-row.history-card {
  display: grid !important;
  grid-template-columns: 1fr !important;
  align-content: start !important;
  gap: 3px !important;
  min-width: 0 !important;
  width: 100% !important;
  min-height: 76px !important;
  padding: 9px 10px !important;
  border-radius: 14px !important;
  border: 1px solid var(--line) !important;
  background: #fff !important;
  color: var(--text) !important;
  text-align: left !important;
  box-shadow: 0 2px 8px rgba(29, 41, 57, .04) !important;
}

.history-card:hover,
.history-row.history-card:hover {
  border-color: #aebcd0 !important;
  background: #fbfdff !important;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(29, 41, 57, .08) !important;
}

.history-card strong {
  display: block !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 12px !important;
  line-height: 1.2 !important;
  color: var(--text) !important;
}

.history-card span,
.history-card small {
  display: block !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  margin: 0 !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
  font-weight: 800 !important;
  color: var(--muted) !important;
}

.history-card .history-countdown {
  justify-self: start !important;
  max-width: 100% !important;
  padding: 3px 7px !important;
  margin-top: 2px !important;
  font-size: 10px !important;
  line-height: 1.1 !important;
}

.history-card.completed,
.history-card.completed_with_errors,
.history-card.completedWithErrors {
  border-color: rgba(3, 152, 85, .22) !important;
}

.history-card.failed,
.history-card.error {
  border-color: rgba(217, 45, 32, .25) !important;
  background: #fffafa !important;
}

.history-card.running,
.history-card.queued {
  border-color: rgba(21, 112, 239, .25) !important;
  background: #f7fbff !important;
}

html[data-theme="dark"] .history-card,
html[data-theme="dark"] .history-row.history-card {
  background: var(--panel-soft) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .history-card:hover,
html[data-theme="dark"] .history-row.history-card:hover {
  background: #172235 !important;
  border-color: #465a75 !important;
}

html[data-theme="dark"] .history-card strong { color: var(--text) !important; }
html[data-theme="dark"] .history-card span,
html[data-theme="dark"] .history-card small { color: var(--muted) !important; }

@media (max-width: 1500px) {
  .history-list { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}
@media (max-width: 1180px) {
  .history-list { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 760px) {
  .history-list { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 520px) {
  .history-list { grid-template-columns: 1fr !important; }
}

html[dir="rtl"] .history-card,
html[dir="rtl"] .history-row.history-card {
  text-align: right !important;
}
html[dir="rtl"] .history-card .history-countdown {
  justify-self: end !important;
}

/* i18n flag picker + notification settings */
.native-language-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}
.custom-language-picker {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  z-index: 50;
}
.custom-language-button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #24364f;
  border-radius: 14px;
  padding: 7px 10px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 2px 7px rgba(29, 41, 57, .04);
}
.custom-language-button::after {
  content: '▾';
  color: var(--muted);
  font-size: 11px;
  margin-left: 2px;
}
.custom-language-button img,
.custom-language-menu img {
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, .12);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
  flex: 0 0 auto;
}
.custom-language-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: 190px;
  max-height: 270px;
  overflow: auto;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(15, 23, 42, .18);
  display: none;
}
.custom-language-picker.open .custom-language-menu { display: grid; gap: 4px; }
.custom-language-menu button {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 24px 34px 1fr;
  align-items: center;
  gap: 8px;
  text-align: left;
  font-weight: 850;
}
.custom-language-menu button:hover,
.custom-language-menu button.active {
  background: rgba(124, 58, 237, .10);
  color: var(--text);
}
.custom-language-menu button span { font-weight: 950; }
.custom-language-menu button strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-language-select + .custom-language-picker {
  margin: 10px auto 4px;
  justify-content: center;
}
.auth-language-select + .custom-language-picker .custom-language-menu {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}
.notifications-toggle { min-width: 0; }
.notifications-modal { width: min(620px, 100%); }
.notifications-list {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--panel);
}
.notification-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}
.notification-setting strong {
  display: block;
  font-size: 15px;
  color: var(--text);
}
.notification-setting small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
}
html[data-theme="dark"] .custom-language-button {
  background: var(--panel-soft);
  color: var(--text);
  border-color: var(--line-strong);
}
html[data-theme="dark"] .custom-language-menu {
  background: var(--panel);
  border-color: var(--line-strong);
  box-shadow: 0 20px 55px rgba(0, 0, 0, .45);
}
html[dir="rtl"] .custom-language-menu {
  right: auto;
  left: 0;
}
html[dir="rtl"] .custom-language-menu button {
  text-align: right;
}
@media (max-width: 1280px) {
  .notifications-toggle { padding-left: 9px; padding-right: 9px; }
  .notifications-toggle { font-size: 0; }
  .notifications-toggle::before { content: '🔔'; font-size: 15px; }
}

.auto-download-toggle { min-width: 0; }
.auto-download-modal { width: min(680px, 100%); }
.auto-download-folder-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 18px;
}
.auto-download-folder-card strong { display: block; color: var(--text); font-size: 15px; }
.auto-download-folder-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 800; }
.auto-download-folder-card.is-ready {
  border-color: rgba(3, 152, 85, .28);
  background: rgba(3, 152, 85, .06);
}
.auto-download-folder-card.is-error {
  border-color: rgba(217, 45, 32, .28);
  background: rgba(217, 45, 32, .06);
}
.auto-download-list { margin-top: 0; }
.auto-download-save-hint { color: var(--muted); font-weight: 800; font-size: 13px; }
html[data-theme="dark"] .auto-download-folder-card {
  background: var(--panel-soft);
  border-color: var(--line);
}
html[data-theme="dark"] .auto-download-folder-card.is-ready {
  border-color: rgba(50, 213, 131, .28);
  background: rgba(50, 213, 131, .08);
}
html[data-theme="dark"] .auto-download-folder-card.is-error {
  border-color: rgba(249, 112, 102, .28);
  background: rgba(249, 112, 102, .08);
}
@media (max-width: 1500px) {
  .auto-download-toggle { padding-left: 9px; padding-right: 9px; }
  .auto-download-toggle { font-size: 0; }
  .auto-download-toggle::before { content: '📁'; font-size: 15px; }
}


.completion-toast {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  z-index: 1200;
  width: min(420px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: 46px 1fr 30px;
  gap: 12px;
  align-items: center;
  padding: 14px 14px;
  border: 1px solid rgba(3, 152, 85, .26);
  border-radius: 20px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 22px 55px rgba(29, 41, 57, .18);
  color: var(--text);
  transform: translateY(-12px) scale(.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  backdrop-filter: blur(16px);
}
.completion-toast:not(.hidden) {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.completion-toast-icon {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(3, 152, 85, .10);
  color: var(--ok);
  font-size: 23px;
  border: 1px solid rgba(3, 152, 85, .22);
}
.completion-toast-body { min-width: 0; }
.completion-toast-body strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}
.completion-toast-body span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 750;
}
.completion-toast-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.completion-toast-close:hover { color: var(--text); border-color: var(--line-strong); }
.completion-toast.is-warning { border-color: rgba(220, 138, 0, .32); }
.completion-toast.is-warning .completion-toast-icon { background: rgba(220, 138, 0, .10); color: var(--warn); border-color: rgba(220, 138, 0, .26); }
.completion-toast.is-error { border-color: rgba(217, 45, 32, .30); }
.completion-toast.is-error .completion-toast-icon { background: rgba(217, 45, 32, .10); color: var(--err); border-color: rgba(217, 45, 32, .24); }
html[data-theme="dark"] .completion-toast {
  background: rgba(13, 25, 44, .96);
  box-shadow: 0 22px 55px rgba(0, 0, 0, .40);
}
@media (max-width: 700px) {
  .completion-toast {
    top: auto;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
  }
}

/* Language template manager */
.template-manager-modal {
  width: min(1080px, 100%);
  max-height: min(86vh, 820px);
}
.template-manager-body {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}
.template-manager-list-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
}
.template-manager-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 950;
}
.template-manager-subhead span {
  display: inline-flex;
  min-width: 26px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(124, 58, 237, .10);
  color: var(--violet);
  font-size: 12px;
}
.template-manager-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template-manager-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(29, 41, 57, .04);
}
.template-manager-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-manager-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.template-manager-item:hover,
.template-manager-item.active {
  background: #f4efff;
  border-color: rgba(124, 58, 237, .62);
}
.template-manager-empty-list {
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  background: rgba(255,255,255,.6);
  font-weight: 800;
}
.template-editor {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}
.template-editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
}
.template-editor-empty div { font-size: 42px; }
.template-editor-empty strong { color: var(--text); font-size: 18px; }
.template-editor-empty span { max-width: 320px; font-size: 13px; line-height: 1.45; font-weight: 750; }
.template-editor-form {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}
.template-name-field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 950;
}
.template-name-field span { font-size: 13px; }
.template-name-field input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
  font-weight: 850;
}
.template-name-field input:focus {
  border-color: rgba(124, 58, 237, .55);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, .10);
}
.template-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  color: var(--text);
}
.template-editor-toolbar strong { font-size: 14px; }
.template-editor-toolbar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}
.template-editor-languages {
  min-height: 0;
  flex: 1;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  padding: 2px 2px 8px;
  align-content: start;
}
.template-language-choice {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 8px 9px;
  background: #fff;
  min-height: 46px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(29, 41, 57, .04);
}
.template-language-choice:hover { background: #fbfdff; border-color: #b7c5d8; }
.template-language-choice input { position: absolute; opacity: 0; pointer-events: none; }
.template-language-choice:has(input:checked) { background: #f4efff; border-color: rgba(124, 58, 237, .65); }
.template-manager-footer { padding-top: 12px; }
.template-manager-footer .modal-actions { flex-wrap: wrap; justify-content: flex-end; }

html[data-theme="dark"] .template-manager-list-wrap,
html[data-theme="dark"] .template-manager-subhead,
html[data-theme="dark"] .template-editor-form,
html[data-theme="dark"] .template-editor,
html[data-theme="dark"] .template-manager-footer {
  background: var(--panel);
}
html[data-theme="dark"] .template-manager-item,
html[data-theme="dark"] .template-language-choice,
html[data-theme="dark"] .template-name-field input,
html[data-theme="dark"] .template-manager-empty-list {
  background: #111827;
  color: var(--text);
  border-color: var(--line);
}
html[data-theme="dark"] .template-manager-item:hover,
html[data-theme="dark"] .template-manager-item.active,
html[data-theme="dark"] .template-language-choice:has(input:checked) {
  background: rgba(124, 58, 237, .18);
  border-color: rgba(167, 139, 250, .58);
}

@media (max-width: 820px) {
  .template-manager-body { grid-template-columns: 1fr; }
  .template-manager-list-wrap { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
  .template-editor-languages { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
}

/* Queue workflow: the input blocks stay available after a task starts/finishes,
   so the next file can be dropped immediately and added to the queue. */
.app-shell.job-final .file-box,
.app-shell.job-active .file-box {
  display: flex !important;
}
.app-shell.job-final .new-task-box,
.app-shell.job-active .new-task-box {
  display: none !important;
}
.app-shell.job-final .run-control,
.app-shell.job-active .run-control {
  display: inline-flex;
}
.app-shell.job-active .control-grid.has-content .run-control,
.app-shell.job-final .control-grid.has-content .run-control {
  display: inline-flex !important;
}

.history-card.queued::before,
.history-card.running::before {
  content: attr(data-job-badge);
  align-self: start;
  justify-self: start;
  max-width: 100%;
  border-radius: 999px;
  padding: 2px 7px;
  margin-bottom: 1px;
  font-size: 9px;
  line-height: 1.1;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #075985;
  background: rgba(14, 165, 233, .10);
  border: 1px solid rgba(14, 165, 233, .22);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-card.running::before {
  color: #854d0e;
  background: rgba(245, 158, 11, .12);
  border-color: rgba(245, 158, 11, .24);
}
html[data-theme="dark"] .history-card.queued::before,
html[data-theme="dark"] .history-card.running::before {
  color: #bae6fd;
  background: rgba(14, 165, 233, .16);
  border-color: rgba(125, 211, 252, .22);
}
html[data-theme="dark"] .history-card.running::before {
  color: #fde68a;
  background: rgba(245, 158, 11, .16);
  border-color: rgba(252, 211, 77, .24);
}

/* Queue input switch — when a current task is open and the user adds a new file/text,
   show language selection for the next queued task instead of the current task progress. */
.app-shell.job-active.queue-input-active .progress-panel,
.app-shell.job-final.queue-input-active .progress-panel {
  display: none !important;
}

.app-shell.job-active.queue-input-active .language-panel,
.app-shell.job-final.queue-input-active .language-panel {
  display: flex !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

.app-shell.job-active.queue-input-active .left-column,
.app-shell.job-final.queue-input-active .left-column {
  display: flex !important;
  min-height: 0 !important;
}


/* Language list controls: display language, alphabetic sort, quick search */
.language-list-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 0 12px 10px;
}
.language-list-tools input,
.language-list-tools select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
  outline: none;
}
.language-list-tools input:focus,
.language-list-tools select:focus {
  border-color: rgba(124, 58, 237, .55);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .10);
}
.language-filter-hidden { display: none !important; }
html[data-theme="dark"] .language-list-tools input,
html[data-theme="dark"] .language-list-tools select {
  background: var(--panel2);
  color: var(--text);
  border-color: var(--line);
}
@media (max-width: 760px) {
  .language-list-tools { grid-template-columns: 1fr; }
}

/* Visible language list controls */
.language-view-controls {
  display: block;
  padding: 8px 12px 7px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}
.language-search-field {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(29,41,57,.04);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
  outline: none;
}
.language-search-field:focus {
  border-color: rgba(124,58,237,.55);
  box-shadow: 0 0 0 3px rgba(124,58,237,.10);
}
.language-hidden-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}
.language-icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  font-weight: 1000;
  box-shadow: 0 2px 8px rgba(29,41,57,.05);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease;
}
.language-icon-btn:hover {
  border-color: rgba(124,58,237,.55);
  box-shadow: 0 0 0 3px rgba(124,58,237,.10);
}
.language-icon-btn:active { transform: scale(.97); }
.language-icon-btn img {
  width: 22px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
  display: block;
  box-shadow: 0 0 0 1px rgba(15,23,42,.08);
}
html[data-theme="dark"] .language-view-controls { background: #111827; border-color: var(--line); }
html[data-theme="dark"] .language-search-field,
html[data-theme="dark"] .language-icon-btn { background: var(--panel2); color: var(--text); border-color: var(--line); }
html[data-theme="dark"] .language-count { background: var(--panel2); color: var(--text); border-color: var(--line); }
@media (max-width: 760px) {
  .language-head { align-items: flex-start; }
  .language-head-actions { gap: 5px; }
  .language-count { padding: 6px 8px; font-size: 11px; }
  .language-icon-btn { width: 32px; height: 32px; min-width: 32px; border-radius: 11px; }
}

/* Compact template controls restored under language header */
.language-template-strip {
  display: grid !important;
  grid-template-columns: 34px 34px minmax(0, 1fr) 34px 34px;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 8px !important;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}
.language-template-strip .language-mini-btn,
.language-template-strip button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px !important;
  padding: 0 !important;
  border-radius: 11px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px !important;
  line-height: 1;
  font-weight: 950;
  white-space: nowrap;
}
.language-template-strip .template-select {
  width: 100%;
  min-width: 0 !important;
  height: 34px;
  min-height: 34px !important;
  padding: 0 28px 0 10px !important;
  border-radius: 11px !important;
  font-size: 12px !important;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
}
.language-template-strip #selectSaved.hidden {
  display: none !important;
}
.template-create-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  min-height: 30px;
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(29,41,57,.04);
}
.template-create-btn:hover {
  border-color: rgba(124,58,237,.55);
  box-shadow: 0 0 0 3px rgba(124,58,237,.10);
}
.template-manager-subhead {
  flex-wrap: wrap;
}
.template-manager-subhead strong {
  flex: 1 1 auto;
  min-width: 110px;
}
html[data-theme="dark"] .language-template-strip,
html[data-theme="dark"] .template-create-btn {
  background: var(--panel2);
  color: var(--text);
  border-color: var(--line);
}

.brand-home {
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.brand-home:hover .brand-logo,
.brand-home:focus-visible .brand-logo {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.16);
}
.result-stats {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.preview-stats {
  margin-left: 8px;
  color: var(--muted);
}


/* Manual voice modal + readable result cards */
.manual-voice-modal {
  width: min(720px, 100%);
  max-height: min(86vh, 760px);
}
.manual-voice-body {
  min-height: 0;
  display: grid;
  gap: 14px;
  padding: 14px;
  overflow: auto;
}
.manual-voice-field {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 950;
}
.manual-voice-field > span, .manual-voice-field-head span { font-size: 13px; }
.manual-voice-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.manual-voice-field-head small, #manualVoiceStatus { color: var(--muted); font-size: 12px; font-weight: 850; }
#manualVoiceTemplateSelect {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  color: var(--text);
  padding: 0 12px;
  font-weight: 850;
  outline: none;
}
.manual-voice-language-list {
  min-height: 0;
  max-height: 320px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 2px;
}
.manual-voice-language-choice {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(29, 41, 57, .04);
}
.manual-voice-language-choice:hover { background: #fbfdff; border-color: #b7c5d8; }
.manual-voice-language-choice:has(input:checked) { background: #f4efff; border-color: rgba(124, 58, 237, .65); }
.manual-voice-flag {
  width: 32px; height: 32px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #eef4ff; border: 1px solid var(--line); overflow: hidden;
}
.manual-voice-flag .lang-flag-img { width: 23px; height: 17px; object-fit: cover; border-radius: 4px; }
.manual-voice-info { min-width: 0; display: block; }
.manual-voice-info strong { display: block; color: var(--text); font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manual-voice-info small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 850; line-height: 1.25; white-space: normal; }
.manual-voice-telegram {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel-soft); color: var(--text); font-weight: 900;
}

.app-shell.job-active .result-row,
.app-shell.job-final .result-row {
  grid-template-columns: 34px minmax(0, 1fr) !important;
  align-items: start !important;
  overflow: visible !important;
}
.app-shell.job-active .result-main,
.app-shell.job-final .result-main {
  min-width: 0 !important;
  overflow: visible !important;
}
.app-shell.job-active .result-main span,
.app-shell.job-final .result-main span,
.app-shell.job-active .result-stats,
.app-shell.job-final .result-stats,
.app-shell.job-active .error-text,
.app-shell.job-final .error-text {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.25 !important;
}
.app-shell.job-active .result-stats,
.app-shell.job-final .result-stats {
  margin-top: 2px !important;
  color: var(--muted) !important;
  font-size: 10.5px !important;
  font-weight: 850 !important;
}
.app-shell.job-active .result-actions,
.app-shell.job-final .result-actions {
  grid-column: 1 / -1 !important;
  min-width: 0 !important;
  width: 100% !important;
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-end !important;
  gap: 6px !important;
  padding-top: 2px !important;
}
.app-shell.job-active .result-actions button,
.app-shell.job-active .result-actions a,
.app-shell.job-final .result-actions button,
.app-shell.job-final .result-actions a {
  min-width: 62px !important;
  text-align: center !important;
}
@media (min-width: 1480px) {
  .app-shell.job-active .result-row,
  .app-shell.job-final .result-row { grid-template-columns: 34px minmax(0, 1fr) auto !important; }
  .app-shell.job-active .result-actions,
  .app-shell.job-final .result-actions { grid-column: auto !important; width: auto !important; padding-top: 0 !important; }
}
html[data-theme="dark"] #manualVoiceTemplateSelect,
html[data-theme="dark"] .manual-voice-language-choice {
  background: #111827; color: var(--text); border-color: var(--line);
}
html[data-theme="dark"] .manual-voice-language-choice:hover,
html[data-theme="dark"] .manual-voice-language-choice:has(input:checked) {
  background: rgba(124, 58, 237, .18);
  border-color: rgba(167, 139, 250, .58);
}

/* UI hotfix: result cards are clickable, no separate Open button, no cramped action column */
.app-shell.job-active .result-row,
.app-shell.job-final .result-row,
.result-row {
  grid-template-columns: 36px minmax(0, 1fr) !important;
  grid-template-areas:
    "flag main"
    "actions actions" !important;
  align-items: start !important;
  gap: 8px 10px !important;
  min-height: 0 !important;
  padding: 9px 10px !important;
  overflow: visible !important;
}
.result-row.clickable { cursor: pointer; }
.result-row.clickable:hover { background: #fbfdff; border-color: #9fb3cc; box-shadow: 0 4px 14px rgba(29, 41, 57, .07); }
.result-row.clickable:focus-visible { outline: 3px solid rgba(124, 58, 237, .22); outline-offset: 2px; }
.result-row .result-flag { grid-area: flag !important; }
.result-row .result-main { grid-area: main !important; min-width: 0 !important; overflow: visible !important; padding-top: 1px; }
.result-row .result-actions {
  grid-area: actions !important;
  width: 100% !important;
  min-width: 0 !important;
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-end !important;
  align-items: center !important;
  gap: 6px !important;
  padding-top: 0 !important;
  overflow: visible !important;
}
.result-row .result-main strong,
.app-shell.job-active .result-main strong,
.app-shell.job-final .result-main strong {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.18 !important;
}
.result-row .result-main span,
.result-row .result-stats,
.result-row .error-text,
.app-shell.job-active .result-main span,
.app-shell.job-final .result-main span,
.app-shell.job-active .result-stats,
.app-shell.job-final .result-stats,
.app-shell.job-active .error-text,
.app-shell.job-final .error-text {
  display: block !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: break-word !important;
  line-height: 1.28 !important;
}
.result-row .result-stats,
.app-shell.job-active .result-stats,
.app-shell.job-final .result-stats {
  margin-top: 2px !important;
  font-size: 11px !important;
  font-weight: 850 !important;
  color: var(--muted) !important;
}
.result-row .error-text {
  color: #b42318 !important;
  font-weight: 850 !important;
}
.result-row .result-actions button,
.result-row .result-actions a,
.app-shell.job-active .result-actions button,
.app-shell.job-active .result-actions a,
.app-shell.job-final .result-actions button,
.app-shell.job-final .result-actions a {
  min-width: 66px !important;
  min-height: 30px !important;
  padding: 6px 10px !important;
  border-radius: 10px !important;
  font-size: 11.5px !important;
  line-height: 1 !important;
  text-align: center !important;
}
.result-row .result-actions .badge,
.app-shell.job-active .result-actions .badge,
.app-shell.job-final .result-actions .badge { display: none !important; }
.preview-panel pre#error,
.preview-panel pre {
  white-space: pre-wrap !important;
  overflow-wrap: anywhere !important;
}
html[data-theme="dark"] .result-row.clickable:hover { background: rgba(124, 58, 237, .10); border-color: rgba(167, 139, 250, .45); }
html[data-theme="dark"] .result-row .error-text { color: #fca5a5 !important; }

/* UI hotfix stage 4 — stable result rows: no vertical overlap, clean compact list */
.results {
  display: block !important;
  padding: 0 10px 10px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
.results .result-row,
.app-shell.job-active .results .result-row,
.app-shell.job-final .results .result-row {
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr) !important;
  grid-template-areas:
    "flag main"
    "actions actions" !important;
  grid-auto-rows: auto !important;
  align-items: center !important;
  width: 100% !important;
  min-height: 58px !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 0 8px 0 !important;
  padding: 8px 10px !important;
  gap: 6px 10px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  border-radius: 15px !important;
}
.results .result-row:last-child { margin-bottom: 0 !important; }
.results .result-flag,
.app-shell.job-active .results .result-flag,
.app-shell.job-final .results .result-flag {
  grid-area: flag !important;
  align-self: start !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  border-radius: 12px !important;
  overflow: hidden !important;
}
.results .result-main,
.app-shell.job-active .results .result-main,
.app-shell.job-final .results .result-main {
  grid-area: main !important;
  min-width: 0 !important;
  width: 100% !important;
  display: grid !important;
  gap: 2px !important;
  overflow: hidden !important;
  padding: 0 !important;
}
.results .result-main strong,
.app-shell.job-active .results .result-main strong,
.app-shell.job-final .results .result-main strong {
  display: block !important;
  font-size: 13px !important;
  line-height: 1.18 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.results .result-main span,
.app-shell.job-active .results .result-main span,
.app-shell.job-final .results .result-main span,
.results .result-stats,
.app-shell.job-active .results .result-stats,
.app-shell.job-final .results .result-stats {
  display: block !important;
  max-width: 100% !important;
  margin: 0 !important;
  font-size: 10.5px !important;
  line-height: 1.18 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  color: var(--muted) !important;
  font-weight: 850 !important;
}
.results .error-text,
.app-shell.job-active .results .error-text,
.app-shell.job-final .results .error-text {
  display: block !important;
  max-height: 2.45em !important;
  margin: 2px 0 0 0 !important;
  font-size: 10.8px !important;
  line-height: 1.22 !important;
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: clip !important;
  color: #b42318 !important;
  font-weight: 850 !important;
}
.results .result-actions,
.app-shell.job-active .results .result-actions,
.app-shell.job-final .results .result-actions {
  grid-area: actions !important;
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-end !important;
  align-items: center !important;
  gap: 6px !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}
.results .result-actions .badge,
.app-shell.job-active .results .result-actions .badge,
.app-shell.job-final .results .result-actions .badge {
  display: none !important;
}
.results .result-actions button,
.results .result-actions a,
.app-shell.job-active .results .result-actions button,
.app-shell.job-active .results .result-actions a,
.app-shell.job-final .results .result-actions button,
.app-shell.job-final .results .result-actions a {
  min-width: 58px !important;
  min-height: 28px !important;
  padding: 5px 8px !important;
  border-radius: 9px !important;
  font-size: 11px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}
@media (min-width: 1480px) {
  .results .result-row,
  .app-shell.job-active .results .result-row,
  .app-shell.job-final .results .result-row {
    grid-template-columns: 34px minmax(0, 1fr) auto !important;
    grid-template-areas: "flag main actions" !important;
    align-items: center !important;
  }
  .results .result-actions,
  .app-shell.job-active .results .result-actions,
  .app-shell.job-final .results .result-actions {
    width: auto !important;
    justify-content: flex-end !important;
  }
}
html[data-theme="dark"] .results .error-text { color: #fca5a5 !important; }

.auto-download-choice-modal {
  width: min(560px, 100%);
  overflow: hidden;
}

.auto-download-choice-head {
  padding-bottom: 14px;
}

.auto-download-choice-hint {
  max-width: 420px;
}

.auto-download-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  margin: 16px 20px 0;
  border: 1px solid var(--border, #d7e0ef);
  border-radius: 18px;
  background: rgba(80, 103, 246, .06);
}

.auto-download-segment {
  min-height: 42px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--text, #182133);
  font-weight: 900;
  font-size: 14px;
  box-shadow: none;
}

.auto-download-segment:hover {
  transform: none;
  background: rgba(255,255,255,.70);
  box-shadow: none;
}

.auto-download-segment.is-active {
  background: linear-gradient(135deg, var(--accent, #5167f6), #6b7cff);
  color: #fff;
  box-shadow: 0 10px 24px rgba(81, 103, 246, .25);
}

.auto-download-choice-summary {
  margin: 14px 20px 0;
  padding: 14px 16px;
  border: 1px solid rgba(81, 103, 246, .18);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(81, 103, 246, .08), rgba(81, 103, 246, .035));
}

.auto-download-choice-summary strong {
  display: block;
  color: var(--text, #182133);
  font-size: 15px;
  font-weight: 950;
}

.auto-download-choice-summary small {
  display: block;
  margin-top: 5px;
  color: var(--muted, #64748b);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 750;
}

.auto-download-choice-footer {
  margin-top: 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auto-download-choice-footer .btn {
  min-width: 140px;
}

@media (max-width: 520px) {
  .auto-download-segmented { margin-left: 14px; margin-right: 14px; }
  .auto-download-choice-summary { margin-left: 14px; margin-right: 14px; }
  .auto-download-choice-footer { flex-direction: column-reverse; align-items: stretch; }
  .auto-download-choice-footer .btn { width: 100%; }
}

html[data-theme="dark"] .auto-download-segmented {
  background: rgba(99, 102, 241, .12);
  border-color: rgba(148, 163, 184, .22);
}

html[data-theme="dark"] .auto-download-segment:hover {
  background: rgba(255,255,255,.06);
}

html[data-theme="dark"] .auto-download-choice-summary {
  background: rgba(99, 102, 241, .10);
  border-color: rgba(148, 163, 184, .20);
}

/* autosave settings mode patch */
.auto-download-mode-box {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-soft);
}
.auto-download-mode-label strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 950;
}
.auto-download-mode-label small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}
.auto-download-mode-box .auto-download-segmented {
  margin: 12px 0 0;
}
.auto-download-mode-summary {
  margin: 12px 0 0;
}
.auto-download-folder-card .btn {
  white-space: nowrap;
}
@media (max-width: 560px) {
  .auto-download-folder-card {
    flex-direction: column;
    align-items: stretch;
  }
  .auto-download-folder-card .btn {
    width: 100%;
  }
}
