/* ═══════════════════════════════════════════════════════
   Douyin Downloader — Dark Glass-Morphism Design System
   Tech-Utility direction adapted for dark theme + glass
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────── */
:root {
  /* Core palette */
  --bg:             oklch(11% 0.012 250);
  --bg-alt:         oklch(13% 0.014 250);
  --surface-glass:  oklch(16% 0.018 250 / 0.65);
  --surface-solid:  oklch(17% 0.016 250);
  --surface-hover:  oklch(20% 0.02 250 / 0.8);
  --surface-elevated: oklch(22% 0.02 250 / 0.85);

  --fg:             oklch(92% 0.004 250);
  --fg-dim:         oklch(78% 0.008 250);
  --muted:          oklch(62% 0.014 250);
  --muted-dim:      oklch(48% 0.015 250);

  --border-glass:   oklch(28% 0.02 250 / 0.45);
  --border-solid:   oklch(28% 0.018 250);
  --border-focus:   oklch(62% 0.18 245 / 0.6);

  --accent:         oklch(62% 0.18 245);
  --accent-hover:   oklch(67% 0.19 248);
  --accent-soft:    oklch(62% 0.18 245 / 0.15);
  --accent-glow:    oklch(62% 0.18 245 / 0.25);

  --success:        oklch(66% 0.16 155);
  --success-soft:   oklch(66% 0.16 155 / 0.15);
  --warning:        oklch(72% 0.14 80);
  --warning-soft:   oklch(72% 0.14 80 / 0.15);
  --danger:         oklch(60% 0.18 20);
  --danger-soft:    oklch(60% 0.18 20 / 0.15);

  /* Typography */
  --font:           'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;

  /* Spacing & radii */
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --radius-full:    9999px;

  --sidebar-w:      68px;
  --titlebar-h:     44px;
  --statusbar-h:    32px;

  /* Transitions */
  --ease-out:       cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:    cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:       150ms;
  --dur-normal:     250ms;
  --dur-slow:       400ms;
  --dur-glacial:    800ms;

  /* Shadows */
  --shadow-sm:      0 1px 2px oklch(0% 0 0 / 0.3);
  --shadow-md:      0 4px 12px oklch(0% 0 0 / 0.4);
  --shadow-lg:      0 8px 32px oklch(0% 0 0 / 0.5);
  --shadow-glow:    0 0 20px var(--accent-glow);
}

/* ── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* 默认允许选择; 仅特定容器 (lightbox 等) 显式禁选 */
  user-select: text;
}

/* ── App Shell ─────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Title bar */
.titlebar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--titlebar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: oklch(13% 0.014 250 / 0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-glass);
  -webkit-app-region: drag;
}
.titlebar-l { display: flex; align-items: center; gap: 10px; }
.titlebar-logo { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); }
.titlebar-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg); }

/* Sidebar */
.sidebar {
  position: fixed; top: var(--titlebar-h); left: 0; bottom: var(--statusbar-h); z-index: 90;
  width: var(--sidebar-w);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px;
  background: oklch(13% 0.014 250 / 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border-glass);
}
.sidebar-nav {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%;
}
.sidebar-tab {
  width: 48px; height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none; cursor: pointer;
  color: var(--muted);
  font-size: 10px; font-weight: 500;
  transition: all var(--dur-normal) var(--ease-out);
  position: relative;
}
.sidebar-tab:hover { background: var(--surface-hover); color: var(--fg-dim); }
.sidebar-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.sidebar-tab.active::before {
  content: ''; position: absolute; left: -8px; top: 12px; bottom: 12px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar-tab svg { width: 20px; height: 20px; }
@keyframes sidebarPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.7; }
}
.sidebar-tab.flash {
  animation: sidebarPulse 1.2s ease-in-out infinite;
}
.sidebar-divider {
  width: 32px; height: 1px;
  background: var(--border-glass);
  margin: 8px 0;
}

/* Main content area */
.main-content {
  position: fixed;
  top: var(--titlebar-h); left: var(--sidebar-w);
  right: 0; bottom: var(--statusbar-h);
  overflow-y: auto; overflow-x: hidden;
  padding: 20px 24px;
}

/* Status bar */
.statusbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--statusbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: oklch(14% 0.014 250 / 0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border-glass);
  font-size: 11px; color: var(--muted-dim);
}
.statusbar-l, .statusbar-r { display: flex; align-items: center; gap: 12px; }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
}
.status-dot.idle { background: var(--muted-dim); }
.status-dot.working { background: var(--accent); animation: pulse-dot 1.5s ease-in-out infinite; }
.status-dot.error { background: var(--danger); }

/* ── Glass Panel ───────────────────────────────── */
.glass-panel {
  background: var(--surface-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--dur-normal) var(--ease-out);
}
.glass-panel:hover { border-color: oklch(34% 0.02 250 / 0.5); }

/* ── Section Headers ───────────────────────────── */
.section-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border-glass);
}

/* ── Inputs ────────────────────────────────────── */
.input-group {
  display: flex; gap: 8px; align-items: center;
}
.input {
  flex: 1;
  background: oklch(15% 0.015 250 / 0.8);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  transition: all var(--dur-fast) var(--ease-out);
  outline: none;
}
.input::placeholder { color: var(--muted-dim); }
.input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-family: var(--font-mono); font-size: 12px; }

textarea.input {
  min-height: 80px; resize: vertical;
  font-family: var(--font-mono); font-size: 12px;
  line-height: 1.6;
}

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border: none; border-radius: var(--radius-md);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:disabled { background: oklch(35% 0.02 250); color: var(--muted-dim); box-shadow: none; cursor: not-allowed; }

.btn-accent {
  background: linear-gradient(135deg, oklch(62% 0.18 245), oklch(66% 0.16 155));
  color: #fff;
  box-shadow: 0 2px 8px oklch(62% 0.18 245 / 0.3);
}
.btn-accent:hover { box-shadow: 0 4px 16px oklch(62% 0.18 245 / 0.5); filter: brightness(1.1); }
.btn-accent:disabled { background: oklch(35% 0.02 250); color: var(--muted-dim); box-shadow: none; cursor: not-allowed; }

.btn-secondary {
  background: oklch(22% 0.018 250 / 0.7);
  border: 1px solid var(--border-solid);
  color: var(--fg-dim);
}
.btn-secondary:hover { background: oklch(28% 0.02 250 / 0.8); border-color: var(--border-focus); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--fg-dim); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid oklch(60% 0.18 20 / 0.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-icon {
  width: 36px; height: 36px; padding: 0 10px;
  border-radius: var(--radius-md);
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.btn-icon:hover { background: var(--surface-hover); color: var(--fg-dim); }
.btn-icon.active { background: var(--accent-soft); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); }

/* ── Inline Copy Button ─────────────────────────── */
.copy-btn-inline {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: 11px;
  background: oklch(30% 0.015 250 / 0.5);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer;
  transition: all var(--dur-fast);
  vertical-align: middle; margin-left: 6px;
}
.copy-btn-inline:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.copy-btn-inline.copied { background: var(--success-soft); color: var(--success); border-color: var(--success); }

/* ── Progress ──────────────────────────────────── */
.progress-bar {
  width: 100%; height: 4px;
  background: oklch(22% 0.018 250 / 0.6);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s var(--ease-out);
  width: 0%;
}
.progress-bar.indeterminate .fill {
  width: 40%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

/* ── Table ─────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table thead th {
  text-align: left; padding: 10px 12px;
  background: oklch(16% 0.015 250 / 0.8);
  border-bottom: 1px solid var(--border-solid);
  color: var(--muted);
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.03em; text-transform: uppercase;
  position: sticky; top: 0; z-index: 1;
}
.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid oklch(22% 0.015 250 / 0.3);
}
.data-table tbody tr { transition: background var(--dur-fast); }
.data-table tbody tr:hover { background: oklch(20% 0.018 250 / 0.4); }
.data-table tbody tr.selected { background: var(--accent-soft); }
.data-table .col-cb { width: 36px; text-align: center; }
.data-table .col-idx { width: 44px; color: var(--muted-dim); text-align: center; }
.data-table .col-title { min-width: 200px; }
.data-table .col-size { width: 80px; color: var(--muted); text-align: right; font-family: var(--font-mono); }
.data-table .col-status { width: 80px; text-align: center; }

/* ── Checkbox ──────────────────────────────────── */
.checkbox-wrap {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.checkbox-wrap input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px;
  border: 2px solid var(--border-solid);
  border-radius: 4px;
  background: oklch(16% 0.015 250 / 0.6);
  cursor: pointer;
  transition: all var(--dur-fast);
  flex-shrink: 0;
  position: relative;
}
.checkbox-wrap input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-wrap input[type="checkbox"]:checked::after {
  content: ''; position: absolute;
  left: 5px; top: 2px;
  width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ── Toast ─────────────────────────────────────── */
.toast-container {
  position: fixed; top: calc(var(--titlebar-h) + 12px); right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-glass);
  pointer-events: auto;
  animation: toast-in 0.35s var(--ease-spring), toast-out 0.3s var(--ease-out) 3s forwards;
  max-width: 380px;
}
.toast.success { background: var(--success-soft); color: var(--success); border-color: oklch(66% 0.16 155 / 0.3); }
.toast.error { background: var(--danger-soft); color: var(--danger); border-color: oklch(60% 0.18 20 / 0.3); }
.toast.info { background: var(--accent-soft); color: var(--accent); border-color: oklch(62% 0.18 245 / 0.3); }

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: oklch(0% 0 0 / 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in 0.2s var(--ease-out);
}
.modal-overlay.closing { animation: fade-out 0.2s var(--ease-out); }
.modal {
  background: var(--surface-elevated);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 28px;
  min-width: 400px; max-width: 640px;
  animation: modal-in 0.3s var(--ease-spring);
  box-shadow: var(--shadow-lg);
}
.modal.closing { animation: modal-out 0.2s var(--ease-out); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-body { font-size: 13px; color: var(--fg-dim); line-height: 1.6; margin-bottom: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Empty State ───────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center; gap: 12px;
  color: var(--muted-dim);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.4; margin-bottom: 8px; }
.empty-state .empty-title { font-size: 14px; font-weight: 600; color: var(--muted); }
.empty-state .empty-desc { font-size: 12px; max-width: 320px; line-height: 1.5; }

/* ── Badge / Pill ──────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.error { background: var(--danger-soft); color: var(--danger); }

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: oklch(30% 0.015 250 / 0.5); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: oklch(38% 0.015 250 / 0.7); }

/* ── Keyframes ─────────────────────────────────── */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes modal-out { from { opacity: 1; transform: scale(1) translateY(0); } to { opacity: 0; transform: scale(0.95) translateY(8px); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Skeleton Loading ──────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, oklch(22% 0.015 250 / 0.4) 25%, oklch(28% 0.018 250 / 0.5) 50%, oklch(22% 0.015 250 / 0.4) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }
.skeleton-cover { width: 100%; height: 320px; border-radius: var(--radius-md); }

/* ── Image Carousel ────────────────────────────── */
.carousel {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 8px;
  scroll-behavior: smooth;
}
.carousel::-webkit-scrollbar { height: 4px; }
.carousel-thumb {
  flex-shrink: 0; width: 120px; height: 160px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--dur-fast) var(--ease-out);
  background: var(--surface-solid);
}
.carousel-thumb:hover { border-color: var(--border-focus); }
.carousel-thumb.active { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.carousel-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Drag & Drop Zone ──────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-solid);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease-out);
  background: oklch(15% 0.015 250 / 0.4);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-zone-icon {
  width: 48px; height: 48px; margin: 0 auto 12px;
  color: var(--muted-dim);
}
.drop-zone-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.drop-zone-desc { font-size: 12px; color: var(--muted-dim); }

/* ── Tab Content Transition ────────────────────── */
.tab-content {
  display: none;
  animation: slide-up 0.3s var(--ease-out);
}
.tab-content.active { display: block; }

/* ── Utility ───────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.flex-1 { flex: 1; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Info Row (for video metadata) ─────────────── */
.info-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px;
  font-size: 12px;
}
.info-grid dt { color: var(--muted-dim); font-weight: 500; }
.info-grid dd { color: var(--fg-dim); }

/* ── File List ─────────────────────────────────── */
.file-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 240px; overflow-y: auto;
}
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: oklch(17% 0.015 250 / 0.5);
  transition: background var(--dur-fast);
}
.file-item:hover { background: var(--surface-hover); }
.file-item .file-icon { color: var(--accent); flex-shrink: 0; }
.file-item .file-name { flex: 1; font-size: 12px; }
.file-item .file-size { font-size: 11px; color: var(--muted-dim); font-family: var(--font-mono); }
.file-item .file-status { font-size: 11px; }
.file-item .btn-icon { width: 28px; height: 28px; }
