:root {
  --bg: #0a0a0f;
  --bg-2: #131320;
  --card: rgba(255,255,255,.055);
  --card-solid: #161622;
  --line: rgba(255,255,255,.08);
  --fg: #f2efe8;
  --muted: #8d8a99;
  --gold: #e8b13f;
  --gold-fg: #191305;
  --m0: #e8b13f;   /* member 1 */
  --m1: #c77dff;   /* member 2 */
  --r: 16px;
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(199,125,255,.10), transparent 60%),
    radial-gradient(900px 420px at 10% -10%, rgba(232,177,63,.10), transparent 55%),
    var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; min-height: 100vh;
}

header h1 {
  font-size: 1.05rem; letter-spacing: .34em; font-weight: 800;
}
header h1 span { color: var(--gold); }
#greeting { color: var(--muted); font-size: .84rem; margin-top: 3px; }

#tabs { display: flex; gap: 8px; margin: 16px 0 18px; }
.tab {
  flex: 1; padding: 10px 0; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted); font-weight: 700; font-size: .9rem;
  cursor: pointer; transition: all .18s;
}
.tab.active { background: var(--gold); border-color: var(--gold); color: var(--gold-fg); }

.pane { display: none; animation: fade .22s ease; }
.pane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.skeleton { height: 190px; border-radius: var(--r); background:
  linear-gradient(100deg, var(--card) 40%, rgba(255,255,255,.10) 50%, var(--card) 60%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* -- hero ------------------------------------------------------------- */
.hero {
  position: relative; border-radius: 20px; overflow: hidden; margin-bottom: 18px;
  aspect-ratio: 16/9.5; background: var(--bg-2); box-shadow: 0 18px 40px rgba(0,0,0,.45);
}
.hero .bg { position: absolute; inset: 0; background-size: cover; background-position: center;
  transform: scale(1.04); }
.hero .scrim { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,10,15,.05) 30%, rgba(10,10,15,.92) 88%); }
.hero .content { position: absolute; left: 16px; right: 16px; bottom: 14px; }
.hero .when {
  display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--gold-fg); background: var(--gold);
  border-radius: 999px; padding: 4px 10px; margin-bottom: 8px;
}
.hero h2 { font-size: 1.5rem; line-height: 1.15; text-shadow: 0 2px 14px rgba(0,0,0,.6); }
.hero .sub { color: #cfccc2; font-size: .84rem; margin-top: 4px; }

/* -- night rows --------------------------------------------------------- */
.day { color: var(--muted); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  margin: 14px 4px 6px; }
.night, .wl-item, .result {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px; margin-bottom: 10px;
  backdrop-filter: blur(6px); transition: transform .15s, opacity .15s;
}
.night:active, .wl-item:active, .result:active { transform: scale(.985); }
.night.dragging { opacity: .35; }
.night.droptarget { outline: 2px solid var(--gold); outline-offset: 2px; }
.poster {
  width: 54px; height: 81px; border-radius: 10px; object-fit: cover;
  background: var(--bg-2); flex-shrink: 0; box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.poster.placeholder { display: grid; place-items: center; font-size: 22px; color: var(--muted); }
.meta { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: .95rem; }
.sub { color: var(--muted); font-size: .8rem; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 5px; vertical-align: 1px; }
.badge {
  font-size: .7rem; font-weight: 800; padding: 4px 9px; border-radius: 999px;
  white-space: nowrap; border: 1px solid var(--line); color: var(--muted);
}
.badge.tonight { background: var(--gold); border-color: var(--gold); color: var(--gold-fg); }
.badge.watched { color: #9ad186; border-color: rgba(154,209,134,.35); }
.badge.member { border: none; color: #0e0c14; }
.grip { color: var(--muted); font-size: 1.1rem; padding: 0 2px; cursor: grab; user-select: none; }

h2.wl-owner { font-size: .8rem; letter-spacing: .18em; text-transform: uppercase;
  margin: 20px 4px 10px; }

.searchbox input {
  width: 100%; padding: 13px 16px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  font-size: 1rem; outline: none; backdrop-filter: blur(6px);
}
.searchbox input:focus { border-color: var(--gold); }

/* -- sheet -------------------------------------------------------------- */
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); opacity: 0;
  pointer-events: none; transition: opacity .22s; z-index: 40; }
#scrim.show { opacity: 1; pointer-events: auto; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card-solid); border-radius: 22px 22px 0 0;
  transform: translateY(105%); transition: transform .26s cubic-bezier(.3,1,.4,1);
  max-width: 640px; margin: 0 auto; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 -18px 60px rgba(0,0,0,.6);
}
#sheet.show { transform: translateY(0); }
#sheet-backdrop { height: 150px; background-size: cover; background-position: center 25%;
  border-radius: 22px 22px 0 0;
  mask-image: linear-gradient(180deg, #000 40%, transparent); }
#sheet-body { padding: 0 18px calc(22px + env(safe-area-inset-bottom)); margin-top: -56px;
  position: relative; }
#sheet-head { display: flex; gap: 14px; align-items: flex-end; }
#sheet-poster { width: 96px; height: 144px; border-radius: 12px; object-fit: cover;
  box-shadow: 0 12px 30px rgba(0,0,0,.55); background: var(--bg-2); }
#sheet-title { font-size: 1.25rem; line-height: 1.2; }
#sheet-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: .72rem; font-weight: 700; color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.chip.lb { color: var(--gold); border-color: rgba(232,177,63,.4); }
#sheet-credits { color: var(--muted); font-size: .82rem; margin: 12px 0 0; }
#sheet-overview { color: #c9c6bd; font-size: .88rem; margin: 10px 0 16px; }
#sheet-actions { display: flex; gap: 10px; }
.btn {
  flex: 1; border: 1px solid var(--line); border-radius: 14px; padding: 13px 0;
  background: var(--card); color: var(--fg); font-weight: 800; font-size: .95rem;
  cursor: pointer; transition: transform .12s;
}
.btn:active { transform: scale(.97); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-fg); }
.btn:disabled { opacity: .4; }

/* -- night modal ---------------------------------------------------------- */
#nightmodal {
  position: fixed; left: 14px; right: 14px; bottom: 18px; z-index: 60;
  background: var(--card-solid); border-radius: 20px; padding: 16px;
  transform: translateY(120%); transition: transform .26s cubic-bezier(.3,1,.4,1);
  max-width: 620px; margin: 0 auto; max-height: 70vh; overflow-y: auto;
  box-shadow: 0 -18px 60px rgba(0,0,0,.6);
}
#nightmodal.show { transform: translateY(0); }
#nightmodal h3 { font-size: 1rem; }
#nightmodal .hint { color: var(--muted); font-size: .78rem; margin: 2px 0 12px; }
#nightgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.nightopt {
  border-radius: 14px; padding: 10px 12px; cursor: pointer;
  border: 1.5px solid var(--nc, var(--line)); background: var(--card);
  transition: transform .12s;
}
.nightopt:active { transform: scale(.97); }
.nightopt .nd { font-weight: 800; font-size: .9rem; }
.nightopt .np { font-size: .74rem; font-weight: 700; color: var(--nc, var(--muted));
  margin-top: 2px; }
.nightopt .nt { font-size: .72rem; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -- view toggle & filters ------------------------------------------------ */
.viewtoggle { display: flex; gap: 6px; margin-bottom: 14px; }
.vt { border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .8rem; cursor: pointer; }
.vt.active { color: var(--fg); border-color: var(--gold); }

#chips { display: flex; gap: 8px; margin: 10px 0 14px; }
#chips select {
  flex: 1; min-width: 0; padding: 8px 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-solid); color: var(--fg);
  font-size: .82rem; font-weight: 600; outline: none; appearance: none;
}

/* -- browse grid ----------------------------------------------------------- */
#results .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 2/3;
  background: var(--bg-2); cursor: pointer; transition: transform .12s; }
.tile:active { transform: scale(.96); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .t-label { position: absolute; inset: auto 0 0 0; padding: 18px 8px 6px;
  background: linear-gradient(transparent, rgba(5,5,8,.92));
  font-size: .68rem; font-weight: 700; line-height: 1.2; }
.tile .t-label .y { color: var(--muted); font-weight: 600; }
.tile.noimg { display: grid; place-items: center; }
.tile.noimg .t-label { position: static; background: none; padding: 8px; text-align: center;
  font-size: .78rem; }

/* -- calendar --------------------------------------------------------------- */
#cal-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
#cal-head b { font-size: .95rem; letter-spacing: .06em; }
#cal-head button { background: var(--card); border: 1px solid var(--line); color: var(--fg);
  border-radius: 10px; width: 34px; height: 34px; font-size: 1rem; cursor: pointer; }
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; color: var(--muted); font-size: .62rem; font-weight: 800;
  letter-spacing: .1em; padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border-radius: 10px; background: var(--card); border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: .78rem; color: var(--muted); position: relative; cursor: pointer;
}
.cal-day.dim { opacity: .28; }
.cal-day.today { border-color: var(--gold); color: var(--fg); }
.cal-day .cd-dot { width: 9px; height: 9px; border-radius: 50%; }
.cal-day .cd-x { font-size: .6rem; color: var(--muted); }
.cal-day.has { color: var(--fg); font-weight: 700; }

/* -- sheet action rows / queue delete -------------------------------------- */
#sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#sheet-actions .btn { flex: 1 1 45%; }
.wl-x { border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 10px; width: 34px; height: 34px; font-size: .95rem; cursor: pointer;
  flex-shrink: 0; }
.nightopt.taken { opacity: .55; }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(90px);
  background: var(--gold); color: var(--gold-fg); font-weight: 800; font-size: .9rem;
  padding: 11px 20px; border-radius: 999px; transition: transform .25s; z-index: 90;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }
