:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f8f7fb;
  background: #07070a;
  --purple: #8b5cf6;
  --purple-strong: #7c3aed;
  --panel: #111116;
  --panel-soft: #17171e;
  --line: rgba(255, 255, 255, 0.1);
  --muted: #9998a6;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #07070a; }
body { min-width: 320px; }
button, input, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.muted { color: var(--muted); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; min-height: 72px; padding: 0 5vw;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 10, 0.86); backdrop-filter: blur(18px);
}
.brand { border: 0; background: transparent; font-size: 1.3rem; font-weight: 900; letter-spacing: -0.04em; cursor: pointer; }
.brand span { color: var(--purple); }
.nav { display: flex; gap: 6px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.nav-button {
  border: 0; border-radius: 999px; padding: 10px 14px;
  background: transparent; color: var(--muted); font-weight: 700; cursor: pointer;
}
.nav-button:hover, .nav-button.active { background: var(--panel-soft); color: #fff; }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 5px; border-radius: 999px; background: var(--purple); color: white; font-size: .72rem; }
.sync-button {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 12px; background: var(--panel);
  color: var(--muted); font-size: .78rem; font-weight: 800; cursor: pointer;
}
.sync-button:hover { border-color: rgba(167,139,250,.55); color: #fff; }
.sync-button:disabled { cursor: wait; opacity: .7; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #71717a; }
.sync-button[data-status="online"] .sync-dot { background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,.12); }
.sync-button[data-status="syncing"] .sync-dot { background: #fbbf24; }
.sync-button[data-status="error"] .sync-dot { background: #fb7185; }

.view { display: none; width: min(1400px, 92vw); margin: 0 auto; padding: 56px 0 100px; }
.view.active { display: block; }
.search-view { width: 100%; padding-top: 0; }
.hero {
  display: grid; align-content: center; min-height: 54vh; padding: 70px max(5vw, calc((100vw - 1120px)/2));
  text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(124,58,237,.32), transparent 42%), linear-gradient(#0c0b12, #07070a);
}
.eyebrow { margin: 0 0 12px; color: #a78bfa; font-size: .73rem; font-weight: 900; letter-spacing: .18em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(2.25rem, 6vw, 5.6rem); letter-spacing: -.065em; line-height: .96; }
h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.5rem); letter-spacing: -.04em; }
.search-form {
  display: flex; gap: 10px; width: min(760px, 100%); margin: 36px auto 0; padding: 8px;
  border: 1px solid rgba(167,139,250,.35); border-radius: 18px; background: rgba(15,14,21,.94);
  box-shadow: 0 26px 80px rgba(0,0,0,.45);
}
.search-form input, .filter-search input, textarea {
  width: 100%; border: 1px solid transparent; outline: 0; color: #fff; background: transparent;
}
.search-form input { min-width: 0; padding: 15px; font-size: 1rem; }
.primary-button, .secondary-button {
  border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 850; cursor: pointer;
}
.primary-button { background: var(--purple-strong); color: #fff; }
.primary-button:hover { background: var(--purple); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 1px solid var(--line); background: var(--panel); }
.secondary-button:hover { border-color: rgba(167,139,250,.55); }

.content-section { width: min(1400px, 92vw); margin: 0 auto; padding: 54px 0 90px; }
.recommendations { width: min(1400px, 92vw); margin: 0 auto; padding: 48px 0 20px; }
.recommendation-summary { margin: 7px 0 0; font-size: .82rem; }
.recommendation-track {
  display: flex; align-items: flex-start; gap: 14px; overflow-x: auto; padding: 4px 2px 24px;
  scroll-behavior: smooth; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.recommendation-track::-webkit-scrollbar { display: none; }
.recommendation-track .movie-card { flex: 0 0 210px; scroll-snap-align: start; }
.carousel-controls { display: flex; gap: 7px; }
.carousel-controls button {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer;
}
.carousel-controls button:hover { border-color: var(--purple); }
.section-head, .page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.results-tools { display: flex; align-items: end; gap: 14px; }
.sort-control { display: grid; gap: 5px; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.sort-control select {
  min-height: 40px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 34px 0 11px; color: #fff; background: var(--panel); cursor: pointer;
  font-size: .78rem; font-weight: 700; text-transform: none;
}
.page-head h1 { font-size: clamp(2.4rem, 6vw, 4.8rem); }
.page-head .muted { margin: 12px 0 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.movie-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 28px 16px; }
.movie-card { min-width: 0; }
.poster-wrap {
  position: relative; overflow: hidden; aspect-ratio: 2/3; border-radius: 14px;
  background: var(--panel-soft); box-shadow: 0 16px 38px rgba(0,0,0,.3);
}
.poster { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .18s ease; }
.movie-card:hover .poster { transform: scale(1.035); }
.card-actions {
  position: absolute; inset: auto 9px 9px; display: grid; grid-template-columns: 1fr auto; gap: 7px;
  opacity: 0; transform: translateY(5px); transition: .18s ease;
}
.movie-card:hover .card-actions, .movie-card:focus-within .card-actions { opacity: 1; transform: none; }
.watch-button, .icon-button {
  border: 0; border-radius: 10px; min-height: 40px; cursor: pointer; font-weight: 850;
  box-shadow: 0 8px 22px rgba(0,0,0,.42);
}
.watch-button { background: var(--purple-strong); }
.icon-button { min-width: 42px; background: rgba(18,18,24,.94); }
.favorite-button {
  position: absolute; top: 9px; right: 9px; display: grid; place-items: center;
  width: 38px; height: 38px; border: 0; border-radius: 999px;
  background: rgba(9,9,12,.82); color: #fff; font-size: 1.15rem; cursor: pointer;
}
.favorite-button.saved { color: #fb7185; }
.movie-title { margin: 11px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.movie-meta { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; color: var(--muted); font-size: .76rem; }
.movie-meta span:last-child { text-align: right; }
.tmdb-score { color: #fbbf24; font-weight: 850; white-space: nowrap; }
.movie-director { margin: 6px 0 0; overflow: hidden; color: #c4b5fd; font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.movie-cast { margin: 7px 0 0; color: #d7d4df; font-size: .72rem; line-height: 1.4; }
.recommendation-source { margin: 6px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.42; }
.category-dots { display: flex; gap: 4px; margin-top: 8px; min-height: 8px; }
.category-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--purple); opacity: .8; }
.empty-message { padding: 60px 20px; color: var(--muted); text-align: center; }

.filters { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.filter-search { flex: 0 1 320px; }
.filter-search input { padding: 12px 15px; border-color: var(--line); border-radius: 12px; background: var(--panel); }
.filter-groups { display: grid; min-width: 0; gap: 8px; }
.facet-filters { display: grid; gap: 8px; min-width: 0; }
.facet-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.facet-label { flex: 0 0 72px; color: var(--muted); font-size: .67rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.filter-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.filter-chip { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 9px 12px; background: transparent; color: var(--muted); cursor: pointer; }
.filter-chip.active { border-color: var(--purple); background: rgba(124,58,237,.16); color: #fff; }
.filter-chip strong { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; border-radius: 999px; background: rgba(255,255,255,.09); color: #ddd6fe; font-size: .68rem; }

.people-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.person-card { padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg,var(--panel-soft),var(--panel)); }
.person-avatar { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; background: rgba(124,58,237,.22); color: #c4b5fd; font-size: 1.3rem; font-weight: 900; }
.person-card h3 { margin: 18px 0 5px; font-size: 1.2rem; }
.person-role { color: var(--muted); font-size: .85rem; }
.person-count { margin: 18px 0; color: #ddd9e8; }
.person-card button { width: 100%; }
.director-note { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-top: 48px; padding: 28px; border: 1px dashed rgba(167,139,250,.38); border-radius: 18px; }
.director-note p:last-child { max-width: 720px; color: var(--muted); }
.status-pill { flex: 0 0 auto; border-radius: 999px; padding: 9px 12px; background: #2a2113; color: #fbbf24; font-size: .8rem; font-weight: 800; }

.selection-bar {
  position: fixed; right: 24px; bottom: 20px; left: 24px; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 18px; border: 1px solid rgba(167,139,250,.45); border-radius: 16px;
  background: rgba(18,17,25,.96); box-shadow: 0 20px 70px rgba(0,0,0,.6); backdrop-filter: blur(18px);
}
.selection-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.selection-actions button { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #252331; cursor: pointer; }

.dialog { width: min(540px, calc(100vw - 24px)); border: 0; padding: 0; border-radius: 20px; color: #fff; background: transparent; }
.dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.dialog-card { position: relative; display: grid; gap: 22px; padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: #111116; }
.dialog-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; color: var(--muted); font-size: 1.7rem; cursor: pointer; }
.edit-metadata { display: flex; flex-wrap: wrap; gap: 8px; }
.edit-metadata:empty { display: none; }
.edit-metadata span { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: .76rem; }
.edit-metadata strong { color: #ddd9e8; font-size: .67rem; letter-spacing: .08em; text-transform: uppercase; }
.edit-people { display: grid; gap: 9px; }
.people-buttons { display: flex; flex-wrap: wrap; gap: 7px; max-height: 180px; overflow-y: auto; }
.people-buttons button {
  display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 11px;
  padding: 8px 10px; background: #191820; text-align: left; cursor: pointer;
}
.people-buttons button:hover { border-color: var(--purple); background: rgba(124,58,237,.13); }
.people-buttons strong { font-size: .78rem; }
.people-buttons span { color: var(--muted); font-size: .68rem; }
.field-label { display: block; margin: 0 0 9px; color: #d7d4df; font-size: .84rem; font-weight: 800; }
.rating-picker { display: flex; gap: 7px; }
.rating-picker button { border: 0; background: transparent; color: #4b4854; font-size: 1.65rem; cursor: pointer; }
.rating-picker button.active { color: #fbbf24; }
.edit-categories { display: flex; flex-wrap: wrap; gap: 7px; }
.edit-categories label { border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; cursor: pointer; }
.edit-categories label:has(input:checked) { border-color: var(--purple); background: rgba(124,58,237,.18); }
.edit-categories input { display: none; }
.notes-field textarea, .import-card textarea { resize: vertical; padding: 12px; border-color: var(--line); border-radius: 12px; background: #0b0b0f; }
.toast { position: fixed; top: 88px; right: 20px; z-index: 50; padding: 11px 14px; border-radius: 11px; background: #f4f0ff; color: #17131f; font-weight: 800; opacity: 0; transform: translateY(-8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.player { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 16/9; border: 0; background: #000; }

@media (max-width: 1100px) { .movie-grid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 14px; }
  .nav { overflow-x: auto; }
  .topbar-actions { min-width: 0; }
  .nav-button { padding: 9px 10px; font-size: .82rem; white-space: nowrap; }
  .hero { min-height: 48vh; padding-inline: 14px; }
  .search-form { display: grid; }
  .page-head, .section-head, .director-note, .selection-bar { align-items: stretch; flex-direction: column; }
  .filters { align-items: stretch; flex-direction: column; }
  .results-tools { align-items: stretch; flex-direction: column; }
  .filter-search { flex-basis: auto; }
  .recommendation-track .movie-card { flex-basis: 155px; }
  .movie-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px 11px; }
  .card-actions { opacity: 1; transform: none; }
  .people-grid { grid-template-columns: 1fr 1fr; }
  .selection-bar { right: 10px; bottom: 10px; left: 10px; }
}
@media (max-width: 560px) {
  .brand { display: none; }
  .topbar { justify-content: center; }
  .sync-button { padding-inline: 10px; }
  #syncLabel { display: none; }
  .people-grid { grid-template-columns: 1fr; }
}
