:root {
  --bg: #08080f;
  --bg2: #111120;
  --bg3: #1a1a2e;
  --bg4: #222238;
  --gold: #e8c86a;
  --gold2: #c9a048;
  --gold-dim: rgba(232,200,106,0.12);
  --green: #4caf50;
  --red: #e05252;
  --text: #ede8d8;
  --text2: #7a7590;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: clip;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9998;
}

/* ===================== LOGIN ===================== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(232,200,106,0.06) 0%, transparent 70%);
}

.pass-wrap {
  position: relative;
}

.pass-wrap .field-input {
  padding-right: 3rem;
}

.pass-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.45;
  padding: 0.2rem;
  line-height: 1;
  transition: opacity 0.2s;
}

.pass-toggle:hover { opacity: 1; }

.login-error {
  font-size: 0.8rem;
  color: var(--red);
  text-align: center;
  margin-top: 0.85rem;
  min-height: 1.1em;
  line-height: 1.4;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.auth-box.shake { animation: shake 0.38s ease; }

/* ===================== AUTH ===================== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(232,200,106,0.06) 0%, transparent 70%);
}

.auth-box {
  background: var(--bg2);
  border: 1px solid rgba(232,200,106,0.12);
  border-radius: 16px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 40px 80px rgba(0,0,0,0.6);
}

.auth-film-strip {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 2rem;
}

.film-hole {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--bg4);
  border: 1px solid rgba(255,255,255,0.06);
}

.auth-logo {
  font-family: 'Playfair Display', serif;
  font-size: 3.2rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: -1.5px;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.auth-tagline {
  color: var(--text2);
  font-size: 0.88rem;
  font-weight: 300;
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

.field-group { margin-bottom: 1.25rem; text-align: left; }

.field-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text2);
  margin-bottom: 0.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--text);
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.field-input:focus { border-color: rgba(232,200,106,0.4); }

.btn-primary {
  width: 100%;
  background: var(--gold);
  color: #08080f;
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.btn-primary:hover { background: var(--gold2); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.auth-hint {
  margin-top: 1.25rem;
  font-size: 0.78rem;
  color: var(--text2);
  line-height: 1.6;
}

.auth-hint a { color: var(--gold); text-decoration: none; }
.auth-hint a:hover { text-decoration: underline; }

/* ===================== APP ===================== */
#app { display: none; min-height: 100vh; }

/* HEADER */
header {
  position: sticky;
  top: 0;
  z-index: 500;
  background: rgba(8,8,15,0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  height: 58px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo span { font-style: italic; font-weight: 400; }

.media-toggle {
  display: flex;
  background: var(--bg3);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  padding: 0.28rem 0.9rem;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.toggle-btn.active {
  background: var(--gold);
  color: #08080f;
  font-weight: 600;
}

.header-filters {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.excl-btn {
  padding: 0.26rem 0.7rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  line-height: 1;
}

.excl-btn:hover {
  border-color: rgba(224,82,82,0.4);
  color: var(--text);
}

.excl-btn.active {
  background: rgba(224,82,82,0.12);
  border-color: rgba(224,82,82,0.5);
  color: #e07878;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stats-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--gold-dim);
  border: 1px solid rgba(232,200,106,0.2);
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.stats-chip:hover { background: rgba(232,200,106,0.18); }

.logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text2);
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* INTEGRATIONS DROPDOWN */
.int-wrap { position: relative; }

.int-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.int-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.int-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text2);
}
.int-dot.ok  { background: var(--green); box-shadow: 0 0 4px rgba(76,175,80,.6); }
.int-dot.off { background: var(--text2); }

.int-name   { font-size: .82rem; color: var(--text); flex: 1; }
.int-status { font-size: .78rem; color: var(--text2); white-space: nowrap; }

/* FILTER BAR */
#filter-bar {
  background: var(--bg2);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding: 0 1.5rem;
  position: sticky;
  top: 58px;
  z-index: 400;
}

.view-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.view-tab {
  padding: 0.8rem 1.1rem;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
  white-space: nowrap;
}

.view-tab:hover { color: var(--text); }

.view-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.filter-row {
  padding: 0.65rem 0;
  display: flex;
  gap: 0.4rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  min-height: 46px;
}

.filter-row::-webkit-scrollbar { display: none; }

.chip {
  padding: 0.3rem 0.85rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: var(--text2);
  font-size: 0.8rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip:hover { border-color: rgba(232,200,106,0.3); color: var(--text); }

.chip.active {
  background: var(--gold);
  color: #08080f;
  border-color: var(--gold);
  font-weight: 600;
}

.search-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text2);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--text);
  padding: 0.5rem 1rem 0.5rem 2.2rem;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: rgba(232,200,106,0.3); }
.search-input::placeholder { color: var(--text2); }

/* GRID */
#main-content {
  padding: 1.5rem;
  padding-bottom: 3rem;
}

#results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1.1rem;
}

/* HISTORY STATS BAR */
.history-stats {
  grid-column: 1 / -1;
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.history-stat {
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  flex: 1;
  min-width: 120px;
}

.history-stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.history-stat-label {
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 0.2rem;
}

/* ─── PROFILE VIEW ──────────────────────────────── */

.profile-wrap {
  grid-column: 1 / -1;
  max-width: 560px;
  margin: 0 auto;
  padding: 3rem 1rem 4rem;
  width: 100%;
  box-sizing: border-box;
}

.profile-header {
  text-align: center;
  margin-bottom: 3rem;
}

.profile-total {
  font-family: 'Playfair Display', serif;
  font-size: 5.5rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.6rem;
}

.profile-subtitle {
  font-size: 0.9rem;
  color: var(--text2);
  margin-bottom: 0.3rem;
}

.profile-tagline {
  font-size: 0.78rem;
  color: var(--text2);
  opacity: 0.55;
  letter-spacing: 0.05em;
}

.profile-section {
  margin-bottom: 2rem;
}

.profile-section-label {
  font-size: 0.68rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.65rem;
}

.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.profile-chip {
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 20px;
  padding: 0.38rem 0.9rem;
  font-size: 0.84rem;
  color: var(--text);
}

.profile-chip.primary {
  background: var(--gold-dim);
  border-color: rgba(232,200,106,0.22);
  color: var(--gold);
  font-weight: 500;
}

.profile-insights {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.profile-insight {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 0.6rem;
  opacity: 0.8;
}

.profile-insight:last-child { margin-bottom: 0; }

/* ─────────────────────────────────────────────── */

.history-filter-wrap {
  grid-column: 1 / -1;
  margin-bottom: 0.75rem;
}

/* CARD */
.movie-card {
  background: var(--bg2);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  border: 2px solid transparent;
  user-select: none;
}

@media (hover: hover) {
  .movie-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.6);
    border-color: rgba(232,200,106,0.2);
  }
  .movie-card:hover .card-hover-overlay { opacity: 1; }
}

@media (pointer: coarse) {
  .card-hover-overlay { display: none !important; pointer-events: none !important; }
  .synopsis-actions   { display: flex !important; }
}

.movie-card.watched { border-color: var(--gold); }
.movie-card.watched.from-pmdb { border-color: #6ab3e8; }

.card-source-label {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.55;
}
.card-source-label.pmdb {
  color: #6ab3e8;
  opacity: 0.75;
}

.card-hover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.2) 0%, rgba(8,8,15,0.95) 60%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.6rem;
  opacity: 0;
  transition: opacity 0.22s;
  z-index: 3;
}

.card-overlay-links {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.overlay-link {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  padding: 4px;
}

.overlay-link img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.overlay-link:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-2px);
}

.card-watch-btn {
  background: var(--gold);
  color: #08080f;
  border: none;
  border-radius: 5px;
  padding: 0.4rem 0.7rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
  flex-shrink: 0;
}

.card-watch-btn:hover { background: var(--gold2); }

.card-watch-btn.remove {
  background: transparent;
  border: 1px solid rgba(224,82,82,0.5);
  color: #e07070;
}

.card-watch-btn.remove:hover { background: rgba(224,82,82,0.12); }

.card-overview {
  font-size: 0.7rem;
  color: rgba(237,232,216,0.8);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-watched-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  background: var(--gold);
  color: #08080f;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  z-index: 4;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s;
}

.movie-card.watched .card-watched-badge {
  opacity: 1;
  transform: scale(1);
}

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--bg3);
}

.card-no-poster {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--bg3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 2rem;
  gap: 0.5rem;
}

.card-no-poster span {
  font-size: 0.7rem;
  text-align: center;
  padding: 0 0.5rem;
}

.card-info { padding: 0.65rem 0.75rem 0.75rem; }

.card-title {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-size: 0.72rem;
  color: var(--text2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-rating { color: var(--gold); font-weight: 600; }

/* LOAD MORE */
#load-more-wrap { text-align: center; padding: 1.5rem 0; }

.btn-load-more {
  background: transparent;
  border: 1px solid rgba(232,200,106,0.2);
  color: var(--gold);
  padding: 0.65rem 2rem;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  display: none;
}

.btn-load-more:hover { background: var(--gold-dim); border-color: var(--gold); }

/* SPINNER */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(232,200,106,0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 4rem auto;
  grid-column: 1 / -1;
}

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

/* EMPTY STATE */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text2);
}

.empty-state .big-icon { font-size: 3rem; margin-bottom: 1rem; }

.empty-state h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* TOAST */
#toast {
  position: fixed;
  top: 76px;
  right: 1.5rem;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 9000;
  transform: translateX(calc(100% + 1.5rem + 20px));
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

#toast.show { transform: translateX(0); }
#toast.success { border-color: rgba(76,175,80,0.4); }
#toast.error { border-color: rgba(224,82,82,0.4); }

/* SYNOPSIS MODAL */
#synopsis-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

#synopsis-modal.show { display: flex; }

.synopsis-box {
  background: var(--bg2);
  border: 1px solid rgba(232,200,106,0.2);
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.synopsis-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.synopsis-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
}

.synopsis-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.synopsis-meta {
  font-size: 0.9rem;
  color: var(--text2);
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
}

.synopsis-text {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.7;
  word-break: break-word;
}

.synopsis-credits {
  margin-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.synopsis-credit-row {
  font-size: 0.88rem;
  color: var(--text2);
  line-height: 1.5;
}

.synopsis-credit-row strong {
  color: var(--text);
  font-weight: 600;
  margin-right: 0.5rem;
}

.synopsis-credit-loading {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text2);
}

.person-link {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: rgba(232,200,106,0.35);
  transition: color 0.15s, text-decoration-color 0.15s;
}
.person-link:hover {
  color: #fff;
  text-decoration-color: rgba(255,255,255,0.5);
}

.person-search-banner {
  grid-column: 1 / -1;
  background: rgba(232,200,106,0.07);
  border: 1px solid rgba(232,200,106,0.2);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.person-search-banner strong { color: var(--gold); }
.person-search-banner button {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text2);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.15s;
  flex-shrink: 0;
}
.person-search-banner button:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}

.rec-source-label {
  font-size: 0.82rem;
  color: var(--text2);
  margin-right: 0.4rem;
  white-space: nowrap;
}

/* ── SORT WIDGET ────────────────────────────────────────── */
.sort-widget {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.sort-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  color: var(--text2);
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.25s ease, border-color 0.2s, color 0.2s;
  transform: rotate(0deg);
}
.sort-arrow.asc {
  transform: rotate(180deg);
}
.sort-arrow:hover {
  border-color: rgba(232,200,106,0.3);
  color: var(--accent);
}

.sort-select {
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0.28rem 2rem 0.28rem 0.85rem;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237a7590'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
}
.sort-select:focus { border-color: rgba(232,200,106,0.3); }
.sort-select option { background: var(--bg3); color: var(--text); }

/* ── GENRES WRAP LAYOUT ─────────────────────────────────── */
.filter-row.genres-mode {
  flex-direction: column;
  flex-wrap: nowrap;
  overflow-x: hidden;
  min-height: auto;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.55rem 0;
}

.genres-sort-row {
  display: flex;
  justify-content: flex-start;
}

.genres-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* ── SEARCH EXTENDED ────────────────────────────────────── */
.filter-row.search-mode {
  flex-wrap: wrap;
  min-height: auto;
  gap: 0;
  padding: 0.5rem 0;
  row-gap: 0.45rem;
}

.search-type-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  width: 100%;
}

.search-input-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  width: 100%;
}

.chip-sm {
  font-size: 0.75rem;
  padding: 0.22rem 0.65rem;
}

/* ── GENRE TAGS ON CARDS ─────────────────────────────────── */
.card-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.card-genre-tag {
  font-size: 0.62rem;
  background: rgba(232,200,106,0.08);
  border: 1px solid rgba(232,200,106,0.2);
  color: var(--gold);
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.4;
}

/* ── WATCHLIST BADGE & BUTTON ───────────────────────────── */
.card-watchlist-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  background: rgba(232,200,106,0.9);
  color: #08080f;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  z-index: 4;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s;
}

.movie-card.in-watchlist .card-watchlist-badge {
  opacity: 1;
  transform: scale(1);
}

.card-want-btn {
  background: transparent !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  color: var(--text2) !important;
  font-weight: 500 !important;
}

.card-want-btn:hover {
  border-color: rgba(232,200,106,0.5) !important;
  color: var(--gold) !important;
  background: rgba(232,200,106,0.06) !important;
}

.card-want-btn.in-list {
  border-color: rgba(232,200,106,0.5) !important;
  color: var(--gold) !important;
}

/* ── SYNOPSIS GENRES & COUNTRIES ────────────────────────── */
.synopsis-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.synopsis-countries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.synopsis-country {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 0.2rem 0.65rem 0.2rem 0.45rem;
  border-radius: 20px;
}

.synopsis-country-flag { font-size: 1.05rem; line-height: 1; }

/* ── SYNOPSIS EXTERNAL LINKS ─────────────────────────────── */
.synopsis-ext-links {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.synopsis-ext-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text2);
  padding: 0.32rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  text-decoration: none;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}

.synopsis-ext-link:hover {
  border-color: rgba(232,200,106,0.3);
  color: var(--text);
  background: rgba(232,200,106,0.05);
}

.synopsis-ext-link img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── PERSON MODAL ────────────────────────────────────────── */
#person-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 1rem;
}

#person-modal.show { display: flex; }

.person-modal-box {
  background: var(--bg2);
  border: 1px solid rgba(232,200,106,0.2);
  border-radius: 12px;
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.person-modal-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.person-modal-photo {
  width: 120px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--bg3);
}

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

.person-modal-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.person-modal-meta {
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 0.35rem;
  line-height: 1.5;
}

.person-modal-dept {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--gold);
  opacity: 0.75;
  background: rgba(232,200,106,0.08);
  border: 1px solid rgba(232,200,106,0.2);
  padding: 0.1rem 0.55rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.person-modal-bio {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 0.75rem;
  opacity: 0.9;
}

.person-filmography-btn {
  font-size: 0.85rem !important;
  padding: 0.6rem 1.2rem !important;
  margin-top: 0.5rem !important;
  width: auto !important;
}

/* ─── STREMIO VIEW ──────────────────────────────────────── */

.stremio-view-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.stremio-view-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.stremio-addon-card {
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
}

.stremio-addon-top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
}

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

.stremio-addon-badge {
  background: var(--gold-dim);
  border: 1px solid rgba(232,200,106,0.22);
  color: var(--gold);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-weight: 500;
}

.stremio-addon-desc {
  font-size: 0.84rem;
  color: var(--text2);
  margin: 0 0 1rem;
  line-height: 1.55;
}

.stremio-url-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.stremio-url-input {
  flex: 1;
  font-size: 0.72rem !important;
  padding: 0.3rem 0.5rem !important;
  cursor: text;
  font-family: monospace;
  letter-spacing: 0;
}

.stremio-install-hint {
  font-size: 0.76rem;
  color: var(--text2);
  opacity: 0.75;
  margin: 0;
}

.stremio-install-hint--warn {
  color: var(--gold);
  opacity: 0.85;
}

/* RESPONSIVE */
@media (max-width: 600px) {
  #results-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .view-tab { padding: 0.8rem 0.7rem; font-size: 0.8rem; }
  .person-modal-layout { flex-direction: column; }
  .person-modal-photo { width: 100%; height: 200px; }

  /* Header: fila 1 logo+salir, fila 2 toggle */
  header {
    height: auto;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    gap: 0.4rem 0.75rem;
  }
  #filter-bar { top: 88px; }

  /* Fila 1: logo a la izquierda ocupa el espacio sobrante */
  .logo { flex: 1; font-size: 1.2rem; }

  /* Fila 1: header-right (solo botón Salir) a la derecha */
  .header-right { order: 2; margin-left: 0; gap: 0; }

  /* Stats ocultos en móvil (accesibles desde Mi historial) */
  .stats-chip { display: none; }

  /* Fila 2: toggle ocupa todo el ancho y se centra */
  .media-toggle { order: 3; width: 100%; justify-content: center; }

  /* Salir: compacto y discreto */
  .logout-btn { padding: 0.22rem 0.55rem; font-size: 0.72rem; opacity: 0.75; }

  /* Tabs y chips: scroll horizontal */
  .view-tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .view-tabs::-webkit-scrollbar { display: none; }
  .filter-row { -webkit-overflow-scrolling: touch; }

  /* History stats más compactos en móvil */
  .history-stats { gap: 0.5rem; }
  .history-stat { min-width: 70px; padding: 0.6rem 0.75rem; }
  .history-stat-value { font-size: 1.4rem; }
  .history-stat-label { font-size: 0.68rem; }

  /* Profile en móvil */
  .profile-wrap { padding: 2rem 0.75rem 3rem; }
  .profile-total { font-size: 4rem; }

  /* excl-btn compacto en móvil */
  .excl-btn { padding: 0.24rem 0.5rem; font-size: 0.7rem; }

  /* header-right: pequeño gap entre Opciones y Salir */
  .header-right { gap: 0.4rem; }

  /* opts-panel: no sobresalir del viewport */
  .opts-panel { width: min(270px, calc(100vw - 1.5rem)); }

  /* géneros: toggle visible en móvil */
  .genres-toggle-btn {
    display: inline-flex;
    align-items: center;
    background: var(--bg3);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text2);
    border-radius: 20px;
    padding: 0.22rem 0.65rem;
    font-size: 0.76rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 0.4rem;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .genres-toggle-btn::before { content: '🎭 Géneros ▾'; }
  .genres-toggle-btn.collapsed::before { content: '🎭 Géneros ▸'; }
  .genres-toggle-btn:hover { border-color: rgba(232,200,106,0.3); color: var(--text); }

  /* géneros chips: colapsable con transición */
  .genres-chips-row {
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.28s ease, opacity 0.22s ease;
    opacity: 1;
  }
  .genres-chips-row.collapsed {
    max-height: 0;
    opacity: 0;
  }
}

/* ── OPTIONS PANEL ───────────────────────────────────────── */
.opts-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 270px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.opts-section {
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.opts-section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.opts-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.opts-filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.opts-filter-btn {
  padding: 0.32rem 0.5rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-align: center;
}

.opts-filter-btn:hover {
  border-color: rgba(224,82,82,0.4);
  color: var(--text);
}

.opts-filter-btn.active {
  background: rgba(224,82,82,0.12);
  border-color: rgba(224,82,82,0.5);
  color: #e07878;
}

/* ── GENRES COLLAPSIBLE TOGGLE (desktop: hidden) ─────────── */
.genres-toggle-btn { display: none; }
/* ── RATINGS ─────────────────────────────────────────────── */
.card-user-rating {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
  margin-left: 0.15rem;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.card-user-rating:hover { opacity: 1; }

.rating-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--text2);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.13s, color 0.13s, background 0.13s;
  flex-shrink: 0;
}
.rating-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.rating-btn.active {
  background: var(--gold);
  color: #08080f;
  border-color: var(--gold);
}
.rating-btn-delete {
  width: 24px;
  margin-left: 0.3rem;
  color: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.08);
}
.rating-btn-delete:hover {
  border-color: #e07878;
  color: #e07878;
}

/* ── RATING POPOVER ──────────────────────────────────────── */
.rating-popover {
  position: fixed;
  z-index: 9000;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.rating-popover-label {
  font-size: 0.72rem;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
}
.rating-popover-buttons {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

/* ── SYNOPSIS ACTION BUTTONS (touch only) ────────────────── */
.synopsis-actions {
  display: none;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin: 0.1rem 0 0.5rem;
}
.synopsis-action-btn {
  flex: 1 1 40%;
  min-width: 0;
  padding: 0.55rem 0.5rem;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.14);
  background: transparent;
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.synopsis-action-btn:hover   { border-color: rgba(255,255,255,0.25); color: var(--text); }
.synopsis-action-btn.watched { background: var(--gold); color: #08080f; border-color: var(--gold); }
.synopsis-action-btn.in-list { border-color: rgba(232,200,106,0.5); color: var(--gold); }
.synopsis-action-btn.dismiss { flex: 0 0 100%; font-size: 0.73rem; border-color: rgba(255,255,255,0.08); color: rgba(255,255,255,0.35); }
.synopsis-action-btn.dismiss:hover { border-color: #e07878; color: #e07878; }

/* ── SYNOPSIS RATING SECTION ─────────────────────────────── */
.synopsis-rating {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin: 0.1rem 0 0.5rem;
}
.synopsis-rating-label {
  font-size: 0.78rem;
  color: var(--text2);
  white-space: nowrap;
}
.synopsis-rating-picker {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}
