@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Default (dark) theme. Light theme overrides below. */
:root,
:root[data-theme="dark"] {
  --bg: #0f172a;
  --bg-soft: #111c34;
  --panel: #1b2742;
  --panel-2: #22304f;
  --text: #e6edf6;
  --muted: #9aa7be;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --border: #2a3a5c;
  --success: #22c55e;
  --on-accent: #0b1220;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --bg-glow-1: #1a2a55;
  --bg-glow-2: #14305a;
  --header-grad: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  --error: #fca5a5;
  --error-border: #7f1d1d;
  --error-bg: rgba(127,29,29,.18);
  --code-bg: #0b1428;
  --radius: 14px;
}

:root[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f5fb;
  --text: #0f172a;
  --muted: #5a6679;
  --accent: #0284c7;
  --accent-2: #4f46e5;
  --border: #d8e0ec;
  --success: #16a34a;
  --on-accent: #ffffff;
  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --bg-glow-1: #d6e4ff;
  --bg-glow-2: #e4ecff;
  --header-grad: linear-gradient(180deg, rgba(15,23,42,.02), rgba(15,23,42,0));
  --error: #b91c1c;
  --error-border: #fecaca;
  --error-bg: #fef2f2;
  --code-bg: #f1f5fb;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f4f7fb;
    --bg-soft: #ffffff;
    --panel: #ffffff;
    --panel-2: #f1f5fb;
    --text: #0f172a;
    --muted: #5a6679;
    --accent: #0284c7;
    --accent-2: #4f46e5;
    --border: #d8e0ec;
    --success: #16a34a;
    --on-accent: #ffffff;
    --shadow: 0 10px 30px rgba(15,23,42,.08);
    --bg-glow-1: #d6e4ff;
    --bg-glow-2: #e4ecff;
    --header-grad: linear-gradient(180deg, rgba(15,23,42,.02), rgba(15,23,42,0));
    --error: #b91c1c;
    --error-border: #fecaca;
    --error-bg: #fef2f2;
    --code-bg: #f1f5fb;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 700px at 10% -10%, var(--bg-glow-1) 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 10%, var(--bg-glow-2) 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
  direction: rtl;
  min-height: 100vh;
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: var(--panel);
  background-image: var(--header-grad);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.15);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.brand-text { min-width: 0; }
.brand-text .title { font-weight: 700; font-size: 22px; }
.brand-text .subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
  padding: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; display: block; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* Engine preload banner.
   Layout strategy:
   - On wide screens: a single horizontal row [label] [progress bar] [%].
   - On narrow screens (≤640px): a vertical column-stack — every child
     occupies a full row, so the progress bar can never spill outside the
     rounded card no matter how narrow the viewport (320px, 360px, etc).
   - Hard-clipped via overflow:hidden + box-sizing:border-box + max-width:100%
     so even if a child miscomputes its width, nothing leaks past the box. */
.engine-banner {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 14px 0 0;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
  box-shadow: var(--shadow);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
}
.engine-banner.active { display: flex; }
.engine-banner.ready {
  display: flex;
  color: var(--success);
  border-color: var(--success);
}
.engine-label {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.engine-progress-wrap {
  flex: 1 1 120px;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
  max-width: 100%;
  box-sizing: border-box;
}
.engine-progress {
  width: 0%;
  max-width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.engine-banner.ready .engine-progress { width: 100%; background: var(--success); }
.engine-progress-text {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* On narrow screens, stack vertically. Each row owns a full line, so
   nothing can ever overflow horizontally. */
@media (max-width: 640px) {
  .engine-banner {
    padding: 10px 12px;
    font-size: 12px;
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }
  .engine-label,
  .engine-progress-wrap {
    flex: 0 0 auto;
    width: 100%;
  }
  .engine-progress-text {
    align-self: flex-end; /* sits at the inline-end (left in RTL) */
  }
}

/* Card / Panel */
.card-panel {
  margin-top: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card-panel h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}

.card-panel .lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.field .hint {
  font-size: 12px;
  color: var(--muted);
}

.input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.input::placeholder { color: var(--muted); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.input.ltr {
  direction: ltr;
  text-align: left;
}

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.consent {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text);
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.consent input[type="checkbox"] {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}
.consent label { cursor: pointer; line-height: 1.7; flex: 1 1 200px; }
.consent .muted { color: var(--muted); display: block; margin-top: 2px; font-size: 12px; }

/* Save status banner: a full-width row that drops below the checkbox label so
   it remains very prominent on mobile too. */
.consent .save-status {
  flex: 1 0 100%;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  font-size: 14.5px;
  padding: 10px 16px;
  border-radius: 12px;
  line-height: 1.3;
  box-shadow: 0 6px 16px rgba(0,0,0,.22);
  text-align: center;
  letter-spacing: .2px;
}
.consent.saving .save-status,
.consent.saved .save-status,
.consent.error .save-status { display: flex; }

.consent.saving {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.consent.saving .save-status {
  background: var(--accent);
  color: var(--on-accent);
}
.consent.saving .save-status .save-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.consent.saved {
  border-color: #16a34a;
  background: color-mix(in srgb, #16a34a 18%, var(--panel-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, #16a34a 45%, transparent);
  animation: pulseGreen 1.4s ease-out 1;
}
.consent.saved .save-status {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #04140a;
  border: 1px solid #15803d;
}
@keyframes pulseGreen {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.7); }
  70%  { box-shadow: 0 0 0 14px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 3px color-mix(in srgb, #16a34a 45%, transparent); }
}

.consent.error {
  border-color: #ef4444;
  background: color-mix(in srgb, #ef4444 16%, var(--panel-2));
  color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, #ef4444 45%, transparent);
  animation: pulseRed 1.4s ease-out 1;
}
.consent.error .save-status {
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: #fff;
  border: 1px solid #b91c1c;
}
@keyframes pulseRed {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.7); }
  70%  { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 3px color-mix(in srgb, #ef4444 45%, transparent); }
}

.consent .save-status .save-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.28);
  font-size: 14px;
  font-weight: 800;
  flex: 0 0 auto;
}
.consent.saving .save-status .save-icon { background: rgba(255,255,255,.4); }

.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border: 0;
  padding: 12px 22px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform .06s ease, filter .15s, box-shadow .15s;
  box-shadow: 0 6px 18px rgba(129,140,248,.25);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Result */
.result {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 14px;
  display: none;
}
.result.show { display: block; }
.result.error { border-color: var(--error-border); background: var(--error-bg); color: var(--error); }
.result.error .result-title { color: var(--error); }
/* Error messages are Persian sentences, not URLs — show them RTL with the
   default font instead of the LTR/monospace styling used for download links. */
.result.error .link-text {
  direction: rtl;
  text-align: right;
  font-family: inherit;
  font-size: 14px;
  background: transparent;
  border-color: transparent;
  user-select: text;
}
.result.error .link-actions { display: none; }

.result-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 14px;
}

.link-box {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
}

.link-text {
  flex: 1 1 320px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  direction: ltr;
  text-align: left;
  user-select: all;
}

.link-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.copy-btn, .download-btn {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  transition: border-color .15s, color .15s, background-color .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

.download-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #04140a;
  border-color: transparent;
  font-weight: 700;
}
.download-btn:hover { filter: brightness(1.05); color: #04140a; }

/* Info sections */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  /* Without min-width:0, a long URL inside the card forces the grid track
     to grow past minmax(280px, 1fr) and the card overflows behind its
     neighbour. */
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.info-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.info-card .icon-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
}

.info-card ol, .info-card ul {
  margin: 0;
  padding-right: 20px;
  color: var(--text);
}
.info-card li { margin: 4px 0; color: var(--text); }
.info-card li small { color: var(--muted); }

.kbd {
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 1px 6px;
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  direction: ltr;
  display: inline;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Block-level code box for long URLs inside the help cards. Placed as a
   direct child of .info-card (NOT inside <li>) so it does not collide with
   list-marker positioning in RTL. */
.code-line {
  display: block;
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  max-width: 100%;
}
.code-line em { font-style: normal; color: var(--accent); }

.info-card .info-text { margin: 6px 0; }
.info-card li {
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
.info-card ul, .info-card ol { min-width: 0; }

.player-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  margin: 4px 0 4px 4px;
  transition: border-color .15s, color .15s;
}
.player-link:hover { border-color: var(--accent); color: var(--accent); }

.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--text);
  font-size: 14px;
}
.notice a { font-weight: 700; }

/* Footer */
.site-footer {
  margin-top: 28px;
  padding: 18px 22px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.site-footer a { color: var(--accent); }

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: flex-end; }
  .brand-logo { width: 64px; height: 64px; }
  .brand-text .title { font-size: 18px; }
}

/* =========================
   Converter-specific styles
   ========================= */

.converter {
  margin-top: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.converter h2 { margin: 0 0 10px; font-size: 18px; }
.converter .lead { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; line-height: 1.8; }

.drop-zone {
  margin-top: 12px;
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover,
.drop-zone.drag {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-soft));
}
.drop-zone .dz-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.drop-zone .dz-hint { font-size: 13px; color: var(--muted); line-height: 1.9; }
.drop-zone .dz-or { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 11.5px; margin: 6px 4px; }
.drop-zone input[type="file"] { display: none; }

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  justify-content: center;
}

.files-summary {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
}
.files-summary strong { color: var(--accent); }

.groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.group-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.group-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.group-card h3 .count-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.group-card ol {
  margin: 8px 0 0;
  padding-inline-start: 22px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.9;
  max-height: 140px;
  overflow-y: auto;
  word-break: break-all;
}
.group-card ol li.skipped { color: var(--error); text-decoration: line-through; opacity: .8; }
.group-card ol li.done { color: var(--success); }

.progress-wrap {
  margin-top: 10px;
  height: 10px;
  width: 100%;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease;
}

.log {
  margin-top: 12px;
  max-height: 180px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--muted);
}
.log .err { color: var(--error); }
.log .ok { color: var(--success); }

.outputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}

.output-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.output-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.output-card audio, .output-card video {
  display: block;
  width: 100%;
  margin-top: 8px;
  border-radius: 10px;
  background: #000;
}
.output-card audio { background: var(--bg-soft); }

.status-banner {
  margin-top: 14px;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
}
.status-banner.loading {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}
.status-banner.success {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 40%, transparent);
  color: var(--success);
}
.status-banner.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
}
.status-banner .dot {
  width: 10px; height: 10px; border-radius: 50%; background: currentColor;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.info-card h3 { margin: 0 0 8px; font-size: 15px; }
.info-card p, .info-card li { font-size: 13px; color: var(--muted); line-height: 1.9; margin: 0; }
.info-card ul { padding-inline-start: 20px; margin: 6px 0 0; }

.footer {
  margin-top: 28px;
  padding: 16px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px dashed var(--border);
}
.footer a { color: var(--accent); }

@media (max-width: 520px) {
  .drop-zone { padding: 18px 12px; }
  .drop-zone .dz-title { font-size: 14.5px; }
  .group-card h3 { font-size: 14px; }
}

/* Progress row: bar + numeric percent */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.progress-row .progress-wrap { margin-top: 0; flex: 1; }
.progress-text {
  min-width: 52px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  direction: ltr;
}

/* Danger (cancel) button */
.btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border-color: #b91c1c;
}
.btn.danger:hover { filter: brightness(1.08); }

/* Log step style: primary-colored, less noisy than error lines */
.log div.step {
  color: var(--accent);
  font-weight: 600;
}

/* Modal overlay for "new vs continue" prompt */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 20px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.modal-box h3 {
  margin: 0 0 8px 0;
  color: var(--text);
  font-size: 18px;
}
.modal-box p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-btns .btn { width: 100%; justify-content: center; }

/* =========================================================
   Chat extraction (ftchat*.xml) + Full-class video build
   sections — added on top of the converter without altering
   the original visuals. Reuses existing CSS variables.
   ========================================================= */

.chat-section .lead,
.full-build .lead { margin-bottom: 10px; }

.chat-stats {
  margin: 6px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.chat-stats strong { color: var(--accent); }
.chat-stats .muted { color: var(--muted); }

.chat-empty {
  margin: 4px 0 6px;
  padding: 18px 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

.chat-list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
  padding: 4px;
}

.chat-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.chat-item.same-author {
  border-top-color: transparent;
  margin-top: -2px;
}
.chat-item.empty {
  background: transparent;
  border-style: dashed;
  opacity: .55;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  margin-bottom: 4px;
}
.chat-author {
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-time {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  direction: ltr;
}
.chat-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.85;
  word-break: break-word;
}
.chat-text .muted { color: var(--muted); font-size: 12.5px; }

/* Timeline summary card inside the full-build section */
.timeline-summary {
  margin: 6px 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.timeline-summary .t-row { margin: 4px 0; }
.timeline-summary .t-key { color: var(--muted); }
.timeline-summary .t-row strong { color: var(--accent); }
.timeline-summary .t-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.timeline-summary .t-list {
  margin: 6px 0 0;
  padding-inline-start: 22px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.9;
  max-height: 160px;
  overflow-y: auto;
  word-break: break-word;
}
.timeline-summary .t-list li strong { color: var(--text); }
.timeline-summary .warn,
.timeline-summary .t-list li .warn {
  color: var(--error);
}
.timeline-summary .muted { color: var(--muted); }


/* =================================================================== */
/* PDF + ftcontent → synced video                                       */
/* =================================================================== */

.pdfvideo-section {
  border-top: 2px solid var(--accent);
  padding-top: 22px;
}

.pv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 12px 0 14px;
}

.pv-pickbox {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.pv-pickbox-title {
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
}

.pv-pickbox-help {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}

.pv-pickbox .btn-row {
  margin: 4px 0 2px;
  gap: 6px;
}

.pv-pickbox .btn {
  font-size: 13px;
  padding: 8px 12px;
}

.pv-fileinfo {
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text);
  min-height: 18px;
  word-break: break-word;
}

.pv-fileinfo strong { color: var(--accent); }

.pv-summary {
  margin: 8px 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.pv-summary .t-row { margin: 4px 0; }
.pv-summary .t-key { color: var(--muted); }
.pv-summary strong { color: var(--accent); }

.pv-grid-single {
  grid-template-columns: 1fr;
}

.pv-folder-status {
  margin: 6px 0 14px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

.pv-folder-status strong { color: var(--text); }

.pv-folder-status.ok {
  border-style: solid;
  border-color: rgba(63, 168, 96, 0.45);
  background: rgba(63, 168, 96, 0.06);
  color: var(--text);
}

.pv-folder-status.warn {
  border-color: rgba(220, 140, 0, 0.5);
  background: rgba(220, 140, 0, 0.08);
}

.pv-folder-status .warn { color: rgb(204, 130, 0); }

/* Multi-PDF list with reorder/remove controls */
.pv-pdf-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pv-pdf-list:empty { display: none; }
.pv-pdf-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 13px;
}
.pv-pdf-list li .pv-pdf-idx {
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  background: var(--accent);
  color: #fff;
}
.pv-pdf-list li .pv-pdf-meta {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.pv-pdf-list li .pv-pdf-meta .pv-pdf-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pv-pdf-list li .pv-pdf-meta .pv-pdf-sub {
  color: var(--muted);
  font-size: 11.5px;
}
.pv-pdf-list li .pv-pdf-meta .pv-pdf-sub.ok { color: rgb(63, 140, 96); }
.pv-pdf-list li .pv-pdf-meta .pv-pdf-sub.warn { color: rgb(204, 130, 0); }
.pv-pdf-list li .pv-pdf-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
}
.pv-pdf-list li .pv-pdf-actions button {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  font-size: 14px;
  line-height: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.pv-pdf-list li .pv-pdf-actions button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pv-pdf-list li .pv-pdf-actions button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pv-pdf-list li .pv-pdf-actions button.danger:hover {
  border-color: rgb(220, 80, 80);
  color: rgb(220, 80, 80);
}

.pv-pdf-map-hint {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}
.pv-pdf-map-hint.ok {
  border-style: solid;
  border-color: rgba(63, 168, 96, 0.45);
  background: rgba(63, 168, 96, 0.06);
  color: var(--text);
}
.pv-pdf-map-hint.warn {
  border-color: rgba(220, 140, 0, 0.55);
  background: rgba(220, 140, 0, 0.08);
  color: rgb(204, 130, 0);
}
