/* ==========================================================================
   Nexus — Media and Content Workspace Stylesheet
   ========================================================================== */

:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-elevated: #282e38;
  --bg-card: rgba(22, 27, 34, 0.85);
  --bg-card-hover: rgba(33, 38, 45, 0.95);
  
  --border-color: rgba(240, 246, 252, 0.1);
  --border-color-strong: rgba(240, 246, 252, 0.18);
  --border-focus: #58a6ff;

  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --text-inverse: #0d1117;

  --accent-primary: #2f81f7;
  --accent-primary-hover: #388bfd;
  --accent-glow: rgba(47, 129, 247, 0.35);

  --accent-success: #238636;
  --accent-success-hover: #2ea043;
  --accent-warning: #d29922;
  --accent-danger: #da3633;
  --accent-danger-hover: #f85149;
  --accent-purple: #a371f7;
  --accent-cyan: #39c5bb;
  --accent-orange: #f0883e;

  /* Category / Type Accent Colors */
  --color-image: #38bdf8;
  --color-video: #ec4899;
  --color-audio: #a855f7;
  --color-doc: #3b82f6;
  --color-code: #10b981;
  --color-archive: #f59e0b;
  --color-other: #64748b;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Elevation & Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Dimensions & Radius */
  --header-height: 64px;
  --sidebar-width: 290px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  
  --border-color: rgba(15, 23, 42, 0.08);
  --border-color-strong: rgba(15, 23, 42, 0.16);
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.2);

  --accent-success: #16a34a;
  --accent-success-hover: #15803d;
  --accent-warning: #d97706;
  --accent-danger: #dc2626;
  --accent-danger-hover: #b91c1c;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
}

/* Light/Dark Toggle Icon States */
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Base Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-color-strong);
}

/* --------------------------------------------------------------------------
   App Layout Structure
   -------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  z-index: 40;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Header Search */
.header-search {
  flex: 1;
  max-width: 580px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 40px;
  padding: 0 68px 0 42px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input-wrapper input:focus {
  border-color: var(--border-focus);
  background-color: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-shortcut {
  position: absolute;
  right: 36px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
  pointer-events: none;
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.clear-search-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

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

.view-mode-group {
  display: flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.view-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.view-mode-btn.active, .view-mode-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.view-mode-btn.active {
  color: var(--accent-primary);
}

/* --------------------------------------------------------------------------
   Buttons & Common UI Elements
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(47, 129, 247, 0.3);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 12px rgba(47, 129, 247, 0.45);
}

.btn-outline {
  background: var(--bg-tertiary);
  border-color: var(--border-color-strong);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-elevated);
  border-color: var(--border-focus);
}

.btn-danger {
  background: var(--accent-danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--accent-danger-hover);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-color-strong);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover {
  text-decoration: underline;
  color: var(--accent-primary-hover);
}

.tiny-btn {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.tiny-btn:hover {
  text-decoration: underline;
}

.mobile-menu-btn {
  display: none;
}

/* --------------------------------------------------------------------------
   Workspace Layout: Sidebar + Main Content
   -------------------------------------------------------------------------- */
.workspace-body {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
  position: relative;
}

/* Left Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 20px;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 20;
  transition: transform var(--transition-base);
}

.storage-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.storage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.storage-info {
  display: flex;
  flex-direction: column;
}

.storage-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.storage-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.storage-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: rgba(47, 129, 247, 0.15);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.storage-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 10px;
}

.storage-progress {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #a855f7);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.storage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.db-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #3fb950;
  background: rgba(35, 134, 54, 0.15);
  border: 1px solid rgba(35, 134, 54, 0.3);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.db-status-badge.offline {
  color: #d29922;
  background: rgba(210, 153, 34, 0.15);
  border-color: rgba(210, 153, 34, 0.3);
}

.db-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  display: inline-block;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Sidebar Section Titles & Nav */
.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(47, 129, 247, 0.15);
  color: var(--accent-primary);
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon.type-image { color: var(--color-image); }
.nav-icon.type-video { color: var(--color-video); }
.nav-icon.type-audio { color: var(--color-audio); }
.nav-icon.type-doc { color: var(--color-doc); }
.nav-icon.type-code { color: var(--color-code); }
.nav-icon.type-star { color: #eab308; }

.nav-label {
  flex: 1;
}

.nav-count {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-tertiary);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.nav-item.active .nav-count {
  background: var(--accent-primary);
  color: #fff;
}

/* Status Filter Chips */
.chip-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.status-chip:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.status-chip.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  font-weight: 600;
  border-color: var(--text-primary);
}

/* Tag Cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 4px;
}

.empty-tags-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag-badge:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.tag-badge.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.tag-count {
  opacity: 0.75;
  font-size: 0.7rem;
}

/* Form selects in sidebar */
.filter-controls-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.form-select-sm, .form-select {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color-strong);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.form-select {
  padding: 6px 12px;
  font-size: 0.88rem;
  border-radius: var(--radius-md);
}

.form-select-sm:focus, .form-select:focus {
  border-color: var(--border-focus);
}

/* Sidebar Backup & Tools */
.sidebar-footer-section {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.sidebar-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sidebar-tools-grid.sidebar-tools-grid-4 {
  grid-template-columns: repeat(2, 1fr);
}

/* --------------------------------------------------------------------------
   Main Content Area
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  overflow-y: auto;
  position: relative;
  padding: 20px 24px 60px 24px;
}

.main-content.admin-view > :not(#adminScreen) {
  display: none !important;
}

.admin-screen {
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

.admin-screen-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--border-color);
}

.admin-screen-header h1 {
  margin: 6px 0 8px;
  font-size: 1.8rem;
}

.admin-screen-header p,
.admin-danger-copy p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.eyebrow-label {
  color: var(--accent-primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-status-badge,
.admin-danger-count {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.admin-status-badge {
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-full);
  padding: 6px 10px;
  white-space: nowrap;
}

.admin-danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 28px;
  padding: 24px;
  border: 1px solid rgba(248, 81, 73, 0.45);
  border-radius: var(--radius-md);
  background: rgba(248, 81, 73, 0.06);
}

.admin-danger-copy {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.admin-danger-copy h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.admin-danger-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-danger);
  color: #fff;
  font-weight: 800;
}

.admin-danger-count {
  display: block;
  margin-top: 10px;
}

@media (max-width: 640px) {
  .admin-screen-header,
  .admin-danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-danger-zone .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Toolbar */
.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.active-filter-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-main-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.items-count-badge {
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sort-control-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Checkbox Custom Styling */
.checkbox-wrapper {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.checkbox-wrapper input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color-strong);
  border-radius: 4px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.checkbox-wrapper:hover .custom-checkbox {
  border-color: var(--accent-primary);
}

.checkbox-wrapper input:checked ~ .custom-checkbox {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-wrapper input:checked ~ .custom-checkbox::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

/* Batch Action Floating Bar */
.batch-action-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.2s ease-out;
  gap: 12px;
}

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

.batch-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.batch-count-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.batch-action-btn {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.batch-action-btn:hover { text-decoration: underline; }

.batch-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-batch {
  background: var(--bg-tertiary);
  border-color: var(--border-color-strong);
  color: var(--text-primary);
}
.btn-batch:hover {
  background: var(--bg-primary);
  border-color: var(--accent-primary);
}

/* Active Filter Ribbon */
.active-filter-ribbon {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(47, 129, 247, 0.08);
  border: 1px solid rgba(47, 129, 247, 0.2);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.ribbon-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.ribbon-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color-strong);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  color: var(--text-primary);
}

.remove-filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  font-size: 1rem;
  line-height: 1;
}
.remove-filter-btn:hover { color: var(--accent-danger); }

.clear-all-filters-btn {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
}
.clear-all-filters-btn:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Drag & Drop Curtain
   -------------------------------------------------------------------------- */
.drag-drop-curtain {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drag-drop-curtain.active {
  display: flex;
}

.curtain-box {
  border: 3px dashed var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: 40px 60px;
  text-align: center;
  background: var(--bg-card);
  box-shadow: var(--shadow-glow);
  color: var(--accent-primary);
}

.curtain-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 12px;
  color: var(--text-primary);
}

.curtain-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Items Views: Grid, List, Compact
   -------------------------------------------------------------------------- */
.items-view-container {
  min-height: 300px;
}

/* GRID VIEW */
.items-view-container.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.file-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  cursor: pointer;
}

.file-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-color-strong);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.file-card.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary);
}

/* Card Media Preview Area */
.card-thumb-wrapper {
  position: relative;
  height: 160px;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.file-card:hover .card-thumb-image {
  transform: scale(1.04);
}

.card-thumb-icon-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.card-thumb-ext-badge {
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* Floating Overlays on Thumbnail */
.card-overlay-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}

.card-check-box {
  background: rgba(13, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}

.card-star-btn {
  background: rgba(13, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.card-star-btn:hover { color: #facc15; }
.card-star-btn.starred { color: #eab308; }

.card-play-overlay-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: all var(--transition-fast);
}

.file-card:hover .card-play-overlay-btn {
  transform: scale(1.1);
  opacity: 1;
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.card-type-chip {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(4px);
  color: #fff;
}

.card-duration-chip {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
}

/* Card Body & Metadata */
.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-filename {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.card-status-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
}
.card-status-badge.status-published { background: rgba(35, 134, 54, 0.2); color: #3fb950; }
.card-status-badge.status-draft { background: rgba(210, 153, 34, 0.2); color: #d29922; }
.card-status-badge.status-review { background: rgba(163, 113, 247, 0.2); color: #a371f7; }
.card-status-badge.status-archived { background: rgba(110, 118, 129, 0.2); color: #8b949e; }

.card-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.card-tag-pill {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Card Actions Footer */
.card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.card-act-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.card-act-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.card-act-btn.delete-act:hover {
  color: var(--accent-danger);
  background: rgba(218, 54, 51, 0.15);
}

/* LIST VIEW */
.items-view-container.list-view {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item-row {
  display: grid;
  grid-template-columns: 36px 48px 2fr 1.2fr 100px 140px 120px;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.list-item-row:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
}

.list-item-row.selected {
  border-color: var(--accent-primary);
  background: rgba(47, 129, 247, 0.08);
}

.list-thumb-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.list-title-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-filename {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.list-tags-col {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow: hidden;
  max-height: 24px;
}

.list-size-col {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.list-date-col {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.list-actions-col {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* COMPACT VIEW */
.items-view-container.compact-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.compact-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.compact-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
  transform: translateY(-2px);
}

.compact-card.selected {
  border-color: var(--accent-primary);
}

.compact-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.compact-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.compact-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Empty State */
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  margin: 20px 0;
}

.empty-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 440px;
  margin-bottom: 24px;
}

.empty-actions {
  display: flex;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   Modals & Dialogs
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog.modal-lg {
  max-width: 780px;
}

.modal-dialog.modal-sm {
  max-width: 440px;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header-danger {
  border-bottom-color: rgba(218, 54, 51, 0.3);
  background: rgba(218, 54, 51, 0.08);
}

.modal-header-danger .modal-title-group {
  color: var(--accent-danger);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.modal-title-group h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.footer-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

#textShareModal { z-index: 160; }
.text-share-dialog { max-width: 520px; }
.text-share-preview { overflow: hidden; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-primary); }
.text-share-header { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); font-size: 0.78rem; font-weight: 600; }
.text-share-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-success); }
.text-share-thread { display: flex; justify-content: flex-end; padding: 14px 12px; }
.text-share-bubble { width: min(100%, 360px); overflow: hidden; border-radius: 16px 16px 4px 16px; background: #16804a; color: #fff; }
.text-share-bubble-text { margin: 0; padding: 10px 12px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.88rem; line-height: 1.4; }
.text-share-bubble-text:empty { display: none; }
.text-share-link-card { display: block; margin: 8px; overflow: hidden; border-radius: var(--radius-sm); background: #f5f7f8; color: #17212b; text-decoration: none; }
.text-share-image { display: block; width: 100%; max-height: 190px; aspect-ratio: 1.91; object-fit: cover; }
.text-share-image[hidden] { display: none; }
.text-share-card-copy { display: flex; flex-direction: column; gap: 3px; padding: 9px 10px; overflow-wrap: anywhere; }
.text-share-card-copy strong { font-size: 0.84rem; line-height: 1.3; }
.text-share-card-copy span { color: #52616a; font-size: 0.76rem; line-height: 1.35; }
.text-share-card-copy small { color: #78868e; font-size: 0.68rem; }
.text-share-label { display: block; margin: 2px 0 6px; color: var(--text-secondary); font-size: 0.82rem; font-weight: 600; }
#textShareMessage { width: 100%; resize: vertical; }
.text-share-length { margin: 6px 0 0; color: var(--text-muted); font-size: 0.75rem; }

/* Upload Dropzone */
.upload-dropzone {
  border: 2px dashed var(--border-color-strong);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  background: var(--bg-tertiary);
  margin-bottom: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background: rgba(47, 129, 247, 0.08);
}

.dropzone-icon {
  color: var(--accent-primary);
  margin-bottom: 10px;
}

.dropzone-main-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.dropzone-main-text strong {
  color: var(--accent-primary);
}

.dropzone-sub-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.selected-file-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.preview-thumbnail {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.preview-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-meta {
  flex: 1;
  overflow: hidden;
}

.preview-filename {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-size-type {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* File Summary Strip in Edit Modal */
.file-summary-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  border: 1px solid var(--border-color);
}

.strip-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.strip-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.strip-type-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-primary);
}

.strip-size-meta {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* Forms & Metadata Inputs */
.metadata-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-row-2 { grid-template-columns: repeat(2, 1fr); }
.form-row-3 { grid-template-columns: 1.2fr 1.2fr 1fr; }

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

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group label .required {
  color: var(--accent-danger);
}

.form-input, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-elevated);
}

.datetime-input-group {
  display: flex;
  gap: 6px;
}

.datetime-input-group input {
  flex: 1;
}

/* Star Rating Controls */
.star-rating-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.star-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.star-btn:hover {
  transform: scale(1.2);
}

.star-btn.active {
  color: #eab308;
}

.star-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 6px;
}

/* Tags Input Wrapper */
.tags-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  min-height: 42px;
}

.tags-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(47, 129, 247, 0.2);
  color: var(--accent-primary);
  border: 1px solid rgba(47, 129, 247, 0.4);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.tag-remove-x {
  background: none;
  border: none;
  color: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.tag-field-input {
  flex: 1;
  min-width: 120px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

.suggested-tags-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.sugg-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sugg-tag-btn {
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-color-strong);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.sugg-tag-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-style: solid;
}

/* Custom Properties List */
.custom-props-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.custom-props-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-prop-row {
  display: grid;
  grid-template-columns: 1fr 1fr 32px;
  gap: 8px;
  align-items: center;
}

.remove-prop-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.remove-prop-btn:hover {
  color: var(--accent-danger);
  background: rgba(218, 54, 51, 0.15);
}

/* Shortcuts Dialog Grid */
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.shortcut-key {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--accent-primary);
}

.shortcut-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Media Viewer & Fullscreen Player
   -------------------------------------------------------------------------- */
.viewer-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(10px);
  z-index: 150;
  display: none;
  flex-direction: column;
}

.viewer-modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.viewer-container {
  display: flex;
  flex-direction: column;
  width: min(96vw, 1400px);
  height: min(94vh, 900px);
  height: min(94dvh, 900px);
  margin: auto;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
}

.viewer-modal-backdrop:fullscreen {
  background: var(--bg-primary);
}

.viewer-modal-backdrop:fullscreen .viewer-container {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.viewer-modal-backdrop:fullscreen .viewer-header {
  position: absolute;
  inset: 0 0 auto;
  background: linear-gradient(to bottom, rgba(12, 16, 24, 0.9), transparent);
  border: 0;
}

.viewer-modal-backdrop:fullscreen .viewer-stage-wrapper {
  height: 100%;
  min-height: 0;
}

.viewer-modal-backdrop:fullscreen .viewer-stage {
  min-width: 0;
  min-height: 0;
}

.viewer-modal-backdrop:fullscreen .viewer-stage.image-controls-toggle {
  padding: 0;
}

.viewer-modal-backdrop:fullscreen .viewer-sidebar,
.viewer-modal-backdrop:fullscreen #viewerToggleSidebarBtn {
  display: none;
}

.viewer-modal-backdrop:fullscreen .image-display {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

.exit-fs-icon {
  display: none;
}

.viewer-modal-backdrop:fullscreen .enter-fs-icon {
  display: none;
}

.viewer-modal-backdrop:fullscreen .exit-fs-icon {
  display: block;
}

.viewer-header {
  height: 60px;
  background: rgba(22, 27, 34, 0.95);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 20;
}

.viewer-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.viewer-type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--accent-primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

.viewer-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.viewer-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

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

.viewer-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color-strong);
  margin: 0 4px;
}

.viewer-act-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.viewer-act-btn:hover {
  background: var(--accent-primary);
  color: #fff;
}

.viewer-close-btn {
  background: rgba(218, 54, 51, 0.2);
  border: 1px solid var(--accent-danger);
  color: #f85149;
}
.viewer-close-btn:hover {
  background: var(--accent-danger);
  color: #fff;
}

.viewer-stage-wrapper {
  display: flex;
  flex: 1;
  height: calc(100% - 60px);
  overflow: hidden;
  position: relative;
}

.viewer-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  position: relative;
  touch-action: pan-y;
}

.viewer-stage.image-controls-toggle {
  cursor: pointer;
}

.image-display {
  cursor: default;
}

/* Viewer Sidebar */
.viewer-sidebar {
  width: 320px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform var(--transition-base), width var(--transition-base);
}

.viewer-sidebar.collapsed {
  display: none;
}

.viewer-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}
.viewer-sidebar-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.viewer-sidebar-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.85rem;
  color: var(--text-primary);
  word-break: break-word;
}

/* Image Player inside Viewer */
.image-viewer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.image-display {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s ease;
  user-select: none;
}

.image-toolbar {
  position: absolute;
  bottom: 20px;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
}

.image-toolbar.is-hidden {
  display: none;
}

.img-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}
.img-ctrl-btn:hover { background: var(--bg-elevated); color: var(--accent-primary); }

/* Video Player inside Viewer */
.video-player-wrapper {
  width: 100%;
  max-width: 1080px;
  max-height: 80vh;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
}

.video-player-element {
  width: 100%;
  max-height: 70vh;
  outline: none;
}

.video-custom-controls {
  background: rgba(22, 27, 34, 0.95);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border-color);
}

/* Audio Player inside Viewer */
.audio-player-wrapper {
  width: 100%;
  max-width: 640px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.audio-hero-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.audio-disc-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
  animation: spinSlow 8s linear infinite;
  animation-play-state: paused;
}

.audio-disc-icon.playing {
  animation-play-state: running;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.audio-track-info {
  flex: 1;
  overflow: hidden;
}

.audio-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.audio-artist {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Visualizer Canvas */
.audio-visualizer-canvas {
  width: 100%;
  height: 80px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.audio-progress-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-timeline-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}
.audio-timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-glow);
}

.audio-time-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.audio-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audio-main-ctrls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audio-play-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(47, 129, 247, 0.4);
  transition: transform var(--transition-fast);
}

.audio-play-btn:hover {
  transform: scale(1.08);
}

/* Text / Code / Markdown Viewer */
.text-viewer-container {
  width: 100%;
  max-width: 900px;
  height: 75vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.text-viewer-toolbar {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-viewer-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-primary);
  background: var(--bg-primary);
}

.markdown-rendered-view {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  white-space: normal;
  line-height: 1.7;
}
.markdown-rendered-view h1, 
.markdown-rendered-view h2, 
.markdown-rendered-view h3 {
  margin-top: 1.2em;
  margin-bottom: 0.6em;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}
.markdown-rendered-view p { margin-bottom: 1em; }
.markdown-rendered-view code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: 2px 5px;
  border-radius: 4px;
}
.markdown-rendered-view pre {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1em 0;
}

/* Generic / Binary File Viewer */
.binary-viewer-container {
  width: 100%;
  max-width: 520px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}

.binary-icon-box {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

/* --------------------------------------------------------------------------
   Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  animation: slideLeft 0.25s ease-out;
  min-width: 280px;
  max-width: 420px;
}

@keyframes slideLeft {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.toast-success { border-left: 4px solid var(--accent-success); }
.toast.toast-danger { border-left: 4px solid var(--accent-danger); }
.toast.toast-info { border-left: 4px solid var(--accent-primary); }

.toast-message {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
}

.toast-undo-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color-strong);
  color: var(--accent-primary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.toast-undo-btn:hover { background: var(--bg-elevated); }

/* --------------------------------------------------------------------------
   Responsive Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .list-item-row {
    grid-template-columns: 36px 44px 2fr 1fr 100px;
  }
  .list-size-col, .list-tags-col { display: none; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .search-shortcut { display: none; }
  .viewer-sidebar { display: none; }
}

/* --------------------------------------------------------------------------
   Mobile Layout Refinements
   -------------------------------------------------------------------------- */
.app-layout {
  height: 100vh;
  height: 100dvh;
}

@media (max-width: 768px) {
  .app-header {
    height: auto;
    min-height: 108px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "search search";
    gap: 8px 12px;
    padding: 10px 16px;
  }

  .header-left {
    grid-area: brand;
    min-width: 0;
    gap: 8px;
  }

  .header-right {
    grid-area: actions;
    justify-self: end;
    gap: 6px;
  }

  .header-search {
    grid-area: search;
    width: 100%;
    max-width: none;
  }

  .workspace-body {
    height: auto;
    min-height: 0;
  }

  .sidebar {
    width: min(88vw, 320px);
    max-width: 100%;
  }

  .workspace-body:has(.sidebar.open)::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 19;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(2px);
  }

  .main-content {
    min-width: 0;
    padding: 16px 18px calc(32px + env(safe-area-inset-bottom));
  }

  .content-toolbar {
    align-items: flex-start;
  }

  .toolbar-left,
  .toolbar-right,
  .sort-control-wrapper {
    min-width: 0;
  }

  .sort-control-wrapper {
    flex-wrap: wrap;
  }

  .sort-control-wrapper .form-select {
    max-width: min(100%, 320px);
  }

  .batch-action-bar,
  .batch-bar-left,
  .batch-bar-right {
    flex-wrap: wrap;
  }

  .batch-bar-right {
    justify-content: flex-start;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-dialog,
  .modal-dialog.modal-lg,
  .modal-dialog.modal-sm {
    width: 100%;
    max-width: none;
    max-height: min(94vh, 900px);
    max-height: min(94dvh, 900px);
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-body {
    min-height: 0;
    overscroll-behavior: contain;
  }

  .viewer-header {
    height: auto;
    min-height: 60px;
    gap: 8px;
    padding: 8px 12px;
  }

  .viewer-header-info {
    min-width: 0;
    gap: 8px;
  }

  .viewer-title {
    max-width: 28vw;
    font-size: 0.9rem;
  }

  .viewer-header-actions {
    flex-shrink: 0;
    gap: 4px;
  }

  .viewer-header-actions .icon-btn {
    width: 34px;
    height: 36px;
  }

  .viewer-stage-wrapper {
    min-height: 0;
    height: auto;
  }

  .viewer-stage {
    min-width: 0;
    padding: 12px;
  }
}

@media (max-width: 560px) {
  .app-header {
    gap: 8px;
    padding: 9px 12px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .header-right {
    gap: 4px;
  }

  .header-right > .icon-btn,
  .header-right > .btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
  }

  .view-mode-btn {
    min-width: 36px;
    min-height: 36px;
  }

  .search-input-wrapper input,
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
  }

  .card-act-btn {
    min-width: 32px;
    min-height: 32px;
  }

  .header-right > .btn span,
  .header-right > #shortcutsHelpBtn {
    display: none;
  }

  .view-mode-btn {
    padding: 6px 7px;
  }

  .main-content {
    padding: 14px 12px calc(28px + env(safe-area-inset-bottom));
  }

  .content-toolbar {
    gap: 10px;
  }

  .toolbar-left {
    gap: 8px;
  }

  .active-filter-indicator {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .filter-main-title {
    font-size: 1.15rem;
  }

  .sort-label {
    display: none;
  }

  .sort-control-wrapper .form-select {
    width: min(100%, 260px);
    font-size: 0.82rem;
  }

  .items-view-container.grid-view,
  .items-view-container.compact-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card-thumb-wrapper {
    height: 118px;
  }

  .card-body {
    padding: 10px;
    gap: 6px;
  }

  .card-title {
    font-size: 0.86rem;
  }

  .card-filename {
    font-size: 0.68rem;
  }

  .card-meta-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .card-footer {
    padding: 8px 10px;
  }

  .list-item-row {
    grid-template-columns: 28px 40px minmax(0, 1fr) 72px;
    gap: 7px;
    padding: 7px 8px;
  }

  .list-thumb-box {
    width: 40px;
    height: 40px;
  }

  .list-date-col,
  .list-size-col,
  .list-tags-col {
    display: none;
  }

  .list-title {
    font-size: 0.82rem;
  }

  .batch-action-bar {
    align-items: flex-start;
    padding: 10px;
  }

  .batch-bar-left {
    gap: 8px;
  }

  .batch-bar-right .btn span {
    display: none;
  }

  .batch-bar-right .btn {
    width: 38px;
    min-width: 38px;
    height: 36px;
    padding: 0;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-title-group {
    min-width: 0;
  }

  .modal-title-group h3 {
    font-size: 0.95rem;
  }

  .modal-footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .viewer-type-badge,
  .viewer-meta,
  .viewer-divider,
  #viewerToggleSidebarBtn {
    display: none;
  }

  .viewer-title {
    max-width: 30vw;
    font-size: 0.82rem;
  }

  .viewer-header-actions .icon-btn {
    width: 32px;
    height: 34px;
  }

  .viewer-stage {
    padding: 8px;
  }

  .image-toolbar {
    max-width: calc(100vw - 20px);
    overflow-x: auto;
  }

}

@media (max-width: 380px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-right: 8px;
    padding-left: 8px;
  }

  .header-left {
    gap: 5px;
  }

  .brand-container {
    gap: 6px;
  }

  .brand-badge,
  #viewCompactBtn {
    display: none;
  }

  .main-content {
    padding-right: 10px;
    padding-left: 10px;
  }
}

@media (hover: none) {
  .file-card:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
