/* Watchlist – dark, mobile first */

:root {
  --bg: #000;
  --tile: #131315;
  --tile-2: #1b1b1f;
  --line: #26262b;
  --line-2: #34343b;
  --text: #fff;
  --soft: #d4d4d8;
  --muted: #a1a1aa;
  --dim: #6b6b74;
  --accent: #8b7bff;
  --accent-soft: rgba(139, 123, 255, .16);
  --danger: #ff5d6c;
  --maxw: 460px;
  --radius: 18px;
  --gap: 12px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(32px + var(--bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
img { display: block; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px;
  padding: calc(6px + var(--top)) max(8px, calc((100vw - var(--maxw)) / 2 + 8px)) 6px;
  background: rgba(0, 0, 0, .82);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid #111;
}
.topbar .search { min-width: 0; }
.topbar .search-field {
  height: 44px; padding-left: 40px; border-radius: 12px; font-size: 16px;
  background-position: 12px center; background-size: 18px;
}
.iconbtn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 12px; border: 0; background: none; cursor: pointer;
}
.iconbtn:active { background: var(--tile-2); }

/* ---------- Home ---------- */

.hero { padding: calc(36px + var(--top)) 2px 22px; }
.brand {
  margin: 0;
  font: 800 clamp(38px, 11vw, 54px)/1 var(--display);
  letter-spacing: -.035em;
}
.brand .dot { color: var(--accent); }
.brand-sm { font-size: 30px; padding: calc(28px + var(--top)) 0 12px; }
.brand-page { font-size: 26px; padding: 18px 2px 2px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }

.sq {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  aspect-ratio: 1 / .86; padding: 16px;
  background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .12s ease, background-color .12s ease;
}
.sq:active { transform: scale(.97); background: var(--tile-2); }
.sq-ico {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 14px; background: var(--tile-2); color: var(--text);
}
.sq-label { display: block; font-weight: 700; font-size: 17px; line-height: 1.2; }
.sq-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.sq-list { background: linear-gradient(150deg, #241f45 0%, #131315 70%); border-color: #2f2a52; }
.sq-list .sq-ico { background: var(--accent); color: #fff; }
.sq-logo { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; background: var(--tile-2); }
.sq-manage { background: transparent; border-style: dashed; border-color: var(--line-2); }
.sq-manage .sq-ico { background: transparent; border: 1px solid var(--line-2); }

.credits {
  margin: 40px 0 0; padding-top: 20px; border-top: 1px solid #141416;
  color: var(--dim); font-size: 12px; text-align: center;
}
.credits p { margin: 6px 0 0; }
.tmdb {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  font: 800 13px/1.2 var(--display); letter-spacing: .04em;
  background: #383838;
  color: #8f8f8f;
}

/* ---------- Tabs ---------- */

.tabs {
  position: sticky; top: calc(57px + var(--top)); z-index: 20;
  display: flex; gap: 8px; padding: 12px 0; background: var(--bg);
}
.tab {
  flex: 1; text-align: center; padding: 11px 8px; border-radius: 14px;
  background: var(--tile); border: 1px solid var(--line);
  color: var(--muted); font-weight: 650; font-size: 15px;
}
.tab .n { margin-left: 5px; font-weight: 500; opacity: .7; }
.tab.on { background: #666; border-color: #666; color: #fff; }
.tab.on .n { opacity: .85; }

.hint { margin: 0 2px 10px; color: var(--dim); font-size: 13px; }

/* ---------- Ranked rows ---------- */

.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.row {
  background: var(--tile); border: 1px solid var(--line); border-radius: 16px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: background-color .15s ease, border-color .15s ease;
}
.row > a, .row-in {
  display: grid; grid-template-columns: 34px 44px minmax(0, 1fr) minmax(40px, auto); align-items: center; gap: 12px;
  min-height: 82px; padding: 8px 12px 8px 6px;
}
.row > a:active { background: var(--tile-2); border-radius: 15px; }
.rank {
  text-align: center; color: var(--muted);
  font: 600 18px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}
.rows > li:nth-child(1) .rank { color: #fff; }
.poster {
  width: 44px; height: 66px; border-radius: 7px; object-fit: cover; background: var(--tile-2);
  pointer-events: none;
}
.poster-none {
  display: grid; place-items: center; color: var(--dim);
  font: 700 18px/1 var(--display);
}
.row-text { min-width: 0; }
.row-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 650; font-size: 15.5px; line-height: 1.25;
}
.row-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.avail { display: grid; place-items: center; }
.avail img { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; pointer-events: none; }
.avail-none { width: 38px; height: 38px; border-radius: 10px; border: 1.5px dashed var(--line-2); }
.mrank { color: var(--dim); font-size: 12px; font-weight: 600; text-align: center; line-height: 1.1; }
.mrank b { display: block; color: var(--muted); font-size: 14px; }

/* while dragging */
.is-sorting, .is-sorting * { cursor: grabbing !important; }
.is-chosen { background: var(--tile-2); border-color: var(--accent); }
.is-ghost { opacity: .25; }
.is-drag, .sortable-fallback {
  opacity: 1 !important; background: #222228 !important; border-color: var(--accent) !important;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .7);
}

/* ---------- Buttons / misc ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--tile); font-weight: 650; cursor: pointer;
}
.btn-primary { background: #666; color: #fff; border-color: #666; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255, 93, 108, .35); }
.btn-block { display: flex; width: 100%; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 18px; }
.err { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.section-title { margin: 28px 2px 6px; font: 600 15px/1.2 var(--display); letter-spacing: -.01em; }

.field {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--tile); color: var(--text);
  font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--dim); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 999px;
  background: #fff; color: #000; font-weight: 600; font-size: 14px;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Search ---------- */

.search-field {
  padding-left: 46px;
  background: var(--tile) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 15px center / 20px;
}
.hero .search { margin-top: 20px; }
.results { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; transition: opacity .15s; }
.results.loading { opacity: .45; }
.result {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; padding: 12px;
  background: var(--tile); border: 1px solid var(--line); border-radius: 16px;
}
.result:active { background: var(--tile-2); }
.result .poster, .result .poster-none { width: 76px; height: 114px; border-radius: 9px; }
.result h3 { margin: 2px 0 4px; font-size: 16px; line-height: 1.25; }
.result p {
  margin: 6px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.badge {
  padding: 2px 7px; border-radius: 6px; background: #26262b; color: var(--soft);
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.badge-on { background: var(--accent-soft); color: #c4bbff; }

/* ---------- Title page ---------- */

.backdrop {
  position: relative; height: min(58vw, 320px); margin: 0 -16px;
  background: var(--tile) center 20% / cover no-repeat;
}
.backdrop::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.1) 0%, rgba(0,0,0,.35) 55%, #000 100%);
}
.title-head {
  position: relative; z-index: 1; margin-top: -72px;
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: end;
}
.poster-lg {
  width: 112px; aspect-ratio: 2 / 3; border-radius: 12px; object-fit: cover;
  background: var(--tile-2); box-shadow: 0 12px 30px rgba(0,0,0,.6);
}
.title-name { margin: 0 0 8px; font: 700 23px/1.15 var(--display); letter-spacing: -.02em; }
.tagline { margin: 18px 0 0; color: var(--muted); font-style: italic; }
.overview { margin: 10px 0 0; color: var(--soft); line-height: 1.6; }
.facts { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.facts b { color: var(--soft); font-weight: 600; }

.add-tile {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  width: 100%; min-height: 88px; margin: 22px 0 0; padding: 12px 18px;
  border: 0; border-radius: 20px; background: #fff; color: #000; cursor: pointer;
  font-size: 19px; font-weight: 750; text-align: left;
  transition: transform .12s ease;
}
.add-tile:active { transform: scale(.98); }
.add-tile:disabled { opacity: .5; }
.add-tile .big { font-size: 46px; font-weight: 300; line-height: 1; margin-top: -4px; }
.add-tile small { display: block; font-size: 13px; font-weight: 600; opacity: .65; }
.add-tile.on { background: var(--accent-soft); color: #fff; border: 1px solid #3b3470; }
.add-tile.on .big { font-size: 30px; font-weight: 700; color: var(--accent); margin: 0; }
.tile-actions { display: flex; gap: 10px; margin-top: 10px; }
.tile-actions .btn { flex: 1; gap: 6px; padding: 0 8px; }
.tile-actions svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .4; cursor: default; }

.providers { display: flex; flex-wrap: wrap; gap: 14px 12px; }
.prov { width: 60px; text-align: center; font-size: 11px; line-height: 1.25; color: var(--muted); }
.prov img { width: 52px; height: 52px; margin: 0 auto 6px; border-radius: 13px; object-fit: cover; }
.prov.mine img { box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--accent); }
.prov.mine { color: #fff; }
.prov-sm { width: 44px; }
.prov-sm img { width: 38px; height: 38px; border-radius: 10px; }
.group-label { margin: 16px 0 10px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.source { margin: 14px 0 0; color: var(--dim); font-size: 12px; }

.cast { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none; }
.cast::-webkit-scrollbar { display: none; }
.person { flex: 0 0 84px; font-size: 12px; line-height: 1.3; }
.person img, .person .ph { width: 84px; height: 84px; margin-bottom: 7px; border-radius: 50%; object-fit: cover; background: var(--tile-2); }
.person b { display: block; font-weight: 600; color: var(--soft); }
.person span { color: var(--dim); }

.skeleton { background: linear-gradient(90deg, var(--tile) 0%, var(--tile-2) 50%, var(--tile) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Service page ---------- */

.svc-head {
  display: flex; align-items: center; gap: 16px; margin-top: 14px; padding: 16px;
  background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius);
}
.svc-head img { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; flex: none; }
.svc-head h2 { margin: 0 0 4px; font: 700 22px/1.15 var(--display); letter-spacing: -.02em; }
.svc-head p { margin: 0; color: var(--muted); font-size: 14px; }
.svc-head + .tabs { top: calc(57px + var(--top)); }

/* ---------- Manage services ---------- */

.row-in .logo { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; pointer-events: none; }
.row-in .iconbtn { color: var(--dim); }
.row-in .iconbtn:active { color: var(--danger); }

.pick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 10px; margin-top: 14px; }
.pick-grid > p { grid-column: 1 / -1; margin: 0; }
.pick {
  position: relative; padding: 0; border: 0; background: none; cursor: pointer;
  text-align: center; font-size: 11.5px; line-height: 1.25; color: var(--soft);
}
.pick img { width: 100%; aspect-ratio: 1; margin-bottom: 6px; border-radius: 16px; object-fit: cover; background: var(--tile-2); }
.pick span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pick:active img { transform: scale(.95); }
.pick.added { opacity: .35; }
.pick.added::after {
  content: "✓"; position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 800;
}

.sheet-bg {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6);
  opacity: 0; transition: opacity .2s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: var(--maxw); max-height: 85vh; margin: 0 auto; overflow-y: auto;
  padding: 20px 16px calc(16px + var(--bottom));
  background: #151518; border: 1px solid var(--line-2); border-bottom: 0; border-radius: 24px 24px 0 0;
  transform: translateY(100%); transition: transform .22s ease;
}
.sheet-bg.open { opacity: 1; }
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.sheet-head img { width: 56px; height: 56px; border-radius: 14px; }
.sheet-head h3 { margin: 0; font: 700 19px/1.2 var(--display); }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check img { width: 32px; height: 32px; border-radius: 8px; }
.sheet .btn { margin-top: 12px; }

/* ---------- Setup / login ---------- */

.setup-log { color: var(--soft); line-height: 1.8; }
.setup-owner .field { margin-bottom: 10px; }
.login { max-width: 360px; margin: 0 auto; padding-top: 12vh; text-align: center; }
.login .field { text-align: center; letter-spacing: .3em; margin: 24px 0 12px; }
.login .field-name { letter-spacing: normal; margin-top: 6px; }
.field-label { display: block; margin-top: 24px; color: var(--muted); font-size: 13px; font-weight: 600; }
.login .brand + p { margin-top: 18px; }
.lead { margin: 0 0 6px; font-size: 19px; font-weight: 700; }
.kicker { margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.note {
  margin: 22px 0 0; padding: 14px 16px; border-radius: 14px; text-align: left;
  background: var(--tile); border: 1px solid var(--line); color: var(--soft); font-size: 14px;
}
.note b { color: var(--text); }
.note .btn { margin-top: 12px; }
.note-ok { margin-bottom: 14px; background: var(--accent-soft); border-color: #3b3470; color: #fff; }
.owner { margin-top: 28px; color: var(--muted); font-size: 14px; }
.owner summary { cursor: pointer; padding: 8px; }
.owner .field { margin-top: 12px; }

/* ---------- Invite friends ---------- */

.inline-form { display: flex; gap: 8px; }
.inline-form .field { flex: 1; min-width: 0; }
.inline-form .btn { flex: none; min-height: 52px; }
.linkbox {
  margin-top: 10px; padding: 14px; border-radius: 16px;
  background: var(--accent-soft); border: 1px solid #3b3470;
}
.linkbox p { margin: 0 0 10px; }
.linkbox .field-sm { margin-top: 10px; color: var(--muted); }
.field-sm { height: 44px; font-size: 14px; padding: 0 12px; }

/* How the link will look in a message */
.preview { overflow: hidden; border-radius: 16px; background: #1c1c21; border: 1px solid var(--line-2); }
.preview img { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; }
.preview div { padding: 10px 14px 12px; }
.preview b { display: block; font-size: 15px; line-height: 1.3; }
.preview span { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }
.btn-sm { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.mt { margin-top: 10px; }
.btn.mt svg, .install-btn svg { width: 20px; height: 20px; }

.plain { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plain li {
  display: flex; align-items: center; gap: 4px; min-height: 64px; padding: 8px 8px 8px 16px;
  background: var(--tile); border: 1px solid var(--line); border-radius: 16px;
}
.plain .grow { flex: 1; min-width: 0; }
.plain b { display: block; font-weight: 650; font-size: 15.5px; }
.plain small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.plain .iconbtn { color: var(--dim); }

/* ---------- Home screen ---------- */

.banner {
  display: flex; align-items: center; gap: 4px; margin: 0 0 var(--gap); padding: 10px 6px 10px 12px;
  background: var(--accent-soft); border: 1px solid #3b3470; border-radius: var(--radius);
}
.banner a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.banner .sq-ico { flex: none; background: var(--accent); }
.banner b { display: block; font-size: 15px; }
.banner small { display: block; color: var(--soft); font-size: 13px; }

.hero-sm { padding: calc(20px + var(--top)) 0 4px; }
.hero-sm .brand-page { padding-top: 0; }
.hero-sm p { margin: 12px 2px 0; }
.install-btn { margin: 18px 0 0; }
.install-next { margin-top: 24px; }

.seg { display: flex; gap: 4px; margin: 18px 0 4px; padding: 4px; background: var(--tile); border: 1px solid var(--line); border-radius: 14px; }
.seg button {
  flex: 1; min-height: 40px; padding: 0 6px; border: 0; border-radius: 10px; background: none; cursor: pointer;
  color: var(--muted); font-weight: 650; font-size: 14px;
}
.seg button[aria-selected="true"] { background: #666; color: #fff; }

.steps { list-style: none; counter-reset: step; margin: 14px 0 0; padding: 0; }
.steps li {
  counter-increment: step; position: relative;
  margin: 0 0 16px; padding-left: 44px; color: var(--soft); line-height: 1.5;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: #fff; font: 700 14px/1 var(--display);
}
.steps b { color: var(--text); }
.steps li > span { display: block; margin-top: 3px; color: var(--muted); font-size: 13.5px; }
.key { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--tile-2); border: 1px solid var(--line-2); }
.steps .ico { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }

/* Desktop: smaller home tiles, three across */
@media (min-width: 560px) {
  .hero { padding-top: calc(28px + var(--top)); padding-bottom: 18px; }
  .hero .brand { font-size: 44px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .sq { aspect-ratio: auto; min-height: 118px; padding: 14px; gap: 10px; border-radius: 16px; }
  .sq-ico { width: 38px; height: 38px; border-radius: 11px; }
  .sq-ico svg { width: 20px; height: 20px; }
  .sq-logo { width: 40px; height: 40px; border-radius: 11px; }
  .sq-label { font-size: 15px; }
  .sq-meta { font-size: 12px; }
}
