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

:root {
  --bg:        #0f1117;
  --surface:   #181b27;
  --surface2:  #21253a;
  --surface3:  #2b3050;
  --accent:    #e50914;
  --accent-lo: rgba(229,9,20,.15);
  --gold:      #f59e0b;
  --gold-lo:   rgba(245,158,11,.15);
  --rec:       #6366f1;
  --rec-lo:    rgba(99,102,241,.15);
  --seen:      #22c55e;
  --seen-lo:   rgba(34,197,94,.15);
  --text:      #eceef5;
  --muted:     #7c83a8;
  --border:    #292e47;
  --radius:    12px;
  --shadow:    0 8px 32px rgba(0,0,0,.4);
}

/* ── Light mode ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f3f4f8;
  --surface:   #ffffff;
  --surface2:  #eef0f7;
  --surface3:  #e2e5f0;
  --text:      #111827;
  --muted:     #6b7299;
  --border:    #d4d7ec;
  --shadow:    0 4px 20px rgba(0,0,0,.1);
}
[data-theme="light"] header {
  background: rgba(255,255,255,.92);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  background: rgba(10,12,18,.88);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.logo {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.logo-icon {
  background: var(--accent);
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.logo-icon svg { width: 62%; height: auto; display: block; }
.logo-watch { font-weight: 300; }
/* ── Main search ──────────────────────────────────────────── */
.main-search-wrap {
  position: relative;
  margin-bottom: 1.5rem;
}
.main-search-wrap input {
  width: 100%;
  padding: .8rem 1.25rem .8rem 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s, background .2s;
}
.main-search-wrap input:focus {
  border-color: var(--accent);
  background: var(--surface2);
}
.main-search-wrap input::placeholder { color: var(--muted); }
.main-search-wrap input:disabled { opacity: .4; cursor: not-allowed; }
.search-clear-btn {
  display: none;
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface3);
  border: none;
  color: var(--muted);
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  font-size: .72rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.search-clear-btn:hover { background: var(--accent); color: #fff; }
.main-search-wrap.has-value .search-clear-btn { display: flex; }
.main-search-wrap.has-value input { padding-right: 2.75rem; }
.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: flex;
}

/* ── Mobile header ─────────────────────────────────────────── */
@media (max-width: 700px) {
  .header-inner { padding: .85rem 0; gap: .85rem; }
  .user-chip { margin-left: auto; }
}

/* ── Main ─────────────────────────────────────────────────── */
main { padding: 2.5rem 2.5rem 6rem; max-width: 1440px; margin: 0 auto; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .35rem;
  width: fit-content;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: .55rem 1.4rem;
  border-radius: 7px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  letter-spacing: .01em;
}
.tab-btn.active {
  background: var(--accent);
  color: #fff;
}
.tab-btn:hover:not(.active) {
  background: var(--surface2);
  color: var(--text);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Section heading ──────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .02em;
  text-transform: uppercase;
}
.badge {
  background: var(--surface2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  padding: .18rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  letter-spacing: .03em;
}
.filter-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}
.filter-row select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .35rem .8rem;
  border-radius: 7px;
  font-size: .82rem;
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
}
.filter-row select:focus { border-color: var(--accent); }

/* ── List local search ────────────────────────────────────── */
.list-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.list-search-wrap input {
  padding: .32rem 1.8rem .32rem 2rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: .8rem;
  outline: none;
  width: 160px;
  transition: border-color .2s, width .2s;
}
.list-search-wrap input:focus {
  border-color: var(--accent);
  width: 200px;
}
.list-search-wrap input::placeholder { color: var(--muted); }
.list-search-icon {
  position: absolute;
  left: .65rem;
  color: var(--muted);
  pointer-events: none;
  display: flex;
}
.list-search-clear {
  display: none;
  position: absolute;
  right: .45rem;
  background: var(--surface3);
  border: none;
  color: var(--muted);
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  font-size: .6rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background .15s, color .15s;
}
.list-search-clear:hover { background: var(--accent); color: #fff; }

/* ── Filter buttons ───────────────────────────────────────── */
.filter-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .32rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  transition: all .2s;
}
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.filter-btn:hover:not(.active) {
  border-color: var(--muted);
  color: var(--text);
}
.filter-btn-fav.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.filter-btn-fav:hover:not(.active) {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-lo);
}

/* ── Stats bar ────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2.5rem;
}
.stat {
  background: var(--surface);
  padding: 1.1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1px;
}
.stat-label {
  font-size: .73rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ── Search results ───────────────────────────────────────── */
#search-results {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 0;
  margin-bottom: 2.5rem;
  overflow: hidden;
}
#search-results.visible { display: block; }
#search-results .section-head { padding: 0 1.5rem; }
#search-results .load-more-btn { margin-bottom: .5rem; }

/* ── Card grid ────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  cursor: pointer;
  transition: transform .2s ease;
  position: relative;
  border-radius: var(--radius);
}
.card:hover .card-overlay { opacity: 1; }

.card-poster-wrap {
  width: 100%;
  aspect-ratio: 235 / 384;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface2);
}
.card-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-no-poster {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .75rem;
  gap: .5rem;
}
.card-no-poster .np-icon { font-size: 2.25rem; opacity: .6; }

.card-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(to top, rgba(0,0,0,.9) 0%, rgba(0,0,0,.3) 50%, transparent 100%);
  opacity: 0;
  transition: opacity .22s ease;
  display: flex;
  align-items: flex-end;
  padding: .75rem;
}
.add-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .45rem .5rem;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .02em;
  transition: background .15s;
}
.add-btn:hover { background: #c4070f; }
.add-btn.in-list {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(4px);
}
.add-btn.in-list:hover { background: rgba(229,9,20,.8); }
.add-btn.add-btn--seen { background: var(--seen); }
.add-btn.add-btn--seen:hover { background: #16a34a; }

.details-btn {
  width: 100%;
  background: var(--rec);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .45rem .5rem;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .02em;
  transition: background .15s;
}
.details-btn:hover { background: #4f46e5; }

.rec-btn {
  width: 100%;
  background: rgba(99,102,241,.85);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .45rem .5rem;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .02em;
  transition: background .15s;
}
.rec-btn:hover { background: var(--rec); }
.rec-btn.in-rec {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(4px);
}
.rec-btn.in-rec:hover { background: rgba(99,102,241,.8); }
.card-overlay-dual { flex-direction: column; gap: .3rem; justify-content: flex-end; align-items: stretch; }

.card-info { padding: .55rem .1rem 0; }
.card-title {
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--text);
}
.card-meta {
  font-size: .72rem;
  color: var(--muted);
  margin-top: .25rem;
  display: flex;
  gap: .4rem;
  align-items: center;
}
.type-pill {
  padding: .06rem .38rem;
  border-radius: 4px;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.type-pill.movie  { background: rgba(59,130,246,.18); color: #60a5fa; }
.type-pill.series { background: rgba(168,85,247,.18); color: #c084fc; }
.type-pill.person { background: rgba(16,185,129,.18); color: #34d399; }

.card-known-for {
  font-size: .68rem;
  color: var(--muted);
  margin-top: .15rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Modal footnote ───────────────────────────────────────── */
.modal-footnote {
  margin-top: 1.1rem;
  font-size: .73rem;
  color: var(--muted);
  font-style: italic;
  opacity: .75;
}

/* ── In-list indicator ────────────────────────────────────── */
.in-list-dot {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ── Favorite dot (card corner) ───────────────────────────── */
.fav-dot {
  position: absolute;
  top: .5rem;
  left: .5rem;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ── Favorite star (list row) ─────────────────────────────── */
.list-fav-star {
  font-size: 1rem;
  color: var(--surface3);
  flex-shrink: 0;
  margin-left: .25rem;
  transition: color .2s, transform .2s;
}
.list-fav-star.is-fav {
  color: var(--gold);
}

/* ── Loading skeleton ─────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.card.loading { pointer-events: none; }
.card.loading .card-poster-wrap {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius) var(--radius) 0 0;
}
.card.loading .card-info { padding: .55rem .1rem; }
.skel-line {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skel-title { height: 11px; width: 78%; margin-bottom: 8px; }
.skel-meta  { height:  9px; width: 48%; }

/* ── Empty state ──────────────────────────────────────────── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: .6; }
.empty p { font-size: .9rem; line-height: 1.6; }

/* ── Suggest refresh row ──────────────────────────────────── */
.suggest-refresh-wrap {
  display: flex;
  justify-content: center;
  margin-top: 2.5rem;
}
.suggest-refresh {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .6rem 2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
  letter-spacing: .02em;
}
.suggest-refresh:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}
.suggest-refresh:disabled { opacity: .4; cursor: default; }

/* ── Load-more button ─────────────────────────────────────── */
.load-more-btn {
  display: block;
  margin: 1.5rem auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .6rem 2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
  letter-spacing: .02em;
}
.load-more-btn:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

/* ── Toast ────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: .8rem 1.25rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .28s, transform .28s;
  z-index: 999;
  pointer-events: none;
  max-width: 320px;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ── Server error banner ──────────────────────────────────── */
#server-error {
  display: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.6;
}
#server-error strong { color: var(--text); display: block; margin-bottom: .3rem; }
#server-error code {
  background: var(--bg);
  padding: .1rem .45rem;
  border-radius: 5px;
  font-size: .82rem;
  color: #f87171;
}

/* ── Detail modal ─────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}
#modal-overlay.open { display: flex; }
#modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 660px;
  width: 100%;
  overflow: hidden;
  animation: pop .22s ease;
  box-shadow: var(--shadow);
  margin: auto;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-hero { display: flex; gap: 1.75rem; padding: 1.75rem; }
.modal-poster {
  width: 256px;
  height: 384px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface2);
}
.modal-body { flex: 1; min-width: 0; }
.modal-body h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: .4rem; letter-spacing: -.3px; }
.modal-meta { color: var(--muted); font-size: .82rem; margin-bottom: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.overview { font-size: .86rem; line-height: 1.7; color: var(--muted); }
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 1.1rem 1.75rem;
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  #modal-overlay {
    align-items: flex-start;
    padding: 1rem .75rem;
  }
  .modal-hero {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.25rem .75rem;
  }
  .modal-poster { width: 256px; height: 384px; }
  .modal-body h2 { text-align: center; }
  .modal-meta { justify-content: center; }
  .modal-footer { padding: .9rem 1.25rem; }
}
.btn-primary, .btn-secondary, .btn-remove, .btn-danger, .btn-rec, .btn-seen {
  padding: .55rem 1.3rem;
  border-radius: 8px;
  font-size: .86rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .15s;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: #c4070f; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); }
.btn-remove { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-remove:hover { color: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--accent); color: #fff; }
.btn-danger:hover { background: #c4070f; }
.btn-rec  { background: var(--rec);  color: #fff; border: none; }
.btn-rec:hover  { background: #4f46e5; }
.btn-seen { background: var(--seen); color: #fff; border: none; }
.btn-seen:hover { background: #16a34a; }

/* ── Login overlay ────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 2.25rem;
}
.login-logo-icon {
  background: var(--accent);
  color: #fff;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.login-logo-icon svg { width: 62%; height: auto; display: block; }
.login-logo-text {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -1px;
}
.login-field {
  position: relative;
  margin-bottom: 1rem;
}
.login-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: .95rem;
  padding: .75rem 1rem;
  outline: none;
  transition: border-color .2s;
}
.login-field input:focus { border-color: var(--accent); }
.login-field input::placeholder { color: var(--muted); }
.login-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: .8rem;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: .5rem;
  transition: background .15s;
  letter-spacing: .02em;
}
.login-btn:hover { background: #c4070f; }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-error {
  color: #f87171;
  font-size: .84rem;
  margin-top: .75rem;
  text-align: center;
  min-height: 1.2em;
}

/* ── User menu in header ───────────────────────────────────── */
.user-chip {
  position: relative;
  white-space: nowrap;
  margin-left: auto;
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .35rem .75rem .35rem .55rem;
  font-size: .83rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.user-menu-trigger:hover {
  border-color: var(--accent);
  background: var(--surface3);
}
.user-menu-trigger strong { color: var(--text); font-size: .83rem; }
.user-avatar {
  width: 1.6rem;
  height: 1.6rem;
  background: var(--surface3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  overflow: hidden;
  flex-shrink: 0;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.user-menu-caret {
  font-size: .7rem;
  color: var(--muted);
  transition: transform .2s;
}
.user-chip.open .user-menu-caret { transform: rotate(180deg); }

.user-menu {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  overflow: hidden;
  z-index: 200;
  animation: menuIn .15s ease;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .75rem 1.1rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: .88rem;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.user-menu-item:hover { background: var(--surface3); }
.user-menu-danger { color: var(--accent); }
.user-menu-danger:hover { background: var(--accent-lo); }
.user-menu-admin { color: var(--rec); }
.user-menu-admin:hover { background: var(--rec-lo); }
.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: .25rem 0;
}

/* ── Modal hint text ──────────────────────────────────────── */
.modal-hint {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 1.25rem;
}
.modal-hint a { color: var(--accent); text-decoration: none; }
.modal-hint a:hover { text-decoration: underline; }

/* ── Password-change modal ─────────────────────────────────── */
#email-overlay,
#pw-overlay,
#create-user-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
#email-overlay.open,
#pw-overlay.open,
#create-user-overlay.open { display: flex; }
.pw-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
.pw-modal h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
.pw-field {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: 1rem;
}
.pw-field label {
  font-size: .82rem;
  color: var(--muted);
  font-weight: 600;
}
.pw-field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .6rem .85rem;
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
.pw-field input:focus { border-color: var(--accent); }
.pw-error {
  color: var(--accent);
  font-size: .83rem;
  min-height: 1.2em;
  margin-bottom: .5rem;
}
.pw-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ── View toggle ──────────────────────────────────────────── */
.view-toggle {
  display: flex;
  gap: .25rem;
  margin-left: .25rem;
}
.view-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 2rem;
  height: 2rem;
  border-radius: 7px;
  cursor: pointer;
  font-size: .85rem;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.view-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.view-btn:hover:not(.active) {
  border-color: var(--muted);
  color: var(--text);
}

/* ── List view ────────────────────────────────────────────── */
.grid.list-view {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.list-row-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color .2s;
}
.list-row-wrap:hover {
  border-color: var(--accent);
}
.swipe-confirm-overlay {
  position: absolute;
  inset: 0;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: .5rem;
}
.swipe-cancel-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.5);
  color: #fff;
  padding: .4rem .9rem;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.swipe-confirm-btn {
  background: #fff;
  border: none;
  color: var(--accent);
  padding: .4rem .9rem;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--surface);
  border-radius: 12px;
  padding: .5rem .75rem .5rem .5rem;
  cursor: pointer;
  transition: background .2s;
  will-change: transform;
}
.list-row-wrap:hover .list-row {
  background: var(--surface2);
}
.list-poster {
  width: 42px;
  flex-shrink: 0;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface2);
  display: block;
}
.list-no-poster {
  width: 42px;
  flex-shrink: 0;
  aspect-ratio: 2/3;
  background: var(--surface2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.list-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.list-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.list-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  font-size: .75rem;
  color: var(--muted);
}

/* ── Seen button (watchlist rec rows) ────────────────────── */
.seen-row-btn {
  flex-shrink: 0;
  padding: .3rem .75rem;
  border-radius: 999px;
  background: var(--seen-lo);
  border: 1px solid rgba(34,197,94,.4);
  color: var(--seen);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.seen-row-btn:hover {
  background: var(--seen);
  color: #fff;
  border-color: var(--seen);
}

/* ── Rec dot (card corner) ────────────────────────────────── */
.rec-dot {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--rec);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ── Search list add button ───────────────────────────────── */
.list-add-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.list-add-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.list-add-btn.in-list {
  font-size: .8rem;
  color: #4ade80;
  border-color: rgba(74,222,128,.35);
  background: rgba(74,222,128,.1);
}

/* ── Paging ───────────────────────────────────────────────── */
.paging {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-top: 1.25rem;
}
.paging-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  line-height: 1;
}
.paging-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.paging-btn:disabled {
  opacity: .3;
  cursor: default;
}
.paging-info {
  font-size: .83rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 4rem;
  text-align: center;
}

/* ── Footer ───────────────────────────────────────────────── */
#site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .75rem;
  color: var(--muted);
  letter-spacing: .03em;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

/* ── Responsive grid ──────────────────────────────────────── */
@media (max-width: 1200px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 960px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .stats-bar { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 1.35rem; }
  .stat-label { font-size: .65rem; }
}
@media (max-width: 720px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  header { padding: .9rem 1.25rem; gap: 1rem; }
  main { padding: 1.5rem 1.25rem 6rem; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .stats-bar { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 1.35rem; }
  .stat-label { font-size: .65rem; }
  .filter-row { margin-left: 0; width: 100%; }
  .tabs { width: 100%; }
  .tab-btn { flex: 1; text-align: center; }
}
