/* ============ PlayLocal v2 Design System ============ */

/* ============ Design Tokens ============ */
:root {
  --font-sans: 'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, monospace;

  /* Light theme */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F3F4F6;
  --surface-3: #E9EBEF;
  --text: #111827;
  --text-secondary: #374151;
  --muted: #6B7280;
  --border: #E5E7EB;
  --border-hover: #D1D5DB;
  --brand: #2563EB;
  --brand-hover: #1D4ED8;
  --brand-light: rgba(37, 99, 235, 0.12);
  --brand-gradient: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --success: #10B981;
  --warning: #F59E0B;
  --accent-warm: #F97316;
  --accent-soft: #FBBF24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.15);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --container: 1280px;
  --gap: 24px;
  --topbar-height: 64px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-2: #1F2937;
  --surface-3: #374151;
  --text: #F9FAFB;
  --text-secondary: #E5E7EB;
  --muted: #9CA3AF;
  --border: #374151;
  --border-hover: #4B5563;
  --brand: #3B82F6;
  --brand-hover: #60A5FA;
  --brand-light: rgba(59, 130, 246, 0.15);
  --brand-gradient: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
  --danger: #F87171;
  --danger-light: rgba(248, 113, 113, 0.15);
  --success: #34D399;
  --accent-warm: #FB923C;
  --accent-soft: #FCD34D;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { display: block; max-width: 100%; }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

/* ============ Top Bar ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.logo svg {
  width: 16px;
  height: 16px;
  fill: white;
  margin-left: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), #8B5CF6);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
}

.avatar:hover {
  border-color: var(--brand);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn svg:not([fill="none"]) {
  fill: currentColor;
}

.btn-primary {
  background: var(--brand-gradient);
  border-color: transparent;
  color: white;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #DC2626;
  border-color: #DC2626;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.8125rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.btn-icon.danger:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* ============ Outline Buttons ============ */
.btn-outline-primary {
  background: transparent;
  border: 1px solid var(--brand);
  color: var(--brand);
}
.btn-outline-primary:hover {
  background: var(--brand);
  color: white;
}

.btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-outline-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-outline-success {
  background: transparent;
  border: 1px solid var(--success);
  color: var(--success);
}
.btn-outline-success:hover {
  background: var(--success);
  color: white;
}

.btn-outline-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger);
  color: white;
}

/* Ensure SVGs in outline buttons are visible */
.btn-outline-primary svg,
.btn-outline-secondary svg,
.btn-outline-success svg,
.btn-outline-danger svg {
  stroke: currentColor;
  fill: none;
}

/* ============ Playlist Cards ============ */
.playlist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.playlist-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

/* Button groups */
.btn-group {
  display: inline-flex;
  gap: 4px;
}

.btn-group .btn {
  border-radius: var(--radius-xs);
}

/* ============ Main Content ============ */
.main-content {
  padding: 24px 0 120px;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--muted);
  font-size: 0.9375rem;
  max-width: 50ch;
}

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

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--gap);
  align-items: start;
}

/* ============ Toolbar ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.search:focus-within {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  flex-shrink: 0;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
}

.search input::placeholder {
  color: var(--muted);
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  background: var(--surface-2);
  color: var(--text);
}

.pill.active {
  background: var(--brand-light);
  border-color: color-mix(in srgb, var(--brand) 30%, var(--border));
  color: var(--brand);
  font-weight: 600;
}

.sort-select {
  padding: 10px 32px 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  appearance: none;
  transition: all 0.15s ease;
}

.sort-select:hover {
  border-color: var(--border-hover);
}

.sort-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

/* ============ Media Grid ============ */
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 16px;
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s ease,
              border-color 0.2s ease;
  cursor: pointer;
}

.media-card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: color-mix(in srgb, var(--brand) 25%, var(--border));
  box-shadow: var(--shadow-lg);
}

.media-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--surface-2);
  overflow: hidden;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.media-card:hover .media-thumb img,
.media-card:hover .media-thumb video {
  transform: scale(1.08);
}

.media-tag {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}

[data-theme="dark"] .media-tag {
  background: rgba(255, 255, 255, 0.15);
}

.media-tag.video {
  background: rgba(37, 99, 235, 0.85);
}

.media-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.media-name {
  font-weight: 650;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.media-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

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

/* ============ Sidebar Panel ============ */
.sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title {
  font-weight: 700;
  font-size: 0.9375rem;
}

.panel-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 15%, var(--surface));
  color: var(--success);
  font-weight: 600;
}

.panel-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.code-section {
  text-align: center;
}

.code-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.playlist-code {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 14px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.url-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.url-field .url {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-container {
  aspect-ratio: 1;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
}

.qr-code {
  width: 140px;
  height: 140px;
  background: white;
  border-radius: var(--radius-xs);
  padding: 10px;
  display: grid;
  place-items: center;
}

.qr-code svg,
.qr-code img {
  width: 100%;
  height: 100%;
}

.qr-url {
  font-size: 0.75rem;
  color: var(--muted);
}

.preview-section label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-box {
  position: relative;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: block;
}

.preview-link {
  text-decoration: none;
  cursor: pointer;
}

.preview-link:hover {
  border-color: var(--brand);
}

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

.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
  transform: scale(1);
  transform-origin: top left;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 8px;
}

.preview-placeholder span {
  font-size: 0.75rem;
}

.preview-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  padding: 12px;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.preview-link:hover .preview-overlay {
  opacity: 1;
}

.preview-overlay svg {
  color: white;
}

.preview-overlay span {
  font-size: 0.75rem;
  color: white;
  font-weight: 500;
}

.preview-url {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: white;
  opacity: 0.9;
}

.toggles {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.2s ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-switch {
  background: var(--brand-light);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
}

.toggle input:checked + .toggle-switch::after {
  left: 22px;
  background: var(--brand);
  border-color: var(--brand);
}

.toggle-label {
  font-size: 0.875rem;
  color: var(--muted);
}

.btn-fullscreen {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

/* ============ Mobile Bottom CTA ============ */
.bottom-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 20px 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: none;
  z-index: 90;
}

.bottom-cta .btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 1rem;
}

/* ============ Theme Toggle ============ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.sun-icon { display: none; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state-icon svg,
.empty-state > svg {
  width: 64px;
  height: 64px;
  stroke: var(--muted);
  stroke-width: 1.5;
  margin: 0 auto 16px;
}

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

.empty-state p {
  color: var(--muted);
  margin-bottom: 20px;
}

/* ============ Breadcrumb ============ */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: '/';
  margin-right: 8px;
  color: var(--muted);
}

.breadcrumb-item a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.15s ease;
}

.breadcrumb-item a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: var(--muted);
}

/* ============ Flash Messages ============ */
.flash-messages {
  margin-bottom: 20px;
}

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-success {
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  border-color: var(--success);
  color: var(--success);
}

.alert-danger {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border-color: var(--danger);
  color: var(--danger);
}

.alert-warning {
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  border-color: var(--warning);
  color: var(--warning);
}

.alert-info {
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
  border-color: var(--brand);
  color: var(--text);
  flex-direction: column;
  align-items: flex-start;
}

/* ============ Forms ============ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  transition: all 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.form-control::placeholder {
  color: var(--muted);
}

.form-text {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ============ Dropzone ============ */
.dropzone {
  padding: 40px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--brand);
  background: var(--brand-light);
}

.dropzone svg {
  width: 48px;
  height: 48px;
  stroke: var(--muted);
  stroke-width: 1.5;
  margin: 0 auto 12px;
}

.dropzone.drag-over svg {
  stroke: var(--brand);
}

.dropzone h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.dropzone p {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ============ Modal Overrides ============ */
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

.modal-title {
  font-weight: 700;
  font-size: 1.125rem;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
}

/* ============ Impersonation Banner ============ */
.impersonation-banner {
  background: var(--warning);
  color: #1a1a1a;
  padding: 10px 16px;
  font-weight: 500;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.impersonation-banner .container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.impersonation-banner a.btn {
  background: #1a1a1a;
  color: white;
  border-color: #1a1a1a;
  text-decoration: none;
}

.impersonation-banner a.btn:hover {
  background: #333;
  border-color: #333;
}

/* ============ Sortable / Reorder ============ */
.media-card.sortable-ghost {
  opacity: 0.4;
}

.media-card.sortable-chosen {
  box-shadow: var(--shadow-lg);
}

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr 340px;
  }
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    order: -1;
  }
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  .chip {
    display: none;
  }
}

@media (max-width: 768px) {
  .media-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-title {
    font-size: 1.75rem;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .header-actions .btn-primary {
    flex: 1;
  }
  .playlist-card {
    margin-bottom: 16px;
  }

  .main-content {
    padding-bottom: 100px;
  }
  .media-card {
    display: block;
  }
  .media-thumb {
    aspect-ratio: 16/9;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }
  .media-tag {
    font-size: 0.625rem;
    padding: 3px 6px;
    bottom: 6px;
    left: 6px;
  }
  .media-body {
    padding: 10px;
  }
  .media-name {
    font-size: 0.8125rem;
  }
  .media-meta {
    display: none;
  }
  .media-actions {
    display: none;
  }
  .filter-pills {
    display: none;
  }
  .bottom-cta {
    display: block;
  }
  .toggles {
    gap: 12px;
  }
}

@media (max-width: 400px) {
  .media-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .media-body {
    padding: 12px;
  }
  .media-name {
    font-size: 0.875rem;
  }
}

/* ============ Mobile Media Actions Overlay ============ */
.media-actions-overlay {
  display: none;
}

@media (max-width: 640px) {
  .media-card {
    position: relative;
  }

  .media-actions-overlay {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    border-radius: var(--radius);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 10;
  }

  .media-actions-overlay.show {
    opacity: 1;
    visibility: visible;
  }

  .media-actions-overlay-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 8px;
    padding: 16px;
  }

  .media-actions-overlay .btn-action {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 500;
    min-height: 64px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
  }

  .media-actions-overlay .btn-action:active {
    transform: scale(0.96);
  }

  .media-actions-overlay .btn-action-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
  }

  .media-actions-overlay .btn-action-danger:active {
    background: rgba(239, 68, 68, 0.25);
  }

  .media-actions-overlay form {
    flex: 1;
    display: flex;
  }

  .media-actions-overlay form .btn-action {
    width: 100%;
  }
}

/* ============ Animations ============ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.media-card {
  animation: fadeInUp 0.4s ease forwards;
}

.media-card:nth-child(1) { animation-delay: 0.05s; }
.media-card:nth-child(2) { animation-delay: 0.1s; }
.media-card:nth-child(3) { animation-delay: 0.15s; }
.media-card:nth-child(4) { animation-delay: 0.2s; }
.media-card:nth-child(5) { animation-delay: 0.25s; }
.media-card:nth-child(6) { animation-delay: 0.3s; }

/* ============ Utilities ============ */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.d-flex { display: flex; }
.d-none { display: none; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============ Dropdown ============ */
.dropdown,
.user-menu {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  min-width: 180px;
  padding: 8px 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.15s ease;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--surface-2);
}

.dropdown-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.dropdown-header {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-header strong {
  font-size: 0.875rem;
  color: var(--text);
}

.dropdown-header small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dropdown-divider {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.dropdown-item-danger {
  color: var(--danger);
}

.dropdown-item-danger:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.dropdown-item-warning {
  color: var(--warning);
}

.dropdown-item-warning:hover {
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}

/* ============ Toast Notifications ============ */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 10000;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success {
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  border-color: var(--success);
  color: var(--success);
}

.toast-error {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border-color: var(--danger);
  color: var(--danger);
}

/* ============ Global Dropzone Overlay ============ */
.global-dropzone-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(37, 99, 235, 0.1);
  border: 4px dashed var(--brand);
  z-index: 9998;
  pointer-events: none;
  align-items: center;
  justify-content: center;
}

.global-dropzone-overlay.active {
  display: flex;
}

.global-dropzone-message {
  background: var(--surface);
  padding: 32px 48px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.global-dropzone-message svg {
  color: var(--brand);
  margin-bottom: 12px;
}

.global-dropzone-message h4 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

/* ============ Upload Cards ============ */
.upload-card {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-body {
  padding: 16px;
}

.form-hint {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 6px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.file-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  color: var(--success);
  font-size: 0.875rem;
}

.file-selected svg {
  flex-shrink: 0;
}

/* ============ Dropzone Enhanced ============ */
.dropzone {
  padding: 40px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.dropzone-icon {
  margin-bottom: 12px;
  color: var(--muted);
}

.dropzone-icon svg {
  width: 48px;
  height: 48px;
}

.dropzone.dragover .dropzone-icon {
  color: var(--brand);
}

.dropzone-text {
  font-size: 1rem;
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 0.875rem;
  color: var(--muted);
}

.dropzone-formats {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 12px;
}

/* ============ Progress Bar ============ */
.progress-bar-container {
  position: relative;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  width: 100%;
}

.progress-bar-animated {
  animation: progressAnimation 1.5s ease-in-out infinite;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-hover) 50%, var(--brand) 100%);
  background-size: 200% 100%;
}

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

.progress-text {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 8px;
}

/* ============ Upload Progress Card ============ */
.upload-progress-card {
  margin-top: 16px;
}

.upload-progress-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-progress-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upload-filename {
  font-weight: 600;
  font-size: 0.9375rem;
}

.upload-status {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ============ Spinner ============ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ Modal System ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

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

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ============ Video Play Icon ============ */
.video-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  opacity: 0.9;
  pointer-events: none;
}

/* ============ Reorder Mode ============ */
.reorder-handle {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  background: rgba(37, 99, 235, 0.9);
  color: white;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: none;
  cursor: grab;
  touch-action: none;
}

.reorder-handle:active {
  cursor: grabbing;
  background: rgba(37, 99, 235, 1);
}

.media-grid.reorder-mode .reorder-handle {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Handle más grande en móvil para facilitar el toque */
@media (max-width: 768px) {
  .reorder-handle {
    padding: 12px;
    top: 10px;
    left: 10px;
  }

  .reorder-handle svg {
    width: 20px;
    height: 20px;
  }
}

.media-grid.reorder-mode .media-card {
  border: 2px dashed var(--brand);
}

.media-grid.reorder-mode .media-card:hover {
  transform: scale(1.02);
}

.media-grid.reorder-mode .media-actions {
  display: none !important;
}

/* Sortable ghost */
.sortable-ghost {
  opacity: 0.4;
}

.sortable-drag {
  opacity: 0.8;
}

/* ============ Empty State Enhanced ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  margin-top: 16px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state-icon {
  margin-bottom: 16px;
}

.empty-state-icon svg {
  width: 64px;
  height: 64px;
  stroke: var(--muted);
  stroke-width: 1.5;
  margin: 0 auto;
}

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

.empty-state-message {
  color: var(--muted);
  margin-bottom: 20px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state .btn {
  display: inline-flex;
  width: auto;
  padding: 12px 20px;
}

.empty-state .btn svg {
  width: 18px;
  height: 18px;
  margin: 0;
  stroke: currentColor;
}

/* ============ Preview Placeholder ============ */
.preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
}

/* ============ Header Actions Inline ============ */
.header-actions-inline {
  display: inline-flex;
  gap: 10px;
}

/* ============ Auth Pages (Login/Register) ============ */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
}

.auth-card--wide {
  max-width: 720px;
  padding: 48px 56px;
}

@media (min-width: 768px) {
  .auth-card--wide .auth-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 32px;
  }

  .auth-card--wide .auth-section-title {
    grid-column: 1 / -1;
    margin-bottom: 8px;
  }

  .auth-card--wide .form-group {
    margin-bottom: 0;
  }

  .auth-card--wide .form-group.full-width {
    grid-column: 1 / -1;
  }

  .auth-card--wide .code-suggestions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767px) {
  .auth-card--wide {
    padding: 32px 24px;
  }
}

.auth-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.auth-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.auth-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  text-decoration: underline;
  text-decoration-color: var(--brand);
  text-underline-offset: 4px;
}

.code-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.code-suggestions-label {
  width: 100%;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.code-suggestion-btn {
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.code-suggestion-btn:hover {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand);
}

.input-with-status {
  position: relative;
}

.input-with-status input {
  padding-right: 40px;
}

.input-status-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.input-status-icon.valid { color: var(--success); }
.input-status-icon.invalid { color: var(--danger); }
.input-status-icon.loading {
  animation: spin 1s linear infinite;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--brand);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.auth-logo svg {
  width: 32px;
  height: 32px;
  fill: white;
}

.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.auth-header p {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.auth-form label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus,
.auth-form input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-form input::placeholder {
  color: var(--muted);
}

.checkbox-group {
  flex-direction: row !important;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 400 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.btn-full {
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
}

.auth-footer {
  text-align: center;
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.875rem;
}

.auth-footer a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  margin-left: 4px;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.email-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--brand-light);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--border));
  border-radius: var(--radius-sm);
  color: var(--brand);
  font-size: 1.125rem;
  margin-bottom: 24px;
}

.email-display svg {
  flex-shrink: 0;
  stroke: var(--brand);
}

.steps-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.steps-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.steps-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.steps-list li {
  margin-bottom: 8px;
}

.steps-list li:last-child {
  margin-bottom: 0;
}

.steps-list strong {
  color: var(--text);
}

/* ============ Profile Page ============ */
.profile-page {
  display: flex;
  justify-content: center;
  padding: 24px 0;
}

.profile-card {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.profile-info h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.profile-info p {
  color: var(--muted);
  margin: 0;
  font-size: 0.9375rem;
}

.account-info {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 24px;
}

.account-info-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.account-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.account-info-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.account-info-label {
  color: var(--muted);
  font-size: 0.875rem;
  min-width: 140px;
}

.account-info-value {
  font-weight: 500;
  font-size: 0.9375rem;
}

.playlist-code-badge {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--brand);
  color: white;
  border-radius: var(--radius-xs);
  letter-spacing: 0.05em;
}

.profile-form .auth-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.profile-form .auth-section:last-of-type {
  border-bottom: none;
}

@media (min-width: 768px) {
  .profile-form .auth-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 32px;
  }

  .profile-form .auth-section-title {
    grid-column: 1 / -1;
    margin-bottom: 8px;
  }

  .profile-form .form-group {
    margin-bottom: 0;
  }

  .profile-form .form-group.full-width {
    grid-column: 1 / -1;
  }
}

.billing-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  color: var(--muted);
}

.billing-notice svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.billing-notice strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.billing-notice p {
  margin: 0;
  font-size: 0.875rem;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 640px) {
  .profile-card {
    padding: 24px;
  }

  .profile-header {
    flex-direction: column;
    text-align: center;
  }

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

  .account-info-label {
    min-width: auto;
  }
}

.auth-copyright {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Auth alerts */
.auth-card .alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.auth-card .alert-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-card .alert svg {
  flex-shrink: 0;
}

/* Responsive auth */
@media (max-width: 480px) {
  .auth-card {
    padding: 28px 20px;
    border-radius: var(--radius-sm);
  }

  .auth-logo {
    width: 56px;
    height: 56px;
  }

  .auth-header h1 {
    font-size: 1.5rem;
  }
}

/* ============ Floating Action Button - Open on TV ============ */
.fab-tv {
  display: none;
}

@media (max-width: 640px) {
  .fab-tv {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 14px 24px;
    background: var(--brand);
    color: white;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    text-decoration: none;
    transition: all 0.2s ease;
  }

  .fab-tv:hover {
    background: var(--brand-hover);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
  }

  .fab-tv:active {
    transform: translateX(-50%) translateY(0);
  }

  .fab-tv svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }
}

/* ============ Stats Grid (Playlist Edit) ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: center;
  padding: 20px 0;
}

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

.stats-item .stats-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.stats-item .stats-label {
  font-size: 0.8125rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stats-item {
    flex-direction: row;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }

  .stats-item:last-child {
    border-bottom: none;
  }
}

/* ============ Toggle Switch Field ============ */
.toggle-switch-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.toggle-switch-field .toggle-info {
  flex: 1;
}

.toggle-switch-field .toggle-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
}

.toggle-switch-field .toggle-description {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ============ URL Preview ============ */
.url-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--brand-light);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--border));
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}

.url-preview svg {
  flex-shrink: 0;
  color: var(--brand);
}

.url-preview a {
  color: var(--brand);
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 600;
}

.url-preview a:hover {
  text-decoration: underline;
}

.url-preview code {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--brand);
}

/* ============ Playlist Code Display ============ */
.playlist-code-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.playlist-code-display .code {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
  text-transform: uppercase;
}

.playlist-code-display .lock-icon {
  color: var(--muted);
}

/* ============ Card Actions (Form Footers) ============ */
.card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.card-actions-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-actions-split .actions-left {
  display: flex;
  gap: 10px;
}

@media (max-width: 480px) {
  .card-actions-split {
    flex-direction: column;
    align-items: stretch;
  }

  .card-actions-split .actions-left {
    flex-direction: column;
  }

  .card-actions-split .btn {
    width: 100%;
  }
}

/* ============ Playlist Card (Index Page) ============ */
.playlist-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.playlist-card .playlist-code {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
  background: var(--surface-2);
  padding: 6px 12px;
  border-radius: var(--radius-xs);
}

.playlist-card-body {
  padding-bottom: 16px;
}

.playlist-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.playlist-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.playlist-card-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.875rem;
}

.playlist-card-meta .meta-item svg {
  flex-shrink: 0;
}

.playlist-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.playlist-card.inactive {
  border-color: var(--warning);
}

.playlist-card.inactive .playlist-code {
  background: color-mix(in srgb, var(--warning) 15%, var(--surface));
  color: var(--warning);
}

/* Badge variants */
.badge-success {
  background: color-mix(in srgb, var(--success) 15%, var(--surface));
  border-color: var(--success);
  color: var(--success);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-success::before {
  content: '';
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.badge-warning {
  background: color-mix(in srgb, var(--warning) 15%, var(--surface));
  border-color: var(--warning);
  color: var(--warning);
}

/* ============ Custom Tooltips ============ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 6px 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ============ Float Animation (Empty States) ============ */
.float-animation {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ============ Skeleton Loaders ============ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

/* ============ Upload Progress (Enhanced) ============ */
.upload-progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: var(--brand-gradient);
  transition: width 0.3s ease;
}

/* ============ Accessibility Improvements ============ */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

:focus:not(:focus-visible) {
  outline: none;
}

.skip-link {
  position: fixed;
  top: 0;
  left: 16px;
  padding: 8px 16px;
  background: var(--brand);
  color: white;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(16px);
}

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

/* ============ Polish: Selection & Scrollbar ============ */
::selection {
  background: rgba(37, 99, 235, 0.2);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-2);
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Cursor improvements */
.btn {
  cursor: pointer;
}

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