:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-hover: #fbfbfc;
  --border: #e5e5e8;
  --border-strong: #d9d9dd;
  --text: #16161a;
  --text-muted: #6b6b75;
  --text-faint: #9797a1;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --accent-soft-text: #4338ca;
  --success: #0f9d58;
  --success-soft: #e6f7ee;
  --warning: #b45309;
  --warning-soft: #fef3e0;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --star: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 16, 20, 0.06), 0 1px 3px rgba(16, 16, 20, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 16, 20, 0.10), 0 2px 8px rgba(16, 16, 20, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 250px;
}

[data-theme="dark"] {
  --bg: #0f0f12;
  --surface: #17171b;
  --surface-hover: #1c1c21;
  --border: #27272d;
  --border-strong: #34343b;
  --text: #f2f2f4;
  --text-muted: #9d9da8;
  --text-faint: #6f6f79;
  --accent: #6366f1;
  --accent-hover: #7476f3;
  --accent-soft: #23234a;
  --accent-soft-text: #a5a6f6;
  --success: #34d399;
  --success-soft: #123024;
  --warning: #fbbf24;
  --warning-soft: #3a2a0c;
  --danger: #f87171;
  --danger-soft: #3a1717;
  --star: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

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

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 14px 12px 6px;
}

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.nav-item i { width: 16px; text-align: center; font-size: 14px; }

.nav-item:hover { background: var(--surface-hover); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-soft-text);
}

.nav-item .count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 20px;
}

.nav-item.active .count {
  color: var(--accent-soft-text);
  background: rgba(79, 70, 229, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------------- Main ---------------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 22px 32px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid transparent;
}

.search-wrap {
  flex: 1;
  max-width: 560px;
  position: relative;
}

.search-wrap i.fa-magnifying-glass {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 11px 16px 11px 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-icon {
  padding: 10px;
  width: 40px;
  height: 40px;
  justify-content: center;
}

.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); border-color: var(--danger); }

.content {
  padding: 8px 32px 48px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 4px;
}

/* ---------------- Stats ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}

.stat-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  margin-top: 10px;
  letter-spacing: -0.02em;
}

.section-block {
  margin-bottom: 32px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 15.5px;
  font-weight: 700;
  margin: 0;
}

.link-more {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* ---------------- Filter bar ---------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.filter-select:focus { border-color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}

.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--accent-soft); color: var(--accent-soft-text); border-color: transparent; }

.filter-clear {
  font-size: 12.5px;
  color: var(--text-faint);
  font-weight: 600;
  padding: 6px 10px;
}
.filter-clear:hover { color: var(--danger); }

/* ---------------- Video grid / cards ---------------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.video-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
}

.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.card-thumb {
  width: 100%;
  aspect-ratio: 16/10;
  background: linear-gradient(135deg, #eef0fe, #f7f7f8);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="dark"] .card-thumb { background: linear-gradient(135deg, #1c1c30, #17171b); }

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-thumb .thumb-fallback {
  font-size: 30px;
  color: var(--accent);
  opacity: 0.35;
}

.platform-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(17,17,20,0.72);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  backdrop-filter: blur(4px);
}

.fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 14px;
  transition: transform 0.1s;
}

.fav-btn:hover { transform: scale(1.08); }
.fav-btn.is-fav { color: var(--star); }
.fav-btn.is-fav i { font-weight: 900; }

.card-body {
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.card-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-note {
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  font-style: italic;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.tag-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  cursor: pointer;
}

.card-footer {
  padding: 10px 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.card-date { font-size: 11.5px; color: var(--text-faint); }

.status-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 6px;
}

.status-unwatched { background: var(--warning-soft); color: var(--warning); }
.status-watched { background: var(--success-soft); color: var(--success); }

.card-actions { display: flex; align-items: center; gap: 6px; }

.icon-action {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12.5px;
  transition: all 0.12s;
}

.icon-action:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.icon-action.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.icon-action.success:hover { color: var(--success); border-color: var(--success); background: var(--success-soft); }

/* Compact list row (Watch Later) */
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.list-row:hover { box-shadow: var(--shadow-md); }

.list-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: var(--accent-soft);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-thumb i { color: var(--accent); font-size: 18px; opacity: 0.5; }

.list-body { flex: 1; min-width: 0; }

.list-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.list-note { font-size: 12px; color: var(--text-faint); font-style: italic; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }

.list-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------------- Empty state ---------------- */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 38px; color: var(--text-faint); margin-bottom: 14px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin: 0 0 6px; }
.empty-state p { font-size: 13.5px; margin: 0 0 18px; }

/* ---------------- Tags page ---------------- */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.tag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.tag-card:hover { box-shadow: var(--shadow-md); }

.tag-card-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.tag-card-count { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.tag-card-actions { display: flex; gap: 4px; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.18s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h2 { font-size: 17px; font-weight: 700; margin: 0; }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.modal-close:hover { background: var(--surface-hover); color: var(--text); }

.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }

.modal-footer {
  padding: 16px 22px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.field .optional-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
}

.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select {
  padding: 10px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}

.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.platform-detect-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.platform-detect-row .platform-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-weight: 600;
  font-size: 12px;
}

.status-options { display: flex; gap: 8px; }

.status-option {
  flex: 1;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}

.status-option.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-text); }

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.tag-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.tag-token {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  border-radius: 20px;
  padding: 3px 6px 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.tag-token button {
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  font-size: 11px;
  padding: 2px;
  display: flex;
}
.tag-token button:hover { opacity: 1; }

.tag-input-wrap input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  flex: 1;
  min-width: 100px;
  padding: 4px;
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag-suggestion-chip {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-weight: 600;
}
.tag-suggestion-chip:hover { border-color: var(--accent); color: var(--accent); }

.metadata-preview {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.metadata-preview .mp-thumb {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  background: var(--accent-soft);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.metadata-preview .mp-thumb img { width: 100%; height: 100%; object-fit: cover; }
.metadata-preview .mp-thumb i { color: var(--accent); opacity: 0.5; font-size: 20px; }

.metadata-preview .mp-info { min-width: 0; flex: 1; }
.metadata-preview .mp-title { font-size: 13px; font-weight: 700; margin: 0 0 4px; }
.metadata-preview .mp-sub { font-size: 12px; color: var(--text-muted); }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.duplicate-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warning-soft);
  border: 1px solid rgba(180, 83, 9, 0.25);
  color: var(--warning);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}

.duplicate-banner .db-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.2s ease;
}

[data-theme="dark"] .toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

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

.toast i { color: var(--success); }

/* Quick save bar (dashboard) */
.quick-save-bar {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  align-items: center;
}

.quick-save-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  padding: 8px 10px;
  color: var(--text);
}

.quick-save-bar i.fa-paste { color: var(--text-faint); margin-left: 6px; }

/* Settings */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
  max-width: 640px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }

.settings-row-label { font-size: 14px; font-weight: 600; }
.settings-row-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.toggle-switch {
  width: 44px;
  height: 26px;
  border-radius: 20px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.2s;
  border: none;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch.on { background: var(--accent); }
.toggle-switch.on::after { transform: translateX(18px); }

.future-list { display: flex; flex-direction: column; gap: 4px; }
.future-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13.5px;
  color: var(--text-muted);
}
.future-item i { color: var(--text-faint); width: 16px; text-align: center; }

/* Mobile sidebar toggle */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: left 0.2s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .mobile-topbar { display: flex; }
  .topbar { padding: 12px 16px; }
  .topbar #theme-toggle-top,
  .topbar #save-video-btn-top { display: none; }
  .topbar .search-wrap { max-width: none; }
  .content { padding: 8px 16px 40px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .video-grid { grid-template-columns: 1fr; }
  .list-row { flex-wrap: wrap; }
  .list-actions { width: 100%; justify-content: flex-end; margin-top: 6px; }
  .quick-save-bar { flex-wrap: wrap; }
  .quick-save-bar #quick-save-btn { flex-shrink: 0; }
}

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

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}
.sidebar-overlay.show { display: block; }

.hidden { display: none !important; }

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

.kbd {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-faint);
  font-weight: 600;
}
