/* ── Variables ── */
:root {
  --bg:         #0a0a0a;
  --surface-1:  #141414;
  --surface-2:  #1c1c1c;
  --surface-3:  #242424;
  --border:     #2a2a2a;
  --text-1:     #f0f0f0;
  --text-2:     #999;
  --text-3:     #555;
  --red:        #e50914;
  --red-dim:    rgba(229, 9, 20, 0.15);
  --blue:       #3b82f6;
  --blue-dim:   rgba(59, 130, 246, 0.15);
  --purple:     #8b5cf6;
  --gold:       #f5c518;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.6);
  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  height: 60px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 3px;
  cursor: pointer;
  user-select: none;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.logo:hover { opacity: 0.8; }

nav { display: flex; gap: 2px; }

nav button {
  background: none;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
nav button:hover:not(.active) { color: var(--text-1); background: var(--surface-2); }
nav button.active             { color: var(--red); background: var(--red-dim); }

nav button span {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ── Layout ── */
.container { max-width: 1280px; margin: 0 auto; padding: 28px 28px 60px; }

/* ── Search bar ── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.ac-wrapper { flex: 1; position: relative; }

.ac-wrapper input {
  width: 100%;
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ac-wrapper input::placeholder { color: var(--text-3); }
.ac-wrapper input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}

.search-bar > button {
  padding: 12px 24px;
  background: var(--red);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  align-self: flex-start;
}
.search-bar > button:hover  { background: #c4070f; }
.search-bar > button:active { transform: scale(0.97); }

/* ── Autocomplete dropdown ── */
.ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 300;
  box-shadow: var(--shadow);
  animation: fadeDown 0.15s ease;
}
.ac-dropdown.open { display: block; }

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

.ac-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.ac-item:hover { background: var(--surface-3); }
.ac-item + .ac-item { border-top: 1px solid var(--border); }

.ac-poster {
  width: 36px; height: 54px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.ac-no-poster {
  width: 36px; height: 54px;
  background: var(--surface-3);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.ac-title { font-size: 0.875rem; font-weight: 600; color: var(--text-1); }
.ac-year  { font-size: 0.75rem;  color: var(--text-2); margin-top: 2px; }

/* ── Section label ── */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

/* ── Movies grid ── */
.movies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

/* ── Movie card ── */
.movie-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 2/3;
  background: var(--surface-1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.movie-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
}

.movie-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.movie-card:hover img { transform: scale(1.06); }

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.92) 0%,
    rgba(0, 0, 0, 0.5)  35%,
    rgba(0, 0, 0, 0.1)  60%,
    transparent         100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  transition: background var(--transition);
}

.card-badges {
  position: absolute;
  top: 8px; right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.badge {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.badge-fav   { background: rgba(229, 9, 20, 0.85); color: #fff; }
.badge-watch { background: rgba(59, 130, 246, 0.85); color: #fff; }
.badge-tv    { background: rgba(139, 92, 246, 0.85); color: #fff; font-size: 0.62rem; }

.card-title {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.card-meta {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.55);
  margin-top: 3px;
}

.no-poster {
  width: 100%; height: 100%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}

/* ── Skeleton loading ── */
.skeleton-card {
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 50%, var(--surface-1) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 0.9rem;
}

/* ── Modal ── */
.modal-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  padding: 20px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition: opacity 0.25s ease, backdrop-filter 0.25s ease, background 0.25s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  display: flex;
  gap: 24px;
  padding: 28px;
  position: relative;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: scale(0.95) translateY(12px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.25s ease;
}
.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-poster { flex-shrink: 0; width: 175px; }
.modal-poster img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: block;
}
.modal-poster .no-poster {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  font-size: 3rem;
}

.modal-body { flex: 1; min-width: 0; }
.modal-body h2 {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
  color: var(--text-1);
}

.close-btn {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.close-btn:hover { background: var(--surface-3); color: var(--text-1); border-color: var(--text-3); }

/* ── Modal content ── */
.tagline {
  font-style: italic;
  color: var(--text-2);
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.modal-meta {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.meta-dot { color: var(--text-3); }

.genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.genre-pill {
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.meta-rows { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.meta-row  { font-size: 0.8rem; color: var(--text-2); }
.meta-row strong { color: var(--text-1); font-weight: 600; }

.modal-overview {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-2);
  margin-bottom: 20px;
}

/* ── Cast ── */
.cast-section { margin-top: 18px; margin-bottom: 20px; }
.cast-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.cast-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.cast-card { flex-shrink: 0; width: 66px; text-align: center; }
.cast-photo {
  width: 54px; height: 54px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 7px;
  border: 2px solid var(--border);
  transition: border-color var(--transition);
}
.cast-card:hover .cast-photo { border-color: var(--red); }
.cast-no-photo {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  margin: 0 auto 7px;
}
.cast-name {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cast-char {
  font-size: 0.62rem;
  color: var(--text-3);
  line-height: 1.3;
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Buttons ── */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: scale(0.97); }

.btn-red        { background: var(--red);  color: #fff; }
.btn-red:hover  { background: #c4070f; box-shadow: 0 4px 12px rgba(229,9,20,0.35); }

.btn-red-ghost  { background: transparent; color: var(--red); border: 1px solid rgba(229,9,20,0.4); }
.btn-red-ghost:hover { background: var(--red-dim); border-color: var(--red); }

.btn-blue       { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #2563eb; box-shadow: 0 4px 12px rgba(59,130,246,0.35); }

.btn-blue-ghost { background: transparent; color: var(--blue); border: 1px solid rgba(59,130,246,0.4); }
.btn-blue-ghost:hover { background: var(--blue-dim); border-color: var(--blue); }

.btn-dark       { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.btn-dark:hover { background: var(--surface-3); color: var(--text-1); }

.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Star rating ── */
.stars { display: flex; gap: 4px; margin: 16px 0 4px; }
.star {
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--surface-3);
  transition: color 0.1s, transform 0.1s;
  line-height: 1;
}
.star.on           { color: var(--gold); }
.star:hover        { color: var(--gold); transform: scale(1.15); }
.rating-label      { font-size: 0.75rem; color: var(--text-3); margin-bottom: 16px; }

/* ── Notes ── */
.notes-section { margin-top: 18px; }

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.notes-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.notes-status {
  font-size: 0.72rem;
  color: #2ecc71;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.notes-status.show { opacity: 1; }

.notes-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.65;
  padding: 10px 12px;
  resize: vertical;
  min-height: 85px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.notes-textarea::placeholder { color: var(--text-3); }
.notes-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.1);
}

.fav-note-preview {
  font-size: 0.75rem;
  color: var(--text-3);
  font-style: italic;
  margin-top: 6px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fav-note-preview::before { content: '📝 '; font-style: normal; }

/* ── Favorites / Watchlist list ── */
.fav-list { display: flex; flex-direction: column; gap: 10px; }

.fav-item {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  gap: 16px;
  padding: 14px;
  align-items: flex-start;
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.fav-item:hover { background: var(--surface-2); cursor: pointer; }
.fav-item.is-fav     { border-left-color: var(--red); }
.fav-item.is-watch   { border-left-color: var(--blue); }
.fav-item.is-tv-fav  { border-left-color: var(--purple); }
.fav-item.is-tv-watch{ border-left-color: var(--purple); }

.fav-item img {
  width: 60px; height: 90px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.fav-no-poster {
  width: 60px; height: 90px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.fav-body { flex: 1; min-width: 0; }
.fav-body h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 3px; }
.fav-body .yr { font-size: 0.75rem; color: var(--text-2); margin-bottom: 6px; }
.fav-body .ov {
  font-size: 0.78rem; color: var(--text-3); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.fav-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex-shrink: 0; }
.fav-stars { display: flex; gap: 2px; }
.fav-stars .star { font-size: 1rem; }

/* ── List section header ── */
.list-section { display: flex; flex-direction: column; gap: 10px; }
.list-section + .list-section { margin-top: 28px; }

.list-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.list-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Type badge ── */
.type-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  margin-bottom: 5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.type-badge.movie { background: var(--red-dim);  color: var(--red); }
.type-badge.tv    { background: rgba(139,92,246,0.15); color: var(--purple); }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
  grid-column: 1 / -1;
}
.empty .icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty h3    { font-size: 1rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty p     { font-size: 0.85rem; line-height: 1.6; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 400;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  pointer-events: none;
  box-shadow: var(--shadow);
}
#toast.show  { opacity: 1; transform: translateY(0); }
#toast.ok    { border-color: #2ecc71; color: #2ecc71; }
#toast.blue  { border-color: var(--blue); color: var(--blue); }
#toast.err   { border-color: var(--red);  color: var(--red); }

/* ── Auth overlay ── */
.auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}

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

.auth-logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-3);
  font-size: 0.82rem;
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--transition);
}
.auth-tab.active { background: var(--surface-3); color: var(--text-1); }

.auth-error {
  font-size: 0.8rem;
  color: var(--red);
  margin-bottom: 12px;
  min-height: 18px;
  text-align: center;
  opacity: 0;
  transition: opacity var(--transition);
}
.auth-error.show { opacity: 1; }
.auth-error.ok   { color: #2ecc71; }

.auth-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  margin-bottom: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.auth-input::placeholder { color: var(--text-3); }
.auth-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}

.auth-submit {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--red);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background var(--transition);
}
.auth-submit:hover    { background: #c4070f; }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-3);
  font-size: 0.75rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: var(--radius-sm);
  color: #3c4043;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.auth-google:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-watched {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  transition: background var(--transition), color var(--transition);
}
.btn-watched:hover { background: rgba(245, 197, 24, 0.15); }

/* ── Responsive ── */
@media (max-width: 640px) {

  /* Header: nav wraps to a second sticky row */
  header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px 0;
    gap: 4px;
  }
  .logo { font-size: 1rem; letter-spacing: 2px; }
  #logout-btn { margin-left: auto; }
  nav {
    order: 3;
    width: 100%;
    border-top: 1px solid var(--border);
    padding: 4px 0 6px;
    justify-content: space-around;
  }
  nav button {
    flex: 1;
    padding: 8px 2px;
    font-size: 0.7rem;
    text-align: center;
    border-radius: 6px;
  }

  /* Container — extra bottom padding so last item isn't behind nav */
  .container { padding: 16px 14px 60px; }

  /* Movies grid — smaller min to fit more columns */
  .movies-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

  /* Modal */
  .modal { flex-direction: column; gap: 16px; padding: 18px; max-height: 90vh; overflow-y: auto; }
  .modal-poster { width: 100%; max-width: 140px; align-self: center; }
  .cast-row { gap: 10px; }
  .cast-card { width: 70px; }
  .cast-photo, .cast-no-photo { width: 70px; height: 70px; }

  /* Fav / watchlist item: wrap so action row goes below poster+body */
  .fav-item { flex-wrap: wrap; gap: 12px 16px; }
  .fav-side {
    flex-direction: row;
    flex-shrink: unset;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    gap: 6px;
  }
  .fav-side .btn, .fav-side .groups-btn {
    font-size: 0.72rem;
    padding: 5px 10px;
  }
  .fav-stars .star { font-size: 0.9rem; }

  /* Favorites sub-tabs */
  .fav-subtab { padding: 7px 10px; font-size: 0.8rem; }

  /* Group pills new-group form: wrap the input to its own line */
  .new-group-form { flex-wrap: wrap; }
  .new-group-input { flex: 1 1 100%; }

  /* Share / add-to-group modals: full-width on small screens */
  .share-modal, .add-to-group-modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
  .share-modal-overlay, .add-to-group-overlay { align-items: flex-end; padding: 0; }
  .add-to-group-modal { max-height: 80vh; }
}

/* ── Groups ── */
.group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  align-items: center;
}

.group-pill {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.group-pill:hover { border-color: var(--text-3); color: var(--text-1); }
.group-pill.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.group-pill-new {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-3);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}
.group-pill-new:hover { border-color: var(--text-2); color: var(--text-2); }

.new-group-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.new-group-input {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-1);
  font-size: 0.82rem;
  outline: none;
  width: 140px;
}
.new-group-input:focus { border-color: var(--red); }

.new-group-select {
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}

.item-group-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.item-group-tag {
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--red-dim);
  color: var(--red);
  font-size: 0.73rem;
  border: 1px solid rgba(229,9,20,0.25);
}

.group-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 4px;
}

.group-panel-header {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.group-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.group-check-row:last-child { border-bottom: none; }

.group-check-row input[type="checkbox"] {
  accent-color: var(--red);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.group-check-row label {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-1);
  cursor: pointer;
}

.group-delete-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.group-check-row:hover .group-delete-btn { opacity: 1; }
.group-delete-btn:hover { color: var(--red); background: var(--red-dim); }

.group-panel-empty {
  font-size: 0.82rem;
  color: var(--text-3);
  font-style: italic;
}

.groups-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition);
  margin-top: 6px;
}

/* ── Share feature ── */
.share-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-3);
  padding: 0 4px;
  line-height: 1;
  vertical-align: middle;
  transition: color var(--transition);
  border-radius: var(--radius-sm);
}
.share-icon-btn:hover {
  color: var(--text-1);
}

.share-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.share-modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

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

.share-modal-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-1);
}

.share-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.share-url-input {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.78rem;
  padding: 8px 10px;
  outline: none;
  min-width: 0;
}
.groups-btn:hover, .groups-btn.active { border-color: var(--red); color: var(--red); }

/* ── Favorites sub-tabs ── */
.fav-subtabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.fav-subtab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.fav-subtab:hover { color: var(--text-2); }
.fav-subtab.active { color: var(--text-1); border-bottom-color: var(--red); }
.fav-subtab-count {
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 700;
}
.fav-subtab.active .fav-subtab-count {
  background: var(--red-dim);
  color: var(--red);
}

/* ── Group pill delete (✕ on active pill) ── */
.group-pill-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.65);
  padding: 0 0 0 5px;
  line-height: 1;
  transition: color var(--transition);
}
.group-pill-del:hover { color: #fff; }

/* ── Add-to-group button (inside group view) ── */
.group-add-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  margin-bottom: 18px;
  background: var(--red-dim);
  border: 1px dashed rgba(229, 9, 20, 0.45);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.group-add-btn:hover { background: rgba(229, 9, 20, 0.2); }

/* ── Add-to-group picker modal ── */
.add-to-group-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.add-to-group-modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.add-to-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.add-to-group-list { overflow-y: auto; flex: 1; }
.add-item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.add-item-row:last-child { border-bottom: none; }
.add-item-row:hover { background: var(--surface-2); }
.add-item-poster {
  width: 38px;
  height: 57px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.add-item-no-poster {
  width: 38px;
  height: 57px;
  border-radius: 4px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.add-item-info { flex: 1; min-width: 0; }
.add-item-title {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-item-year { font-size: 0.78rem; color: var(--text-3); margin-top: 2px; }

/* ── In-list filter ──────────────────────────────────────────────────────── */
.list-filter-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 6px;
}
.list-filter-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: 0.85rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
}
.list-filter-input:focus { border-color: var(--accent); }
.list-filter-input::placeholder { color: var(--text-3); }
.list-filter-clear {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.8rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}
.list-filter-clear:hover { color: var(--text-1); border-color: var(--text-2); }
