/**
 * Content-DB Styles
 * Mobile-first responsive design with CSS variables
 */

/* ==========================================================================
   CSS VARIABLES
   ========================================================================== */
:root {
  /* Colors - Electric Cream theme */
  --color-cream: #faf8f5;
  --color-cream-dark: #f0ebe3;
  --color-ink: #1a1a1a;
  --color-ink-light: #333333;
  --color-ink-muted: #666666;
  --color-electric: #e94560;
  --color-electric-dark: #d13b54;
  --color-electric-light: #f06b80;
  
  /* Semantic colors */
  --color-bg: var(--color-cream);
  --color-bg-secondary: var(--color-cream-dark);
  --color-text: var(--color-ink);
  --color-text-secondary: var(--color-ink-light);
  --color-text-muted: var(--color-ink-muted);
  --color-primary: var(--color-electric);
  --color-primary-dark: var(--color-electric-dark);
  --color-primary-light: var(--color-electric-light);
  
  /* Border color — visible in both themes */
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-subtle: rgba(0, 0, 0, 0.05);
  
  /* Status colors */
  --color-success: #2ecc71;
  --color-warning: #f39c12;
  --color-error: #e74c3c;
  --color-info: #3498db;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Layout */
  --header-height: 56px;
  --bottom-nav-height: 64px;
  --max-width: 1200px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #121212;
    --color-bg-secondary: #1e1e1e;
    --color-text: #e8e6e3;
    --color-text-secondary: #c0bdb8;
    --color-text-muted: #7a7a7a;
    
    /* Dark mode borders — use light rgba */
    --color-border: rgba(255, 255, 255, 0.1);
    --color-border-subtle: rgba(255, 255, 255, 0.06);
    
    /* Darker shadows for dark mode */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  }
}

/* ==========================================================================
   BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--header-height) + var(--safe-top));
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Mobile viewport fix */
@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
  }
}

img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* Display */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

/* Spacing */
.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.m-xs { margin: var(--space-xs); }
.m-sm { margin: var(--space-sm); }
.m-md { margin: var(--space-md); }
.m-lg { margin: var(--space-lg); }

/* Text */
.text-sm { font-size: 0.875rem; }
.text-md { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Visibility */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
#app {
  min-height: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: calc(var(--space-md) + var(--safe-left));
  padding-right: calc(var(--space-md) + var(--safe-right));
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@media (prefers-color-scheme: dark) {
  .app-header {
    background: rgba(18, 18, 18, 0.85);
  }
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
}

.header-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  color: var(--color-text-secondary);
}

.header-btn:hover,
.header-btn:active {
  background: var(--color-bg-secondary);
}

/* ==========================================================================
   BOTTOM NAVIGATION
   ========================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

@media (prefers-color-scheme: dark) {
  .bottom-nav {
    background: rgba(18, 18, 18, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item span {
  font-size: 0.6875rem;
  font-weight: 500;
}

.nav-item.active {
  color: var(--color-primary);
}

/* Highlighted nav item (Add button) */
.nav-item.highlight {
  position: relative;
}

.nav-item.highlight svg {
  background: var(--color-primary);
  color: white;
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: var(--radius-full);
  transform: translateY(-6px);
  box-shadow: 0 4px 12px rgba(233, 69, 96, 0.35);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.nav-item.highlight:active svg {
  transform: translateY(-4px);
  box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

.nav-item.highlight span {
  transform: translateY(-4px);
  color: var(--color-primary);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-secondary);
  border-color: var(--color-text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-bg-secondary);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.875rem;
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
}

/* ==========================================================================
   FORMS
   ========================================================================== */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--color-text-secondary);
}

.form-label .required {
  color: var(--color-error);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

.form-help {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border-subtle);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Content Card */
.content-card {
  position: relative;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--color-border-subtle);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.content-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.content-card.selected {
  box-shadow: 0 0 0 2px var(--color-primary);
}

.card-thumbnail {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--color-bg-secondary);
}

@media (prefers-color-scheme: dark) {
  .card-thumbnail {
    background: #2a2a2a;
  }
}

.card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-base);
}

.content-card:hover .card-thumbnail img {
  transform: scale(1.05);
}

.card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.card-duration {
  position: absolute;
  bottom: var(--space-sm);
  right: var(--space-sm);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.card-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.content-card:hover .card-play-overlay {
  opacity: 1;
}

.card-play-overlay svg {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-full);
  padding: 8px;
  color: var(--color-ink);
}

.card-select-indicator {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: all var(--transition-fast);
}

.content-card.selected .card-select-indicator {
  opacity: 1;
  transform: scale(1);
  background: var(--color-primary);
  color: white;
}

.card-info {
  padding: var(--space-sm);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-collection {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-xs);
}

.card-tag {
  font-size: 0.6875rem;
  color: var(--color-primary);
  background: rgba(233, 69, 96, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.card-tag-more {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

/* Collection Card */
.collection-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.collection-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
}

.collection-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.collection-info {
  flex: 1;
  min-width: 0;
}

.collection-name {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.collection-count {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.collection-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-menu-btn {
  padding: var(--space-sm);
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
}

.collection-menu-btn:hover {
  background: var(--color-bg);
}

/* ==========================================================================
   SEARCH
   ========================================================================== */
.search-container {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-top));
  left: 0;
  right: 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  z-index: 90;
  transform: translateY(-100%);
  opacity: 0;
  transition: all var(--transition-base);
  pointer-events: none;
}

.search-container.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--space-md);
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md) var(--space-sm) 2.5rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.search-clear {
  position: absolute;
  right: var(--space-sm);
  padding: var(--space-xs);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
}

.search-clear.visible {
  opacity: 1;
  visibility: visible;
}

.search-clear:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* ==========================================================================
   FILTER CHIPS
   ========================================================================== */
.filter-chips-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md) 0;
}

.filter-chips {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: var(--space-xs);
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.filter-chip:hover {
  border-color: var(--color-text-muted);
}

.filter-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

/* Sort chips — slightly smaller/muted to distinguish from type filters */
.sort-chips .filter-chip {
  font-size: 0.75rem;
  padding: 4px 12px;
}

/* ==========================================================================
   GRID LAYOUT
   ========================================================================== */
.content-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  padding: var(--space-md);
}

@media (min-width: 480px) {
  .content-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .content-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
  }
}

@media (min-width: 1024px) {
  .content-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ==========================================================================
   COLLECTIONS LIST
   ========================================================================== */
.collections-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
}

.collections-header {
  padding: var(--space-sm) var(--space-md) 0;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

@media (prefers-color-scheme: dark) {
  .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
  }
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  width: 100%;
  max-height: 90vh;
  background: var(--color-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transform: translateY(100%);
  transition: transform var(--transition-base);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-bottom: none;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: var(--space-lg);
  }
  
  .modal-container {
    max-width: 480px;
    border-radius: var(--radius-xl);
    border-bottom: 1px solid var(--color-border);
    transform: translateY(20px) scale(0.95);
  }
  
  .modal-overlay.active .modal-container {
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
}

.modal-close:hover {
  background: var(--color-bg-secondary);
}

.modal-content {
  padding: var(--space-lg);
  overflow-y: auto;
  max-height: calc(90vh - 60px);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: 0 var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-tab {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
}

.modal-tab.active {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.tab-panel {
  display: none;
  padding: var(--space-lg);
}

.tab-panel.active {
  display: block;
}

/* File Dropzone */
.file-dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.file-dropzone:hover,
.file-dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(233, 69, 96, 0.05);
}

.dropzone-content svg {
  margin-bottom: var(--space-md);
  color: var(--color-text-muted);
}

.dropzone-content p {
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-lg));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  padding: 0 var(--space-md);
  width: 100%;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-ink);
  color: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-base);
  pointer-events: auto;
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: #2d2d2d;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: var(--color-success);
}

.toast-error {
  background: var(--color-error);
}

.toast-warning {
  background: var(--color-warning);
}

.toast-info {
  background: var(--color-info);
}

.toast-icon {
  flex-shrink: 0;
}

.toast-message {
  font-size: 0.9375rem;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  /* Allow the empty state to center in the grid */
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-lg);
  opacity: 0.4;
  /* Make SVG icons inside render bigger */
}

.empty-icon svg {
  width: 56px;
  height: 56px;
  stroke-width: 1.5;
  color: var(--color-text-muted);
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}

.empty-state p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  max-width: 280px;
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-bg-secondary);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 60px;
  height: 60px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: var(--space-md);
}

.loading-screen p {
  color: var(--color-text-muted);
}

/* Skeleton Loader */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-secondary) 25%,
    var(--color-bg) 50%,
    var(--color-bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(
      90deg,
      #1e1e1e 25%,
      #2a2a2a 50%,
      #1e1e1e 75%
    );
    background-size: 200% 100%;
  }
}

.skeleton-card {
  aspect-ratio: 1;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   FAB (FLOATING ACTION BUTTON)
   ========================================================================== */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-md));
  right: calc(var(--space-md) + var(--safe-right));
  width: 56px;
  height: 56px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(233, 69, 96, 0.35);
  transition: all var(--transition-fast);
  z-index: 150;
}

.fab:hover {
  transform: scale(1.05);
  background: var(--color-primary-dark);
}

.fab:active {
  transform: scale(0.95);
}

/* ==========================================================================
   CONTEXT MENU
   ========================================================================== */
.context-menu {
  position: fixed;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: var(--space-xs);
  min-width: 160px;
  z-index: 250;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--color-text);
  transition: background var(--transition-fast);
}

.context-item:hover {
  background: var(--color-bg-secondary);
}

.context-item.danger {
  color: var(--color-error);
}

/* ==========================================================================
   COLOR PICKER
   ========================================================================== */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.color-option {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
  border: 2px solid transparent;
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.selected {
  border-color: var(--color-text);
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-text);
}

/* ==========================================================================
   VIEWER PAGE
   ========================================================================== */
.viewer-container {
  position: fixed;
  inset: 0;
  background: var(--color-ink);
  z-index: 150;
  display: flex;
  flex-direction: column;
}

.viewer-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  padding-top: calc(var(--space-md) + var(--safe-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
  z-index: 10;
}

.viewer-header button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viewer-content img,
.viewer-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.viewer-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + var(--safe-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  color: white;
  transform: translateY(calc(100% - 60px));
  transition: transform var(--transition-base);
}

.viewer-info.expanded {
  transform: translateY(0);
}

.viewer-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.viewer-meta {
  font-size: 0.875rem;
  opacity: 0.8;
}

.viewer-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.viewer-action {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: white;
  backdrop-filter: blur(4px);
}

/* ==========================================================================
   SETUP PAGE
   ========================================================================== */
.setup-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-xl);
  padding-top: calc(var(--space-xl) + var(--safe-top));
}

.setup-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.setup-logo {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.setup-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.setup-header p {
  color: var(--color-text-muted);
}

.setup-form {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.setup-section {
  margin-bottom: var(--space-xl);
}

.setup-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--color-text-secondary);
}

.setup-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

/* ==========================================================================
   SETTINGS PAGE
   ========================================================================== */
.settings-container {
  padding: var(--space-md);
}

.settings-section {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.settings-section-title {
  padding: var(--space-md) var(--space-lg);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border-subtle);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border-subtle);
}

.settings-item:first-of-type {
  border-top: none;
}

.settings-item-label {
  font-weight: 500;
}

.settings-item-value {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.settings-item-button {
  color: var(--color-primary);
  font-size: 0.875rem;
  font-weight: 500;
}

.text-danger {
  color: var(--color-error) !important;
}

/* ==========================================================================
   INSTALL PROMPT (dark mode fix)
   ========================================================================== */
#install-prompt {
  background: var(--color-bg) !important;
  border: 1px solid var(--color-border);
}

/* ==========================================================================
   PULL TO REFRESH
   ========================================================================== */
.ptr-indicator {
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.ptr-indicator.visible {
  top: calc(var(--header-height) + var(--space-md));
}

.ptr-indicator.spinning .spinner {
  animation: spin 0.6s linear infinite;
}

/* ==========================================================================
   OFFLINE INDICATOR
   ========================================================================== */
body.offline::before {
  content: 'Offline';
  position: fixed;
  top: calc(var(--header-height) + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-warning);
  color: white;
  padding: var(--space-xs) var(--space-md);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 99;
}

/* ==========================================================================
   ERROR STATES
   ========================================================================== */
.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: var(--space-xl);
  text-align: center;
}

.error-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
}

.error-screen h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.error-screen p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-xl);
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease;
}

.animate-fade-in-up {
  animation: fadeInUp 0.3s ease;
}

/* ==========================================================================
   SCROLLBAR STYLING
   ========================================================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-text-muted);
  border-radius: var(--radius-full);
  opacity: 0.3;
}

::-webkit-scrollbar-thumb:hover {
  opacity: 0.5;
}

/* ==========================================================================
   SELECTION MODE
   ========================================================================== */
.selection-bar {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  background: var(--color-primary);
  color: white;
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 95;
  transform: translateY(100%);
  transition: transform var(--transition-base);
}

.selection-bar.active {
  transform: translateY(0);
}

.selection-count {
  font-weight: 600;
}

.selection-actions {
  display: flex;
  gap: var(--space-md);
}

.selection-action {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */
@media (max-width: 360px) {
  :root {
    --space-md: 0.75rem;
    --space-lg: 1rem;
  }
  
  .content-grid {
    gap: var(--space-xs);
    padding: var(--space-sm);
  }
}

/* Tablet and above */
@media (min-width: 768px) {
  .app-header {
    padding-left: calc(var(--space-xl) + var(--safe-left));
    padding-right: calc(var(--space-xl) + var(--safe-right));
  }
  
  .setup-container {
    padding: var(--space-2xl);
  }
  
  .settings-container {
    padding: var(--space-xl);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .app-header,
  .bottom-nav,
  .fab {
    display: none !important;
  }
  
  body {
    padding: 0;
  }
}