/* ============================================================
   ZOOMER — Precision Dark Design System
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Accent */
  --accent:          #3B82F6;
  --accent-bright:   #60A5FA;
  --accent-dim:      rgba(59, 130, 246, 0.15);
  --accent-border:   rgba(59, 130, 246, 0.45);
  --amber:           #F59E0B;
  --amber-dim:       rgba(245, 158, 11, 0.15);
  --green:           #10B981;
  --green-dim:       rgba(16, 185, 129, 0.15);
  --danger:          #EF4444;
  --danger-dim:      rgba(239, 68, 68, 0.15);
  --purple:          #8B5CF6;

  /* Surfaces — tight stepped grays */
  --s0:  #000000;
  --s1:  #0A0A0A;
  --s2:  #111111;
  --s3:  #181818;
  --s4:  #202020;
  --s5:  #2A2A2A;
  --s6:  #333333;

  /* Borders */
  --b1:  rgba(255, 255, 255, 0.06);
  --b2:  rgba(255, 255, 255, 0.10);
  --b3:  rgba(255, 255, 255, 0.16);
  --b4:  rgba(255, 255, 255, 0.24);

  /* Text */
  --t1:  rgba(255, 255, 255, 0.95);
  --t2:  rgba(255, 255, 255, 0.65);
  --t3:  rgba(255, 255, 255, 0.38);
  --t4:  rgba(255, 255, 255, 0.20);

  /* Typography — system fonts only (CSP: style-src 'self') */
  --font-ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Menlo', 'Monaco', 'Cascadia Mono', 'Consolas', monospace;

  /* Radii */
  --r-sm:  4px;
  --r-md:  7px;
  --r-lg:  10px;
  --r-xl:  14px;

  /* Shadows */
  --shadow-card:  0 1px 3px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.3);
  --shadow-float: 0 8px 30px rgba(0,0,0,0.7), 0 2px 8px rgba(0,0,0,0.5);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.8), 0 4px 16px rgba(0,0,0,0.5);
  --glow-accent:  0 0 0 1px var(--accent-border), 0 0 16px var(--accent-dim);
}

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

/* ── Base ──────────────────────────────────────────────────── */
body {
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--s0);
  color: var(--t1);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}

/* ── Scrollbars ────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--s6); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--b4); }

/* ── Global Buttons ────────────────────────────────────────── */
button {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

button:hover:not(:disabled) { background: var(--accent-bright); }
button:active:not(:disabled) { opacity: 0.85; }
button:disabled { background: var(--s5); color: var(--t3); cursor: not-allowed; }

.primary-btn {
  background: var(--accent);
  margin-top: 10px;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-bright); }

.secondary-btn {
  background: var(--s5);
  color: var(--t2);
  border: 1px solid var(--b2);
  margin-top: 10px;
}
.secondary-btn:hover:not(:disabled) { background: var(--s6); color: var(--t1); border-color: var(--b3); }

/* ── Browser: top bar action buttons ──────────────────────── */
.browser-action-btn,
.slideshow-back-btn {
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 500;
  background: var(--s4);
  color: var(--t2);
  border: 1px solid var(--b2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.browser-action-btn:hover { background: var(--s5); color: var(--t1); border-color: var(--b3); }
.slideshow-back-btn:hover { background: var(--s5); color: var(--t1); border-color: var(--b3); }
.browser-action-btn.downloading::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 5px;
  vertical-align: middle;
  animation: dl-pulse 1.2s ease-in-out infinite;
}
@keyframes dl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.download-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--r-md);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.download-indicator:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.5);
}
.download-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: dl-pulse 1.2s ease-in-out infinite;
}

.play-btn {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}
.play-btn:hover:not(:disabled) { background: #0EA573; box-shadow: 0 0 12px rgba(16,185,129,0.35); }
.play-btn:disabled { background: var(--s5); color: var(--t3); cursor: not-allowed; box-shadow: none; }

.queue-btn {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s;
}
.queue-btn:hover { background: var(--accent-bright); }

.delete-btn {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s;
}
.delete-btn:hover { background: #F87171; }

.scan-btn {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  background: var(--amber);
  color: #000;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s;
}
.scan-btn:hover { background: #FCD34D; }

.close-btn, .rescan-btn {
  background: none;
  border: none;
  color: var(--t3);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: background 0.15s, color 0.15s;
}
.close-btn:hover { background: var(--s5); color: var(--t1); }
.rescan-btn:hover { background: var(--accent-dim); color: var(--accent); transform: rotate(180deg); }

/* ── Icon Button (slideshow) ───────────────────────────────── */
.icon-btn {
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--t2);
  border: 1px solid var(--b2);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.2s;
}
.icon-btn:hover { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent-bright); }
#settings-btn:hover { transform: rotate(90deg); }

/* ── Icon Buttons Container ────────────────────────────────── */
.icon-buttons {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 10px;
  z-index: 1000;
  transition: left 0.3s ease-in-out;
}

/* ── Slideshow ─────────────────────────────────────────────── */
.main-content,
.slideshow-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.slideshow-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.92);
  border-bottom: 1px solid var(--b1);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 100;
}

#slideshow-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: radial-gradient(ellipse at center, #0d0d0d 0%, #000 100%);
}

#media-rotate-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 0.3s ease;
}

#main-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  transform-origin: center center;
  opacity: 1;
  will-change: transform, opacity;
  filter: drop-shadow(0 12px 40px rgba(0,0,0,0.7));
}
#main-image.loading { opacity: 0.2; }
#main-image.zooming { transition: transform 2s cubic-bezier(0.4, 0, 0.2, 1); }
#main-image.instant { transition: none; }

#main-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center center;
  will-change: transform;
  filter: drop-shadow(0 12px 40px rgba(0,0,0,0.7));
}
#main-video.instant { transition: none; }

#controls {
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.88);
  border-top: 1px solid var(--b1);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

#info {
  display: flex;
  gap: 15px;
  align-items: center;
}

#image-title {
  color: var(--t2);
  font-size: 13px;
  font-family: var(--font-mono);
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.control-buttons button {
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--s4);
  border: 1px solid var(--b2);
  color: var(--t1);
}
.control-buttons button:hover:not(:disabled) { background: var(--accent); border-color: transparent; }

.control-trash-btn {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}
.control-trash-btn:hover:not(:disabled) { background: rgba(239, 68, 68, 0.4) !important; }

/* Video Controls */
#video-controls {
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.88);
  border-top: 1px solid var(--b1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seek-container {
  display: flex;
  align-items: center;
  gap: 10px;
}
.seek-container span {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t3);
  min-width: 40px;
  text-align: center;
}

#seek-bar,
#volume-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--s6);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
#seek-bar { flex: 1; }
#volume-slider { width: 80px; }

#seek-bar::-webkit-slider-thumb,
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(59,130,246,0.5);
}

.video-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

#mute-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  border-radius: 50%;
  background: var(--s4);
  border: 1px solid var(--b2);
  color: var(--t2);
}
#mute-btn:hover { background: var(--s5); color: var(--t1); }

#speed-select {
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--s4);
  color: var(--t1);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  cursor: pointer;
}
#speed-select:focus { outline: none; border-color: var(--accent-border); }
#speed-select option { background: var(--s3); }

.media-badge {
  display: inline-block;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 3px;
  margin-left: 10px;
}
.media-badge.image { background: var(--green-dim); color: var(--green); }
.media-badge.video { background: var(--amber-dim); color: var(--amber); }

#loading-indicator {
  color: var(--accent);
  font-size: 11px;
  font-family: var(--font-mono);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* Fullscreen overrides */
body.fullscreen #controls,
body.fullscreen #info,
body.fullscreen .icon-buttons,
body.fullscreen .slideshow-topbar,
body.fullscreen #video-controls {
  position: fixed; left: 0; right: 0;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
body.fullscreen .slideshow-topbar { top: 0; z-index: 1000; }
body.fullscreen #controls { bottom: 0; }
body.fullscreen #video-controls { bottom: 0; }
body.fullscreen.show-ui #controls,
body.fullscreen.show-ui #info,
body.fullscreen.show-ui .icon-buttons,
body.fullscreen.show-ui .slideshow-topbar,
body.fullscreen.show-ui #video-controls { opacity: 1; pointer-events: auto; }
body.fullscreen .side-panel.open { opacity: 1; pointer-events: auto; }

/* ── Side Panel ────────────────────────────────────────────── */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 0;
  height: 100vh;
  background: rgba(14, 14, 14, 0.97);
  backdrop-filter: blur(20px);
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid var(--b1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.6);
  z-index: 500;
}
.side-panel.open { width: 320px; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--b1);
  width: 320px;
}
.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.01em;
}

.panel-content {
  padding: 16px 20px;
  overflow-y: auto;
  height: calc(100vh - 62px);
  display: flex;
  flex-direction: column;
  width: 320px;
}

.panel-group {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
}
.panel-group:has(.directory-list),
.panel-group:has(.image-list) { flex: 1; min-height: 0; }
.panel-group label {
  display: block;
  color: var(--t2);
  margin-bottom: 8px;
  font-size: 13px;
}
.panel-group input[type="range"] {
  width: 100%;
  height: 3px;
  background: var(--s5);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.panel-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #fff;
}
.panel-group input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--accent);
  cursor: pointer;
  border-radius: 50%;
  border: none;
}
.panel-group input[type="checkbox"] {
  margin-right: 8px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

#duration-value, #zoom-multiplier-value,
#smoothness-value, #keyframe-interval-value {
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent-bright);
}

/* Settings sections */
.settings-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--b1);
}
.settings-section:last-child { border-bottom: none; margin-bottom: 0; }
.settings-section h3 {
  color: var(--t3);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.settings-section .panel-group { margin-bottom: 14px; }
.settings-section .panel-group:last-child { margin-bottom: 0; }

/* Directory list */
.directory-list, .image-list, .media-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--b1);
  border-radius: var(--r-md);
  background: var(--s1);
  min-height: 0;
}
.directory-list:empty::before,
.image-list:empty::before,
.media-list:empty::before {
  content: 'None found';
  display: block;
  padding: 24px;
  text-align: center;
  color: var(--t3);
  font-size: 12px;
}
.directory-item {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-bottom: 1px solid var(--b1);
  gap: 8px;
  transition: background 0.1s;
}
.directory-item:last-child { border-bottom: none; }
.directory-item:hover { background: var(--s2); }
.directory-header {
  font-size: 13px;
  color: var(--t1);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}
.directory-header:hover { color: var(--accent-bright); }
.directory-item.disabled .directory-header { color: var(--t3); }
.directory-buttons { display: flex; align-items: center; gap: 8px; }

/* Toggles */
.directory-toggle, .image-toggle, .media-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  position: relative;
  cursor: pointer;
}
.directory-toggle input,
.image-toggle input,
.media-toggle input { opacity: 0; width: 0; height: 0; }
.directory-toggle-slider,
.image-toggle-slider,
.media-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--s5);
  border: 1px solid var(--b2);
  transition: background 0.25s, border-color 0.25s;
  border-radius: 10px;
}
.directory-toggle-slider::before,
.image-toggle-slider::before,
.media-toggle-slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  transition: transform 0.25s;
  border-radius: 50%;
}
.directory-toggle input:checked + .directory-toggle-slider,
.image-toggle input:checked + .image-toggle-slider,
.media-toggle input:checked + .media-toggle-slider {
  background: var(--accent);
  border-color: transparent;
}
.directory-toggle input:checked + .directory-toggle-slider::before,
.image-toggle input:checked + .image-toggle-slider::before,
.media-toggle input:checked + .media-toggle-slider::before { transform: translateX(16px); }

.directory-remove-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 11px;
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--r-sm);
  min-width: auto;
}
.directory-remove-btn:hover { background: var(--danger); color: #fff; border-color: transparent; }

.add-directory-btn {
  width: 100%;
  padding: 7px 12px;
  margin-bottom: 10px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.2);
  font-size: 13px;
}
.add-directory-btn:hover { background: var(--green); color: #fff; border-color: transparent; }

.back-btn {
  padding: 3px 10px;
  font-size: 12px;
  background: var(--s5);
  color: var(--t2);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  min-width: auto;
}
.back-btn:hover { background: var(--s6); color: var(--t1); }

/* Image / media list items */
.image-item, .media-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--b1);
  gap: 10px;
  min-height: 56px;
  transition: background 0.1s;
  cursor: pointer;
}
.image-item:last-child, .media-item:last-child { border-bottom: none; }
.image-item:hover, .media-item:hover { background: var(--s2); }
.image-item.active, .media-item.active {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

.image-thumbnail, .media-thumbnail {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--b2);
  flex-shrink: 0;
  background: var(--s3);
}
.image-item.disabled .image-thumbnail,
.media-item.disabled .media-thumbnail { opacity: 0.35; filter: grayscale(1); }
.image-name, .media-name {
  flex: 1;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-item.disabled .image-name,
.media-item.disabled .media-name { color: var(--t3); }

.image-selector-header, .media-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.image-selector-header h3, .media-selector-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-type-indicator {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.media-type-indicator.image { background: var(--green-dim); color: var(--green); }
.media-type-indicator.video { background: var(--amber-dim); color: var(--amber); }

.directory-clean-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 11px;
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--r-sm);
  min-width: auto;
}
.directory-clean-btn:hover { background: var(--amber); color: #000; border-color: transparent; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: modal-in 0.15s ease;
}
@keyframes modal-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-content {
  background: var(--s3);
  border: 1px solid var(--b2);
  padding: 28px 30px;
  border-radius: var(--r-xl);
  min-width: 380px;
  max-width: 580px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-modal);
  animation: modal-rise 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-rise {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-content h2 {
  margin-bottom: 18px;
  font-size: 18px;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.02em;
}
.modal-content p {
  margin: 8px 0;
  color: var(--t2);
  font-size: 13px;
  line-height: 1.5;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--s5);
  border-radius: 2px;
  margin: 18px 0;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.2s ease;
  width: 0%;
  border-radius: 2px;
}

.error-list {
  text-align: left;
  max-height: 180px;
  overflow-y: auto;
  margin: 12px 0;
  padding-left: 16px;
  color: #FF6B6B;
  font-size: 12px;
  font-family: var(--font-mono);
}
.error-list li { margin: 4px 0; }
.error-list:empty { display: none; }

/* Rename Modal */
.rename-modal-content {
  min-width: 340px;
  max-width: 440px;
  text-align: left;
}
.rename-modal-content h2 {
  text-align: left;
  margin-bottom: 14px;
}
.rename-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--s2);
  color: var(--t1);
  border: 1px solid var(--b3);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 16px;
}
.rename-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.rename-input::placeholder { color: var(--t3); }
.rename-modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.rename-modal-footer button { margin-top: 0; }

/* ── Progress / Results modals (process) ───────────────────── */
#mod-progress-modal .modal-content,
#mod-results-modal .modal-content { max-width: 420px; }

/* ── Dir Picker Modal ──────────────────────────────────────── */
.dir-picker-content {
  min-width: 380px;
  max-width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.dir-picker-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--b2);
  border-radius: var(--r-md);
  background: var(--s2);
  margin: 12px 0 18px;
  max-height: 360px;
  min-height: 120px;
}
.dir-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--t2);
  cursor: pointer;
  border-bottom: 1px solid var(--b1);
  transition: background 0.1s, color 0.1s;
}
.dir-picker-item:last-child { border-bottom: none; }
.dir-picker-item:hover { background: var(--s3); color: var(--t1); }
.dir-picker-item.selected { background: var(--accent-dim); color: var(--accent-bright); }
.dir-picker-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-picker-item-count { font-size: 10px; color: var(--t3); flex-shrink: 0; }
.dir-picker-footer { display: flex; gap: 8px; justify-content: flex-end; }
.dir-picker-footer button { margin-top: 0; }
.dir-picker-loading { padding: 28px; text-align: center; color: var(--t3); font-size: 13px; }

/* Drop Overlay (drag files from Finder onto browser window) */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.drop-overlay.active {
  pointer-events: all;
}
.drop-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 2px dashed var(--accent);
  border-radius: var(--r-xl);
  padding: 48px 64px;
  box-shadow: var(--glow-accent);
  background: var(--accent-dim);
}
.drop-overlay-icon { font-size: 40px; color: var(--accent); }
.drop-overlay-title { font-size: 20px; font-weight: 600; color: var(--t1); }
.drop-overlay-dest { font-size: 13px; color: var(--t3); }
.drop-overlay-dest span { color: var(--t2); font-family: ui-monospace, monospace; }

/* Upload Modal */
.upload-modal-content { width: 540px; max-width: 95vw; text-align: left; }
.upload-modal-content h2 { text-align: left; }
.upload-dropzone {
  border: 1.5px dashed var(--b3);
  border-radius: var(--r-lg);
  padding: 28px 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 12px;
  cursor: default;
}
.upload-dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.upload-dropzone-icon { font-size: 32px; color: var(--t3); margin-bottom: 8px; }
.upload-dropzone-hint { color: var(--t3); font-size: 13px; margin-bottom: 14px; }
.upload-btn-group { display: flex; gap: 10px; justify-content: center; }
.upload-label-btn { cursor: pointer; padding: 7px 16px; font-size: 12px; }
.upload-file-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.upload-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-sm);
  min-width: 0;
}
.upload-item-name {
  flex: 1;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-item-bar {
  width: 80px;
  height: 3px;
  background: var(--s5);
  border-radius: 2px;
  flex-shrink: 0;
  overflow: hidden;
}
.upload-item-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}
.upload-item-status {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t3);
  min-width: 52px;
  text-align: right;
  flex-shrink: 0;
}
.upload-item-ok  { color: var(--green);  }
.upload-item-err { color: var(--danger); }
.upload-footer { display: flex; justify-content: space-between; align-items: center; }
#upload-status-text { font-size: 12px; color: var(--t3); font-family: var(--font-mono); }

/* ============================================================
   FILE BROWSER
   ============================================================ */

#page-browser { position: relative; }

/* Browser body: sidebar + main content */
.browser-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.browser-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--s2);
  border-right: 1px solid var(--b1);
  overflow-y: auto;
  padding: 10px 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

.sidebar-item {
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--t2);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.sidebar-item:hover {
  background: var(--s4);
  color: var(--t1);
}

.sidebar-item.active {
  color: var(--t1);
  font-weight: 500;
  cursor: default;
}

.sidebar-item.active:hover {
  background: transparent;
}

.sidebar-item-root {
  color: var(--accent);
  font-weight: 500;
  padding-left: 14px;
}

.sidebar-item-root:hover {
  color: var(--accent-bright);
}

.sidebar-item-root.active {
  color: var(--t1);
}

.sidebar-item.drag-over {
  background: var(--accent-dim);
  color: var(--t1);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-divider {
  height: 1px;
  background: var(--b1);
  margin: 6px 10px;
}

.browser-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Top bar */
.browser-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
  gap: 10px;
  z-index: 50;
}

.browser-primary-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

/* Toolbar separator */
.browser-toolbar-sep {
  width: 1px;
  height: 14px;
  background: var(--b2);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Overflow menu */
.browser-overflow-wrap {
  position: relative;
  flex-shrink: 0;
}

.overflow-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r-md);
  color: var(--t2);
  font-size: 16px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  padding-bottom: 4px;
  font-family: var(--font-ui);
}
.overflow-btn:hover,
.overflow-btn.open { background: var(--s5); color: var(--t1); border-color: var(--b3); }

.overflow-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
  padding: 6px;
  box-shadow: var(--shadow-float);
  z-index: 300;
  flex-direction: column;
  gap: 2px;
}
.overflow-dropdown.open { display: flex; }

.overflow-item {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  color: var(--t1);
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.1s;
}
.overflow-item:hover { background: var(--s5); }
.overflow-item-danger { color: var(--danger); }
.overflow-item-danger:hover { background: var(--danger-dim); }

.overflow-divider {
  height: 1px;
  background: var(--b1);
  margin: 4px 0;
}

/* Sort button */
.sort-btn {
  font-family: var(--font-mono);
  min-width: 68px;
  text-align: center;
}

/* Status bar */
.browser-statusbar {
  padding: 4px 16px;
  background: var(--s2);
  border-top: 1px solid var(--b1);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  user-select: none;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 1px;
  font-size: 13px;
  font-family: var(--font-mono);
  flex: 1;
  min-width: 0;
}
.breadcrumb-segment {
  color: var(--accent);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  transition: background 0.15s;
  white-space: nowrap;
}
.breadcrumb-segment:hover { background: var(--accent-dim); }
.breadcrumb-segment:last-child { color: var(--t1); cursor: default; }
.breadcrumb-segment:last-child:hover { background: transparent; }
.breadcrumb-separator { color: var(--t4); padding: 0 2px; }

/* Selection count */
.selection-count {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent-bright);
  font-weight: 500;
  white-space: nowrap;
  padding: 3px 10px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 20px;
}

.queue-toggle-btn.has-items {
  border-color: var(--accent-border);
  color: var(--accent-bright);
  background: var(--accent-dim);
}

/* Inline Viewer */

/* Grid */
.browser-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  grid-auto-rows: min-content;
  gap: 14px;
  align-content: start;
}

.browser-loading,
.browser-empty,
.browser-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--t3);
  font-size: 14px;
}
.browser-error { color: var(--danger); }

/* Tag filter bar */
.tags-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.tag-filter-chip {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 11px;
  border-radius: 20px;
  border: 1px solid var(--b2);
  background: var(--s3);
  color: var(--t2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.tag-filter-chip:hover { background: var(--s4); border-color: var(--b3); color: var(--t1); }
.tag-filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent-bright);
}

/* Tag chips on directory cards */
.grid-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 10px 8px;
  margin-top: -2px;
}
.tag-chip {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--tag-color, var(--s4));
  color: #fff;
  opacity: 0.9;
  white-space: nowrap;
}
.tag-chip-more {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--s4);
  color: var(--t3);
}

/* Tags modal */
.tags-modal-content {
  width: 360px;
  max-width: 95vw;
}
.tags-modal-dirname {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t3);
  margin: -8px 0 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tags-modal-list {
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--b1);
  border-radius: var(--r-md);
  background: var(--s2);
  margin-bottom: 4px;
}
.tags-modal-list:empty::after {
  content: 'No tags yet — create one below';
  display: block;
  padding: 16px;
  font-size: 12px;
  color: var(--t4);
  text-align: center;
}
.tags-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--b1);
}
.tags-modal-item:last-child { border-bottom: none; }
.tags-modal-item:hover { background: var(--s3); }
.tags-modal-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--accent); width: 14px; height: 14px; }
.tags-modal-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--tag-color, var(--s4));
}
.tags-modal-item-label { font-size: 13px; color: var(--t1); flex: 1; }
.tags-add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.tags-add-row .rename-input { flex: 1; }
.tags-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* Grid item — the card */
.grid-item {
  position: relative;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color 0.18s,
    background 0.18s,
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.18s;
}
.grid-item:hover {
  background: var(--s3);
  border-color: var(--b3);
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-card);
}
.grid-item.selected {
  border-color: var(--accent);
  background: var(--s3);
  box-shadow: var(--glow-accent);
}

/* Drag states */
.grid-item.dragging {
  opacity: 0.4;
  pointer-events: none;
}
.grid-item-folder.drag-over {
  border-color: var(--accent-border);
  background: var(--accent-dim);
  box-shadow: var(--glow-accent);
  transform: scale(1.03);
}

/* Checkbox */
.grid-item-checkbox-area {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.18s;
}
.grid-item:hover .grid-item-checkbox-area,
.grid-item.selected .grid-item-checkbox-area { opacity: 1; }
.grid-item-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
  border-radius: 4px;
}

/* Preview area */
.grid-item-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--s1);
  position: relative;
}
.grid-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.grid-item:hover .grid-item-preview img { transform: scale(1.04); }

.grid-item-folder-icon {
  font-size: 44px;
  background: var(--s1);
}

.grid-item-video-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  backdrop-filter: blur(2px);
}

/* Type badges */
.grid-item-type-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  pointer-events: none;
  z-index: 2;
  line-height: 1.4;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
}
.badge-dir { background: rgba(139, 92, 246, 0.80); color: #fff; }
.badge-img { background: rgba(16, 185, 129, 0.80); color: #fff; }
.badge-vid { background: rgba(245, 158, 11, 0.80); color: #000; }

/* Label / meta */
.grid-item-label {
  padding: 7px 10px 3px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.grid-item-meta {
  padding: 0 10px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--t3);
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: rgba(22, 22, 22, 0.97);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
  padding: 5px 0;
  min-width: 190px;
  z-index: 10000;
  box-shadow: var(--shadow-float);
  animation: menu-in 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes menu-in {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.context-menu-item {
  display: block;
  width: 100%;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--t1);
  background: none;
  border: none;
  border-radius: 0;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
  letter-spacing: 0.005em;
}
.context-menu-item:hover { background: var(--accent-dim); color: var(--accent-bright); }
.context-menu-divider {
  height: 1px;
  background: var(--b1);
  margin: 4px 8px;
  border: none;
}
.context-menu-danger { color: var(--danger); }
.context-menu-danger:hover { background: var(--danger-dim); color: #FCA5A5; }

/* ── Queue Panel ─────────────────────────────────────────────── */
.queue-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 290px;
  height: 100%;
  background: rgba(13, 13, 13, 0.97);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--b1);
  display: flex;
  flex-direction: column;
  z-index: 200;
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
}
.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 14px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.queue-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.01em;
}
.queue-header-actions { display: flex; gap: 6px; align-items: center; }

.queue-list { flex: 1; overflow-y: auto; min-height: 0; }
.queue-list:empty::before {
  content: 'Queue empty';
  display: block;
  padding: 40px 16px;
  text-align: center;
  color: var(--t3);
  font-size: 12px;
  font-family: var(--font-mono);
}
.queue-item {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--b1);
  transition: background 0.1s;
}
.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: var(--s2); }
.queue-item-number {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--t4);
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
}
.queue-item-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  background: var(--s3);
  border: 1px solid var(--b1);
}
.queue-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.queue-item-name {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-item-type {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t3);
}
.queue-item-trash,
.queue-item-remove {
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 12px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--t3);
  transition: background 0.15s, color 0.15s;
}
.queue-item-trash:hover { background: var(--danger-dim); color: var(--danger); }
.queue-item-remove:hover { background: var(--s5); color: var(--t1); }
.queue-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--b1);
  flex-shrink: 0;
}
.queue-footer .play-btn { width: 100%; }

#page-browser.queue-open .browser-grid { margin-right: 290px; }

/* ============================================================
   MODIFICATIONS PAGE
   ============================================================ */
.mod-topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
  z-index: 100;
}
#mod-image-count { font-size: 12px; color: var(--t3); font-family: var(--font-mono); }

.mod-layout { flex: 1; display: flex; min-height: 0; overflow: hidden; }

.mod-sidebar {
  width: 210px;
  flex-shrink: 0;
  border-right: 1px solid var(--b1);
  overflow-y: auto;
  background: var(--s1);
}
.mod-image-list { display: flex; flex-direction: column; }
.mod-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--b1);
  transition: background 0.1s;
}
.mod-list-item:hover { background: var(--s2); }
.mod-list-item.active {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}
.mod-list-item img {
  width: 38px; height: 38px;
  object-fit: cover;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.mod-list-name {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--t2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mod-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #0d0d0d 0%, #000 100%);
  position: relative;
}
#mod-preview-img {
  max-width: 90%;
  max-height: 85%;
  object-fit: contain;
  filter: drop-shadow(0 12px 40px rgba(0,0,0,0.7));
}
.mod-preview-info {
  position: absolute;
  bottom: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t3);
}

.mod-controls {
  width: 270px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 14px;
  border-left: 1px solid var(--b1);
  background: var(--s2);
}
.mod-controls select,
.mod-controls input[type="text"] {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--s1);
  color: var(--t1);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  cursor: pointer;
  margin-top: 4px;
  outline: none;
}
.mod-controls select:focus,
.mod-controls input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.mod-controls select option { background: var(--s3); }

#mod-saturation-value, #mod-brightness-value, #mod-contrast-value,
#mod-scale-value, #mod-quality-value {
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent-bright);
}

.mod-bottombar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--s2);
  border-top: 1px solid var(--b1);
  flex-shrink: 0;
}
.proc-current-btn {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.25);
  border-radius: var(--r-md);
}
.proc-current-btn:hover:not(:disabled) { background: var(--green); color: #fff; border-color: transparent; }
.proc-all-btn {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  border-radius: var(--r-md);
}
.proc-all-btn:hover:not(:disabled) { background: var(--accent-bright); }

.modify-btn { padding: 6px 16px; font-size: 13px; font-weight: 600; border-radius: var(--r-md); }

/* ============================================================
   GALLERY PAGE
   ============================================================ */
.gallery-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.95);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
#gallery-counter {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--t3);
  background: var(--s3);
  border: 1px solid var(--b2);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
#gallery-filename {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--t2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.gallery-icon-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  font-size: 16px;
  width: 30px;
  height: 28px;
  cursor: pointer;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
  flex-shrink: 0;
}
.gallery-icon-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent-bright);
}

.gallery-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Directory sidebar inside gallery */
.gallery-dir-sidebar {
  width: 200px;
  min-width: 160px;
  flex-shrink: 0;
  overflow-y: auto;
  background: rgba(6, 6, 6, 0.98);
  border-right: 1px solid var(--b1);
}

/* Right view container */
.gallery-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.gallery-body {
  flex: 1;
  display: flex;
  align-items: stretch;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #0d0d0d 0%, #000 100%);
  min-height: 0;
}
.gallery-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 0;
  transform-origin: 50% 50%;
  will-change: transform;
}
.gallery-main.zoomed { cursor: grab; }
.gallery-main.dragging { cursor: grabbing !important; }
.gallery-main.zoom-animated { transition: transform 0.22s ease; }

#gallery-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 48px rgba(0,0,0,0.8));
  transition: opacity 0.15s ease;
}
#gallery-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 48px rgba(0,0,0,0.8));
}

/* Nav arrows */
.gallery-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 72px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.5);
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--r-md);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  padding: 0;
  backdrop-filter: blur(8px);
}
.gallery-nav-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent-bright);
}
.gallery-nav-prev { left: 14px; }
.gallery-nav-next { right: 14px; }

/* Thumb strip */
.gallery-thumbstrip {
  height: 82px;
  flex-shrink: 0;
  background: rgba(8, 8, 8, 0.97);
  border-top: 1px solid var(--b1);
  overflow: hidden;
}
.gallery-thumbstrip-track {
  display: flex;
  gap: 5px;
  padding: 8px 14px;
  overflow-x: auto;
  height: 100%;
  align-items: center;
  scroll-behavior: smooth;
}
.gallery-thumbstrip-track::-webkit-scrollbar { height: 3px; }
.gallery-thumbstrip-track::-webkit-scrollbar-thumb { background: var(--s6); border-radius: 2px; }

.gallery-thumb {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.18s, opacity 0.18s, transform 0.18s;
  background: var(--s3);
  opacity: 0.55;
}
.gallery-thumb:hover { border-color: var(--b3); opacity: 0.85; transform: scale(1.06); }
.gallery-thumb.active { border-color: var(--accent); opacity: 1; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb-video {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--t3);
  background: var(--s2);
}

/* ============================================================
   CROP OVERLAY
   ============================================================ */
#gallery-crop-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  user-select: none;
}
#gallery-crop-sel {
  position: absolute;
  border: 1.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.58);
  cursor: move;
  box-sizing: border-box;
}
/* Rule-of-thirds guides */
.crop-rule {
  position: absolute;
  background: rgba(255,255,255,0.18);
  pointer-events: none;
}
.crop-rule-h1, .crop-rule-h2 {
  left: 0; right: 0; height: 1px;
}
.crop-rule-h1 { top: 33.33%; }
.crop-rule-h2 { top: 66.66%; }
.crop-rule-v1, .crop-rule-v2 {
  top: 0; bottom: 0; width: 1px;
}
.crop-rule-v1 { left: 33.33%; }
.crop-rule-v2 { left: 66.66%; }
/* Resize handles */
.crop-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.4);
  border-radius: 2px;
  z-index: 1;
}
.crop-handle[data-pos="nw"] { top: -5px; left: -5px; cursor: nw-resize; }
.crop-handle[data-pos="n"]  { top: -5px; left: calc(50% - 5px); cursor: n-resize; }
.crop-handle[data-pos="ne"] { top: -5px; right: -5px; cursor: ne-resize; }
.crop-handle[data-pos="e"]  { top: calc(50% - 5px); right: -5px; cursor: e-resize; }
.crop-handle[data-pos="se"] { bottom: -5px; right: -5px; cursor: se-resize; }
.crop-handle[data-pos="s"]  { bottom: -5px; left: calc(50% - 5px); cursor: s-resize; }
.crop-handle[data-pos="sw"] { bottom: -5px; left: -5px; cursor: sw-resize; }
.crop-handle[data-pos="w"]  { top: calc(50% - 5px); left: -5px; cursor: w-resize; }
/* Action buttons */
#gallery-crop-actions {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 201;
  pointer-events: all;
}
.crop-action-btn {
  padding: 7px 18px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.crop-cancel {
  background: rgba(40,40,40,0.92);
  color: rgba(255,255,255,0.65);
}
.crop-cancel:hover { background: rgba(60,60,60,0.98); color: #fff; }
.crop-apply {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.crop-apply:hover { filter: brightness(1.12); }
.crop-apply:disabled { opacity: 0.5; cursor: not-allowed; }
/* Active state for crop toggle button */
#gallery-crop-btn.crop-active {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent-bright);
}

/* ============================================================
   TRASH PAGE
   ============================================================ */
.trash-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
  z-index: 100;
}
#trash-item-count { font-size: 12px; font-family: var(--font-mono); color: var(--t3); }
.trash-topbar-info {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t4);
  margin-left: auto;
}
.trash-topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Trash list + preview layout */
.trash-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.trash-list {
  width: 360px;
  min-width: 240px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--b1);
  background: var(--s1);
}

.trash-list-loading, .trash-list-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--t3);
  font-size: 13px;
}

.trash-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--b1);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.trash-list-row:hover { background: var(--s3); }
.trash-list-row.selected { background: var(--accent-dim); }
.trash-list-row.focused { background: var(--accent-dim); outline: 1px solid var(--accent-border) inset; }

.trash-list-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.trash-list-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--s4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.trash-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trash-list-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.trash-list-name {
  font-size: 13px;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.trash-list-meta {
  font-size: 11px;
  color: var(--t3);
  font-family: var(--font-mono);
}

.trash-countdown-badge {
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono);
  border-radius: 3px;
  flex-shrink: 0;
}
.countdown-safe   { background: rgba(16,185,129,0.25); color: var(--green); }
.countdown-warning { background: rgba(245,158,11,0.25); color: var(--amber); }
.countdown-urgent  { background: rgba(239,68,68,0.25); color: var(--danger); }

/* Preview panel */
.trash-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--s0);
  overflow: hidden;
  padding: 24px;
}

.trash-preview-empty {
  color: var(--t4);
  font-size: 13px;
  text-align: center;
}

.trash-preview-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}
.trash-preview-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
}
.trash-preview-icon {
  font-size: 72px;
  opacity: 0.5;
}

.trash-preview-details {
  width: 100%;
  max-width: 480px;
  margin-top: 20px;
  flex-shrink: 0;
}
.trash-preview-filename {
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
  text-align: center;
  margin-bottom: 12px;
  word-break: break-all;
}
.trash-preview-meta-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--b1);
  font-size: 12px;
}
.trash-preview-meta-row:last-of-type { border-bottom: none; }
.trash-preview-meta-label { color: var(--t3); }
.trash-preview-meta-value { color: var(--t2); font-family: var(--font-mono); text-align: right; max-width: 60%; word-break: break-all; }

.trash-preview-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.trash-restore-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font-ui);
}
.trash-restore-btn:hover { background: var(--green); color: #fff; border-color: transparent; }

.trash-bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--s2);
  border-top: 1px solid var(--b1);
  flex-shrink: 0;
}
.trash-bottombar span { font-size: 13px; color: var(--t2); }
.trash-bottombar-actions { display: flex; gap: 8px; }
.trash-bottombar-actions .delete-btn { padding: 6px 16px; font-size: 13px; font-weight: 600; }

/* ============================================================
   PROCESSING MODALS (slideshow)
   ============================================================ */
#processing-modal .modal-content { max-width: 400px; }

/* ============================================================
   MISC / UTILITY
   ============================================================ */
#duration-value, #zoom-multiplier-value { font-weight: 600; font-family: var(--font-mono); color: var(--accent-bright); }
#smoothness-value, #keyframe-interval-value { font-weight: 600; font-family: var(--font-mono); color: var(--accent-bright); }
#mod-saturation-value, #mod-brightness-value, #mod-contrast-value,
#mod-scale-value, #mod-quality-value { font-weight: 600; font-family: var(--font-mono); color: var(--accent-bright); }
#confidence-value { font-weight: 600; font-family: var(--font-mono); color: var(--accent-bright); }

/* ── Confirm Modal ─────────────────────────────────────────── */
.confirm-modal-content {
  max-width: 380px;
  text-align: center;
}
.confirm-modal-content p {
  font-size: 14px;
  color: var(--t2);
  line-height: 1.5;
  margin-bottom: 20px;
}
.confirm-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--s4);
  border: 1px solid var(--b3);
  border-radius: var(--r-lg);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--t1);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: all;
  animation: toast-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 400px;
  white-space: nowrap;
}
.toast-undo-btn {
  background: none;
  padding: 3px 10px;
  border: 1px solid var(--accent-border);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--accent-bright);
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.toast-undo-btn:hover { background: var(--accent-dim); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.95); }
}

/* ============================================================
   KEYBOARD SHORTCUTS MODAL
   ============================================================ */
.shortcuts-modal-content { max-width: 540px; width: 100%; }
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 16px;
}
.shortcuts-section h3 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--t3);
  margin-bottom: 10px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
  font-size: 13px;
}
.shortcut-row span {
  color: var(--t2);
  margin-left: auto;
  padding-left: 12px;
}
kbd {
  background: var(--s5);
  border: 1px solid var(--b3);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  padding: 2px 7px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--t1);
  line-height: 1.6;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.browser-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 20px;
  gap: 10px;
}
.empty-state-icon { font-size: 48px; opacity: 0.25; line-height: 1; }
.empty-state-title { font-size: 15px; color: var(--t2); font-weight: 500; margin-top: 4px; }
.empty-state-hint  { font-size: 13px; color: var(--t3); }
.empty-upload-btn  { margin-top: 8px; }

/* ============================================================
   QUEUE DRAG REORDER
   ============================================================ */
.queue-item { cursor: grab; transition: opacity 0.15s; }
.queue-item:active { cursor: grabbing; }
.queue-item.dragging { opacity: 0.35; }
.queue-item.drag-over { border-top: 2px solid var(--accent); }

/* ============================================================
   THUMBNAIL SKELETON
   ============================================================ */
@keyframes skeleton-shimmer {
  to { background-position: 200% 0; }
}
.grid-item-skeleton {
  background: linear-gradient(90deg, var(--s3) 25%, var(--s5) 50%, var(--s3) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite linear;
}

/* ============================================================
   TRASH COUNTDOWN COLORS
   ============================================================ */
.countdown-safe {
  background: var(--green-dim) !important;
  color: var(--green) !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
}
.countdown-warning {
  background: var(--amber-dim) !important;
  color: var(--amber) !important;
  border: 1px solid rgba(245, 158, 11, 0.3) !important;
}
.countdown-urgent {
  background: var(--danger-dim) !important;
  color: var(--danger) !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

/* ============================================================
   MOBILE / RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  /* Collapse primary actions on very small screens */
  .browser-primary-actions .browser-action-btn:not(.sort-btn):not(#select-all-btn):not(#deselect-all-btn) {
    display: none;
  }
  .browser-toolbar-sep { display: none; }

  /* Address bar: shrink on small screens */
  .browser-topbar {
    position: relative;
    gap: 6px;
    padding: 6px 10px;
  }
  .browser-path {
    min-width: 0;
    flex: 1;
  }
  .breadcrumb-part {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
  }

  /* Larger touch targets for topbar buttons */
  .slideshow-back-btn,
  .gallery-icon-btn,
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Gallery nav buttons: bigger tap area */
  .gallery-nav-btn {
    font-size: 36px;
    width: 52px;
  }

  /* Slideshow controls: bigger buttons */
  .control-buttons button {
    min-width: 44px;
    min-height: 44px;
    font-size: 18px;
  }

  /* Shortcuts modal: single column */
  .shortcuts-grid {
    grid-template-columns: 1fr;
  }

  /* Mod page: stack vertically */
  .mod-layout {
    flex-direction: column;
  }
  .mod-sidebar {
    width: 100%;
    max-height: 160px;
    border-right: none;
    border-bottom: 1px solid var(--b1);
  }
  .mod-controls {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--b1);
  }
}

/* ============================================================
   DOWNLOAD DRAWER
   ============================================================ */
.download-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 0;
  height: 100vh;
  background: rgba(14, 14, 14, 0.97);
  backdrop-filter: blur(20px);
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid var(--b1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.6);
  z-index: 600;
  display: flex;
  flex-direction: column;
}
.download-drawer.open { width: 440px; }

.download-drawer-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 100%;
  cursor: ew-resize;
  z-index: 10;
}
.download-drawer-resize-handle:hover,
.download-drawer-resize-handle.resizing {
  background: var(--accent, #4a9eff);
  opacity: 0.5;
}

.download-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.download-drawer-title {
  font-weight: 600;
  font-size: 1rem;
}

.download-drawer-close {
  background: none;
  border: none;
  color: var(--t2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.download-drawer-close:hover { background: var(--s2); color: var(--t1); }

.download-drawer-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
}

.download-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-form label {
  font-size: 0.85rem;
  color: var(--t2);
}

.download-hint {
  opacity: 0.6;
}

.download-urls-input {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: 6px;
  color: var(--t1);
  font-size: 0.9rem;
  font-family: monospace;
  resize: vertical;
  box-sizing: border-box;
}

.download-urls-input:focus {
  outline: none;
  border-color: var(--accent, #4a9eff);
}

.download-log {
  flex: 1;
  background: #0d0d0d;
  border: 1px solid var(--b1);
  border-radius: 6px;
  padding: 12px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #ccc;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.download-save-dir {
  font-size: 0.82rem;
  color: var(--t2);
  padding: 6px 0 2px;
}

.download-saved-dir-path {
  color: var(--accent, #4a9eff);
  font-family: monospace;
  word-break: break-all;
}

.download-progress {
  font-size: 0.85rem;
  color: var(--t2);
  padding: 6px 12px 4px;
  font-family: monospace;
}

.download-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================
   SPLIT VIEW
   ============================================================ */

#page-split {
  flex-direction: column;
  background: var(--s0);
}

/* ── Topbar ─────────────────────────────────────────────────── */
.split-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}

.split-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--t1);
}

.split-hint {
  font-size: 0.72rem;
  color: var(--t3);
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Layout ─────────────────────────────────────────────────── */
.split-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Pane ───────────────────────────────────────────────────── */
.split-pane {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--s0);
  min-width: 0;
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color 0.15s;
}

.split-pane-focused {
  outline-color: var(--accent);
}

.split-pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}

.split-pane-counter {
  font-size: 0.78rem;
  color: var(--t2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.split-pane-filename {
  flex: 1;
  font-size: 0.78rem;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-zoom-reset-btn {
  font-size: 0.7rem;
  color: var(--t3);
  background: var(--s4);
  border: 1px solid var(--b1);
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.split-zoom-reset-btn:hover {
  color: var(--t1);
  background: var(--s5);
}

/* ── Content + Media ────────────────────────────────────────── */
.split-pane-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.split-media-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  will-change: transform;
  cursor: default;
  overflow: hidden;
}

.split-media-wrap.zoomed {
  cursor: grab;
}

.split-media-wrap.dragging {
  cursor: grabbing;
}

.split-media-wrap.zoom-animated {
  transition: transform 0.22s ease;
}

.split-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  display: block;
}

.split-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ── Nav buttons ────────────────────────────────────────────── */
.split-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.45);
  color: var(--t1);
  border: none;
  border-radius: 4px;
  width: 34px;
  height: 60px;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.split-pane-content:hover .split-nav-btn {
  opacity: 0.75;
}

.split-nav-btn:hover {
  opacity: 1 !important;
  background: rgba(0, 0, 0, 0.72);
}

.split-prev-btn { left: 6px; }
.split-next-btn { right: 6px; }

/* ── Divider ────────────────────────────────────────────────── */
.split-divider {
  width: 6px;
  flex-shrink: 0;
  background: var(--b1);
  cursor: ew-resize;
  transition: background 0.15s;
}

.split-divider:hover,
.split-divider.dragging {
  background: var(--accent);
}

/* Image zoom transition within split panes */
.split-image {
  transition: transform 2s ease-out;
}

/* ── Fullscreen button in split topbar ──────────────────────── */
.split-fs-btn {
  background: none;
  border: 1px solid var(--b1);
  border-radius: 4px;
  color: var(--t2);
  font-size: 1rem;
  line-height: 1;
  padding: 3px 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.split-fs-btn:hover { color: var(--t1); background: var(--s2); }

/* ── Quad (2×2) split layout ─────────────────────────────────── */
.split-layout-quad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
  background: var(--b1);
}
.split-layout-quad .split-pane {
  flex: unset;
  min-height: 0;
}

/* ── Split View Fullscreen ───────────────────────────────────── */

/* Topbar becomes a fixed floating overlay, hidden by default */
body.split-fullscreen .split-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  background: rgba(10, 10, 10, 0.88);
  backdrop-filter: blur(10px);
}
body.split-fullscreen.show-ui .split-topbar {
  opacity: 1;
  pointer-events: auto;
}

/* Layout fills the entire viewport once topbar is out of flow */
body.split-fullscreen #page-split {
  position: fixed;
  inset: 0;
}
body.split-fullscreen .split-layout {
  height: 100%;
}

/* Pane headers become floating overlays at the top of each pane */
body.split-fullscreen .split-pane-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(8px);
}
body.split-fullscreen.show-ui .split-pane-header {
  opacity: 1;
  pointer-events: auto;
}

/* Nav arrows always visible on hover in fullscreen */
body.split-fullscreen.show-ui .split-nav-btn {
  opacity: 0.75;
}

/* Focused outline is more subtle in fullscreen */
body.split-fullscreen .split-pane-focused {
  outline-color: rgba(74, 158, 255, 0.4);
}

/* Divider becomes a thin line in fullscreen, glows on show-ui */
body.split-fullscreen .split-divider {
  width: 3px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.25s, width 0.25s;
}
body.split-fullscreen.show-ui .split-divider {
  width: 5px;
  background: var(--b2);
}
body.split-fullscreen .split-divider:hover,
body.split-fullscreen .split-divider.dragging {
  background: var(--accent);
}

/* Inline video-processing overlay */
.split-pane-processing {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 10;
}
.split-pane-processing-bar {
  width: 60%;
  height: 4px;
  background: var(--b2);
  border-radius: 2px;
  overflow: hidden;
}
.split-pane-processing-fill {
  height: 100%;
  background: var(--accent, #4a9eff);
  border-radius: 2px;
  transition: width 0.2s linear;
  width: 0%;
}
.split-pane-processing-text {
  font-size: 0.75rem;
  color: var(--t2);
}

/* ─── Split Playlist Drawer ─────────────────────────────────── */

.split-pl-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
  background: rgba(14, 14, 14, 0.97);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--b1);
  box-shadow: 0 -6px 32px rgba(0, 0, 0, 0.7);
  z-index: 650;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.split-pl-drawer.open {
  height: 40vh;
}

/* Drag handle */
.split-pl-drag-handle {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ns-resize;
  flex-shrink: 0;
}
.split-pl-drag-handle::before {
  content: '';
  width: 44px;
  height: 4px;
  background: var(--b2);
  border-radius: 2px;
  transition: background 0.15s;
}
.split-pl-drag-handle:hover::before {
  background: var(--accent);
}

/* Header */
.split-pl-header {
  display: flex;
  align-items: center;
  padding: 0 20px 10px;
  flex-shrink: 0;
  gap: 12px;
}
.split-pl-title {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
  color: var(--t1);
}
.split-pl-close {
  background: none;
  border: none;
  color: var(--t2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.split-pl-close:hover { background: var(--s2); color: var(--t1); }

/* Mode toggle */
.split-pl-mode-toggle {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.split-pl-mode-btn {
  background: var(--s2);
  border: 1px solid var(--b1);
  color: var(--t3);
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.split-pl-mode-btn:hover { color: var(--t1); }
.split-pl-mode-btn.active {
  background: var(--accent, #4a9eff);
  border-color: var(--accent, #4a9eff);
  color: #fff;
}

/* 4-slot list grid */
.split-pl-lists-quad {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  display: grid !important;
}
.split-pl-lists-quad .split-pl-list {
  min-height: 0;
}

/* Playlist columns */
.split-pl-lists {
  display: flex;
  flex: 1;
  gap: 10px;
  padding: 10px 16px;
  min-height: 0;
}
.split-pl-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--b1);
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}
.split-pl-list-header {
  padding: 8px 12px;
  background: var(--s1);
  border-bottom: 1px solid var(--b1);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}
.split-pl-list-label { flex: 1; }
.split-pl-list-sublabel {
  font-weight: normal;
  color: var(--t3);
  font-size: 0.75rem;
}
.split-pl-list-count {
  color: var(--t3);
  font-weight: normal;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.split-pl-list-clear {
  background: none;
  border: none;
  color: var(--t3);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.split-pl-list-clear:hover { background: var(--s2); color: var(--t1); }

/* Drop zone */
.split-pl-drop-zone {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  min-height: 60px;
  transition: background 0.15s, border 0.15s;
  border: 2px solid transparent;
  border-radius: 0 0 6px 6px;
}
.split-pl-drop-zone.drag-over {
  background: rgba(74, 158, 255, 0.08);
  border-color: var(--accent);
}
.split-pl-drop-empty {
  height: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t3);
  font-size: 0.8rem;
  pointer-events: none;
  border: 1px dashed var(--b2);
  border-radius: 4px;
}

/* Playlist items */
.split-pl-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
}
.split-pl-item:hover { background: var(--s2); }
.split-pl-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--t2);
}
.split-pl-item-type {
  color: var(--t3);
  font-size: 0.7rem;
  flex-shrink: 0;
}
.split-pl-item-remove {
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.75rem;
  opacity: 0;
  flex-shrink: 0;
  line-height: 1;
}
.split-pl-item:hover .split-pl-item-remove { opacity: 1; }
.split-pl-item-remove:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.split-pl-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 18px;
  background: var(--accent, #4a9eff);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
.split-pl-play-btn:hover { background: #3a8eef; }
.split-pl-play-btn:disabled {
  background: var(--s2);
  color: var(--t3);
  cursor: not-allowed;
  opacity: 0.6;
}
