:root {
  --bg-dark: #240046;
  --bg-panel: #3C096C;
  --bg-card: #5A189A;
  --border-glow: #7B2CBF;
  --accent-primary: #FF6D00;
  --accent-hover: #FF7900;
  --accent-star: #FF9E00;
  --accent-contrast: #240046;
  --text-main: #FFFFFF;
  --text-muted: #C8A2F0;
  /* Accent used as text: the fill orange is under 4.5:1 on the card purple */
  --accent-text: #FF9A4D;
  --danger-text: #FF9E9E;
  --danger-fill: #D93636;
  /* Hairline in the text colour so every theme's cards get an edge in its own hue */
  --card-border: color-mix(in srgb, var(--text-main) 9%, transparent);
  --card-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  --bg-overlay: rgba(36, 0, 70, 0.7);
  --bg-overlay-solid: rgba(36, 0, 70, 0.8);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

::selection {
  background-color: var(--accent-primary);
  color: var(--accent-contrast);
}

/* ============================== */
/* ☀️ LIGHT MODE OVERRIDES       */
/* ============================== */
body.light-mode {
  --bg-dark: #F5EEFC;      /* Pale lavender for the sidebar */
  --bg-panel: #FFFFFF;     /* Pure white for the main content */
  --bg-card: #EDE2FA;      /* Soft lilac cards */
  --border-glow: #D1C4E9;  /* Soft lavender border */
  --text-main: #240046;    /* Dark Amethyst for main text */
  --text-muted: #5A189A;   /* Indigo Velvet for muted text */
  --accent-text: #A84300;
  --danger-text: #C92A2A;
  --card-shadow: 0 1px 2px rgba(36, 0, 70, 0.04), 0 8px 24px rgba(36, 0, 70, 0.06);
  --bg-overlay: rgba(36, 0, 70, 0.45);
  --bg-overlay-solid: rgba(36, 0, 70, 0.55);
}

/* AI Match Score Badge - force dark circle in light mode */
body.light-mode .ai-match-score {
  background-color: #240046;
  color: #FFFFFF;
  border-color: #5A189A;
}

/* AI Drawer Light Mode Fixes */
body.light-mode .ai-drawer {
  background: rgba(255, 255, 255, 0.85); /* Bright frosted glass */
}

body.light-mode .chat-input-area {
  background: rgba(237, 226, 250, 0.9); /* Soft lilac for the bottom */
}

body.light-mode .drawer-search-input {
  color: var(--text-main); /* Flips the typing text from white to dark */
}

body.light-mode .drawer-search-input::placeholder {
  color: var(--text-muted);
}

body.light-mode .close-btn {
  color: var(--text-muted); /* Makes the 'X' visible in light mode */
}

/* Details modal close button stays visible against backdrop */
body.light-mode .details-close-btn {
  background-color: rgba(0,0,0,0.55);
  color: #FFFFFF;
}

/* Featured description text needs better contrast */
body.light-mode .featured-desc {
  color: var(--text-main);
}

/* Movie card title text */
body.light-mode .card-title {
  color: var(--text-main);
}

/* Modal header border */
body.light-mode .modal-header {
  border-bottom-color: var(--border-glow);
}

/* Drawer header border */
body.light-mode .drawer-header {
  border-bottom-color: var(--border-glow);
}

/* Settings card border */
body.light-mode .settings-card {
  border-color: var(--border-glow);
}

/* Search input */
body.light-mode .search-input {
  color: var(--text-main);
}

body.light-mode .search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Form fields: the dark-mode black tint turns muddy gray on light backgrounds */
body.light-mode .input-group input,
body.light-mode .api-key-row input {
  background-color: #FFFFFF;
}

/* Tint of the text colour, not --border-glow: the golden themes' borders match the orange fill */
/* Accent-coloured text is too faint on pale surfaces; keep the accent on the icon only */
body.light-mode .ai-status-btn {
  color: var(--text-main);
}

body.light-mode .ai-status-btn i {
  color: var(--accent-primary);
}

body.light-mode .ai-status-btn:hover,
body.light-mode .ai-status-btn:hover i {
  color: var(--accent-contrast);
}

body.light-mode .progress-bg {
  background-color: color-mix(in srgb, var(--text-main) 12%, transparent);
}

/* The dark gradient ends in a fixed purple that clashes with light palettes */
body.light-mode .train-banner {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--border-glow) 100%);
}

/* ============================== */
/* 🎨 CUSTOM THEMES (DARK MODE)   */
/* ============================== */

/* Golden Summer Glow */
body.theme-golden-summer {
  --accent-text: var(--accent-primary);
  --bg-dark: #082440;
  --bg-panel: #0A2D4D;
  --bg-card: #0D3B66;
  --border-glow: #F95738;
  --accent-primary: #F4D35E;
  --accent-hover: #EE964B;
  --accent-contrast: #0D3B66;
  --text-main: #FAF0CA;
  --text-muted: #F4D35E;
  --bg-overlay: rgba(8, 36, 64, 0.75);
  --bg-overlay-solid: rgba(8, 36, 64, 0.85);
}

/* Golden Twilight */
body.theme-golden-twilight {
  --accent-text: var(--accent-primary);
  --bg-dark: #000814;
  --bg-panel: #001D3D;
  --bg-card: #003566;
  --border-glow: #FFD60A;
  --accent-primary: #FFC300;
  --accent-hover: #FFD60A;
  --accent-contrast: #000814;
  --text-main: #FFFFFF;
  --text-muted: #8AA1B1;
  --bg-overlay: rgba(0, 8, 20, 0.75);
  --bg-overlay-solid: rgba(0, 8, 20, 0.85);
}

/* Blue Gradient */
body.theme-blue-gradient {
  /* Surfaces sit one step deeper than the palette's mid blues: pale text on #1976D2 is only 3.3:1 */
  --accent-text: #BBDEFB;
  --bg-dark: #0A3A85;
  --bg-panel: #0D47A1;
  --bg-card: #1154AC;
  --border-glow: #64B5F6;
  /* Light accent with navy text: any mid blue blends into this theme's surfaces */
  --accent-primary: #90CAF9;
  --accent-hover: #BBDEFB;
  --accent-contrast: #0D47A1;
  --text-main: #E3F2FD;
  --text-muted: #BBDEFB;
  --bg-overlay: rgba(13, 71, 161, 0.75);
  --bg-overlay-solid: rgba(13, 71, 161, 0.85);
}

/* Bold Berry */
body.theme-bold-berry {
  --accent-text: var(--accent-primary);
  --bg-dark: #2A0513;
  --bg-panel: #450920;
  --bg-card: #A53860;
  --border-glow: #DA627D;
  --accent-primary: #FFA5AB;
  --accent-hover: #F9DBBD;
  --accent-contrast: #450920;
  --text-main: #FFFFFF;
  --text-muted: #F9DBBD;
  --bg-overlay: rgba(42, 5, 19, 0.75);
  --bg-overlay-solid: rgba(42, 5, 19, 0.85);
}

/* The blue accent disappears on the blue card behind the AI Assistant button */
body.theme-blue-gradient:not(.light-mode) .ai-status-btn {
  color: var(--text-main);
}

/* ============================== */
/* 🎨 CUSTOM THEMES (LIGHT MODE)  */
/* ============================== */

/* Golden Summer Glow Light */
body.light-mode.theme-golden-summer {
  --accent-text: #A8391F;
  --bg-dark: #FAF0CA;      
  --bg-panel: #FFFFFF;     
  --bg-card: #FDF8E4;      
  --border-glow: #F4D35E;  
  --text-main: #0D3B66;    
  --text-muted: #B83A1E;   
}

/* Golden Twilight Light */
body.light-mode.theme-golden-twilight {
  --accent-text: #7A5000;
  --bg-dark: #F5F7FA;      
  --bg-panel: #FFFFFF;     
  --bg-card: #EAEFF4;      
  --border-glow: #FFC300;  
  --text-main: #000814;    
  --text-muted: #003566;   
}

/* Blue Gradient Light */
body.light-mode.theme-blue-gradient {
  --accent-text: #0D47A1;
  --bg-dark: #E3F2FD;      
  --bg-panel: #FFFFFF;     
  --bg-card: #BBDEFB;      
  --border-glow: #64B5F6;  
  --accent-primary: #1565C0;
  --accent-hover: #0D47A1;
  --accent-contrast: #FFFFFF;
  --text-main: #0D47A1;    
  --text-muted: #1565C0;   
}

/* Bold Berry Light */
body.light-mode.theme-bold-berry {
  --accent-text: #8A2C50;
  --bg-dark: #F9DBBD;      
  --bg-panel: #FFFFFF;     
  --bg-card: #FDEEE4;      
  --border-glow: #FFA5AB;  
  --text-main: #450920;    
  --text-muted: #A53860;   
}

/* Score badge overrides for custom light themes */
body.light-mode.theme-golden-summer .ai-match-score {
  background-color: #0D3B66;
  color: #FAF0CA;
  border-color: #F4D35E;
}
body.light-mode.theme-golden-twilight .ai-match-score {
  background-color: #000814;
  color: #FFC300;
  border-color: #FFC300;
}
body.light-mode.theme-blue-gradient .ai-match-score {
  background-color: #0D47A1;
  color: #E3F2FD;
  border-color: #2196F3;
}
body.light-mode.theme-bold-berry .ai-match-score {
  background-color: #450920;
  color: #FFFFFF;
  border-color: #FFA5AB;
}

/* ============================== */
/* TOGGLE SWITCH STYLES           */
/* ============================== */
.theme-toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.theme-toggle-container i {
  font-size: 1.3rem;
}

.theme-text {
  flex-grow: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

/* The actual pill switch */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-glow);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--accent-primary);
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--text-main);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

body {
  --card-border: color-mix(in srgb, var(--text-main) 9%, transparent);
  accent-color: var(--accent-primary);
  scrollbar-color: color-mix(in srgb, var(--text-main) 22%, transparent) transparent;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: system-ui, -apple-system, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background-color: var(--bg-dark);
  border-right: 1px solid var(--border-glow);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
}

.brand-lockup {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 14px;
  margin-bottom: 40px;
  padding: 0;
  text-align: left;
  transition: 0.2s;
  width: 100%;
}

.brand-lockup:hover {
  transform: scale(1.02);
}

.brand-logo-frame {
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--accent-primary);
  border-radius: 50%;
  display: flex;
  height: 56px;
  justify-content: center;
  overflow: hidden;
  position: relative;
  width: 56px;
  flex-shrink: 0;
}

.brand-logo {
  display: none;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.brand-logo-frame.has-logo .brand-logo {
  display: block;
}

.brand-logo-frame.has-logo .brand-logo-fallback {
  display: none;
}

.brand-logo-fallback {
  color: var(--accent-primary);
  font-size: 1rem;
  font-weight: 900;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
}

.avatar { border-radius: 50%; border: 2px solid var(--accent-primary); width: 40px; height: 40px; }
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: bold; font-size: 0.95rem; }
.user-subtext { font-size: 0.75rem; color: var(--text-muted); }

.nav-section-title {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 20px 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar-nav a {
  color: var(--text-main);
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: 0.2s;
}

.sidebar-nav a i { font-size: 1.3rem; color: var(--text-muted); }
.sidebar-nav a:hover, .sidebar-nav a.active {
  background-color: var(--text-main);
  color: var(--bg-dark);
  font-weight: 600;
}
.sidebar-nav a:hover i, .sidebar-nav a.active i { color: var(--bg-dark); }

.spacer { flex-grow: 1; }
.logout-btn { color: var(--text-muted); text-decoration: none; display: flex; align-items: center; gap: 12px; padding: 12px 16px; transition: 0.2s; }
.logout-btn:hover { color: var(--accent-text); }

/* MAIN CONTENT */
.main-content { background-color: var(--bg-panel); display: flex; flex-direction: column; height: 100vh; position: relative; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  border-bottom: 1px solid var(--border-glow);
}

.top-bar-left, .top-bar-right { display: flex; gap: 20px; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }

.search-container {
  display: flex;
  align-items: center;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-glow);
  border-radius: 30px;
  padding: 8px 20px;
  width: 50%;
  transition: 0.3s;
  position: relative;
}

.search-container:focus-within { border-color: var(--accent-primary); box-shadow: 0 0 12px rgba(255, 109, 0, 0.2); }
.search-input { flex-grow: 1; border: none; background: transparent; color: var(--text-main); outline: none; padding: 10px 0 10px 15px; }
.ai-btn { background: transparent; color: var(--accent-text); border: none; font-size: 1.4rem; cursor: pointer; transition: 0.2s; }
.ai-btn:hover { transform: scale(1.1); }

.search-autocomplete {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 100%;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.search-autocomplete.hidden {
  display: none;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
  border-bottom: 1px solid rgba(123, 44, 191, 0.1);
}

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

.autocomplete-item:hover {
  background-color: var(--bg-card);
}

.autocomplete-item img {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
}

.autocomplete-info {
  display: flex;
  flex-direction: column;
}

.autocomplete-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.autocomplete-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.content-area { padding: 40px; overflow-y: auto; flex-grow: 1; }

/* HOME COMPONENTS */
.app-page { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes refreshSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

#top-refresh-btn.spinning {
  animation: refreshSpin 0.45s ease;
  color: var(--accent-text);
}

.hero-row { display: flex; gap: 20px; margin-bottom: 40px; }
.welcome-card, .quick-rec-card { background-color: var(--bg-card); padding: 20px; border-radius: 16px; box-shadow: var(--card-shadow); }
.welcome-card {
  flex: 2;
  min-width: 0;
}

.profile-welcome-card {
  align-items: center;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  gap: 18px;
  text-align: left;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profile-welcome-card:hover,
.profile-welcome-card:focus-visible {
  box-shadow: 0 0 0 1px var(--accent-primary);
  outline: none;
  transform: translateY(-2px);
}

.avatar-large {
  border-radius: 50%;
  border: 3px solid var(--accent-primary);
  flex-shrink: 0;
  height: 64px;
  object-fit: cover;
  width: 64px;
}

.welcome-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.welcome-title {
  color: var(--text-main);
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 5px;
}

.welcome-subtitle {
  color: var(--text-muted);
  display: block;
  font-size: 0.95rem;
}
.stat-circles { display: flex; gap: 20px; }
.circle h3 { color: var(--accent-text); font-size: 1.8rem; }
.circle p { font-size: 0.8rem; color: var(--text-muted); }

.quick-rec-card {
  cursor: pointer;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  min-height: 104px;
  border: 1px solid var(--card-border);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.quick-rec-card h4 {
  align-items: center;
  color: var(--text-main);
  display: flex;
  font-size: 1.08rem;
  gap: 8px;
  line-height: 1.18;
}

.quick-rec-card h4 i {
  flex-shrink: 0;
  font-size: 1.25rem;
}

.quick-rec-card p {
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.35;
  max-width: 28ch;
}

.quick-rec-card:hover { transform: translateY(-3px); border-color: var(--accent-primary); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25); }

.genre-grid { margin-top: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 40px; }
.genre-card {
  border: 0;
  /* Always over a poster or a saturated fill, so it never follows the light palette */
  color: #FFFFFF;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  font: inherit;
  text-align: left;
  width: 100%;
  height: 150px; border-radius: 16px; padding: 20px; display: flex; flex-direction: column; justify-content: flex-end;
  background-size: cover; box-shadow: inset 0 -60px 60px rgba(0,0,0,0.5); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; position: relative;
}
.genre-card:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 3px;
}
.genre-card:hover {
  box-shadow: inset 0 -60px 60px rgba(0,0,0,0.5), 0 0 0 1px var(--accent-primary), 0 10px 24px rgba(0, 0, 0, 0.3);
  transform: translateY(-3px);
}
.genre-card.drama { background-color: #7B2CBF; }
.genre-card.comedy { background-color: #FF6D00; }
.genre-card.scifi { background-color: #3C096C; }
.genre-card.action { background-color: #D90429; }
.genre-card.horror { background-color: #2B2D42; }
.genre-card.thriller { background-color: #8D99AE; }
.genre-card.romance { background-color: #FF006E; }
.genre-card.fantasy { background-color: #8338EC; }
.genre-card.documentary { background-color: #3A86FF; }

.modal.genre-grid { margin-top: 0;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 10px;
}

/* MOVIE CARDS */
.card-grid { margin-top: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.movie-card { border-radius: 16px; overflow: hidden; background: var(--bg-dark); transition: 0.3s; cursor: pointer; position: relative; }
.movie-card:hover { transform: translateY(-5px); }
.card-image { width: 100%; height: 280px; object-fit: cover; }
.card-details { padding: 12px; display: flex; justify-content: space-between; }
.card-title { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.card-rating { color: var(--text-muted); font-size: 0.85rem; }
.card-rating i { color: var(--accent-star); }

/* Rating List Styles (Inline View) */
.precise-score-control {
  align-items: center;
  display: none;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

body.rating-scale-100 .precise-score-control {
  display: flex;
}

body.rating-scale-100 #train-ai-page .score-row,
body.rating-scale-100 .details-score-row,
body.rating-scale-100 .rating-edit-container .score-row {
  display: none;
}

.precise-score-range {
  accent-color: var(--accent-primary);
  flex: 1 1 180px;
  min-width: 0;
}

.precise-score-number {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  color: var(--text-main);
  font: inherit;
  font-weight: 700;
  padding: 8px 10px;
  text-align: center;
  width: 76px;
}

.precise-score-number:focus-visible {
  border-color: var(--accent-primary);
  outline: none;
}

.precise-score-save {
  padding: 10px 22px;
}

.ratings-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.ratings-sort-control {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.85rem;
  font-weight: 700;
  gap: 10px;
}

@media (max-width: 520px) {
  .ratings-sort-control {
    width: 100%;
  }

  .ratings-sort-control select {
    flex: 1;
  }
}

.rating-list-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.rating-list-item {
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  border-radius: 12px;
  padding: 15px;
  border: 1px solid var(--card-border);
}
.rating-list-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rating-list-info {
  display: flex;
  align-items: center;
  gap: 15px;
}
.rating-list-thumb {
  width: 50px;
  height: 75px;
  object-fit: cover;
  border-radius: 8px;
}
.rating-list-title {
  font-size: 1.1rem;
  margin-bottom: 5px;
}
.rating-list-score {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.rating-list-score i {
  color: var(--accent-star);
}
.rating-edit-container {
  display: none;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.rating-edit-container.open {
  display: block;
}

.local-mode-btn {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

/* AI Match Score Badge */
.ai-match-score {
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  font-weight: bold;
  background-color: var(--bg-dark);
  color: white;
  border: 3px solid white;
  flex-shrink: 0;
}

.ai-match-score.user-rating-score {
  border-color: var(--accent-star);
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

body.light-mode .ai-match-score.user-rating-score {
  border-color: var(--accent-star);
}

.user-rating-score i {
  color: var(--accent-star);
  font-size: 0.62em;
}

.featured-score {
  width: 50px;
  height: 50px;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.card-score {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.genre-card-score {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 44px;
  height: 44px;
  font-size: 1rem;
  z-index: 2;
  box-shadow: 0 4px 15px rgba(255, 109, 0, 0.4);
  border-color: var(--accent-primary);
  color: var(--text-main);
}

.genre-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  z-index: 2;
}

.genre-card p {
  z-index: 2;
}

.recommendation-card {
  min-height: 170px;
}

.recommendation-card h3 {
  display: block;
  max-width: calc(100% - 54px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recommendation-card p {
  color: rgba(255, 255, 255, 0.82);
  display: -webkit-box;
  font-size: 0.9rem;
  line-height: 1.35;
  margin-top: 6px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.recommendation-type {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 8px;
  padding: 4px 8px;
  z-index: 2;
}

.recommendation-empty {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: var(--text-muted);
  grid-column: 1 / -1;
  padding: 18px;
}

.data-loading .card-grid,
.data-loading .featured-movie-card {
  opacity: 0.7;
}

/* AI DRAWER STYLES */
.ai-drawer {
  position: fixed; top: 0; right: -450px; width: 400px; height: 100vh;
  background: var(--bg-overlay-solid); backdrop-filter: blur(15px);
  border-left: 1px solid var(--accent-primary); z-index: 1000;
  display: flex; flex-direction: column; transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.ai-drawer.open { right: 0; box-shadow: -10px 0 50px rgba(255, 109, 0, 0.3); }

.drawer-header { padding: 20px; display: flex; justify-content: space-between; border-bottom: 1px solid rgba(123, 44, 191, 0.3); }
.drawer-header h3 { color: var(--accent-text); display: flex; align-items: center; gap: 10px; }
.close-btn { background: none; border: none; color: white; font-size: 2rem; cursor: pointer; }

.ai-provider-status {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.78rem;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(123, 44, 191, 0.2);
}

.ai-provider-dot {
  background: var(--accent-star);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 205, 0, 0.45);
  display: inline-flex;
  height: 8px;
  width: 8px;
}

.ai-provider-status.is-live .ai-provider-dot {
  background: #65d48a;
  box-shadow: 0 0 10px rgba(101, 212, 138, 0.45);
}

.ai-provider-status.is-degraded .ai-provider-dot,
.ai-provider-status.is-local .ai-provider-dot {
  background: #ffb86c;
  box-shadow: 0 0 10px rgba(255, 184, 108, 0.45);
}

.chat-history { flex-grow: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
.chat-bubble { padding: 12px 16px; border-radius: 12px; max-width: 80%; font-size: 0.9rem; }
.bot-bubble { background: var(--bg-card); align-self: flex-start; border: 1px solid var(--border-glow); }
.user-bubble { background: var(--accent-primary); color: var(--accent-contrast); align-self: flex-end; }
.notice-bubble { align-self: flex-start; padding: 4px 4px 0; max-width: 90%; color: var(--text-muted); font-size: 0.78rem; font-style: italic; }

.search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-result-card {
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  color: inherit;
  cursor: pointer;
  display: flex;
  gap: 12px;
  padding: 10px;
  text-align: left;
  transition: border-color 0.2s ease, transform 0.2s ease;
  width: 100%;
}

.search-result-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.search-result-card img {
  border-radius: 8px;
  height: 74px;
  object-fit: cover;
  width: 62px;
}

.search-result-card div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-result-card strong {
  color: var(--text-main);
  font-size: 0.95rem;
}

.search-result-card span,
.search-result-card small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.search-result-card small i {
  color: var(--accent-star);
}

.chat-input-area { padding: 20px; background: rgba(0,0,0,0.2); }
.drawer-search-container { display: flex; background: var(--bg-panel); border-radius: 20px; padding: 10px 15px; border: 1px solid var(--border-glow); }
.drawer-search-input { flex-grow: 1; background: transparent; border: none; color: white; outline: none; }
.drawer-send-btn { background: none; border: none; color: var(--accent-text); font-size: 1.2rem; cursor: pointer; }

/* New AI Bot Button Style */
.ai-status-btn {
  background-color: var(--bg-card);
  color: var(--accent-text);
  border: 1px solid var(--border-glow);
  padding: 8px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.ai-status-btn i {
  font-size: 1.2rem;
}

.ai-status-btn:hover {
  background-color: var(--accent-primary);
  color: var(--accent-contrast);
  box-shadow: 0 0 15px rgba(255, 109, 0, 0.4);
}

/* Adjust top bar left group spacing */
.top-bar-left {
  display: flex;
  gap: 15px; /* Tighter grouping for left icons */
}

/* Featured Hero Section */
.featured-movie-card {
  box-shadow: var(--card-shadow);
  display: flex;
  background-color: var(--bg-card);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 40px;
  border: 1px solid var(--card-border);
  cursor: pointer;
}

.featured-image-container {
  flex: 1;
  max-width: 450px;
}

.featured-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.featured-movie-card:hover .featured-image {
  transform: scale(1.03);
}

.featured-info {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.featured-header h2 {
  font-size: 2.2rem;
  margin-bottom: 10px;
}

.tag-group {
  display: flex;
  gap: 10px;
}

.movie-tag {
  background: rgba(255, 109, 0, 0.15);
  color: var(--accent-text);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.featured-desc {
  color: #ccc;
  line-height: 1.6;
  font-size: 1.1rem;
}

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

.ai-btn-large {
  background-color: var(--accent-primary);
  color: var(--accent-contrast);
  border: none;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.provider-logo {
  height: 30px;
  filter: brightness(1.2);
}

/* Section Header Rows (Title + See All) */
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 20px;
}

.featured-header-row {
  margin-top: 0;
}

.see-all {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.see-all:hover {
  color: var(--accent-text);
}

/* ============================== */
/* SETTINGS PAGE STYLES           */
/* ============================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 30px;
  margin-top: 10px;
}

.settings-card {
  background-color: var(--bg-card);
  box-shadow: var(--card-shadow);
  border-radius: 16px;
  padding: 25px;
  border: 1px solid var(--card-border);
}

.settings-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  color: var(--text-main);
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-glow);
  padding-bottom: 15px;
}

.settings-card-title i {
  color: var(--accent-text);
  font-size: 1.4rem;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid rgba(123, 44, 191, 0.1);
  cursor: pointer;
  transition: transform 0.2s;
}

.setting-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setting-item:hover .arrow-icon {
  color: var(--accent-text);
  transform: translateX(3px);
}

.setting-item-action {
  gap: 16px;
  cursor: default;
}

.settings-select {
  min-width: 132px;
  padding: 10px 34px 10px 12px;
  border: 1px solid color-mix(in srgb, var(--text-main) 18%, transparent);
  border-radius: 8px;
  /* Gradient chevron so the arrow follows the theme colour; a data-URI SVG can't read variables */
  appearance: none;
  background-color: var(--bg-panel);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  color: var(--text-main);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-select:hover {
  border-color: var(--accent-primary);
}

.settings-select:focus-visible {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 30%, transparent);
  outline: none;
}

.settings-select option {
  background-color: var(--bg-panel);
  color: var(--text-main);
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 1rem;
}

.setting-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.api-card {
  grid-column: 1 / -1;
}

.api-status {
  background-color: rgba(0,0,0,0.16);
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 15px;
  padding: 12px 14px;
}

.api-status.connected {
  border-color: var(--accent-primary);
  color: var(--accent-text);
}

.api-status.warning {
  color: var(--accent-star);
}

.api-key-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.api-key-row input {
  background-color: rgba(0,0,0,0.2);
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  color: var(--text-main);
  flex: 1;
  font-size: 1rem;
  outline: none;
  padding: 11px 14px;
}

.api-key-row input:focus {
  border-color: var(--accent-primary);
}

.arrow-icon {
  color: var(--text-muted);
  font-size: 1.5rem;
  transition: all 0.2s ease;
}

/* ============================== */
/* PROFILE PAGE STYLES            */
/* ============================== */
.profile-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
  align-items: stretch;
}

.launch-hidden {
  display: none !important;
}

.profile-details-flex {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-top: 18px;
}

.profile-avatar-xl {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--accent-primary);
  object-fit: cover;
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.profile-text-details h2 {
  font-size: 2rem;
  margin-bottom: 5px;
}

.sub-text {
  color: var(--text-muted);
  font-size: 1rem;
}

.profile-tag {
  background-color: transparent;
  color: var(--accent-text);
  border: 1px solid var(--accent-primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-block;
}

.profile-sync-message {
  color: #ff9d66;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 10px;
  max-width: 520px;
}

.profile-sync-message:empty {
  display: none;
}

.profile-bio {
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 520px;
  white-space: pre-line;
}

.profile-bio:empty,
.profile-tag:empty {
  display: none;
}

.profile-tag.add-tag {
  color: var(--text-muted);
  border: 1px dashed var(--text-muted);
  cursor: pointer;
  transition: 0.2s;
}

.profile-tag.add-tag:hover {
  color: var(--text-main);
  border-color: var(--text-main);
}

.sub-features-list {
  list-style: none;
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.55;
}

.sub-features-list li strong {
  color: var(--text-muted);
}

.tip-jar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
}

.tip-jar-copy p {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.35;
  margin-top: 2px;
}

.tip-jar-kicker {
  color: var(--text-main);
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}

.tip-jar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tip-jar-btn {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  padding: 7px 14px;
  white-space: nowrap;
}

.profile-divider {
  display: none;
}

/* 4 Quadrants Grid */
.profile-quad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.profile-info-card,
.profile-sub-card,
.quad-card {
  background-color: var(--bg-card);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.profile-info-card .section-title,
.profile-sub-card .section-title {
  margin: 0;
}

.profile-sub-card {
  gap: 14px;
}

.profile-card-actions {
  align-items: center;
  display: flex;
  gap: 15px;
}

.profile-import-btn {
  border-radius: 8px;
  font-size: 0.85rem;
  padding: 6px 12px;
}

.profile-sub-card .section-header-row,
.quad-card .section-header-row {
  margin: 0 0 16px;
}

.profile-sub-card > .sub-text {
  margin: 0;
}

.profile-sub-card .browse-btn {
  border-radius: 8px;
}

.quad-card {
  min-height: 190px;
}

.quad-title {
  font-size: 1.2rem;
  margin-bottom: 0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.quad-title i {
  color: var(--accent-text);
}

/* Circular Items (Ratings, Friends, Watchlist) */
.circular-item-row {
  display: flex;
  gap: 25px;
  min-height: 96px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.circle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  width: 90px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.circle-item:hover {
  transform: translateY(-5px);
}

.circle-item img {
  width: 85px;
  height: 85px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid transparent;
  transition: 0.2s ease;
}

.circle-item:hover img {
  border-color: var(--accent-primary);
  box-shadow: 0 5px 15px rgba(255, 109, 0, 0.3);
}

.circle-item span {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.2;
}

.friend-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 20px;
}

.social-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 24px;
}

.social-panel {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 20px;
  min-width: 0;
}

.social-panel-wide {
  grid-column: 1 / -1;
}

.compact-row {
  margin-top: 0;
  margin-bottom: 16px;
}

.social-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--text-main) 18%, transparent);
  border-radius: 8px;
  background-color: var(--bg-panel);
  color: var(--text-muted);
}

.social-search:focus-within {
  border-color: var(--accent-primary);
}

.social-search-input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font: inherit;
}

.social-people-list,
.activity-feed {
  display: grid;
  gap: 12px;
}

.social-person-card,
.activity-row {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-main);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.social-person-card:hover,
.activity-row:hover,
.shared-watchlist-item:hover {
  border-color: var(--accent-primary);
}

.social-person-card img,
.activity-row img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.social-person-card h4 {
  color: var(--text-main);
  margin-bottom: 4px;
}

.social-person-card p,
.activity-row small {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.social-follow-btn {
  padding: 7px 12px;
  border-radius: 8px;
  white-space: nowrap;
}

.social-follow-btn.active,
#fi-follow-btn.active {
  border-color: var(--accent-primary);
  color: var(--accent-text);
}

.activity-row {
  grid-template-columns: 42px 1fr auto;
}

.activity-row img {
  width: 42px;
  height: 42px;
}

.activity-row span {
  line-height: 1.35;
}

.social-rec-grid {
  margin-top: 0;
}

.shared-watchlist-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.shared-watchlist-item {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.shared-watchlist-item img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
}

.shared-watchlist-item span {
  font-size: 0.85rem;
  line-height: 1.25;
}

/* ============================== */
/* DASHBOARD & STATS STYLES       */
/* ============================== */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns perfectly */
  gap: 20px;
}

.dash-card {
  background-color: var(--bg-card);
  box-shadow: var(--card-shadow);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
}

.general-stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 40px;
}

.stat-summary-card {
  background-color: var(--bg-card);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  min-width: 0;
  padding: 18px;
}

.stat-summary-card h3 {
  color: var(--accent-text);
  font-size: 1.9rem;
  line-height: 1;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.stat-summary-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
}

.span-2 {
  grid-column: span 2; /* Makes the chart take up 2 blocks */
}

.dash-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Split Cards (Left stats, Right poster) */
.split-card {
  flex-direction: row;
  padding: 0;
  overflow: hidden;
}

.split-left {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.circle-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid var(--accent-star);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  color: var(--text-main);
}

.dash-time {
  font-weight: bold;
  font-size: 1.1rem;
}

.stats-card-title {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.25;
  max-width: 100%;
  text-align: center;
}

.stats-content-card[data-content-id] {
  cursor: pointer;
}

.stats-rank-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.stats-rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-main);
  font-size: 0.9rem;
}

.stats-rank-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-rank-row span {
  color: var(--text-muted);
  flex: 0 0 auto;
  font-size: 0.8rem;
}

.dash-poster {
  width: 45%;
  object-fit: cover;
  border-left: 1px solid rgba(123, 44, 191, 0.3);
}

/* Progress Bars */
.progress-item {
  margin-bottom: 12px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.progress-info span:last-child {
  color: var(--text-muted);
}

.progress-bg {
  width: 100%;
  height: 8px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--accent-star);
  border-radius: 10px;
}

/* Mock Chart Area */
.mock-chart-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-top: 15px;
}

.mock-chart-line {
  width: 100%;
  height: 120px;
  /* Adds a subtle orange glow behind the chart line */
  filter: drop-shadow(0 10px 10px rgba(255, 109, 0, 0.2)); 
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.chart-labels .active {
  color: var(--text-main);
  background-color: var(--text-muted);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
/* ============================== */
/* PREMIUM THEME BADGE STYLES     */
/* ============================== */

.premium-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-primary);
  color: var(--bg-dark);
  font-size: 0.65rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

.theme-option-premium.locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.subscription-kicker {
  display: inline-block;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.subscription-status-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

#subscription-upgrade-btn:disabled,
#subscription-cancel-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================== */
/* CSV IMPORT MODAL STYLES        */
/* ============================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none; /* Keeps it from blocking clicks when hidden */
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--bg-panel);
  width: 90%;
  max-width: 500px;
  border-radius: 20px;
  border: 1px solid var(--border-glow);
  box-shadow: 0 15px 50px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.genre-results-content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  max-height: calc(100dvh - 48px);
  max-width: 980px;
  overflow: hidden;
  width: min(980px, 100%);
}

.genre-results-content .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
}

.genre-results-content #genre-results-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.content-details-modal {
  z-index: 2500;
}

.details-modal-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.6);
  max-height: 86vh;
  max-width: 920px;
  overflow: auto;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  width: 92%;
}

.modal-overlay.open .details-modal-card {
  transform: translateY(0);
}

.drag-drop-zone.drag-over {
  background-color: rgba(255, 109, 0, 0.08);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.drag-drop-zone.is-busy {
  cursor: progress;
  pointer-events: none;
}

.drag-drop-zone.is-success {
  background-color: rgba(255, 109, 0, 0.08);
  border-color: var(--accent-primary);
  border-style: solid;
}

.drag-drop-zone.is-error {
  border-color: var(--danger-text);
  border-style: solid;
}

.drag-drop-zone.is-busy i,
.drag-drop-zone.is-success i {
  color: var(--accent-text);
}

.drag-drop-zone.is-error i {
  color: var(--danger-text);
}

.drag-drop-zone.is-success i {
  animation: importCheckPop 0.35s ease;
}

@keyframes importCheckPop {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

.drag-drop-zone .drop-zone-file {
  color: var(--text-main);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.csv-import-status {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-top: 14px;
  min-height: 22px;
}

.csv-import-status.success,
.csv-import-status.error {
  border-radius: 10px;
  font-weight: 700;
  padding: 10px 14px;
}

.csv-import-status.success {
  background-color: rgba(255, 109, 0, 0.1);
  border: 1px solid var(--accent-primary);
  color: var(--accent-text);
}

.csv-import-status.error {
  background-color: rgba(255, 82, 82, 0.08);
  border: 1px solid var(--danger-text);
  color: var(--danger-text);
}

.details-close-btn {
  align-items: center;
  background-color: rgba(0,0,0,0.42);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  font-size: 1.6rem;
  height: 42px;
  justify-content: center;
  position: absolute;
  right: 18px;
  top: 18px;
  transition: background-color 0.2s ease, transform 0.2s ease;
  width: 42px;
  z-index: 2;
}

.details-close-btn:hover {
  background-color: var(--accent-primary);
  color: var(--accent-contrast);
  transform: scale(1.05);
}

.details-backdrop {
  background-position: center;
  background-size: cover;
  height: 220px;
}

.details-body {
  display: grid;
  gap: 28px;
  grid-template-columns: 220px 1fr;
  padding: 0 34px 34px;
}

.details-poster-wrap {
  margin-top: -90px;
}

.details-poster {
  aspect-ratio: 2 / 3;
  border: 3px solid var(--accent-primary);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  object-fit: cover;
  width: 100%;
}

.details-info {
  padding-top: 24px;
}

.details-heading-row {
  align-items: center;
  display: flex;
  gap: 15px;
  margin-bottom: 10px;
  min-width: 0;
}

.details-heading-row h2 {
  margin-bottom: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.details-type-pill {
  background-color: rgba(255, 109, 0, 0.15);
  border: 1px solid var(--accent-primary);
  border-radius: 999px;
  color: var(--accent-text);
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding: 5px 11px;
  text-transform: uppercase;
}

.details-info h2 {
  color: var(--text-main);
  font-size: 2rem;
  line-height: 1.1;
  margin-bottom: 12px;
}

.details-heading-row h2 {
  margin-bottom: 0;
}

.details-meta {
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.95rem;
  font-weight: 700;
  gap: 12px;
  margin-bottom: 16px;
}

.details-meta i {
  color: var(--accent-star);
}

.details-overview {
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.65;
  margin: 18px 0 24px;
}

.ai-estimate-panel {
  background-color: rgba(123, 44, 191, 0.12);
  border: 1px solid rgba(123, 44, 191, 0.36);
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.ai-estimate-panel[hidden] {
  display: none;
}

.ai-estimate-heading {
  align-items: center;
  color: var(--text-main);
  display: flex;
  font-weight: 600;
  gap: 8px;
}

.ai-estimate-heading strong {
  font-size: 1.15rem;
  margin-left: auto;
}

.ai-estimate-reason {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 6px 0 0;
}

.ai-estimate-panel.is-loading .ai-estimate-reason {
  font-style: italic;
}

.watch-provider-panel {
  background-color: rgba(255,255,255,0.04);
  border: 1px solid rgba(123, 44, 191, 0.36);
  border-radius: 8px;
  margin-bottom: 22px;
  padding: 14px;
}

.watch-provider-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.watch-provider-header h3 {
  color: var(--text-main);
  font-size: 1rem;
}

.provider-country-control {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.82rem;
  font-weight: 700;
  gap: 8px;
}

.provider-country-control select {
  background-color: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  color: var(--text-main);
  font: inherit;
  max-width: 170px;
  padding: 7px 10px;
}

.watch-provider-list {
  display: grid;
  gap: 12px;
}

.watch-provider-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.watch-provider-group h4 {
  color: var(--accent-text);
  font-size: 0.78rem;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.watch-provider-logos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.watch-provider-chip {
  align-items: center;
  background-color: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--text-main);
  display: flex;
  font-size: 0.86rem;
  font-weight: 700;
  gap: 8px;
  min-height: 38px;
  padding: 6px 9px;
}

a.watch-provider-chip {
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

a.watch-provider-chip:hover,
a.watch-provider-chip:focus-visible {
  background-color: rgba(123, 44, 191, 0.22);
  border-color: var(--border-glow);
}

a.watch-provider-chip .bx-link-external {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.watch-provider-attribution {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.watch-provider-chip img {
  border-radius: 6px;
  height: 28px;
  object-fit: cover;
  width: 28px;
}

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

.details-rating-panel {
  align-items: center;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(123, 44, 191, 0.36);
  border-radius: 8px;
  display: none;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
}

.details-rating-panel.open {
  display: flex;
  flex-wrap: wrap;
}

.details-rating-panel > span {
  color: var(--text-main);
  font-weight: 800;
}

.details-score-row {
  justify-content: flex-start;
  width: auto;
}

.details-episode-panel {
  align-items: center;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(123, 44, 191, 0.36);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 14px;
  padding: 14px;
}

.details-episode-panel[hidden] {
  display: none;
}

.details-episode-panel > label {
  color: var(--text-main);
  font-weight: 800;
}

.details-episode-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.details-episode-controls input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-main);
  font-weight: 700;
  padding: 8px 10px;
  text-align: center;
  width: 5.5em;
}

#details-episodes-total {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.details-score-btn.active,
.browse-btn.active {
  background-color: var(--accent-primary);
  color: var(--accent-contrast);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid rgba(123, 44, 191, 0.3);
}

.modal-header h3 {
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h3 i {
  color: var(--accent-text);
  font-size: 1.4rem;
}

.modal-body {
  padding: 25px;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.drag-drop-zone {
  border: 2px dashed var(--border-glow);
  border-radius: 16px;
  cursor: pointer;
  padding: 40px 20px;
  text-align: center;
  background-color: rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.drag-drop-zone:hover {
  border-color: var(--accent-primary);
  background-color: rgba(255, 109, 0, 0.05);
}

.drag-drop-zone i {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.drag-drop-zone h4 {
  color: var(--text-main);
  margin-bottom: 5px;
}

.drag-drop-zone p {
  color: var(--text-muted);
  margin-bottom: 15px;
  font-size: 0.9rem;
}

.browse-btn {
  background-color: var(--bg-card);
  color: var(--accent-text);
  border: 1px solid var(--accent-primary);
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.browse-btn:hover {
  background-color: var(--accent-primary);
  color: var(--accent-contrast);
}

.danger-btn {
  border-color: var(--danger-text);
  color: var(--danger-text);
  white-space: nowrap;
}

.danger-btn:hover,
.danger-fill-btn,
.danger-fill-btn:hover {
  background-color: var(--danger-fill);
  border-color: var(--danger-fill);
  color: #fff;
}

.danger-fill-btn:hover {
  filter: brightness(1.08);
}

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

.danger-btn:disabled:hover {
  background-color: var(--bg-card);
  border-color: var(--danger-text);
  color: var(--danger-text);
}

.supported-platforms {
  margin-top: 25px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.platform-tags {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.platform-tags .tag {
  background-color: var(--bg-card);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-glow);
}
/* ============================== */
/* TRAIN AI (TINDER) STYLES       */
/* ============================== */

.train-banner {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(123, 44, 191, 0.3) 100%);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  padding: 25px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.banner-text h3 {
  color: var(--text-main);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.banner-text h3 i { color: var(--accent-text); }
.banner-text p { color: var(--text-muted); font-size: 0.95rem; }

.tinder-container {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.progress-bar-container {
  width: 100%;
  margin-bottom: 30px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.tinder-card-area {
  position: relative;
  width: 100%;
  height: 500px;
  perspective: 1000px;
}

.tinder-card {
  width: 100%;
  height: 100%;
  background-color: var(--bg-card);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border: 1px solid var(--border-glow);
  display: flex;
  flex-direction: column;
  position: absolute;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
}

.tinder-card img {
  width: 100%;
  height: 75%;
  object-fit: cover;
}

.tinder-info {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.tinder-info h2 { font-size: 1.8rem; margin-bottom: 5px; }
.tinder-info p { color: var(--text-muted); font-size: 0.95rem; }

/* The Swipe Animations */
.swipe-out-right { transform: translateX(150%) rotate(15deg); opacity: 0; }
.swipe-out-left { transform: translateX(-150%) rotate(-15deg); opacity: 0; }
.swipe-in-bottom { transform: translateY(50px); opacity: 0; animation: popIn 0.4s forwards; }

@keyframes popIn {
  to { transform: translateY(0); opacity: 1; }
}

.rating-controls {
  margin-top: 30px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.score-row {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.score-btn {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-glow);
  width: 45px;
  height: 45px;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.score-btn:hover {
  background-color: var(--accent-primary);
  color: var(--accent-contrast);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(255, 109, 0, 0.4);
}

.score-btn:disabled,
.skip-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.skip-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: 0.2s;
}

.skip-btn:hover { color: var(--text-main); }

.skip-btn:disabled:hover { color: var(--text-muted); }

/* ============================== */
/* LOGIN / LANDING PAGE STYLES    */
/* ============================== */

.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-dark);
  background-image: radial-gradient(circle at center, var(--bg-panel) 0%, var(--bg-dark) 100%);
  z-index: 9999; /* Sits on top of the entire app */
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* We'll use this class via JavaScript to hide it */
.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.login-card {
  background-color: var(--bg-card);
  width: 100%;
  max-width: 420px;
  padding: 40px;
  border-radius: 20px;
  border: 1px solid var(--border-glow);
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
  animation: slideDown 0.6s ease;
}

@keyframes slideDown {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-brand-lockup {
  align-items: center;
  color: var(--accent-primary);
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 10px;
}

.auth-logo-frame {
  height: 64px;
  width: 64px;
}

.auth-brand-name {
  color: var(--accent-primary);
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
}

.login-header h2 {
  color: var(--accent-text);
  font-size: 2.2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.input-group input {
  width: 100%;
  padding: 12px 15px;
  border-radius: 10px;
  background-color: rgba(0,0,0,0.2);
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: 0.3s;
}

.input-group input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(255, 109, 0, 0.2);
}

.login-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  font-size: 0.85rem;
}

.remember-me {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.forgot-link, .login-footer a {
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 600;
  transition: 0.2s;
}

.forgot-link:hover, .login-footer a:hover {
  color: var(--accent-star);
}

.login-submit-btn {
  width: 100%;
  justify-content: center;
}

.login-submit-btn:disabled,
.social-btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.login-submit-btn[aria-busy="true"] {
  cursor: wait;
}

.auth-message {
  min-height: 18px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
}

.auth-message.error {
  color: #ffb4b4;
}

.auth-message.success {
  color: #a7f3d0;
}

.login-footer {
  text-align: center;
  margin-top: 25px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================== */
/* SOCIAL AUTH STYLES             */
/* ============================== */

.social-login {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.social-btn {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 10px;
  background-color: transparent;
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.social-btn i {
  font-size: 1.2rem;
}

.social-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.auth-divider::before, 
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-glow);
}

.auth-divider span {
  padding: 0 10px;
}

/* ============================== */
/* 📱 MOBILE RESPONSIVENESS       */
/* ============================== */

@media (max-width: 768px) {
  /* 1. Collapse the main grid to 1 column */
  .app-container {
    grid-template-columns: 1fr;
  }

  /* 2. Hide the sidebar off-screen by default */
  .sidebar {
    position: fixed;
    left: -300px; /* Hidden to the left */
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 9000;
    transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
  }

  /* When JS adds this class, the sidebar slides in! */
  .sidebar.open {
    left: 0;
  }

  /* 3. Show the hamburger menu, hide extra top-bar icons */
  #mobile-menu-btn {
    display: block !important;
  }
  .top-bar-left .bx-chevron-left, 
  .top-bar-left .bx-refresh {
    display: none; 
  }

  /* 4. Squeeze the search bar and AI button */
  .search-container {
    width: 100%;
    margin: 0 10px;
    padding: 8px 15px;
  }
  .top-bar {
    padding: 15px 20px;
    gap: 10px;
  }
  
  /* Hide the text on the top right AI button, keep just the icon */
  .ai-status-btn {
    padding: 8px;
    border-radius: 50%;
  }
  .ai-status-btn span {
    display: none; 
  }

  .api-key-row {
    flex-direction: column;
  }

  /* 5. Stack all grids into 1 column */
  .hero-row { flex-direction: column; }
  .general-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .genre-grid { margin-top: 0; grid-template-columns: minmax(0, 1fr); }
  .profile-top-grid { grid-template-columns: 1fr; }
  .profile-quad-grid { grid-template-columns: 1fr; }
  .social-layout { grid-template-columns: 1fr; }
  .friend-grid { grid-template-columns: repeat(2, minmax(90px, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .setting-item-action {
    align-items: flex-start;
    flex-direction: column;
  }
  .dash-grid { grid-template-columns: 1fr; }
  .social-person-card,
  .activity-row {
    grid-template-columns: 42px 1fr;
  }
  .social-follow-btn,
  .activity-row small {
    grid-column: 2;
    justify-self: start;
  }
  
  /* Make the big chart span 1 column instead of 2 */
  .span-2 { grid-column: span 1; }

  /* 6. Adjust AI Drawer for Mobile */
  .ai-drawer {
    width: 100%; /* Takes up whole screen on mobile */
    right: -100%;
  }

  /* 7. Train AI Page Adjustments */
  .tinder-card-area { height: 400px; }
  .score-btn { width: 35px; height: 35px; font-size: 0.9rem; }
  .score-row { gap: 5px; }

  .details-modal-card {
    max-height: min(78dvh, 680px);
    overflow-y: auto;
    overscroll-behavior: contain;
    width: min(100%, 430px);
  }

  .details-backdrop {
    height: 104px;
  }

  .details-body {
    align-items: start;
    column-gap: 12px;
    grid-template-columns: minmax(88px, 104px) minmax(0, 1fr);
    padding: 0 16px 20px;
    row-gap: 8px;
  }

  .details-poster-wrap {
    grid-column: 1;
    grid-row: 1 / span 4;
    margin-top: -38px;
    max-width: 104px;
  }

  .details-info {
    display: contents;
  }

  .details-type-pill {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    margin: 10px 0 0;
  }

  .details-heading-row {
    align-items: flex-start;
    gap: 8px;
    grid-column: 2;
    grid-row: 2;
    margin: 0;
  }

  .details-heading-row h2 {
    flex: 1 1 auto;
    font-size: clamp(1.18rem, 5.6vw, 1.45rem);
    line-height: 1.12;
  }

  .details-heading-row .featured-score {
    flex: 0 0 40px;
    font-size: 1rem;
    height: 40px;
    width: 40px;
  }

  .details-meta {
    font-size: 0.82rem;
    gap: 6px 10px;
    grid-column: 2;
    grid-row: 3;
    margin: 0;
  }

  .details-info > .tag-group {
    align-self: start;
    grid-column: 2;
    grid-row: 4;
  }

  .details-info > .tag-group .movie-tag {
    font-size: 0.72rem;
    padding: 4px 9px;
  }

  .details-overview {
    font-size: 0.94rem;
    grid-column: 1 / -1;
    grid-row: 5;
    line-height: 1.55;
    margin: 12px 0 16px;
  }

  .ai-estimate-panel {
    grid-column: 1 / -1;
    grid-row: 6;
    margin-bottom: 12px;
  }

  .watch-provider-panel {
    grid-column: 1 / -1;
    grid-row: 7;
    margin-bottom: 12px;
    padding: 12px;
  }

  .details-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 8;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .details-actions .ai-btn-large {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .details-actions .browse-btn {
    min-width: 0;
    white-space: normal;
  }

  .details-rating-panel {
    grid-column: 1 / -1;
    grid-row: 9;
  }

  .details-episode-panel {
    grid-column: 1 / -1;
    grid-row: 10;
  }

  .watch-provider-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .provider-country-control,
  .provider-country-control select {
    width: 100%;
  }

  /* 8. Profile Adjustments */
  .profile-info-card,
  .profile-sub-card,
  .quad-card {
    padding: 18px;
  }
  .profile-details-flex { flex-direction: column; text-align: center; }
  .profile-sub-card .section-header-row,
  .quad-card .section-header-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
  .tip-jar-card { align-items: stretch; flex-direction: column; }
  .tip-jar-btn { width: 100%; }
  .circular-item-row { flex-wrap: wrap; justify-content: center; }
}

/* Preset Avatar Selection Grid */
.preset-avatar-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.preset-avatar-item:hover {
    transform: scale(1.1);
    border-color: rgba(123, 44, 191, 0.5);
}

.preset-avatar-item.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-primary);
}

/* ============================== */
/* STANDARD SECTION SPACING       */
/* ============================== */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 45px;
    margin-bottom: 24px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Adjust first title in a page for balance */
.app-page > .section-title:first-child,
.app-page > div:first-child > .section-title:first-child {
    margin-top: 5px;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 45px;
    margin-bottom: 24px;
}

.section-header-row .section-title {
    margin: 0;
}

.app-page > .section-header-row:first-child {
    margin-top: 5px;
}

.card-grid, .genre-grid {
    margin-top: 0 !important;
}

/* Mobile modal and featured-card sizing fixes */
.featured-info,
.featured-header > div {
  min-width: 0;
}

.tag-group {
  flex-wrap: wrap;
}

.dash-card {
  min-width: 0;
}

@media (max-width: 768px) {
  .content-area {
    padding: 24px 18px;
  }

  .top-bar {
    gap: 8px;
    padding: 12px;
  }

  .top-bar-left {
    flex: 0 0 auto;
    gap: 12px;
  }

  .top-bar-right {
    flex: 0 0 auto;
  }

  .search-container {
    flex: 1 1 0;
    margin: 0;
    min-width: 0;
    padding: 6px 10px;
    width: auto;
  }

  .search-input {
    min-width: 0;
    padding: 8px 0 8px 8px;
    width: 100%;
  }

  .train-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 28px;
    padding: 20px;
  }

  .train-banner .banner-text {
    min-width: 0;
  }

  .train-banner .banner-text h3 {
    font-size: 1.25rem;
  }

  .train-banner .ai-btn-large {
    justify-content: center;
    width: 100%;
  }

  html,
  body,
  .app-container {
    max-width: 100%;
    overflow-x: hidden;
  }

  .main-content,
  .top-bar,
  .content-area {
    min-width: 0;
    width: 100%;
  }

  .sidebar {
    left: 0;
    transform: translateX(-110%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  }

  .sidebar.open {
    left: 0;
    transform: translateX(0);
  }

  .ai-drawer {
    right: 0;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  }

  .ai-drawer.open {
    right: 0;
    transform: translateX(0);
  }

  .genre-card:hover,
  .movie-card:hover {
    transform: none;
  }

  .section-header-row {
    align-items: center;
    gap: 12px;
    margin-top: 28px;
  }

  .section-header-row .section-title {
    flex: 1 1 auto;
    font-size: 1.32rem;
    line-height: 1.15;
    min-width: 0;
  }

  .featured-header-row .browse-btn {
    flex: 0 0 auto;
    padding: 8px 14px;
    white-space: nowrap;
  }

  .featured-movie-card {
    border-radius: 18px;
    flex-direction: column;
    margin-bottom: 30px;
  }

  .featured-image-container {
    flex: 0 0 auto;
    height: clamp(190px, 54vw, 240px);
    max-width: none;
    width: 100%;
  }

  .featured-info {
    gap: 14px;
    padding: 22px;
  }

  .featured-header > div {
    align-items: flex-start !important;
    flex-wrap: wrap;
    gap: 12px !important;
  }

  .featured-header h2 {
    flex: 1 1 190px;
    font-size: clamp(1.45rem, 7vw, 2rem);
    line-height: 1.12;
    margin-bottom: 2px;
    overflow-wrap: anywhere;
  }

  .featured-score {
    height: 46px;
    width: 46px;
  }

  .featured-desc {
    font-size: 0.98rem;
    line-height: 1.5;
  }

  .featured-actions {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 12px;
  }

  .featured-actions .ai-btn-large {
    justify-content: center;
    min-width: 0;
  }

  .modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }

  #details-modal {
    align-items: center;
    overflow: hidden;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }

  #details-modal .details-close-btn {
    font-size: 1.35rem;
    height: 36px;
    right: 12px;
    top: 12px;
    width: 36px;
  }

  .modal-content,
  #genres-modal .modal-content,
  #detailed-stats-modal .modal-content {
    border-radius: 18px;
    max-height: calc(100dvh - 24px);
    max-width: 100% !important;
    overflow: hidden;
    width: 100% !important;
  }

  .modal-header {
    gap: 12px;
    padding: 16px 18px;
  }

  .modal-header h3 {
    font-size: 1.05rem;
    line-height: 1.2;
    min-width: 0;
  }

  .modal-body,
  #detailed-stats-modal .modal-body,
  #genres-modal .modal-body {
    max-height: calc(100dvh - 88px);
    overflow-y: auto;
    padding: 16px !important;
  }

  .modal-genre-grid {
    gap: 12px;
    grid-template-columns: 1fr !important;
    margin-bottom: 0;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .modal-genre-grid .genre-card {
    border-radius: 14px;
    height: clamp(112px, 31vw, 138px);
    padding: 18px;
  }

  .genre-results-content {
    height: auto;
    max-height: calc(100dvh - 24px);
    width: 100%;
  }

  .genre-results-content .modal-body {
    padding: 16px !important;
  }

  .genre-results-content #genre-results-grid {
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .genre-results-content .card-image {
    height: clamp(180px, 56vw, 230px);
  }

  .genre-results-content .card-title {
    max-width: none;
    min-width: 0;
  }

  #stats-modal-grid {
    gap: 14px;
    grid-template-columns: 1fr !important;
  }

  #detailed-stats-modal .dash-card {
    border-radius: 14px;
    padding: 18px;
  }

  #detailed-stats-modal .dash-card h2 {
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  #detailed-stats-modal .split-card {
    min-height: 176px;
  }

  #detailed-stats-modal .split-left {
    padding: 18px;
  }

  #detailed-stats-modal .dash-poster {
    width: 42%;
  }
}

@media (max-width: 430px) {
  .featured-header-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .featured-header-row .browse-btn {
    align-self: flex-start;
  }

  .genre-results-content #genre-results-grid {
    grid-template-columns: 1fr;
  }

  .genre-results-content .card-image {
    height: clamp(220px, 72vw, 300px);
  }
}

@media (max-width: 360px) {
  #details-modal {
    padding-left: 12px;
    padding-right: 12px;
  }

  .details-body {
    column-gap: 10px;
    grid-template-columns: 80px minmax(0, 1fr);
    padding: 0 12px 16px;
  }

  .details-poster-wrap {
    margin-top: -28px;
    max-width: 80px;
  }

  .details-heading-row {
    gap: 6px;
  }

  .details-heading-row h2 {
    font-size: clamp(1.05rem, 6vw, 1.2rem);
  }

  .details-heading-row .featured-score {
    flex-basis: 36px;
    font-size: 0.9rem;
    height: 36px;
    width: 36px;
  }

  .details-meta {
    font-size: 0.75rem;
  }
}
