/* === Eagle TVC — "Edit Bay" Theme === */
/* Inspired by the color grading suite: warm room black, calibrated monitor gray, waveform scope green */

:root {
  --bg-dark: #0a0a08;
  --bg-base: #0e0e0c;
  --bg-surface: #161614;
  --bg-surface-hover: #1e1e1c;
  --bg-glass: rgba(20, 20, 20, 0.7);
  --bg-glass-heavy: rgba(10, 10, 8, 0.95);
  --bg-glass-medium: rgba(14, 14, 12, 0.96);
  --bg-glass-light: rgba(22, 22, 20, 0.6);
  --bg-deep: #060605;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-color-hover: rgba(255, 255, 255, 0.12);

  --primary: #00e054;
  --primary-hover: #33e677;
  --primary-glow: rgba(0, 224, 84, 0.25);
  --accent: #d4784a;
  --accent-glow: rgba(212, 120, 74, 0.25);
  --danger: #ef4444;

  --text-primary: #f0efe8;
  --text-secondary: #a09888;
  --text-muted: #6e6860;

  --font-display: 'Space Grotesk', -apple-system, system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;

  --sidebar-w: 280px;
  --topbar-h: 64px;
  --thumb-ratio: 16 / 9;
  --touch-target: 44px;
  /* Video card min-width; driven by data-card-size on .grid */
  --card-min: 380px;

  --font-stack: var(--font-body);
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px var(--primary-glow);

  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
.hidden { display: none !important; }

html, body {
  height: 100%; width: 100%;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-stack);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

button, input, textarea, select { font-family: inherit; color: inherit; background: none; border: none; outline: none; }
button { cursor: pointer; }

/* ============================================================
   Login Overlay
   ============================================================ */
.login-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(26,26,22,0.5) 0%, var(--bg-dark) 70%);
}
.login-overlay.hidden { display: none; }
.login-box {
  background: var(--bg-glass);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 40px 32px;
  width: 340px; max-width: 90vw; text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.3s ease;
}
.logo-icon {
  width: 28px; height: 28px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 11px; box-shadow: 0 0 10px var(--primary-glow);
}
/* Login page logo override */
.login-box .logo-icon {
  width: 48px; height: 48px; margin: 0 auto 16px;
  border-radius: 12px; font-size: 18px;
  box-shadow: 0 0 20px var(--primary-glow);
}
.login-box h2 { margin: 0 0 8px; font-size: 22px; color: var(--text-primary); }
.login-hint { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }
.login-input {
  width: 100%; padding: 12px 16px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); color: var(--text-primary); font-size: 16px;
  transition: border-color var(--transition-fast); box-sizing: border-box;
}
.login-input:focus { border-color: var(--primary); box-shadow: 0 0 12px var(--primary-glow); }
.login-input::placeholder { color: var(--text-muted); }
.login-btn {
  width: 100%; margin-top: 16px; padding: 12px;
  background: var(--primary); color: #fff; border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600; transition: all var(--transition-fast);
  min-height: var(--touch-target); box-shadow: var(--shadow-glow);
}
.login-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-error {
  margin-top: 12px; padding: 8px 12px;
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm); color: var(--danger); font-size: 13px;
}
.login-error.hidden { display: none; }

/* ============================================================
   App Layout
   ============================================================ */
#app, #app-layout { display: flex; height: 100vh; }

/* ============================================================
   Sidebar
   ============================================================ */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  height: 100vh; background: var(--bg-glass);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  z-index: 100; overflow: hidden;
  box-shadow: 10px 0 30px rgba(0,0,0,0.15);
  transition: width 0.28s cubic-bezier(0.16,1,0.3,1),
              min-width 0.28s cubic-bezier(0.16,1,0.3,1),
              opacity 0.2s ease;
}
/* Collapsed state — desktop manual/auto collapse. Width → 0, content fades. */
#sidebar.collapsed {
  width: 0; min-width: 0;
  border-right: none; opacity: 0;
  box-shadow: none; pointer-events: none;
}

/* Collapse button — shown on both desktop (sidebar-collapse-btn) and mobile (only-mobile).
   On desktop it lives in the header next to the library selector. */
.sidebar-collapse-btn { flex-shrink: 0; width: 32px; height: 32px; color: var(--text-muted); }
.sidebar-collapse-btn:hover { color: var(--text-primary); }
#sidebar.collapsed .sidebar-collapse-btn { display: none; }

/* Collapsed-sidebar handle. Visible at rest (so it's never lost), but the
   accent sits at background-level intensity — a low-opacity green hairline
   plus a brighter chevron — so it reads as affordance, not as decoration
   competing with the video wall. Hover saturates the green + adds a glow. */
.sidebar-edge {
  position: fixed; left: 0; top: 0; bottom: 0; width: 16px;
  background: var(--bg-surface);
  /* Inner accent hairline: green, but dialed down to ~30% so it whispers. */
  border-left: 2px solid rgba(0, 224, 84, 0.3);
  border-right: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 99;
  transition: width var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), border-left-color var(--transition-fast);
}
.sidebar-edge:hover {
  width: 22px; background: var(--bg-surface-hover);
  border-left-color: var(--primary);
  box-shadow: -4px 0 18px -4px var(--primary-glow);
}
.sidebar-edge svg {
  color: var(--primary); opacity: 0.85;
  /* Disc backing so the chevron reads as a designed control, not a stray glyph. */
  background: rgba(0, 224, 84, 0.12);
  border-radius: 50%; padding: 2px;
  transition: opacity var(--transition-fast), transform var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.sidebar-edge:hover svg { opacity: 1; transform: scale(1.18); background: rgba(0, 224, 84, 0.2); }
.sidebar-header {
  height: 64px; display: flex; align-items: center;
  padding: 0 16px; border-bottom: 1px solid var(--border-color);
  gap: 10px; flex-shrink: 0;
}
.sidebar-header h1 { font-size: 16px; font-weight: 700; color: var(--text-primary); }

/* Library selector dropdown */
.library-selector-wrapper { position: relative; flex: 1; }
.library-current {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; transition: all var(--transition-fast);
}
.library-current:hover { background: rgba(255,255,255,0.05); }
.library-current span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-arrow { color: var(--text-muted); flex-shrink: 0; margin-left: 6px; transition: transform var(--transition-fast); }
.library-selector-wrapper.active .dropdown-arrow { transform: rotate(180deg); }
.library-dropdown-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-glass-medium); backdrop-filter: blur(20px);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); z-index: 200; display: none; flex-direction: column;
}
.library-dropdown-list.open { display: flex; }
.library-dropdown-item {
  padding: 10px 12px; font-size: 12px; color: var(--text-secondary);
  transition: all var(--transition-fast); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.library-dropdown-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.library-dropdown-item.active { background: rgba(0,224,84,0.12); color: var(--primary); }

/* Sidebar stats */
.sidebar-stats {
  padding: 10px 16px; display: flex; gap: 12px;
  border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.stat-item { display: flex; flex-direction: column; align-items: center; flex: 1; text-align: center; }
.stat-value { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* Sidebar shortcuts */
.sidebar-shortcuts { display: flex; padding: 8px 12px; gap: 4px; }
.shortcut-btn {
  flex: 1; height: 32px; font-size: 12px; font-weight: 600;
  border-radius: var(--radius-sm); color: var(--text-secondary);
  background: rgba(255,255,255,0.02); border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
  display: flex; align-items: center; justify-content: center;
}
.shortcut-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.shortcut-btn.active { background: rgba(0,224,84,0.12); border-color: var(--primary); color: var(--primary-hover); }

/* Sidebar dual tabs */
.sidebar-tabs {
  display: flex; background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-color); margin: 0 12px;
  padding: 2px; border-radius: var(--radius-md);
}
.tab-btn {
  flex: 1; height: 32px; font-size: 12px; font-weight: 700;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex; align-items: center; justify-content: center;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background: rgba(255,255,255,0.06); color: var(--text-primary); }

/* Sidebar content with tab panes */
.sidebar-content { flex: 1; display: flex; flex-direction: column; padding: 8px 0; overflow: hidden; min-height: 0; }
.sidebar-tab-pane { display: none; flex-direction: column; height: 100%; overflow: hidden; padding: 0 8px; }
.sidebar-tab-pane.active { display: flex; }

/* Local search input in sidebar */
.local-search-wrapper {
  margin-bottom: 8px; display: flex; align-items: center;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); height: 32px; padding: 0 10px;
  transition: all var(--transition-fast);
}
.local-search-wrapper:focus-within { border-color: var(--primary); background: rgba(255,255,255,0.04); }
.local-search-input, .tag-search-input {
  width: 100%; font-size: 12px; color: var(--text-primary);
}
.local-search-input::placeholder, .tag-search-input::placeholder { color: var(--text-muted); }

/* Nav items */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-section { margin-bottom: 16px; }
.nav-title {
  font-size: 11px; text-transform: uppercase; color: var(--text-muted);
  padding: 8px 12px 4px; font-weight: 600; letter-spacing: 0.05em;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px;
  transition: background var(--transition-fast); min-height: var(--touch-target);
}
.nav-item:hover { background: rgba(255,255,255,0.04); }
.nav-item.active { background: rgba(0,224,84,0.12); color: var(--primary-hover); }
.nav-count { margin-left: auto; font-size: 11px; color: var(--text-muted); background: rgba(255,255,255,0.04); padding: 2px 7px; border-radius: 10px; }

/* Color filter section */
.sidebar-color-section {
  border-top: 1px solid var(--border-color);
  padding: 12px 12px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(0,0,0,0.12); flex-shrink: 0;
}
.sidebar-color-section .color-filter-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.color-option {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  cursor: pointer; border: 2px solid transparent;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  position: relative; box-shadow: var(--shadow-sm);
}
.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: #fff; box-shadow: 0 0 8px var(--primary-glow); transform: scale(1.1); }

/* Volume control — pill-shaped button with horizontal slider */
.volume-control-wrapper { position: relative; display: flex; align-items: center; }

.hover-mute-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition-fast);
  position: relative; flex-shrink: 0;
}
.hover-mute-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.hover-mute-btn.audio-on { color: var(--primary); }
.hover-mute-btn.audio-on:hover { background: rgba(0,224,84,0.12); }

/* Animated sound waves when audio is on */
.hover-mute-btn .sound-wave {
  position: absolute; border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0; pointer-events: none;
}
.hover-mute-btn.audio-on .sound-wave {
  animation: soundPulse 1.8s ease-out infinite;
}
.hover-mute-btn.audio-on .sound-wave:nth-child(2) { animation-delay: 0.6s; }
@keyframes soundPulse {
  0% { width: 18px; height: 18px; opacity: 0.5; }
  100% { width: 40px; height: 40px; opacity: 0; }
}

/* Horizontal volume slider popup */
.volume-slider-popup {
  position: absolute; top: calc(100% + 8px); right: -8px;
  background: var(--bg-glass-medium); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 10px 14px; box-shadow: var(--shadow-md);
  display: none; align-items: center; gap: 8px;
  z-index: 60;
}
.volume-slider-popup.show { display: flex; }
.volume-slider-popup::after {
  content: ''; position: absolute; top: -5px; right: 20px;
  width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-bottom: 5px solid var(--bg-glass-medium);
}

/* ── Play history dropdown ── */
.history-control-wrapper { position: relative; display: flex; align-items: center; }
.history-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-width: 90vw;
  background: var(--bg-glass-medium); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); z-index: 200;
  display: flex; flex-direction: column;
  max-height: 70vh; overflow: hidden;
}
.history-dropdown.hidden { display: none; }
.history-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border-color);
  font-size: 12px; color: var(--text-secondary); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; flex-shrink: 0;
}
.history-clear-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; cursor: pointer; padding: 2px 6px; border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.history-clear-btn:hover { color: var(--danger); }
.history-list { overflow-y: auto; flex: 1; min-height: 0; }
.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background var(--transition-fast);
}
.history-item:hover { background: rgba(255,255,255,0.04); }
.history-item:last-child { border-bottom: none; }
.history-thumb {
  width: 48px; height: 32px; border-radius: 3px; object-fit: cover;
  background: var(--bg-deep); flex-shrink: 0;
}
.history-thumb-placeholder {
  width: 48px; height: 32px; border-radius: 3px; flex-shrink: 0;
  background: var(--bg-surface); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-muted);
}
.history-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.history-item-name {
  font-size: 12px; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item-meta { font-size: 10px; color: var(--text-muted); display: flex; gap: 8px; }
.history-item-meta .time { font-variant-numeric: tabular-nums; }
.history-empty {
  padding: 32px 16px; text-align: center;
  color: var(--text-muted); font-size: 12px;
}

/* Horizontal slider */
.volume-slider {
  -webkit-appearance: none; appearance: none;
  width: 100px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.1); cursor: pointer; outline: none;
}
.volume-slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) var(--vol, 80%), rgba(255,255,255,0.1) var(--vol, 80%));
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); margin-top: -5px;
  transition: transform var(--transition-fast);
}
.volume-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.volume-slider::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) var(--vol, 80%), rgba(255,255,255,0.1) var(--vol, 80%));
}
.volume-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: none; box-shadow: var(--shadow-sm);
}

/* Mobile-only seek row (hidden on desktop) */
.mobile-seek-row { display: none; }

/* Folder tree */
.folder-tree { padding: 0 4px; }
.folder-node { font-size: 13px; }
.folder-node.root > .folder-node-header { font-weight: 600; }
.folder-node-header {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius-sm); transition: background var(--transition-fast);
  min-height: var(--touch-target); cursor: pointer; user-select: none;
}
.folder-node-header:hover { background: rgba(255,255,255,0.04); }
.folder-node-header.active { background: rgba(0,224,84,0.12); color: var(--primary-hover); }
.folder-toggle { font-size: 10px; width: 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; transition: transform var(--transition-fast); cursor: pointer; user-select: none; }
.folder-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; opacity: 0.85; }
.folder-dot.root-dot { width: 10px; height: 10px; }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; user-select: none; }
.folder-node-count { font-size: 10px; color: var(--text-muted); cursor: pointer; user-select: none; }
.folder-pin { font-size: 11px; cursor: pointer; opacity: 0; transition: opacity var(--transition-fast); flex-shrink: 0; padding: 0 2px; }
.folder-node-header:hover .folder-pin { opacity: 0.6; }
.folder-pin:hover { opacity: 1 !important; }
.folder-children { margin-left: 16px; display: none; }
.folder-node.expanded > .folder-children { display: block; }
.folder-node.expanded > .folder-node-header > .folder-toggle { transform: rotate(90deg); }

/* Folder section divider */
.folder-section-divider {
  font-size: 10px; text-transform: uppercase; color: var(--text-muted);
  padding: 10px 12px 4px; font-weight: 600; letter-spacing: 0.08em;
  opacity: 0.6;
}

/* Pinned section */
.pinned-section { margin-bottom: 4px; }
.pinned-section .folder-section-divider { color: var(--accent); opacity: 0.8; }

/* Folder search input */
.folder-search-input {
  width: 100%; padding: 5px 10px; margin: 2px 4px 6px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 12px; outline: none; box-sizing: border-box;
}
.folder-search-input:focus { border-color: var(--primary); }
.folder-search-input::placeholder { color: var(--text-muted); }

/* Folder actions (expand/collapse) */
.folder-actions { display: flex; gap: 2px; margin-left: auto; }
.folder-action-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 10px; cursor: pointer; padding: 1px 4px; border-radius: 3px;
  transition: color var(--transition-fast);
}
.folder-action-btn:hover { color: var(--text-primary); }

/* Tag controls */
.tag-controls { display: flex; align-items: center; gap: 4px; padding: 0 4px; margin-bottom: 4px; }
.tag-controls .tag-search-input { flex: 1; width: auto; margin: 0; background: rgba(255,255,255,0.02); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 6px 10px; }
.tag-controls .tag-search-input:focus { border-color: var(--primary); }
.tag-toggle-btn {
  flex-shrink: 0; padding: 6px 10px; background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 11px; white-space: nowrap; min-height: 34px;
  transition: all var(--transition-fast);
}
.tag-toggle-btn:hover { border-color: var(--primary); color: var(--text-primary); }

/* Tag list — no height limit, flows with sidebar */
.tag-list { overflow-y: auto; overflow-x: hidden; padding: 0 4px; position: relative; }
.tag-list-inner { position: relative; }
.tag-list-window { display: flex; flex-wrap: wrap; gap: 3px; padding: 2px 0; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; margin: 1px; background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color); border-radius: 12px;
  font-size: 12px; transition: all var(--transition-fast); white-space: nowrap;
  height: 28px; cursor: pointer;
}
.tag-chip:hover { border-color: var(--primary); background: rgba(255,255,255,0.06); }
.tag-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 0 10px var(--primary-glow); }
.tag-chip .tag-chip-count { font-size: 10px; opacity: 0.7; background: rgba(255,255,255,0.1); padding: 1px 5px; border-radius: 8px; }
.tag-chip.popular { border-color: var(--accent); font-weight: 600; }
.tag-chip.popular .tag-chip-count { background: rgba(245,158,11,0.2); color: var(--accent); }
.tag-chip.hot { background: rgba(245,158,11,0.1); border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* Focus panel — hidden per user preference */
.sidebar-focus-section { display: none !important; }
.folder-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; }
.focus-card-body {
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
  border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 6px; min-height: 80px;
}
.focus-title { font-size: 12px; font-weight: 600; color: var(--text-primary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.focus-meta { font-size: 10px; color: var(--text-muted); }
.focus-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.focus-tag { font-size: 9px; padding: 1px 4px; background: rgba(255,255,255,0.04); border: 1px solid var(--border-color); border-radius: 2px; color: var(--text-secondary); }

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 16px; border-top: 1px solid var(--border-color);
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0;
}
.lib-stats { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Footer icon buttons — refresh & user management */
.footer-icon-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-muted); flex-shrink: 0;
  background: transparent; border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}
.footer-icon-btn:hover {
  background: rgba(255,255,255,0.06); color: var(--text-primary);
  border-color: var(--border-color-hover);
}
#refresh-btn.spinning {
  background: rgba(0,224,84,0.1);
  border-color: var(--primary);
  color: var(--primary);
  animation: spin 1s linear infinite;
}
#refresh-btn.spinning:hover {
  background: rgba(0,224,84,0.15);
}
.logout-btn {
  flex-shrink: 0; padding: 6px 14px; background: transparent;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 12px; white-space: nowrap;
  min-height: 34px; transition: all var(--transition-fast);
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============================================================
   Main Content
   ============================================================ */
#main-content { flex: 1; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
/* When the sidebar is collapsed, offset the main content past the edge handle
   (16px) plus a gap so the video grid never touches the handle. */
body.sidebar-collapsed #main-content { padding-left: 32px; }

/* Top bar */
#top-bar {
  height: var(--topbar-h); padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(10,10,8,0.4); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 12px; z-index: 50; flex-shrink: 0;
}
.mobile-menu-btn { display: none; }
.search-container {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); height: 40px; padding: 0 14px;
  flex: 1; max-width: 500px; transition: all var(--transition-fast);
}
.search-container:focus-within { border-color: var(--primary); box-shadow: 0 0 12px var(--primary-glow); }
.search-icon { color: var(--text-muted); flex-shrink: 0; display: flex; }
.search-input { flex: 1; font-size: 13px; color: var(--text-primary); }
.search-input::placeholder { color: var(--text-muted); }
.search-clear { color: var(--text-muted); cursor: pointer; display: none; font-size: 14px; }
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--text-primary); }
.filter-toggle-btn {
  height: 40px; padding: 0 14px; background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px; transition: all var(--transition-fast);
}
.filter-toggle-btn:hover { background: rgba(255,255,255,0.06); border-color: var(--border-color-hover); color: var(--text-primary); }
.filter-toggle-btn.active { background: rgba(0,224,84,0.12); border-color: var(--primary); color: var(--primary-hover); }

.top-controls { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.sort-container { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.sort-select {
  background: rgba(255,255,255,0.03); border: 1px solid var(--border-color);
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-primary);
}
.sort-select option { background: var(--bg-surface); }
.view-switch { display: flex; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); padding: 2px; border-radius: var(--radius-sm); }
.view-btn, .icon-btn {
  min-width: 36px; min-height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--text-muted); transition: all var(--transition-fast); background: none; border: none;
}
.view-btn.active, .icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.view-toggle.active { color: var(--primary); }

/* Card-size segmented control (紧凑 / 标准 / 大图). Reuses .view-switch chrome. */
.size-switch { padding: 2px; }
.size-switch .size-btn { padding: 0 8px; }
.size-switch .size-btn.active { background: rgba(0,224,84,0.12); color: var(--primary); }
.size-switch .size-btn:hover:not(.active) { color: var(--text-primary); }
/* Hide in list view — list rows have their own sizing */
body.list-mode .size-switch { display: none; }
@media (max-width: 768px) { .size-switch { display: none; } }

/* Search suggestions */
.search-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: var(--bg-glass-medium); backdrop-filter: blur(20px);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  max-height: 240px; overflow-y: auto; z-index: 50; box-shadow: var(--shadow-md);
}
.search-suggestions.hidden { display: none; }
.search-suggestion-item { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; transition: background var(--transition-fast); }
.search-suggestion-item:hover { background: rgba(255,255,255,0.04); }
.search-suggestion-item .suggestion-tag { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-suggestion-item .suggestion-count { font-size: 11px; color: var(--text-muted); background: rgba(255,255,255,0.04); padding: 1px 6px; border-radius: 8px; }

/* Filter drawer */
#filter-drawer {
  background: var(--bg-glass-medium); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  max-height: 0; opacity: 0; overflow: hidden;
  transition: all var(--transition-normal); z-index: 40;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
}
#filter-drawer.open { padding: 20px 32px; max-height: 280px; opacity: 1; }
.filter-group { display: flex; flex-direction: column; gap: 10px; }
.filter-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.duration-filter-list { display: flex; flex-direction: column; gap: 6px; }
.duration-option { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.duration-option input { accent-color: var(--primary); }
.logic-switch { display: flex; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); padding: 2px; border-radius: var(--radius-sm); width: max-content; }
.logic-btn { padding: 4px 12px; font-size: 11px; font-weight: 700; color: var(--text-muted); border-radius: 4px; }
.logic-btn.active { background: var(--primary); color: white; }

/* Active filter chips bar */
#active-filters-bar { display: none; align-items: center; gap: 10px; padding: 8px 24px; background: rgba(10,10,8,0.2); border-bottom: 1px solid var(--border-color); flex-wrap: wrap; flex-shrink: 0; }
#active-filters-bar.visible { display: flex; }
.active-filter-label { font-size: 12px; color: var(--text-muted); }
.active-filter-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.filter-chip { display: flex; align-items: center; gap: 6px; font-size: 12px; background: rgba(0,224,84,0.1); border: 1px solid rgba(0,224,84,0.3); color: var(--primary-hover); padding: 4px 10px; border-radius: var(--radius-full); }
.filter-chip-remove { cursor: pointer; color: var(--text-muted); font-size: 10px; }
.filter-chip-remove:hover { color: var(--text-primary); }
.filter-clear-all { font-size: 12px; color: var(--text-muted); text-decoration: underline; cursor: pointer; margin-left: auto; }
.filter-clear-all:hover { color: var(--text-primary); }

/* Active tags (existing, kept for compatibility) */
.active-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 24px; border-bottom: 1px solid var(--border-color); min-height: 0; flex-shrink: 0; }
.active-tags:empty { display: none; }
.active-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--primary); color: #fff; border-radius: 12px; font-size: 12px; cursor: pointer; }

/* Hero banner — hidden per user preference */
#hero-banner { display: none !important; }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.45; }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(to top, var(--bg-glass-heavy) 10%, rgba(10,10,8,0.2) 70%, transparent 100%); }
.hero-content { position: relative; padding: 28px; max-width: 60%; display: flex; flex-direction: column; gap: 6px; }
.hero-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--accent); background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); padding: 4px 8px; border-radius: var(--radius-sm); width: max-content; letter-spacing: 1px; }
.hero-title { font-size: 22px; font-weight: 800; line-height: 1.2; }
.hero-desc { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Scroll container */
#grid-container, #scroll-container { flex: 1; overflow-y: auto; padding: 8px 28px 32px; position: relative; scroll-behavior: smooth; }

/* Grid — video wall: tight spacing, sharp corners, monitor-array feel */
.grid, #video-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: 4px; align-content: start; padding: 0 4px 4px 0;
}
/* Card size presets — driven by a single CSS var, no DOM rebuild on switch.
   Desktop-only: the @media rules below still pin columns on tablet/mobile. */
.grid[data-card-size="compact"], #video-grid[data-card-size="compact"] { --card-min: 280px; }
.grid[data-card-size="standard"], #video-grid[data-card-size="standard"] { --card-min: 380px; }
.grid[data-card-size="large"], #video-grid[data-card-size="large"] { --card-min: 520px; }
@media (max-width: 1024px) { .grid, #video-grid { grid-template-columns: repeat(3, 1fr); gap: 3px; } }
@media (max-width: 768px) { .grid, #video-grid { grid-template-columns: repeat(2, 1fr); gap: 2px; } }
@media (max-width: 480px) { .grid, #video-grid { grid-template-columns: 1fr; } }

/* Video card — monitor tile */
.grid-card, .video-card {
  position: relative; aspect-ratio: var(--thumb-ratio);
  background: #000; border: 1px solid rgba(255,255,255,0.04);
  border-radius: 0; overflow: hidden; cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1), border-color 0.25s ease, box-shadow 0.25s ease;
}
.grid-card:hover, .video-card:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 8px 24px rgba(0,0,0,0.6), 0 0 20px rgba(0,224,84,0.15);
  z-index: 10;
}
.grid-card img, .card-thumb {
  width: 100%; height: 100%; object-fit: cover; display: block;
  background: var(--bg-deep); transition: opacity var(--transition-normal);
}
.grid-card .card-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 700; color: var(--text-muted); background: var(--bg-surface);
}
.grid-card .card-placeholder.small { font-size: 32px; }
.grid-card-duration, .card-duration {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.75); color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px; backdrop-filter: blur(4px); z-index: 5;
}
.grid-card-name {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 24px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.9));
  color: rgba(255,255,255,0.85); font-family: var(--font-display);
  font-size: 12px; font-weight: 500; letter-spacing: 0.3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* P2: Staggered card entrance animation */
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.grid-card { animation: cardEnter 0.4s ease both; }
.grid-card:nth-child(1) { animation-delay: 0.02s; }
.grid-card:nth-child(2) { animation-delay: 0.04s; }
.grid-card:nth-child(3) { animation-delay: 0.06s; }
.grid-card:nth-child(4) { animation-delay: 0.08s; }
.grid-card:nth-child(5) { animation-delay: 0.10s; }
.grid-card:nth-child(6) { animation-delay: 0.12s; }
.grid-card:nth-child(7) { animation-delay: 0.14s; }
.grid-card:nth-child(8) { animation-delay: 0.16s; }
.grid-card:nth-child(n+9) { animation-delay: 0.18s; }

/* Display font usage */
.logo-icon, #player-title, .sidebar-header h2, .login-logo h2, .player-sidebar-title {
  font-family: var(--font-display); letter-spacing: 0.5px;
}
#stat-total, #stat-size, #stat-duration {
  font-family: var(--font-display); font-weight: 600;
}
.grid-card video.hover-preview {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 2; background: #000; pointer-events: none;
}
.hover-scrub-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,0.2); z-index: 4; pointer-events: none; }
.hover-scrub-fill { height: 100%; background: var(--primary); transition: width 60ms linear; }
.hover-scrub-time {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff; font-size: 11px; padding: 2px 8px;
  border-radius: 4px; font-variant-numeric: tabular-nums; z-index: 5; pointer-events: none; white-space: nowrap;
}

/* Per-card speaker toggle shown during hover-scrub preview.
   Top-right corner; shares global hoverMuted/volume state with the top-bar button.
   z-index 6 sits above the scrub bar (4) and duration badge (5). */
.card-mute-toggle {
  position: absolute; top: 6px; right: 6px; z-index: 6;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0;  /* revealed by .grid-card:hover via JS-created element */
}
.card-mute-toggle:hover { background: rgba(0,0,0,0.75); color: var(--text-primary); border-color: rgba(255,255,255,0.25); }
.card-mute-toggle.audio-on { color: var(--primary); border-color: rgba(0,224,84,0.4); }
.card-mute-toggle.audio-on:hover { background: rgba(0,224,84,0.15); }
/* The button is only appended during an active hover-scrub, so it's always
   visible then; fade-in for polish. */
.grid-card video.hover-preview ~ .card-mute-toggle { opacity: 1; }

/* Per-card download button (bottom-right). Only present during hover-scrub.
   Same dark-glass chrome as the mute button, anchored to the opposite corner
   so the two don't compete for the same real estate. */
.card-download-btn {
  position: absolute; bottom: 14px; right: 6px; z-index: 6;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-secondary); cursor: pointer;
  opacity: 0; transition: opacity 0.18s, background 0.18s, color 0.18s, border-color 0.18s;
  text-decoration: none;
}
.card-download-btn:hover {
  background: rgba(0,0,0,0.75); color: var(--text-primary);
  border-color: rgba(255,255,255,0.25);
}
.grid-card video.hover-preview ~ .card-download-btn { opacity: 1; }

/* Selection checkbox */
.grid-card .card-checkbox {
  position: absolute; top: 6px; left: 6px; z-index: 5;
  width: 24px; height: 24px; border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; font-size: 14px; color: #fff;
}
.selection-mode .grid-card .card-checkbox { display: flex; }
.grid-card.selected .card-checkbox { background: var(--primary); border-color: var(--primary); }
.grid-card.selected { box-shadow: 0 0 0 2px var(--primary), 0 0 12px rgba(0,224,84,0.3); }

/* List view */
.grid-card.list-card { display: flex; flex-direction: row; aspect-ratio: auto; height: 80px; padding: 8px; gap: 10px; }
.grid-card.list-card img, .grid-card.list-card .card-placeholder { width: 120px; height: 100%; flex-shrink: 0; object-fit: cover; border-radius: 4px; }
.grid-card.list-card .card-placeholder { font-size: 28px; }
.grid-card.list-card .grid-card-duration { position: static; }
.grid-card.list-card .grid-card-name { position: static; background: none; color: var(--text-primary); font-size: 13px; padding: 0; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.list-card-info { display: flex; flex-direction: column; justify-content: center; gap: 4px; flex: 1; min-width: 0; overflow: hidden; }
.list-card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--text-muted); }
.list-card-meta span { background: rgba(255,255,255,0.04); padding: 2px 6px; border-radius: 4px; }
.list-card-tags { display: flex; flex-wrap: wrap; gap: 3px; font-size: 10px; }
.list-card-tags span { background: rgba(255,255,255,0.04); padding: 1px 5px; border-radius: 3px; color: var(--text-muted); }

/* Skeleton loading */
.skeleton-card { aspect-ratio: var(--thumb-ratio); background: var(--bg-surface); border-radius: var(--radius-md); overflow: hidden; position: relative; }
.skeleton-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%); animation: shimmer 1.8s infinite; }
.skeleton-card.list-card { aspect-ratio: auto; height: 80px; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Load more */
.load-more-wrap { display: flex; flex-direction: column; align-items: center; padding: 20px 12px 32px; gap: 8px; }
.load-more-wrap.hidden { display: none; }
.load-more-status { font-size: 12px; color: var(--text-muted); }
.load-more-btn { padding: 10px 28px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-size: 13px; transition: all var(--transition-fast); min-height: var(--touch-target); }
.load-more-btn:hover { background: rgba(255,255,255,0.06); border-color: var(--primary); }
.load-more-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.load-more-spinner { display: flex; justify-content: center; padding: 20px; }
.load-more-spinner.hidden { display: none; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border-color); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.large { width: 40px; height: 40px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Back to top */
.back-to-top {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  width: 44px; height: 44px; background: var(--bg-glass);
  backdrop-filter: blur(12px); border: 1px solid var(--border-color);
  border-radius: 50%; color: var(--text-primary); font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md); transition: all var(--transition-fast);
}
.back-to-top.hidden { display: none; }
.back-to-top:hover { background: rgba(255,255,255,0.06); transform: translateY(-2px); }

/* Loading overlay */
.loading-overlay { position: absolute; inset: 0; z-index: 10; background: rgba(10,10,8,0.7); display: flex; align-items: center; justify-content: center; }
.loading-overlay.hidden { display: none; }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--text-muted); text-align: center; }
.empty-state.hidden { display: none; }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 15px; max-width: 400px; }
.empty-state .empty-query { color: var(--primary); font-weight: 600; }

/* ============================================================
   Player Modal — Split Layout
   ============================================================ */
#player-modal { position: fixed; inset: 0; z-index: 1000; background: var(--bg-dark); }
#player-modal.hidden { display: none; }
#player-modal.open { display: flex; animation: playerEnter 0.35s cubic-bezier(0.16,1,0.3,1) both; }
@keyframes playerEnter {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.player-container { flex: 1; display: flex; height: 100%; width: 100%; }

/* Left rail — vertical adjacent-video navigation (moved from bottom strip) */
.player-thumb-rail {
  width: 200px; min-width: 200px; height: 100%;
  background: var(--bg-glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color); z-index: 210;
  display: flex; flex-direction: column; overflow-y: auto;
  scrollbar-width: thin; -ms-overflow-style: none;
  padding: 12px 10px; gap: 8px;
}
.player-thumb-rail::-webkit-scrollbar { width: 4px; }
.player-thumb-rail::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.player-thumb-rail:empty { display: none; }

/* Hide left thumb rail on narrow screens — use nav arrows instead */
@media (max-width: 900px) {
  .player-thumb-rail { display: none; }
}

/* Player main (left) — flex column: video fills space, controls sit below */
.player-main { flex: 1; background: #000; position: relative; display: flex; flex-direction: column; overflow: hidden; }

/* Video area wrapper — holds video + nav overlay */
.player-video-area { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.player-video, #player-video { flex: 1; min-height: 0; max-width: 100%; width: 100%; height: 100%; object-fit: contain; }

/* Player top controls — close (left) + sidebar toggle (right) */
.player-top-controls { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; z-index: 220; pointer-events: none; }
.player-top-controls > * { pointer-events: auto; }
.top-controls-left, .top-controls-right { display: flex; gap: 8px; }

/* Player nav buttons — large arrows, glass background on hover */
.player-nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 210;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.55); background: transparent;
  border: none; border-radius: 50%; cursor: pointer;
  transition: all 0.2s ease;
}
.player-nav-btn:hover {
  color: #fff;
  background: var(--bg-glass-light); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
}
.player-nav-btn:active { transform: translateY(-50%) scale(0.92); }
#player-prev { left: 8px; }
#player-next { right: 8px; }

/* Player circle buttons (close, sidebar toggle, etc.) */
.player-btn-circle {
  width: 40px; height: 40px; background: var(--bg-glass-light);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.8); cursor: pointer;
  transition: all var(--transition-fast);
}
.player-btn-circle:hover { background: var(--bg-glass-heavy); border-color: var(--primary); color: #fff; transform: scale(1.05); }

/* Controls bar — sits below video, not overlaying */
.player-bottom-panel {
  flex-shrink: 0; width: 100%; z-index: 220;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-glass-heavy); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color); padding: 16px 20px;
}
.player-bottom-panel.autohide { /* disabled — controls always visible */ }

/* Custom timeline */
.player-timeline-container { display: flex; align-items: center; gap: 12px; }
.player-timeline { flex: 1; height: 4px; background: rgba(255,255,255,0.2); border-radius: var(--radius-full); cursor: pointer; position: relative; }
.player-timeline-progress, #player-timeline-bar { height: 100%; background: var(--primary); border-radius: var(--radius-full); width: 0%; }
.player-timeline-handle, #player-timeline-dot { width: 12px; height: 12px; background: white; border-radius: var(--radius-full); position: absolute; top: 50%; transform: translate(-50%, -50%) scale(0); transition: transform var(--transition-fast); box-shadow: var(--shadow-sm); }
.player-timeline:hover .player-timeline-handle, #player-timeline:hover #player-timeline-dot { transform: translate(-50%, -50%) scale(1); }
.player-time-display { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* Player control buttons */
.player-control-actions { display: flex; align-items: center; justify-content: center; gap: 32px; }
.control-left, .control-right { display: flex; align-items: center; gap: 20px; }
.control-btn { color: var(--text-secondary); transition: color var(--transition-fast); display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
.control-btn:hover { color: var(--text-primary); }
.control-btn.play-pause { color: white; width: 44px; height: 44px; }
.control-btn.play-pause:hover { color: var(--primary-hover); }
.control-btn.play-pause svg { width: 26px; height: 26px; }
.control-btn svg { width: 20px; height: 20px; }
.frame-controls { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.04); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 4px 6px; }
.frame-btn, .seek-btn { padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--text-secondary); transition: all var(--transition-fast); border-radius: 4px; }
.frame-btn:hover, .seek-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.seek-btn:active { transform: scale(0.95); }

/* Filmstrip — SCO shot-level frame previews for current video (enlarged) */
.player-filmstrip {
  display: flex; gap: 6px; overflow-x: auto; padding: 6px 0;
  scrollbar-width: none; -ms-overflow-style: none;
}
.player-filmstrip::-webkit-scrollbar { display: none; }
.player-filmstrip:empty { display: none; }
.filmstrip-frame {
  flex-shrink: 0; width: 160px; height: 90px;
  border-radius: 3px; overflow: hidden; cursor: pointer;
  position: relative; padding: 0; border: 1px solid rgba(255,255,255,0.05);
  background: var(--bg-surface); opacity: 0.65;
  transition: opacity 0.15s, border-color 0.15s;
}
.filmstrip-frame:hover { opacity: 1; border-color: var(--primary); }
.filmstrip-frame.active { opacity: 1; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.filmstrip-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.filmstrip-label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  font-size: 11px; color: rgba(255,255,255,0.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filmstrip-time {
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.filmstrip-frame:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Thumbnail rail items — vertical adjacent video previews (enlarged) */
/* .player-thumb-strip is now the left rail (.player-thumb-rail in HTML) */
/* Keep class for JS compatibility — items styled for vertical rail layout */
.player-thumb-strip {
  /* fallback: if class is still used directly */
}
.thumb-strip-item {
  flex-shrink: 0; width: 100%; aspect-ratio: 16 / 9; border-radius: 4px;
  overflow: hidden; cursor: pointer; position: relative;
  border: 1px solid rgba(255,255,255,0.05);
  opacity: 0.5; transition: opacity 0.15s, border-color 0.15s;
}
.thumb-strip-item:hover { opacity: 0.8; border-color: rgba(255,255,255,0.2); }
.thumb-strip-item.active { opacity: 1; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.thumb-strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-strip-item .thumb-label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  font-size: 11px; color: rgba(255,255,255,0.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Player title row — title + copy button, aligned with content below (24px from sidebar edge) */
.player-title-row { display: flex; align-items: flex-start; gap: 10px; margin: 0; }
.player-title-row h2 { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text-primary); letter-spacing: 0.3px; line-height: 1.3; }

/* Copy-title button — sits at the right edge of the title row.
   Subtle green tint at rest so users can see it; brightens on hover; full green on success. */
.player-copy-title-btn {
  flex-shrink: 0;
  width: 30px; height: 30px; margin-top: -3px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 224, 84, 0.08);
  border: 1px solid rgba(0, 224, 84, 0.25);
  border-radius: 6px; color: var(--primary);
  cursor: pointer; opacity: 0.8;
  transition: opacity var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.player-copy-title-btn:hover,
.player-copy-title-btn:focus-visible {
  opacity: 1; color: var(--primary);
  border-color: var(--primary); background: rgba(0, 224, 84, 0.18);
  outline: none;
}
.player-copy-title-btn:focus-visible { box-shadow: 0 0 0 2px rgba(0, 224, 84, 0.3); }
.player-copy-title-btn.copy-ok {
  opacity: 1; color: var(--primary); border-color: var(--primary);
  background: rgba(0, 224, 84, 0.25);
}
.player-copy-title-btn.copy-ok svg { animation: copy-pop 0.32s cubic-bezier(0.16,1,0.3,1); }
@keyframes copy-pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.player-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.player-tag { font-size: 12px; padding: 3px 10px; background: rgba(0,224,84,0.1); border: 1px solid rgba(0,224,84,0.3); border-radius: 12px; color: var(--primary-hover); }
.player-meta { font-size: 12px; color: var(--text-muted); }
.player-meta-grid { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.meta-row { display: flex; justify-content: space-between; }
.meta-row span:last-child { color: var(--text-secondary); }
.player-annotation { margin: 8px 24px; padding: 10px 12px; background: rgba(255,255,255,0.02); border-left: 3px solid var(--primary); border-radius: 4px; font-size: 12px; color: var(--text-secondary); white-space: pre-wrap; line-height: 1.5; }
.player-annotation.hidden { display: none; }

/* Download & screenshot buttons */
.download-btn { flex-shrink: 0; padding: 8px 18px; background: var(--primary); color: #fff; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-glow); transition: all var(--transition-fast); min-height: var(--touch-target); }
.download-btn:hover { background: var(--primary-hover); }
.player-btn-screenshot { flex-shrink: 0; padding: 8px 16px; background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 14px; transition: all var(--transition-fast); min-height: var(--touch-target); }
.player-btn-screenshot:hover { border-color: var(--primary); color: var(--primary-hover); }
.player-btn-edit { padding: 5px 12px; background: transparent; color: var(--text-muted); border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 11px; font-weight: 500; transition: all var(--transition-fast); cursor: pointer; }
.player-btn-edit:hover { border-color: var(--primary); color: var(--primary-hover); }

/* Edit panel */
.player-edit-panel { margin: 12px 24px; padding: 16px; background: rgba(255,255,255,0.02); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.player-edit-panel.hidden { display: none; }
.edit-field { margin-bottom: 12px; }
.edit-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.edit-hint { font-weight: 400; opacity: 0.6; }
.edit-input { width: 100%; padding: 8px 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; box-sizing: border-box; transition: border-color var(--transition-fast); }
.edit-input:focus { border-color: var(--primary); }
.edit-textarea { width: 100%; padding: 8px 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; resize: vertical; box-sizing: border-box; font-family: inherit; min-height: 80px; line-height: 1.5; }
.edit-textarea:focus { border-color: var(--primary); }
.edit-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.edit-actions .btn-primary { padding: 8px 16px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; min-height: var(--touch-target); }
.edit-actions .btn-primary:hover { background: var(--primary-hover); }
.edit-actions .btn-primary:disabled { opacity: 0.5; }
.edit-actions .btn-secondary { padding: 8px 16px; background: transparent; border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px; min-height: var(--touch-target); }
.edit-actions .btn-secondary:hover { background: rgba(255,255,255,0.04); }
.edit-status { font-size: 12px; color: var(--text-muted); }

/* Player detail sidebar (right) */
.player-sidebar, #player-detail-sidebar {
  width: 340px; height: 100%; background: var(--bg-glass);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-color); z-index: 230;
  display: flex; flex-direction: column;
  transition: transform var(--transition-normal);
}
.player-sidebar.collapsed, #player-detail-sidebar.collapsed { transform: translateX(100%); position: absolute; right: 0; top: 0; }
.player-sidebar-header { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--border-color); }
.player-sidebar-title { font-size: 16px; font-weight: 700; }
.player-sidebar-content { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* Player nav row (existing compat) */
.player-nav-row { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 10px 24px; }
.player-nav-btn.compat-btn { background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-size: 18px; padding: 8px 16px; min-width: var(--touch-target); min-height: var(--touch-target); position: static; transform: none; }
.player-nav-btn.compat-btn:hover { background: rgba(255,255,255,0.06); border-color: var(--primary); }
.player-nav-btn.compat-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.player-position { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Seek row */
.player-seek-row { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 24px; flex-wrap: wrap; }

/* Selection bar */
.selection-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 200; background: var(--bg-glass); backdrop-filter: blur(20px); border-top: 1px solid var(--border-color); padding: 12px 24px; display: flex; align-items: center; gap: 12px; box-shadow: 0 -4px 16px rgba(0,0,0,0.5); }
.selection-bar.hidden { display: none; }
#selection-count { font-size: 14px; color: var(--text-primary); flex: 1; }
.selection-bar .btn-primary { padding: 8px 18px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 13px; min-height: var(--touch-target); }
.selection-bar .btn-primary:hover { background: var(--primary-hover); }
.selection-bar .btn-secondary { padding: 8px 18px; background: transparent; border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px; min-height: var(--touch-target); }
.selection-bar .btn-secondary:hover { background: rgba(255,255,255,0.04); }

/* Toast */
#toast {
  position: fixed; bottom: 24px; left: 24px;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  color: var(--text-primary); padding: 12px 20px; border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); font-size: 13px; z-index: 300;
  transform: translateY(100px); opacity: 0;
  transition: all var(--transition-normal); display: flex; align-items: center; gap: 8px;
}
#toast.show { transform: translateY(0); opacity: 1; }

/* ============================================================
   Responsive
   ============================================================ */
.only-mobile { display: none; }
#sidebar-overlay { display: none; }

@media (max-width: 768px) {
  .only-mobile { display: block; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-secondary); margin-right: 8px; flex-shrink: 0; }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000; transform: translateX(-100%); transition: transform var(--transition-normal); width: 85vw; max-width: 320px; min-width: unset; }
  #sidebar.open, #sidebar.mobile-visible { transform: translateX(0); box-shadow: 10px 0 40px rgba(0,0,0,0.7); }
  #sidebar-overlay.open, #sidebar-overlay.mobile-visible { display: block; position: fixed; inset: 0; background: rgba(3,7,18,0.6); backdrop-filter: blur(4px); z-index: 990; }
  #main-content { width: 100%; }
  #top-bar { padding: 0 10px; gap: 6px; height: 52px; flex-wrap: nowrap; }
  .mobile-menu-btn { width: 40px; height: 40px; flex-shrink: 0; }
  /* Mobile sidebar header: shrink library name, give close button room */
  .sidebar-header { padding: 0 12px; gap: 8px; }
  .library-selector-wrapper { min-width: 0; overflow: hidden; }
  .library-current span { max-width: 120px; }
  #sidebar-close { flex-shrink: 0; width: 32px; height: 32px; }
  /* Search fills available space */
  .search-container { flex: 1; width: auto; max-width: 100%; min-width: 0; }
  /* Hide filter text on mobile, keep icon only */
  .filter-toggle-btn span { display: none; }
  .filter-toggle-btn { padding: 0 10px; flex-shrink: 0; }
  /* Sort and view hidden on mobile */
  .sort-container { display: none; }
  .view-switch { display: none; }
  #filter-drawer { grid-template-columns: repeat(2, 1fr); }
  #hero-banner { margin: 16px 16px 8px; height: 160px; }
  .hero-content { padding: 16px; max-width: 90%; }
  .hero-title { font-size: 18px; }
  #grid-container, #scroll-container { padding: 8px 12px 16px; }
  .player-container { flex-direction: column; overflow-y: auto; }
  .player-main { height: auto; width: 100%; flex: none; position: relative; display: flex; flex-direction: column; overflow: visible; background: #000; }
  /* Constrain video height — portrait videos won't fill the screen */
  .player-main .player-video, .player-main #player-video {
    width: 100%; max-height: 42vh; flex-shrink: 0; object-fit: contain; background: #000;
  }
  .player-sidebar, #player-detail-sidebar { width: 100% !important; height: auto !important; flex: 1; border-left: none; border-top: 1px solid var(--border-color); position: relative !important; transform: none !important; }
  #player-sidebar-toggle-btn { display: none !important; }

  /* Mobile controls: static, below video, always visible */
  .player-bottom-panel {
    position: static !important; width: 100% !important; max-width: 100% !important;
    transform: none !important; border-radius: 0; border: none;
    border-top: 1px solid var(--border-color); padding: 8px 12px;
    background: var(--bg-base); opacity: 1 !important; pointer-events: auto !important;
  }
  .player-bottom-panel.autohide { /* disabled */ }
  .player-control-actions { flex-wrap: wrap; justify-content: space-between; gap: 0; }
  /* Mobile Row 1: play on left, volume/screenshot/fullscreen on right */
  .control-left { width: auto; justify-content: flex-start; order: 1; gap: 16px; flex: none; }
  .control-left .frame-controls { display: none !important; }
  .control-right { justify-content: flex-end; order: 1; gap: 16px; flex: none; }
  /* Mobile Row 2: seek buttons */
  .mobile-seek-row { display: flex !important; justify-content: center; flex-wrap: wrap; gap: 2px; padding: 4px 0; width: 100%; order: 3; }
  .mobile-seek-row .seek-btn { padding: 6px 10px; font-size: 12px; min-height: 38px; }
  .control-btn { width: 40px; height: 40px; }
  .control-btn.play-pause svg, .control-btn svg { width: 22px; height: 22px; }
  .player-top-controls { top: 8px; left: 8px; right: 8px; }
  .player-nav-btn { display: none; }
  .player-close { /* in top bar now */ }
  .sidebar-focus-section { display: none !important; }
}

@media (max-width: 480px) {
  #grid-container .grid, #video-grid { grid-template-columns: 1fr; }
  #hero-banner { display: none; }
  #filter-drawer { grid-template-columns: 1fr; }
}

/* ============================================================
   Keyboard shortcuts panel (sidebar bottom)
   ============================================================ */
.player-shortcuts {
  margin-top: auto; padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.shortcuts-title {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 8px; letter-spacing: 0.5px;
}
.shortcuts-grid { display: flex; flex-direction: column; gap: 4px; }
.shortcut-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted);
}
.shortcut-row kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px;
  font-family: inherit; font-size: 10px; font-weight: 500;
  text-align: center; color: var(--text-secondary);
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px; box-shadow: 0 1px 0 rgba(255,255,255,0.04);
  line-height: 1.5;
}
.shortcut-row span { color: var(--text-muted); }

/* ============================================================
   SCO Timeline Markers — AI shot-level annotations
   ============================================================ */
.sco-timeline-marker {
  position: absolute;
  top: 50%;
  width: 8px; height: 8px;
  background: var(--accent);
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 3;
  transition: transform 0.15s, box-shadow 0.15s;
}
.sco-timeline-marker:hover {
  transform: translate(-50%, -50%) scale(1.6);
  box-shadow: 0 0 6px var(--accent-glow);
}
.sco-tooltip {
  position: fixed;
  width: 320px;
  max-height: 340px;
  background: var(--bg-deep);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 0.15s;
}
.sco-tooltip.visible { opacity: 1; }
.sco-tooltip-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--bg-deep);
  display: block;
}
.sco-tooltip-text {
  padding: 10px 12px 6px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.sco-tooltip-time {
  padding: 4px 12px 10px;
  font-size: 11px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ============================================================
   User Management Panel
   ============================================================ */
.user-panel {
  position: fixed; inset: 0; z-index: 10001;
  display: flex; align-items: center; justify-content: center;
}
.user-panel.hidden { display: none; }
.user-panel-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  pointer-events: none;
}
.user-panel-box {
  position: relative; width: 560px; max-width: 94vw; max-height: 85vh;
  background: var(--bg-glass-heavy); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  z-index: 1;
}

.user-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 12px; flex-shrink: 0;
}
.user-panel-header h2 {
  font-size: 17px; font-weight: 700; color: var(--text-primary);
  font-family: var(--font-display);
}

/* Tabs */
.user-panel-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border-color);
  padding: 0 24px; flex-shrink: 0;
}
.user-panel-tabs.hidden { display: none; }
.up-tab {
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: all var(--transition-fast); margin-bottom: -1px;
}
.up-tab:hover { color: var(--text-primary); }
.up-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Tab content */
.up-tab-content { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.up-tab-content.active { display: flex; }

/* Toolbar */
.up-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px 12px; flex-shrink: 0;
}
.up-user-count { font-size: 12px; color: var(--text-muted); }

/* Buttons */
.up-btn {
  padding: 8px 18px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; transition: all var(--transition-fast);
  border: none; cursor: pointer;
}
.up-btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-glow); }
.up-btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.up-btn-secondary { background: rgba(255,255,255,0.04); color: var(--text-secondary); border: 1px solid var(--border-color); }
.up-btn-secondary:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.up-btn-danger { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.up-btn-danger:hover { background: rgba(239,68,68,0.2); }
.up-btn-sm { padding: 4px 10px; font-size: 11px; border-radius: var(--radius-sm); }

/* User list */
.up-user-list { flex: 1; overflow-y: auto; padding: 0 24px 20px; }
.up-user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background var(--transition-fast);
}
.up-user-row:last-child { border-bottom: none; }
.up-user-row:hover { background: rgba(255,255,255,0.02); margin: 0 -4px; padding: 12px 4px; border-radius: var(--radius-sm); }
.up-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.up-user-info { flex: 1; min-width: 0; }
.up-user-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.up-user-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.up-role-badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.up-role-badge.admin { background: rgba(0,224,84,0.12); color: var(--primary); }
.up-role-badge.user { background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.up-user-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Edit form (inline) */
.up-edit-form {
  position: absolute; inset: 0; z-index: 10;
  background: var(--bg-glass-heavy); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
}
.up-edit-form.hidden { display: none; }
.up-edit-form h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.up-edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* Password tab */
.up-pw-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.up-pw-footer { display: flex; justify-content: flex-end; }

/* Login username field */
.login-input[type="text"] { margin-bottom: 10px; }

/* Shared form elements */
.pw-field { display: flex; flex-direction: column; gap: 6px; }
.pw-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.pw-input {
  padding: 10px 14px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 14px;
  transition: border-color var(--transition-fast);
}
.pw-input:focus { border-color: var(--primary); box-shadow: 0 0 10px var(--primary-glow); }
.pw-input::placeholder { color: var(--text-muted); }
.pw-error {
  padding: 8px 12px; background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius-sm);
  color: var(--danger); font-size: 12px;
}
.pw-error.hidden { display: none; }
.pw-success {
  padding: 8px 12px; background: rgba(0,224,84,0.1);
  border: 1px solid rgba(0,224,84,0.3); border-radius: var(--radius-sm);
  color: var(--primary); font-size: 12px;
}
.pw-success.hidden { display: none; }
.modal-close-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer;
  background: transparent; border: none;
  transition: all var(--transition-fast);
}
.modal-close-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ============================================================
   Accessibility — Respect user's motion preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
