:root {
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.15);
  --bg-modal: rgba(18, 18, 24, 0.9);
  --bg-raised: rgba(255, 255, 255, 0.04);
  --text: #ffffff;
  --text-2: #e2e8f0;
  --text-3: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --r-lg: 20px;
  --r-md: 10px;
  --fast: 0.2s;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: modal-fade-in 0.3s ease;
}

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

.auth-modal {
  background: var(--bg-raised);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 22px;
  width: 90%;
  max-width: 440px;
  padding: 48px; /* Balanced padding */
  position: relative;
  animation: modal-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
@keyframes modal-slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.auth-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
  padding-right: 40px; /* Safe zone for close button */
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 24px;
}

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

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

.auth-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--fast) var(--ease);
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.auth-submit {
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: all var(--fast) var(--ease);
}

.auth-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
}

.auth-switch-btn {
  background: none;
  border: none;
  color: var(--accent-light);
  font-weight: 600;
  cursor: pointer;
  padding: 0 4px;
}

.auth-close {
  position: absolute; top: 24px; right: 24px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: var(--text-3); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s ease;
  z-index: 10;
}

.auth-close:hover { background: rgba(255,255,255,0.1); color: var(--text); transform: scale(1.1); }

/* ── PREMIUM COMPONENTS ────────────────────────────────────── */

.premium-input {
  background: rgba(0,0,0,0.2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  padding: 14px 18px !important;
  color: var(--text) !important;
  font-size: 15px !important;
  width: 100%;
  transition: all 0.2s ease !important;
}

.premium-input:focus {
  border-color: var(--accent) !important;
  background: rgba(0,0,0,0.3) !important;
  box-shadow: 0 0 0 4px var(--accent-glow) !important;
}

.premium-btn {
  background: var(--accent);
  color: #fff !important;
  border: none;
  border-radius: var(--r-md);
  padding: 14px 24px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.premium-btn:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.3);
}

.premium-btn.outline {
  background: transparent;
  border: 1px solid var(--border);
  box-shadow: none;
}

.premium-btn.outline:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--text-3);
  transform: translateY(-1px);
}

.settings-modal-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-top: 16px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-light);
  margin-bottom: -16px;
  opacity: 0.8;
}

.settings-card {
  padding: 0;
  background: none;
  border: none;
}

.settings-avatar-zone {
  display: flex;
  align-items: center;
  gap: 24px;
}

.avatar-large-preview {
  width: 90px;
  height: 90px;
  border-radius: 16px;
  background: rgba(0,0,0,0.2);
  border: 2px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.upload-info-box h4 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.upload-info-box p { margin: 0 0 12px; font-size: 13px; color: var(--text-3); line-height: 1.4; }

/* User Profile in Header */
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--fast) var(--ease);
}

.user-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.user-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  color: #fff;
  border: none;
}

/* Sync Banner */
.sync-banner {
  background: rgba(124, 58, 237, 0.1);
  border: 1px dashed rgba(124, 58, 237, 0.3);
  padding: 12px 20px;
  border-radius: var(--r-lg);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sync-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.4;
}

.sync-text b {
  color: var(--accent-light);
}

.sync-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* Mobile specific */
@media (max-width: 768px) {
  .sync-banner {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  #user-auth-section {
    display: none;
  }
}

/* Profile Mode for Watchlist Header */
.sync-banner.profile-mode {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-style: solid;
  padding: 16px 20px;
  margin-bottom: 4px;
}

.profile-strip-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.profile-actions-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.strip-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.strip-action-btn svg {
  color: var(--accent-color);
}

.strip-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-color);
  color: var(--text-main);
  transform: translateY(-2px);
}

.strip-action-btn.logout:hover {
  border-color: #ff4757;
  color: #ff4757;
}

.strip-action-btn.logout svg {
  color: inherit;
}

.strip-icon-box {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-strip-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.strip-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.strip-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-color);
  background: var(--bg-surface);
}

.strip-avatar.placeholder {
  background: var(--accent-glow);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  border-style: solid;
}

.strip-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.strip-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  text-transform: capitalize;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.strip-email {
  font-size: 0.8rem;
  color: var(--text-dim);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Settings Avatar Upload */
.settings-avatar-upload {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease;
}

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

.avatar-preview.uploading {
  opacity: 0.6;
  border-color: var(--accent-color);
}

.avatar-placeholder {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-dim);
}

.upload-controls {
  flex: 1;
}

.settings-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 6px;
  opacity: 0.6;
}

@media (max-width: 600px) {
  .profile-actions-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .strip-action-btn.logout {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .profile-header-info {
    flex-direction: row; /* Keep it row on mobile but maybe stack if tight */
    text-align: left;
    gap: 12px;
  }
  .profile-avatar {
    width: 40px;
    height: 40px;
  }
  .profile-email {
    font-size: 13px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
/* Dashboard & Notifications */
.watchlist-dashboard {
  max-width: 1680px;
  margin: 0 auto 12px;
  padding: 0 32px;
}

.dash-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 12px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-title:first-child {
  margin-top: 0;
}

.dash-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  opacity: 0.5;
}

.dashboard-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

/* ── MOBILE RESPONSIVENESS ─────────────────────────────────── */

@media (max-width: 640px) {
  .auth-modal {
    padding: 32px 24px;
    border-radius: 20px;
  }

  .auth-title {
    font-size: 20px;
  }

  .settings-avatar-zone {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .avatar-large-preview {
    width: 80px;
    height: 80px;
  }

  .dash-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .dash-filter-chips {
    width: 100%;
    overflow-x: auto;
    justify-content: space-between;
  }

  .dash-chip {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .auth-modal {
    padding: 24px 20px;
  }
  
  .premium-btn {
    padding: 12px 20px;
    font-size: 14px;
  }
}

/* ── NOTIFICATION MODAL REFINEMENTS ─────────────────────────── */
.notif-modal {
  max-width: 500px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notif-header-section {
  padding: 32px 32px 24px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dash-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-right: 40px; /* Safe zone for close button if in header */
}

.notif-modal .auth-title { margin-bottom: 0; }

.dash-filter-chips {
  display: flex;
  background: rgba(0,0,0,0.2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}

.dash-chip {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  background: none; border: none;
  cursor: pointer; transition: all 0.2s ease;
}

.dash-chip.active {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.notif-list {
  flex: 1;
  padding: 8px;
  background: rgba(0,0,0,0.1);
}

.auth-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.auth-forgot-link {
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  opacity: 0.8;
}
.auth-forgot-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  transition: transform 0.2s;
}

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

.notif-item:hover {
  background: var(--bg-raised);
}

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.notif-item.airing .notif-icon {
  background: rgba(245, 158, 11, 0.1);
}

.notif-body {
  flex: 1;
  min-width: 0;
}

.notif-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.4;
}

.notif-text b {
  color: var(--text);
}

.notif-time {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

.notif-empty, .notif-loading, .notif-error {
  padding: 40px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  background: rgba(255,255,255,0.02);
  border-radius: var(--r-md);
  margin: 10px 0;
}

@media (max-width: 768px) {
  .watchlist-dashboard {
    padding: 0 16px;
  }
}
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
  margin-top: 20px;
  padding-bottom: 60px;
}
.profile-header-info {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-surface);
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
}
.profile-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.profile-action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}
.profile-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-color);
  color: var(--text-main);
}
.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #ff4757;
  border-radius: 50%;
  border: 2px solid var(--bg-modal);
  box-shadow: 0 0 0 2px rgba(255, 71, 87, 0.2);
}
.settings-input-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

@media (max-width: 480px) {
  .settings-input-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .settings-input-row .premium-btn {
    width: 100%;
  }
}

/* ── TOAST NOTIFICATIONS ────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  background: rgba(20, 20, 25, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.toast.visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-success { border-left: 3px solid #10b981; }
.toast-error { border-left: 3px solid #ef4444; }

.toast-icon {
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.toast-success .toast-icon { color: #10b981; }
.toast-error .toast-icon { color: #ef4444; }
