:root {
  color-scheme: light;
  --bg: #eef4f6;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --text: #16252d;
  --muted: #667986;
  --line: #d8e3e7;
  --primary: #1f6f8b;
  --primary-strong: #134f63;
  --accent: #ef7d4f;
  --success: #157f54;
  --warning: #b26b00;
  --danger: #b3261e;
  --shadow: 0 18px 50px rgba(28, 61, 76, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

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

.nav-brand {
  color: inherit;
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 111, 139, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
}

.status-pill[data-state="online"] .status-dot { background: var(--success); }
.status-pill[data-state="offline"] .status-dot { background: var(--danger); }
.status-pill[data-state="checking"] .status-dot { background: var(--warning); }

.topnav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.topnav a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--primary-strong);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.topnav a.active,
.topnav a:hover {
  background: rgba(31, 111, 139, 0.1);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr);
  gap: 18px;
  padding: 22px clamp(16px, 4vw, 44px) 40px;
}

.page-layout {
  display: grid;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 44px) 40px;
}

.page-layout.wide {
  max-width: 1280px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.command-panel,
.history-panel {
  grid-column: 1;
}

.health-panel,
.tasks-panel,
.subscriptions-panel {
  grid-column: 2;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-header.compact {
  align-items: center;
}

.panel h2 {
  margin: 0;
  font-size: 17px;
}

.panel p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.offline-banner {
  display: grid;
  gap: 3px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(179, 38, 30, 0.25);
  border-radius: 8px;
  color: var(--danger);
  background: rgba(179, 38, 30, 0.08);
  font-size: 13px;
}

.job-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}

input:focus,
select:focus {
  outline: 3px solid rgba(31, 111, 139, 0.18);
  border-color: var(--primary);
}

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

.toolbar-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(180px, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

form.toolbar-row {
  grid-template-columns: minmax(240px, 1fr) auto;
}

.toggle-row {
  min-height: 39px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.toggle-row input {
  width: auto;
  min-height: 0;
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

button,
.secondary-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

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

.primary-btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
}

.primary-btn:hover:not(:disabled) {
  background: var(--primary-strong);
}

.ghost-btn,
.secondary-link {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--primary-strong);
  padding: 0 12px;
}

.compact-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.full-width {
  width: 100%;
  margin-top: 12px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 180px));
  margin-bottom: 14px;
}

.health-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.health-grid span,
.item-meta,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.health-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  font-weight: 700;
  line-height: 1.35;
}

.item-title a {
  color: var(--text);
  text-decoration: none;
}

.item-title a:hover {
  color: var(--primary);
}

.badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(31, 111, 139, 0.1);
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 700;
}

.badge.completed { color: var(--success); background: rgba(21, 127, 84, 0.1); }
.badge.failed { color: var(--danger); background: rgba(179, 38, 30, 0.1); }
.badge.processing { color: var(--warning); background: rgba(178, 107, 0, 0.1); }

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

.mini-link {
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

audio {
  width: 100%;
  min-height: 38px;
}

.view-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  gap: 18px;
}

.view-hero h2 {
  font-size: 24px;
  line-height: 1.25;
}

.view-thumb {
  width: 100%;
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-soft);
}

.reader-content {
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
}

.reader-content h1,
.reader-content h2,
.reader-content h3 {
  margin-top: 20px;
}

.subtitle-pre {
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #16252d;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 30;
}

.toast[data-type="success"] {
  background: #157f54;
}

.toast[data-type="error"] {
  background: #b3261e;
}

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

  .command-panel,
  .history-panel,
  .health-panel,
  .tasks-panel,
  .subscriptions-panel {
    grid-column: 1;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav {
    width: 100%;
  }

  .status-pill {
    width: 100%;
    justify-content: center;
  }

  .panel-header,
  .panel-header.compact {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid,
  .health-grid,
  .toolbar-row,
  form.toolbar-row,
  .view-hero {
    grid-template-columns: 1fr;
  }
}

/* Flask layout parity layer. Keep this at the end so Cloudflare Pages matches
   the current 127.0.0.1:5001 dark glass interface. */
:root {
  color-scheme: dark;
  --color-primary: #667eea;
  --color-secondary: #764ba2;
  --color-cta: #f97316;
  --color-background: #0f172a;
  --color-surface: #1e293b;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --aurora-1: #667eea;
  --aurora-2: #764ba2;
  --aurora-3: #6b8dd6;
  --aurora-4: #8e37d7;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-bg-light: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-blur: 20px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --gradient: linear-gradient(135deg, var(--aurora-1), var(--aurora-2));
  --gradient-cta: linear-gradient(135deg, #f97316, #fb923c);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.3);
  --bg: var(--color-background);
  --surface: var(--glass-bg);
  --surface-soft: rgba(15, 23, 42, 0.45);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --line: var(--glass-border);
  --primary: var(--color-primary);
  --primary-strong: #a5b4fc;
  --accent: var(--color-cta);
  --success: var(--color-success);
  --warning: var(--color-warning);
  --danger: var(--color-error);
  --shadow: var(--shadow-lg);
}

@keyframes aurora {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

body {
  min-height: 100vh;
  padding: 32px;
  background: linear-gradient(-45deg, #0f172a, #1e293b, #0f172a, #1a1a2e);
  background-size: 400% 400%;
  animation: aurora 15s ease infinite;
  color: var(--color-text);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.7;
  overflow-x: hidden;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(60px);
  pointer-events: none;
  z-index: -1;
}

body::before {
  top: 20%;
  left: 10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(102, 126, 234, 0.15) 0%, transparent 70%);
  animation: float 8s ease-in-out infinite;
}

body::after {
  right: 8%;
  bottom: 12%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(118, 75, 162, 0.14) 0%, transparent 72%);
  animation: float 10s ease-in-out infinite reverse;
}

.container,
.page-layout,
.layout {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: 32px;
  display: block;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: fadeIn 0.4s ease-out;
}

.page-layout.wide {
  width: min(100%, 1280px);
  max-width: 1280px;
}

.page-top-header,
.topbar,
.header,
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  position: relative;
}

.page-logo-link,
.logo-link,
.brand,
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--color-text);
  text-decoration: none;
  min-width: 0;
}

.page-logo-img,
.logo-img,
.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.page-logo-title,
.logo-text,
.brand h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text);
}

.brand p {
  display: none;
}

.page-nav-btns,
.header-nav,
.page-header-nav,
.topnav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.page-nav-btn,
.nav-btn,
.topnav a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.page-nav-btn:hover,
.nav-btn:hover,
.topnav a:hover,
.page-nav-btn.active,
.nav-btn.active,
.topnav a.active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.page-nav-blue,
.nav-btn-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.page-nav-orange,
.nav-btn-orange { background: linear-gradient(135deg, #f97316, #ea580c); }
.page-nav-purple,
.nav-btn-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.page-nav-red,
.nav-btn-red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.page-nav-green,
.nav-btn-green { background: linear-gradient(135deg, #10b981, #059669); }

.page-queue-badge,
.queue-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  font-size: 11px;
}

.status-row,
.compact-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: -12px 0 24px;
}

.status-pill {
  min-height: 38px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.36);
  border: 1px solid var(--glass-border);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 10px;
  height: 10px;
  box-shadow: 0 0 16px currentColor;
}

.offline-banner {
  margin: 0 0 22px;
  padding: 14px 16px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

.mui-input-section,
.panel,
.files-section,
.video-info-box,
.summary-content-section,
.subtitle-content-section,
.original-content-section,
.sync-player-section,
.audio-player-section,
.embedded-progress-panel,
.chatbox-section,
.section {
  margin-bottom: 24px;
  padding: 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.panel,
.files-section,
.summary-content-section,
.subtitle-content-section,
.sync-player-section {
  animation: fadeIn 0.35s ease-out;
}

.panel h2,
.files-section h2,
.video-details h2,
.summary-content-section h2,
.subtitle-content-section h2,
.sync-player-section h2,
.embedded-progress-header h3 {
  margin: 0;
  color: var(--color-text);
}

.panel p,
.history-header p,
.muted,
.item-meta,
.file-meta,
.video-meta,
.model-info,
.embedded-progress-info {
  color: var(--color-text-muted);
}

.input-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.input-tabs button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  color: var(--color-text-muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: var(--transition);
}

.input-tabs button.active,
.input-tabs button:hover {
  color: #fff;
  background: var(--gradient);
  box-shadow: var(--shadow-md);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.input-group,
.control-group,
.setting-group,
.form-group,
label {
  display: grid;
  gap: 8px;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 700;
}

.input-group label,
.control-group label {
  color: var(--color-text-muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: var(--color-text);
  font: inherit;
  outline: none;
  transition: var(--transition);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(102, 126, 234, 0.75);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

.multi-url-textarea,
.text-input {
  min-height: 132px;
}

.input-hint {
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.channel-input-group,
.compact-controls-row,
.toolbar-row,
.health-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}

.common-controls-section {
  margin-top: 22px;
}

.workflow-toggle {
  min-height: 72px;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.36);
  cursor: pointer;
}

.workflow-toggle input {
  width: 20px;
  min-height: auto;
  height: 20px;
  accent-color: var(--color-primary);
}

.workflow-toggle strong,
.workflow-toggle small {
  display: block;
}

.workflow-toggle small {
  color: var(--color-text-muted);
  font-weight: 500;
}

.modern-process-btn,
.primary-btn,
.action-btn,
.btn-primary,
.sub-check-all-btn,
.task-queue-toggle-btn,
.history-load-more-btn,
.download-btn,
.ghost-btn,
.mini-link,
.secondary-link,
.failed-action-btn,
.task-action-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.modern-process-btn,
.primary-btn,
.btn-primary {
  background: var(--gradient-cta);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.modern-process-btn:hover,
.primary-btn:hover,
.download-btn:hover,
.ghost-btn:hover,
.mini-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

button:disabled,
.ghost-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.cloudflare-health,
.health-grid {
  margin-top: 22px;
}

.health-grid > div,
.stat-card,
.stat-item {
  min-height: 82px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--glass-border);
}

.health-grid span,
.stat-label {
  display: block;
  color: var(--color-text-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.health-grid strong,
.stat-value {
  display: block;
  margin-top: 4px;
  color: var(--color-text);
  font-size: 22px;
}

.embedded-progress-header,
.history-header,
.panel-header,
.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.header-actions,
.text-action-buttons,
.file-actions,
.item-actions,
.navigation-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.embedded-progress-body,
.files-list,
.list,
.history-list {
  display: grid;
  gap: 14px;
}

.embedded-task-card,
.item,
.file-item,
.task-card,
.failed-card,
.sub-item {
  padding: 16px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.38);
  box-shadow: var(--shadow-sm);
}

.task-main-row,
.file-item-header {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.file-thumbnail,
.video-thumbnail,
.embedded-task-thumb,
.task-thumb,
.failed-thumb,
.placeholder-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.45), rgba(118, 75, 162, 0.45));
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.placeholder-thumb,
.embedded-task-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 26px;
}

.embedded-task-thumb {
  width: 112px;
}

.file-title,
.embedded-task-title,
.item-title,
.task-title,
.failed-title,
.sub-channel {
  display: block;
  color: var(--color-text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
}

.file-info,
.video-details,
.embedded-task-details,
.task-info,
.failed-info,
.sub-info {
  min-width: 0;
  max-width: 100%;
}

.file-title,
.video-details h2,
.embedded-task-title,
.item-title,
.task-title,
.failed-title,
.sub-channel {
  overflow-wrap: anywhere;
}

.file-meta,
.item-meta,
.video-meta,
.model-info,
.task-meta,
.failed-meta,
.sub-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
  font-size: 13px;
}

.tts-player-controls {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.play-tts-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--gradient);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.progress-bar-container,
.embedded-task-progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.progress-bar-fill,
.embedded-task-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--gradient);
}

.compact-actions {
  margin-top: 12px;
}

.autoplay-row,
.action-bar,
.select-all-row {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.34);
}

.history-sort-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.history-sort-label {
  display: inline-flex;
  color: var(--color-text-muted);
}

.history-sort-select {
  width: min(100%, 260px);
}

.history-load-more {
  margin-top: 18px;
  text-align: center;
}

.video-info-box {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.video-thumbnail {
  min-height: 180px;
}

.video-details h2 {
  font-size: 24px;
  line-height: 1.28;
}

.model-info {
  padding: 10px 0;
}

.youtube-frame-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  aspect-ratio: 16 / 9;
  background: #050816;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.youtube-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

audio {
  width: 100%;
  min-height: 42px;
  filter: invert(0.92) hue-rotate(180deg);
}

.audio-player-section {
  margin: 14px 0 0;
}

.reader-content {
  color: var(--color-text);
  line-height: 1.82;
}

.reader-content a {
  color: #93c5fd;
}

.reader-content p {
  margin: 0 0 14px;
}

.subtitle-text,
.subtitle-pre {
  width: 100%;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.badge,
.embedded-task-status,
.error-badge,
.sub-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(148, 163, 184, 0.18);
  color: var(--color-text-muted);
}

.status-completed,
.badge.completed { background: rgba(16, 185, 129, 0.16); color: #86efac; }
.status-processing,
.badge.processing { background: rgba(102, 126, 234, 0.18); color: #c4b5fd; }
.status-pending,
.badge.pending { background: rgba(245, 158, 11, 0.16); color: #fde68a; }
.status-failed,
.badge.failed { background: rgba(239, 68, 68, 0.16); color: #fecaca; }

.toast {
  right: 24px;
  bottom: 24px;
  padding: 13px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(14px);
  z-index: 1000;
}

.toast[data-type="success"] {
  background: rgba(16, 185, 129, 0.94);
}

.toast[data-type="error"] {
  background: rgba(239, 68, 68, 0.94);
}

@media (max-width: 860px) {
  body {
    padding: 18px;
  }

  .container,
  .page-layout,
  .layout {
    padding: 20px;
    border-radius: 18px;
  }

  .page-top-header,
  .topbar,
  .header,
  .page-header,
  .embedded-progress-header,
  .history-header,
  .panel-header,
  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .page-nav-btns,
  .header-nav,
  .page-header-nav,
  .topnav {
    justify-content: flex-start;
  }

  .task-main-row,
  .file-item-header,
  .video-info-box {
    grid-template-columns: 1fr;
  }

  .embedded-task-thumb {
    width: 100%;
  }
}

@media (max-width: 560px) {
  body {
    padding: 12px;
  }

  .container,
  .page-layout,
  .layout,
  .mui-input-section,
  .panel,
  .files-section,
  .video-info-box,
  .summary-content-section,
  .subtitle-content-section,
  .sync-player-section,
  .embedded-progress-panel {
    padding: 16px;
  }

  .page-logo-img,
  .logo-img,
  .brand-icon {
    width: 40px;
    height: 40px;
  }

  .page-logo-title,
  .logo-text,
  .brand h1 {
    font-size: 24px;
  }

  .page-nav-btn,
  .nav-btn,
  .topnav a,
  .download-btn,
  .ghost-btn,
  .mini-link,
  .modern-process-btn {
    width: 100%;
  }

  .history-sort-form,
  .text-action-buttons,
  .file-actions,
  .navigation-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .history-sort-select {
    width: 100%;
  }
}
