:root {
  --bg: #0b0c10;
  --panel: #14161c;
  --panel2: #1c1f27;
  --line: #2a2e38;
  --text: #eef0f4;
  --muted: #9aa1ad;
  --accent: #ffb020;
  --danger: #ff6b6b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 12, 16, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 18px; padding: 12px 24px; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -.02em; white-space: nowrap; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
nav { display: flex; gap: 4px; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; }
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); background: var(--panel2); }
.search { flex: 1; max-width: 600px; position: relative; margin-left: auto; }
.search svg { position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.search input {
  width: 100%; padding: 10px 14px 10px 40px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 15px;
}
.search input:focus { outline: none; border-color: var(--accent); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: var(--panel2); }
.icon-btn svg { width: 22px; height: 22px; display: block; }

.services { display: flex; gap: 8px; padding: 0 24px 12px; overflow-x: auto; scrollbar-width: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); cursor: pointer; font: 600 13px/1 inherit;
  opacity: .5; transition: opacity .15s, border-color .15s;
}
.chip:hover { opacity: .8; }
.chip.on { opacity: 1; color: var(--text); border-color: var(--c); }
.chip .logo, .chip .dot { width: 24px; height: 24px; }
.services .label { color: var(--muted); font-size: 12px; align-self: center; flex: none; margin-right: 2px; }

.logo { border-radius: 6px; display: block; object-fit: cover; }
.dot {
  display: inline-grid; place-items: center; border-radius: 6px;
  background: var(--c); color: #000; font: 800 12px/1 system-ui;
}

/* ---------- layout ---------- */
main { padding: 22px 24px 60px; min-height: 60vh; }
footer { padding: 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.page-title { font-size: 22px; margin: 0 0 16px; }
.section-title { font-size: 17px; margin: 26px 0 12px; }

.row { margin-bottom: 30px; }
.row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.row-head h2 { font-size: 18px; margin: 0; }
.row-head .logo, .row-head .dot { width: 26px; height: 26px; }
.row-head .see-all { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px; }
.row-head .see-all:hover { color: var(--accent); }
.strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: 14px;
  overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 14px; }

/* ---------- cards ---------- */
.card { all: unset; cursor: pointer; display: block; scroll-snap-align: start; min-width: 0; }
.poster { position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--panel2); transition: transform .15s; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noposter { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; text-align: center; color: var(--muted); font-weight: 600; font-size: 13px; }
.card:hover .poster, .card:focus-visible .poster { outline: 2px solid var(--accent); outline-offset: 2px; transform: translateY(-2px); }
.badges { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.badges .logo, .badges .dot { width: 22px; height: 22px; box-shadow: 0 1px 5px rgba(0, 0, 0, .7); }
.card .t { margin-top: 8px; font-weight: 600; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card .note { color: #c9a35a; }
.skeleton .poster { animation: pulse 1.2s ease-in-out infinite; }
.skeleton .t { height: 12px; width: 70%; background: var(--panel2); border-radius: 4px; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; margin-bottom: 20px; }
.filters label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
select, .input {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 14px;
}
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 5px 14px; border-radius: 7px; cursor: pointer; font: 600 13px/1.2 inherit; }
.seg button.on { background: var(--panel2); color: var(--text); }
.btn {
  background: var(--accent); color: #111; border: 0; border-radius: 8px;
  padding: 9px 16px; font: 700 14px/1 inherit; cursor: pointer;
}
.btn.ghost { background: var(--panel2); color: var(--text); }
.center { text-align: center; margin: 24px 0; }
.empty { color: var(--muted); padding: 20px 0; }
.sentinel { height: 1px; }
.spinner { width: 28px; height: 28px; margin: 40px auto; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

details.else { margin-top: 28px; }
details.else summary { cursor: pointer; font-weight: 700; font-size: 16px; color: var(--muted); margin-bottom: 14px; }
details.else summary:hover { color: var(--text); }

.people { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.person-chip { display: inline-flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
.person-chip:hover { border-color: var(--accent); }
.person-chip img, .person-chip .ph { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--panel2); }
.person-head { display: flex; gap: 18px; align-items: center; margin-bottom: 8px; }
.person-head img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; }
.person-head h1 { margin: 0; }

/* ---------- setup ---------- */
.setup { max-width: 640px; margin: 20px auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.setup h1 { margin-top: 0; }
.setup ol { padding-left: 20px; }
.setup li { margin-bottom: 6px; }
.form { display: grid; gap: 14px; margin-top: 18px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--muted); }
.form .input { width: 100%; }

.import { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.import h3 { margin: 0 0 6px; font-size: 15px; }
.import p { margin: 0 0 10px; font-size: 14px; }
.signout { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }
.setup.login { max-width: 440px; }

/* ---------- dialogs ---------- */
dialog {
  padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text);
  width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dlg-wrap { position: relative; }
.settings-wrap { padding: 24px; }
dialog#settings { width: min(560px, calc(100vw - 32px)); }
.close {
  position: absolute; right: 12px; top: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
.hero { position: relative; min-height: 220px; background: var(--panel2) center / cover no-repeat; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(20, 22, 28, .1), var(--panel) 96%); }
.detail { display: grid; grid-template-columns: 180px 1fr; gap: 24px; padding: 0 26px 26px; margin-top: -110px; position: relative; z-index: 1; }
.detail .poster { box-shadow: 0 8px 30px rgba(0, 0, 0, .6); }
.detail h1 { margin: 60px 0 6px; font-size: 26px; line-height: 1.15; }
.facts { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.facts .cert { border: 1px solid var(--muted); border-radius: 4px; padding: 0 5px; font-size: 12px; }
.overview { margin: 14px 0; }
.watch { margin: 18px 0; }
.watch h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 8px; }
.svc-list { display: flex; flex-wrap: wrap; gap: 8px; }
.svc { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.svc.mine { border-color: var(--c); }
.svc .logo, .svc .dot { width: 28px; height: 28px; }
.links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin-top: 10px; }
.cast { display: grid; grid-auto-flow: column; grid-auto-columns: 92px; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.cast button { all: unset; cursor: pointer; text-align: center; font-size: 12px; }
.cast button:hover .nm { color: var(--accent); }
.cast img, .cast .ph { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--panel2); display: block; margin: 0 auto 6px; }
.cast .nm { font-weight: 600; }
.cast .ch { color: var(--muted); }

/* ---------- profiles ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--c); color: #fff; font: 800 15px/1 system-ui; text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; border-radius: 7px; }
.avatar.md { width: 40px; height: 40px; font-size: 18px; }
.avatar.xl { width: 110px; height: 110px; font-size: 46px; border-radius: 16px; }
.profile-btn { background: none; border: 0; padding: 2px; border-radius: 10px; cursor: pointer; }
.profile-btn:hover .avatar { outline: 2px solid var(--text); outline-offset: 2px; }
.picker { max-width: 760px; margin: 30px auto; }
.picker-title { text-align: center; font-size: 30px; margin: 0 0 10px; }
.profile-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; margin: 28px 0; }
.pf { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 10px; color: var(--muted); font-weight: 600; }
.pf:hover, .pf:focus-visible { color: var(--text); }
.pf:hover .avatar, .pf:focus-visible .avatar { outline: 3px solid var(--text); outline-offset: 3px; }
.pf.current .avatar { outline: 3px solid var(--accent); outline-offset: 3px; }
#profiles .avatar.xl { width: 84px; height: 84px; font-size: 36px; }
#profiles .picker-title { font-size: 22px; }
#profiles .profile-grid { gap: 18px; margin: 20px 0; }
.pf-manage { display: grid; gap: 10px; margin: 18px 0; }
.pf-row, .pf-add { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.pf-row .input { flex: 1; min-width: 120px; }
.pf-add { margin: 18px auto; max-width: 560px; }
.pf-add h3 { flex-basis: 100%; margin: 0 0 2px; font-size: 15px; }
.pf-add .input { flex: 1; min-width: 140px; }
.swatches { display: flex; gap: 5px; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches span { display: block; width: 20px; height: 20px; border-radius: 50%; background: var(--c); cursor: pointer; }
.swatches input:checked + span { outline: 2px solid var(--text); outline-offset: 2px; }
.swatches input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 107, 107, .4); }
.btn.danger:hover { background: rgba(255, 107, 107, .12); }
.pf-err:empty { display: none; }
pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; overflow-x: auto; }

/* ---------- watched & ratings ---------- */
.markslot { position: absolute; top: 6px; right: 6px; }
.mark {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 999px;
  background: rgba(0, 0, 0, .78); color: #4ade80; font: 800 12px/1 system-ui; box-shadow: 0 1px 5px rgba(0, 0, 0, .6);
}
.mark b { color: var(--accent); }
.card.watched .poster img { opacity: .55; }
body.hide-watched main:not([data-view="watched"]):not([data-view="lists"]) .card.watched { display: none; }
.mark i { font-style: normal; display: inline-flex; align-items: center; }
.mark .mk-p { color: #fbbf24; }
.mark .mk-l { color: #7dd3fc; }
.avatar.xs { width: 18px; height: 18px; font-size: 10px; border-radius: 5px; }
.avs { display: inline-flex; vertical-align: middle; }
.avs .avatar + .avatar { margin-left: -4px; box-shadow: 0 0 0 2px var(--panel); }
.row-head .avs .avatar { box-shadow: 0 0 0 2px var(--bg); }

/* detail dialog: progress, seasons, lists */
.act-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.act-row .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 2px; }
.act-row .lbl .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.seg.status button.on.watched { background: rgba(74, 222, 128, .16); color: #4ade80; }
.seg.status button.on.partial { background: rgba(251, 191, 36, .16); color: #fbbf24; }
.seg.status button.on.none { background: var(--panel2); color: var(--text); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font: 600 13px/1.1 inherit; cursor: pointer;
}
.pill:hover { color: var(--text); border-color: var(--muted); }
.pill.on { color: var(--text); border-color: #7dd3fc; background: rgba(125, 211, 252, .1); }
.seasons .pill.on { border-color: #fbbf24; background: rgba(251, 191, 36, .12); }
.pill.new { border-style: dashed; }

/* lists page */
.lists-layout { display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start; }
.list-nav { display: grid; gap: 4px; position: sticky; top: 140px; }
.list-nav a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.list-nav a:hover { color: var(--text); background: var(--panel); }
.list-nav a.on { color: var(--text); background: var(--panel2); }
.list-nav .ln-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-nav .count { font-size: 12px; color: var(--muted); }
.list-nav .new-list { margin-top: 8px; justify-self: start; }
.list-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.list-head .page-title { margin-bottom: 4px; }
.list-sub { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.list-actions { display: flex; gap: 8px; }
.list-item { min-width: 0; }
.list-item .card { width: 100%; }
.mark { white-space: nowrap; }
.li-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; min-height: 22px; }
.li-remove { margin-left: auto; background: none; border: 0; color: var(--muted); font: 600 12px/1 inherit; cursor: pointer; padding: 4px; }
.li-remove:hover { color: var(--danger); }
.member-status { display: inline-flex; gap: 6px; }
.ms { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 800; }
.ms i { font-style: normal; }
.ms.none .avatar { opacity: .45; }
.ms.watched i { color: #4ade80; }
.ms.partial i { color: #fbbf24; }
fieldset.members { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; }
fieldset.members legend { font-weight: 600; font-size: 13px; color: var(--muted); padding: 0 4px; }
.member { display: flex !important; align-items: center; gap: 10px; color: var(--text) !important; font-size: 14px !important; cursor: pointer; }
.member input { accent-color: var(--accent); width: 16px; height: 16px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; flex: none; margin-left: auto; padding-left: 12px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.toggle input { accent-color: var(--accent); }

.my-actions { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin: 14px 0 4px; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; }
.my-actions:empty { display: none; }
.my-actions.saving { opacity: .6; pointer-events: none; }
.watch-btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font: 700 13px/1 inherit; cursor: pointer; }
.watch-btn:hover { border-color: var(--muted); }
.watch-btn.on { background: rgba(74, 222, 128, .14); border-color: #4ade80; color: #4ade80; }
.stars { display: inline-flex; }
.stars button { background: none; border: 0; padding: 0 2px; font-size: 24px; line-height: 1; cursor: pointer; color: #4a4f5c; }
.stars button.on { color: var(--accent); }
.stars:hover button { color: var(--accent); }
.stars button:hover ~ button { color: #4a4f5c; }
.stars button:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
.rate-label { font-size: 13px; }
.save-err:empty { display: none; }
.stats { margin: -8px 0 16px; }

@media (max-width: 760px) {
  .bar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .services { padding: 0 16px 10px; }
  main { padding: 18px 16px 50px; }
  .strip { grid-auto-columns: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .detail { grid-template-columns: 1fr; margin-top: -60px; padding: 0 18px 20px; }
  .detail .poster { width: 120px; }
  .lists-layout { grid-template-columns: 1fr; gap: 16px; }
  .list-nav { position: static; display: flex; overflow-x: auto; }
  .list-nav a { flex: none; }
  .list-nav .new-list { margin-top: 0; flex: none; }
  .detail h1 { margin-top: 4px; }
}
