:root {
  --bg: #0b0f17; --bg2: #121826; --bg3: #1a2234; --line: #232d42;
  --fg: #e8ecf3; --muted: #8a94a8; --accent: #2d6fff; --accent2: #5b8cff;
  --ok: #2fbf71; --warn: #f2b134; --bad: #e5484d; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; display: flex; align-items: center; gap: 10px; }
.count { font-size: .8rem; color: var(--muted); background: var(--bg3); padding: 2px 8px; border-radius: 99px; }
.muted { color: var(--muted); }
code { background: var(--bg3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
section { margin-bottom: 36px; }
.narrow { max-width: 480px; }

/* header */
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.topsearch { flex: 1; display: flex; max-width: 560px; }
.topsearch input { flex: 1; min-width: 0; border-radius: 8px 0 0 8px; }
.topsearch button { border-radius: 0 8px 8px 0; border: 1px solid var(--line); border-left: 0; background: var(--bg3); color: var(--fg); padding: 0 14px; cursor: pointer; font-size: 1.1rem; }
nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
nav a, nav button.link { padding: 6px 10px; border-radius: 8px; color: var(--muted); background: none; border: 0; font: inherit; cursor: pointer; }
nav a:hover, nav a.on, nav button.link:hover { color: var(--fg); background: var(--bg3); }
nav .who { color: var(--fg); font-weight: 600; }
.inline { display: inline; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px; border-top: 1px solid var(--line); }

/* forms */
input, select { background: var(--bg3); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
label input { display: block; width: 100%; margin-top: 4px; color: var(--fg); }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
label.check input { width: auto; display: inline; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; background: var(--bg3); color: var(--fg); border: 1px solid var(--line); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: .85rem; }
.btn.wide { width: 100%; }
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.alert { background: rgba(229,72,77,.12); border: 1px solid rgba(229,72,77,.4); color: #ffb3b5; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.alert.ok { background: rgba(47,191,113,.12); border-color: rgba(47,191,113,.4); color: #9fe8bf; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.addform { display: flex; gap: 8px; flex-wrap: wrap; }
.addform input[name="imdb"], .addform input[name="username"], .addform input[name="password"] { flex: 1; min-width: 200px; }

/* login */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 360px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 28px; text-align: center; }
.login-box form { text-align: left; margin-top: 18px; }
.login-logo { width: 56px; height: 56px; margin-bottom: 8px; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.row .card { scroll-snap-align: start; }
.card { display: block; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .15s, border-color .15s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent2); }
.poster { aspect-ratio: 2/3; background: var(--bg3) center/cover no-repeat; position: relative; display: grid; place-items: center; }
.poster.small { width: 72px; border-radius: 8px; flex: none; }
.noimg { font-size: 2.5rem; font-weight: 800; color: var(--line); }
.badge { position: absolute; top: 8px; left: 8px; font-size: .7rem; font-weight: 700; background: rgba(0,0,0,.65); padding: 2px 7px; border-radius: 99px; }
.thumb { aspect-ratio: 16/9; background: var(--bg3) center/cover no-repeat; position: relative; display: grid; place-items: center; }
.thumb .play { font-size: 1.6rem; background: rgba(0,0,0,.55); width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.2); }
.bar i { display: block; height: 100%; background: var(--accent); }
.meta { padding: 10px 12px; }
.meta strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.meta small { color: var(--muted); display: block; }
.empty { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty.small { padding: 30px 16px; background: var(--bg2); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h1 { font-size: 3rem; color: var(--fg); }

/* search results */
.results { display: grid; gap: 10px; }
.result { display: flex; gap: 14px; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 10px 10px; }
.rposter { width: 56px; aspect-ratio: 2/3; border-radius: 6px; background: var(--bg3) center/cover no-repeat; flex: none; }
.rmeta { flex: 1; min-width: 0; }
.rmeta strong, .rmeta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rmeta small { color: var(--muted); }

/* watch */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
.player { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.nowbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-top: 12px; }
.nowbar > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { font-size: .78rem; font-weight: 700; background: var(--bg3); padding: 2px 9px; border-radius: 99px; }
.epnav { display: flex; align-items: center; gap: 6px; }
.epnav label { margin: 0; display: inline-flex; align-items: center; gap: 4px; }
.epnav input { width: 64px; padding: 5px 8px; display: inline; margin: 0; }
.side { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.side-head { display: flex; gap: 12px; margin-bottom: 14px; }
.side-head strong { display: block; margin-bottom: 2px; }
.side-head small { display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.history { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.history li a { display: grid; grid-template-columns: 20px auto 1fr auto; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 8px; font-size: .9rem; }
.history li a:hover { background: var(--bg3); }
.history li.now a { background: rgba(45,111,255,.15); }
.history .tick { color: var(--ok); font-weight: 800; text-align: center; }
.history .right { text-align: right; font-size: .8rem; }

/* status */
.statusbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
table.status { width: 100%; border-collapse: collapse; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.status th, table.status td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.status th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.status tr:last-child td { border-bottom: 0; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-cell input { width: 150px; padding: 5px 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); vertical-align: middle; margin-right: 4px; }
.dot.operational { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.degraded { background: var(--warn); }
.dot.down { background: var(--bad); }

@media (max-width: 900px) {
  .watch { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
  .topsearch { order: 3; flex-basis: 100%; max-width: none; }
  nav a:not(.who) { font-size: .9rem; }
  table.status { display: block; overflow-x: auto; }
}
