/* ========================================
   YOUWEE - Pure PHP Version
   Design System (ported from React/Tailwind)
   ======================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

/* ======= CSS Variables / Themes ======= */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 215 90% 55%;
  --primary-foreground: 0 0% 100%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 210 80% 95%;
  --accent-foreground: 215 90% 30%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 215 90% 55%;
  --radius: 0.625rem;
  --gradient-from: 200 90% 50%;
  --gradient-via: 215 85% 55%;
  --gradient-to: 230 80% 60%;
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 60px;
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 5.9%;
  --card-foreground: 0 0% 98%;
  --popover: 240 10% 5.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 215 95% 60%;
  --primary-foreground: 215 100% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 215 50% 18%;
  --accent-foreground: 215 95% 85%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 215 95% 60%;
  --gradient-from: 200 95% 35%;
  --gradient-via: 215 90% 40%;
  --gradient-to: 230 85% 45%;
}

/* Themes */
[data-theme="midnight"] { --primary: 262 83% 58%; --primary-foreground: 0 0% 100%; --ring: 262 83% 58%; --gradient-from: 240 60% 50%; --gradient-via: 280 70% 55%; --gradient-to: 320 65% 50%; }
.dark[data-theme="midnight"], [data-theme="midnight"].dark { --primary: 270 80% 65%; --primary-foreground: 0 0% 100%; --ring: 270 80% 65%; --gradient-from: 240 70% 35%; --gradient-via: 280 80% 40%; --gradient-to: 320 75% 35%; }

[data-theme="aurora"] { --primary: 175 80% 40%; --primary-foreground: 0 0% 100%; --ring: 175 80% 40%; --gradient-from: 160 80% 45%; --gradient-via: 190 85% 50%; --gradient-to: 220 80% 55%; }
.dark[data-theme="aurora"], [data-theme="aurora"].dark { --primary: 175 85% 50%; --primary-foreground: 180 100% 10%; --ring: 175 85% 50%; --gradient-from: 160 90% 30%; --gradient-via: 190 95% 35%; --gradient-to: 220 90% 40%; }

[data-theme="sunset"] { --primary: 25 95% 53%; --primary-foreground: 0 0% 100%; --ring: 25 95% 53%; --gradient-from: 15 90% 55%; --gradient-via: 35 95% 55%; --gradient-to: 45 90% 50%; }
.dark[data-theme="sunset"], [data-theme="sunset"].dark { --primary: 30 95% 55%; --primary-foreground: 30 100% 10%; --ring: 30 95% 55%; --gradient-from: 15 85% 40%; --gradient-via: 35 90% 42%; --gradient-to: 45 85% 38%; }

[data-theme="ocean"] { --primary: 215 90% 55%; --primary-foreground: 0 0% 100%; --ring: 215 90% 55%; --gradient-from: 200 90% 50%; --gradient-via: 215 85% 55%; --gradient-to: 230 80% 60%; }
.dark[data-theme="ocean"], [data-theme="ocean"].dark { --primary: 215 95% 60%; --primary-foreground: 215 100% 10%; --ring: 215 95% 60%; --gradient-from: 200 95% 35%; --gradient-via: 215 90% 40%; --gradient-to: 230 85% 45%; }

[data-theme="forest"] { --primary: 152 75% 40%; --primary-foreground: 0 0% 100%; --ring: 152 75% 40%; --gradient-from: 140 70% 40%; --gradient-via: 160 65% 45%; --gradient-to: 175 60% 42%; }
.dark[data-theme="forest"], [data-theme="forest"].dark { --primary: 152 80% 48%; --primary-foreground: 150 100% 10%; --ring: 152 80% 48%; --gradient-from: 140 75% 28%; --gradient-via: 160 70% 32%; --gradient-to: 175 65% 30%; }

[data-theme="candy"] { --primary: 340 85% 55%; --primary-foreground: 0 0% 100%; --ring: 340 85% 55%; --gradient-from: 330 85% 60%; --gradient-via: 350 80% 65%; --gradient-to: 10 85% 60%; }
.dark[data-theme="candy"], [data-theme="candy"].dark { --primary: 340 90% 60%; --primary-foreground: 0 0% 100%; --ring: 340 90% 60%; --gradient-from: 330 90% 42%; --gradient-via: 350 85% 48%; --gradient-to: 10 90% 45%; }

/* ======= Base Reset ======= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; border: 0 solid hsl(var(--border)); }

html { height: 100%; }

body {
  font-family: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ======= Scrollbar ======= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--muted-foreground) / 0.2); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.4); }

/* ======= Layout ======= */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Background gradient orbs */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-orbs::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -20%, hsl(var(--gradient-from) / 0.15), transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 0%, hsl(var(--gradient-via) / 0.12), transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 100%, hsl(var(--gradient-to) / 0.1), transparent 50%);
}
.dark .bg-orbs::before {
  background:
    radial-gradient(ellipse 80% 50% at 20% -20%, hsl(var(--gradient-from) / 0.25), transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 0%, hsl(var(--gradient-via) / 0.2), transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 100%, hsl(var(--gradient-to) / 0.15), transparent 50%);
}

/* ======= Sidebar ======= */
.sidebar {
  width: var(--sidebar-width-collapsed);
  min-width: var(--sidebar-width-collapsed);
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  gap: 0.25rem;
  background: hsl(var(--card) / 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid hsl(var(--border) / 0.5);
  position: relative;
  z-index: 10;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar:hover {
  width: var(--sidebar-width);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  height: 3.5rem;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo img { width: 2rem; height: 2rem; border-radius: 0.5rem; flex-shrink: 0; }

.sidebar-logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar:hover .sidebar-logo-text { opacity: 1; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  color: hsl(var(--muted-foreground));
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
}

.sidebar-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.sidebar-item.active {
  background: linear-gradient(135deg, hsl(var(--gradient-from) / 0.15), hsl(var(--gradient-via) / 0.1), hsl(var(--gradient-to) / 0.15));
  color: hsl(var(--gradient-via));
  font-weight: 600;
}

.sidebar-item svg { flex-shrink: 0; width: 1.25rem; height: 1.25rem; }

.sidebar-item-text {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar:hover .sidebar-item-text { opacity: 1; }

.sidebar-footer { margin-top: auto; }

/* ======= Main Content ======= */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 5;
}

/* ======= Pages ======= */
.page {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
.page.active { display: flex; }

/* ======= Page Header ======= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 3.5rem;
  flex-shrink: 0;
}

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

.divider {
  height: 1px;
  margin: 0 1.5rem;
  background: linear-gradient(to right, transparent, hsl(var(--border) / 0.5), transparent);
  flex-shrink: 0;
}

/* ======= Page Body ======= */
.page-body {
  flex: 1;
  min-height: 0;         /* Critical for flex child scrolling gess! */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  gap: 0.75rem;
}

/* ======= URL Input ======= */
.url-input-wrap {
  position: relative;
  flex-shrink: 0;
}

.url-input {
  width: 100%;
  height: 3.25rem;
  background: hsl(var(--input) / 0.3);
  border: 1px solid hsl(var(--border) / 0.5);
  border-radius: 0.875rem;
  padding: 0 9rem 0 1.25rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: hsl(var(--foreground));
  outline: none;
  transition: all 0.2s;
}

.url-input::placeholder { color: hsl(var(--muted-foreground) / 0.5); }

.url-input:focus {
  border-color: hsl(var(--primary) / 0.5);
  box-shadow: 0 0 0 4px hsl(var(--primary) / 0.1);
}

.url-input-actions {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 0.25rem;
}

/* ======= Buttons ======= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm { height: 2.25rem; padding: 0 0.875rem; font-size: 0.8125rem; }
.btn-md { height: 2.75rem; padding: 0 1.25rem; font-size: 0.875rem; }
.btn-lg { height: 3rem; padding: 0 1.5rem; font-size: 0.9375rem; }
.btn-icon-sm { height: 2.25rem; width: 2.25rem; padding: 0; }
.btn-icon-md { height: 2.75rem; width: 2.75rem; padding: 0; }

.btn-ghost {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.btn-ghost:hover:not(:disabled) { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.btn-outline {
  background: transparent;
  border: 1px solid hsl(var(--border) / 0.6);
  color: hsl(var(--muted-foreground));
}
.btn-outline:hover:not(:disabled) { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.btn-gradient {
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-via)), hsl(var(--gradient-to)));
  color: white;
  position: relative;
  overflow: hidden;
}
.btn-gradient::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsl(var(--gradient-from) / 0), hsl(var(--gradient-via) / 0.5), hsl(var(--gradient-to) / 0));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.btn-gradient:hover:not(:disabled)::before { opacity: 1; }
.btn-gradient:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px hsl(var(--gradient-from) / 0.3), 0 2px 10px hsl(var(--gradient-to) / 0.2);
}

.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn-destructive:hover:not(:disabled) { filter: brightness(1.1); }

.btn-muted {
  background: hsl(var(--secondary) / 0.5);
  border: 1px solid hsl(var(--border) / 0.5);
  color: hsl(var(--muted-foreground));
}
.btn-muted:hover:not(:disabled) { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

/* ======= Settings Bar ======= */
.settings-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.settings-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 0.875rem;
  border-radius: 0.75rem;
  background: hsl(var(--secondary) / 0.5);
  border: 1px solid hsl(var(--border) / 0.5);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  font-family: inherit;
  color: hsl(var(--foreground));
}
.settings-chip:hover { background: hsl(var(--secondary)); }

.settings-chip select {
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1rem;
}

.chip-label { color: hsl(var(--muted-foreground)); }

/* ======= Queue ======= */
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.queue-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.queue-count {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.25rem;
}

.queue-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground) / 0.35);
  border: 2px dashed hsl(var(--border) / 0.3);
  border-radius: 1rem;
  min-height: 10rem;
  padding: 2rem;
  gap: 0.5rem;
}

.queue-empty svg { width: 3rem; height: 3rem; }
.queue-empty p { font-size: 0.875rem; }

/* ======= Queue Item ======= */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem;
  border-radius: 0.875rem;
  background: hsl(var(--card) / 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid hsl(var(--border) / 0.5);
  animation: fade-in-up 0.3s ease-out;
  flex-shrink: 0;
}

.queue-thumb {
  width: 6rem;
  height: 3.5rem;
  border-radius: 0.5rem;
  overflow: hidden;
  flex-shrink: 0;
  background: hsl(var(--muted));
  position: relative;
}

.queue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground) / 0.3);
}

.queue-info { flex: 1; min-width: 0; }

.queue-title-text {
  font-size: 0.8125rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: hsl(var(--foreground));
}

.queue-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.queue-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: hsl(var(--secondary));
}

.queue-status-badge.pending { color: hsl(var(--muted-foreground)); }
.queue-status-badge.fetching { color: hsl(var(--primary)); background: hsl(var(--primary) / 0.1); }
.queue-status-badge.downloading { color: hsl(var(--gradient-via)); background: hsl(var(--gradient-via) / 0.15); }
.queue-status-badge.completed { color: #10b981; background: #10b981 / 10; background: rgba(16, 185, 129, 0.1); }
.queue-status-badge.error { color: hsl(var(--destructive)); background: hsl(var(--destructive) / 0.1); }

/* Progress bar */
.queue-progress { margin-top: 0.375rem; }
.progress-bar-track {
  height: 0.25rem;
  border-radius: 9999px;
  background: hsl(var(--muted));
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, hsl(var(--gradient-from)), hsl(var(--gradient-via)), hsl(var(--gradient-to)));
  background-size: 200% 100%;
  transition: width 0.5s ease;
  animation: progress-shine 2s ease-in-out infinite;
}

@keyframes progress-shine {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.queue-actions { display: flex; align-items: center; gap: 0.25rem; }

/* ======= Footer Action Bar ======= */
.page-footer {
  flex-shrink: 0;
  padding: 0.75rem 1.5rem 1rem;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.action-bar .btn-gradient { flex: 1; height: 2.75rem; }

/* ======= Gradient Text ======= */
.gradient-text {
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-via)), hsl(var(--gradient-to)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ======= Glass ======= */
.glass {
  background: hsl(var(--card) / 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid hsl(var(--border) / 0.5);
}

/* ======= Theme Picker ======= */
.theme-picker { position: relative; }
.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border) / 0.5);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.theme-btn:hover { background: hsl(var(--accent)); }
.theme-dot {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 9999px;
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
}

.theme-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border) / 0.6);
  border-radius: 0.875rem;
  padding: 0.5rem;
  width: 13rem;
  z-index: 100;
  box-shadow: 0 10px 40px hsl(0 0% 0% / 0.15);
  backdrop-filter: blur(16px);
}
.theme-dropdown.open { display: block; }

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.15s;
  color: hsl(var(--foreground));
}
.theme-option:hover { background: hsl(var(--accent)); }
.theme-option.active { background: hsl(var(--accent)); font-weight: 600; }

.theme-swatch {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.theme-dark-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  color: hsl(var(--foreground));
  border-top: 1px solid hsl(var(--border) / 0.4);
  margin-top: 0.25rem;
  padding-top: 0.625rem;
}

.toggle-switch {
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border) / 0.5);
  position: relative;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-switch.on { background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to))); }
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: white;
  top: 50%;
  left: 0.0625rem;
  transform: translateY(-50%);
  transition: left 0.2s;
}
.toggle-switch.on::after { left: calc(100% - 1.0625rem); }

/* ======= Toast notifications ======= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: 0 4px 20px hsl(0 0% 0% / 0.15);
  pointer-events: all;
  animation: slide-in 0.3s ease-out;
  max-width: 20rem;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border) / 0.6);
  color: hsl(var(--foreground));
  backdrop-filter: blur(16px);
}

.toast.success { border-color: rgba(16, 185, 129, 0.3); }
.toast.error { border-color: hsl(var(--destructive) / 0.4); }
.toast.info { border-color: hsl(var(--primary) / 0.4); }
.toast.removing { animation: slide-out 0.3s ease-in forwards; }

/* ======= Modal / Dialog ======= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / 0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease;
}
.modal-overlay.open { display: flex; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-box {
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border) / 0.6);
  border-radius: 1.25rem;
  padding: 1.5rem;
  width: 90%;
  max-width: 28rem;
  box-shadow: 0 20px 60px hsl(0 0% 0% / 0.25);
  animation: scale-in 0.2s ease;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

.modal-desc {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.6;
  margin-bottom: 1rem;
}

.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ======= Mobile Responsiveness ======= */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
    height: 100vh;
    padding-bottom: 4.5rem; /* Space for bottom nav */
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    min-width: 100% !important;
    height: 4.5rem;
    flex-direction: row;
    padding: 0 0.5rem;
    border-right: none;
    border-top: 1px solid hsl(var(--border) / 0.5);
    border-bottom: none;
    background: hsl(var(--card) / 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1000;
    border-radius: 1.25rem 1.25rem 0 0;
    box-shadow: 0 -4px 20px hsl(0 0% 0% / 0.1);
    transition: none; /* Disable width transition on mobile */
  }

  .sidebar:hover { width: 100% !important; }

  .sidebar-logo {
    display: none;
  }

  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 0;
  }

  .sidebar-item {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0;
    height: 100%;
    width: 25%;
    justify-content: center;
    border-radius: 0;
    background: none !important;
  }

  .sidebar-item-text {
    opacity: 1 !important;
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
  }

  .sidebar-item svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  .sidebar-item.active {
    background: none !important;
    color: hsl(var(--primary));
  }
  
  .sidebar-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 2rem;
    height: 3px;
    background: hsl(var(--primary));
    border-radius: 0 0 3px 3px;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    height: 100%;
    overflow: hidden;
  }

  .page-header {
    padding: 0.75rem 1rem;
    height: auto;
  }

  .page-body {
    padding: 1rem;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}
.settings-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.75rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: hsl(var(--secondary) / 0.4);
  border: 1px solid hsl(var(--border) / 0.4);
  margin-bottom: 0.5rem;
}

.settings-row-label { font-size: 0.875rem; font-weight: 500; color: hsl(var(--foreground)); }
.settings-row-desc { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

.settings-select {
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border) / 0.6);
  border-radius: 0.5rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-family: inherit;
  color: hsl(var(--foreground));
  outline: none;
  cursor: pointer;
}

/* ======= History Page ======= */
.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: hsl(var(--card) / 0.5);
  border: 1px solid hsl(var(--border) / 0.4);
}

/* ======= Skeleton ======= */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  border-radius: 0.375rem;
  background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--gradient-via) / 0.15) 50%, hsl(var(--muted)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ======= Pulse for download button ======= */
@keyframes pulse-subtle {
  0%, 100% { box-shadow: 0 4px 15px hsl(var(--gradient-from) / 0.2), 0 2px 8px hsl(var(--gradient-to) / 0.15); }
  50% { box-shadow: 0 6px 25px hsl(var(--gradient-from) / 0.35), 0 4px 12px hsl(var(--gradient-to) / 0.25); }
}
.animate-pulse-subtle { animation: pulse-subtle 2s ease-in-out infinite; }

/* ======= Status dot ======= */
.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: hsl(var(--primary) / 0.2);
  border: 1px solid hsl(var(--primary) / 0.3);
}
.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: hsl(var(--primary));
  box-shadow: 0 0 8px hsl(var(--primary));
}

/* Tabs */
.tabs { display: flex; gap: 0.25rem; padding: 0.25rem; background: hsl(var(--secondary) / 0.5); border-radius: 0.75rem; }
.tab {
  flex: 1;
  padding: 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: hsl(var(--muted-foreground));
  transition: all 0.2s;
}
.tab.active {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 4px hsl(0 0% 0% / 0.08);
}
.tab:hover:not(.active) { background: hsl(var(--accent) / 0.5); color: hsl(var(--foreground)); }

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border) / 0.6);
  border-radius: 0.5rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  backdrop-filter: blur(8px);
  z-index: 200;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ======= Input ======= */
input[type="text"], input[type="number"], textarea {
  font-family: inherit;
}

/* ======= Spinner ======= */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* ======= End ======= */
