/* ==========================================================================
   Giao diện website phim. Không cần build (không dùng Vite/Tailwind).
   Tông: xanh đêm của phòng chiếu; hổ phách = điểm số (đèn máy chiếu); xanh ngọc = hành động.
   ========================================================================== */

:root {
  /* ScamClub: nền điện ảnh tối, vàng hổ phách cho hành động và điểm số */
  --bg: #0B0D12;
  --surface: #141821;
  --raised: #1C2230;
  --line: #2A3142;
  --text: #F3F5F9;
  --muted: #A8B0C0;
  --lamp: #FFB020;
  --lamp-ink: #0B0D12;
  --signal: #FFB020;
  --signal-ink: #0B0D12;
  --tmdb: #7DB7FF;
  --danger: #FF8A8E;
  --ok: #3DD68C;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Be Vietnam Pro", "Inter", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --raised: #ECEEF3;
  --line: #D5DAE5;
  --text: #11151F;
  --muted: #566078;
  --lamp: #8A5300;
  --lamp-ink: #FFF7E6;
  --signal: #8A5300;
  --signal-ink: #FFFFFF;
  --tmdb: #1D5FB4;
  --danger: #C2253A;
  --ok: #1A7F4B;
  --shadow: 0 8px 24px rgba(16, 24, 40, .12);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); min-height: 100vh;
  display: flex; flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--signal); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-head); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--raised); font-weight: 600; font-size: 14px; line-height: 1.2;
}
.btn:hover { border-color: var(--signal); color: var(--text); }
.btn-primary { background: var(--signal); color: var(--signal-ink); border-color: transparent; }
.btn-primary:hover { background: var(--signal); color: var(--signal-ink); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn[aria-pressed="true"] { border-color: var(--lamp); color: var(--lamp); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.brand { flex: none; display: inline-flex; align-items: center; gap: 8px; font: 800 22px/1 var(--font-head); letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-logo { width: 30px; height: 30px; }
.brand b { color: var(--lamp); font-weight: 800; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav summary {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 500;
  color: var(--muted); list-style: none; white-space: nowrap;
}
.nav summary::-webkit-details-marker { display: none; }
.nav a:hover, .nav summary:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--raised); }
.nav a.btn-primary, .nav a.btn-primary:hover { color: var(--signal-ink); background: var(--signal); }
.nav a.btn-primary:hover { filter: brightness(1.08); }
.menu { position: relative; }
.menu-panel {
  position: absolute; top: 100%; left: 0; z-index: 60; min-width: 260px; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px;
}
.menu-panel::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; } /* cầu nối để rê chuột không bị mất */
.menu-panel a { padding: 6px 10px; color: var(--text); border-radius: 8px; }
.menu-panel a:hover { background: var(--raised); color: var(--signal); }
@media (min-width: 901px) {
  .nav .menu:not(.menu-right) .menu-panel { min-width: 560px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 6px; }
  .nav .menu:not(.menu-right) .menu-panel::before { top: -16px; height: 16px; }
}
@media (min-width: 901px) and (max-width: 1150px) {
  .nav .menu:not(.menu-right) .menu-panel { min-width: 400px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.menu-right .menu-panel { left: auto; right: 0; grid-template-columns: 1fr; min-width: 200px; }
.header-spacer { flex: 1; }

.search { position: relative; flex: 0 1 260px; min-width: 170px; }
.search input {
  width: 100%; padding: 10px 52px 10px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface);
}
.search input::placeholder { color: var(--muted); }
.search-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: var(--signal); color: var(--signal-ink); cursor: pointer;
  display: grid; place-items: center;
}
.search-btn:hover { filter: brightness(1.1); }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 70; display: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.suggest.open { display: block; }
.suggest a { display: flex; gap: 10px; align-items: center; padding: 8px 12px; }
.suggest a:hover, .suggest a.active { background: var(--raised); color: var(--text); }
.suggest img { width: 34px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--raised); }
.suggest small { display: block; color: var(--muted); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--signal); }

/* ---------- Thông báo ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin: 16px 0 0; border: 1px solid var(--line); background: var(--surface); }
.flash.ok { border-color: var(--signal); }
.flash.err { border-color: var(--danger); color: var(--danger); }

/* ---------- Hero ---------- */
.hero { position: relative; isolation: isolate; min-height: min(560px, 72vh); display: flex; align-items: flex-end; overflow: hidden; }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 70%, transparent) 38%, transparent 75%),
    linear-gradient(0deg, var(--bg) 0%, transparent 40%);
}
.hero-body { padding: 80px 0 48px; max-width: 640px; margin-inline: 0; margin-left: max(16px, calc((100vw - 1240px) / 2)); }
.hero h1 { font-size: clamp(34px, 6vw, 64px); line-height: 1.04; font-weight: 800; letter-spacing: -.03em; text-wrap: balance; }
.hero-orig { color: var(--muted); font-size: 18px; margin-top: 6px; }
.hero-desc { font-family: var(--serif); font-size: 18px; line-height: 1.6; margin: 18px 0 24px; color: color-mix(in srgb, var(--text) 88%, var(--muted)); max-width: 56ch; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); margin-top: 14px; }
.facts span + span { padding-left: 16px; border-left: 1px solid var(--line); }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pill { padding: 4px 12px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; }
a.pill:hover { border-color: var(--signal); color: var(--text); }

/* ---------- Hàng phim và lưới ---------- */
.section { margin-top: 40px; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; gap: 12px; }
.row-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.row-head a { color: var(--muted); font-size: 14px; }
.rail-wrap { position: relative; }
.rail { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 8px; scrollbar-width: thin; }
.rail > .card { flex: 0 0 168px; scroll-snap-align: start; }
.rail-btn {
  position: absolute; top: 40%; transform: translateY(-50%); z-index: 5; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; display: none; place-items: center;
}
.rail-btn.prev { left: -14px; } .rail-btn.next { right: -14px; }
@media (hover: hover) and (min-width: 900px) { .rail-wrap:hover .rail-btn { display: grid; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 16px; }

.card { display: block; min-width: 0; }
.card-img {
  position: relative; display: block; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(160deg, var(--raised), var(--surface)); border: 1px solid var(--line);
}
.card-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; font-weight: 800; color: var(--line); }
.card:hover .card-img { border-color: var(--signal); }
.chip {
  position: absolute; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  background: rgba(8, 12, 22, .78); color: #fff; max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-q { top: 8px; left: 8px; }
.chip-ep { bottom: 8px; left: 8px; }
.score {
  position: absolute; top: 8px; right: 8px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 800;
  background: var(--lamp); color: var(--lamp-ink); font-variant-numeric: tabular-nums;
}
.score-tmdb { background: var(--tmdb); color: #0B0D12; }
.card-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 8px; font-weight: 600; line-height: 1.3; }
.card-sub { display: flex; gap: 10px; color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Bộ lọc ---------- */
.page-head { padding: 32px 0 8px; }
.page-head h1 { font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 26px; }
.filters select, .filters input[type="search"], .field input, .field textarea, .field select {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); min-width: 0;
}
.filters input[type="search"] { flex: 1 1 220px; }
.filters select { flex: 0 1 170px; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 36px 0 8px; }
.pg { min-width: 40px; padding: 8px 12px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
a.pg:hover { border-color: var(--signal); color: var(--text); }
.pg.current { background: var(--signal); color: var(--signal-ink); border-color: transparent; font-weight: 700; }
.pg.disabled, .pg.gap { color: var(--muted); background: transparent; border-color: transparent; }

.empty { padding: 56px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); margin-top: 24px; }
.empty h2 { color: var(--text); font-size: 20px; margin-bottom: 8px; }
.empty code, code.cmd { background: var(--raised); border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px; font-size: 13px; color: var(--text); }
.empty .cmds { display: grid; gap: 8px; justify-items: center; margin-top: 14px; }

/* ---------- Trang chi tiết ---------- */
.detail { position: relative; isolation: isolate; overflow: hidden; border-bottom: 1px solid var(--line); }
.detail-bg { position: absolute; inset: -20px; z-index: -2; width: calc(100% + 40px); height: calc(100% + 40px); object-fit: cover; filter: blur(22px) saturate(1.1); opacity: .5; }
.detail::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, var(--bg), color-mix(in srgb, var(--bg) 72%, transparent)); }
.detail-grid { display: grid; grid-template-columns: 260px 1fr; gap: 32px; padding: 40px 0 36px; align-items: end; }
.detail-poster { aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--raised); box-shadow: var(--shadow); }
.detail-poster img { width: 100%; height: 100%; object-fit: cover; }
.detail h1 { font-size: clamp(28px, 4.6vw, 48px); font-weight: 800; line-height: 1.08; letter-spacing: -.03em; text-wrap: balance; }
.detail .orig { color: var(--muted); font-size: 18px; margin-top: 6px; }

/* Dải "vé xem phim": điểm nguồn ngoài tách khỏi đánh giá thành viên */
.stub {
  display: grid; grid-template-columns: repeat(3, 1fr); position: relative; margin-top: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.stub-cell { position: relative; padding: 18px 22px; min-width: 0; }
.stub-cell + .stub-cell { border-left: 2px dashed var(--line); }
.stub-cell + .stub-cell::before, .stub-cell + .stub-cell::after {
  content: ""; position: absolute; left: -11px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
}
.stub-cell + .stub-cell::before { top: -11px; border-top-color: transparent; border-left-color: transparent; transform: rotate(45deg); }
.stub-cell + .stub-cell::after { bottom: -11px; border-bottom-color: transparent; border-right-color: transparent; transform: rotate(45deg); }
.stub-label { font-weight: 700; }
.stub-note { color: var(--muted); font-size: 12.5px; }
.stub-value { display: flex; align-items: baseline; gap: 6px; margin: 8px 0 2px; }
.stub-value strong { font-size: 40px; line-height: 1; font-weight: 800; color: var(--lamp); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stub-value span { color: var(--muted); }
.stub-none { font-size: 18px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.stub-cell.site strong { color: var(--signal); }
.stub-cell a.more { font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

.block { margin-top: 40px; }
.block > h2 { font-size: 21px; font-weight: 700; margin-bottom: 14px; }
.synopsis { font-family: var(--serif); font-size: 19px; line-height: 1.75; max-width: 68ch; }
.synopsis p + p { margin-top: 12px; }
.alt-names { margin-top: 14px; color: var(--muted); font-size: 13.5px; max-width: 68ch; }

.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.person { display: flex; gap: 10px; align-items: center; min-width: 0; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.person:hover { border-color: var(--signal); color: var(--text); }
.avatar { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; background: var(--raised); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person b { display: block; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.person small { display: block; color: var(--muted); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.person > span:last-child { min-width: 0; }

.providers { display: flex; flex-wrap: wrap; gap: 18px 28px; }
.provider-group h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.provider-list { display: flex; flex-wrap: wrap; gap: 8px; }
.provider-list span { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.provider-list img { width: 26px; height: 26px; border-radius: 50%; }

.review-form { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-width: 680px; }
.stars { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.stars legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.stars label { position: relative; }
.stars input { position: absolute; opacity: 0; }
.stars span {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--raised); cursor: pointer; font-weight: 700; font-variant-numeric: tabular-nums;
}
.stars input:checked + span { background: var(--lamp); color: var(--lamp-ink); border-color: transparent; }
.stars input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
.review-list { display: grid; gap: 12px; margin-top: 20px; max-width: 680px; }
.review { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.review header { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.review .rate { color: var(--signal); font-weight: 800; font-variant-numeric: tabular-nums; }
.review p { margin-top: 6px; white-space: pre-line; overflow-wrap: anywhere; }
.review time { color: var(--muted); font-size: 12.5px; }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; }
.field textarea { min-height: 96px; resize: vertical; }
.field-error { color: var(--danger); font-size: 13.5px; }

dialog#trailer { width: min(960px, 94vw); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #000; overflow: hidden; }
dialog#trailer::backdrop { background: rgba(0, 0, 0, .7); }
dialog#trailer .frame { aspect-ratio: 16 / 9; }
dialog#trailer iframe { width: 100%; height: 100%; border: 0; }
dialog#trailer form { position: absolute; top: 8px; right: 8px; }

/* ---------- Trang xem ---------- */
.player { aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.player iframe, .player video { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.watch-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 20px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.tabs a[aria-current="true"] { background: var(--signal); color: var(--signal-ink); border-color: transparent; font-weight: 700; }
.eps { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; max-height: 320px; overflow: auto; padding: 2px; }
.eps a { text-align: center; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eps a[aria-current="true"] { background: var(--lamp); color: var(--lamp-ink); border-color: transparent; font-weight: 800; }

/* ---------- Tài khoản ---------- */
.auth { width: min(420px, 100% - 32px); margin: 56px auto; padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.auth h1 { font-size: 26px; font-weight: 800; margin-bottom: 18px; }
.auth form { display: grid; gap: 14px; }
.auth .alt { margin-top: 16px; color: var(--muted); }
.auth .alt a { color: var(--signal); }
.check { display: flex; gap: 8px; align-items: center; }

.tabs-line { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 20px 0 24px; }
.tabs-line a { padding: 10px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs-line a[aria-current="page"] { color: var(--text); border-color: var(--signal); }
.history { display: grid; gap: 10px; }
.history-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.history-row img { width: 64px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; background: var(--raised); }

/* ---------- Quản trị ---------- */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 20px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat b { display: block; font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 600; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 999px; background: var(--raised); overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; background: var(--signal); }
.status { padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; border: 1px solid var(--line); }
.status.success, .status.completed { color: var(--ok); border-color: var(--ok); }
.status.stopped, .status.stopping, .status.pending { color: var(--muted); }
.status.failed, .status.partial { color: var(--danger); border-color: var(--danger); }
.status.running, .status.queued { color: var(--lamp); border-color: var(--lamp); }
.status.failed { color: var(--danger); border-color: var(--danger); }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type="number"] { width: 80px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ---------- Trang chủ (landing) ---------- */
.btn-lg { padding: 14px 26px; font-size: 16px; }
.lp-hero { position: relative; isolation: isolate; overflow: hidden; padding: 56px 0 72px; }
.lp-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 55% at 85% 10%, color-mix(in srgb, var(--signal) 22%, transparent), transparent 70%),
    radial-gradient(50% 50% at 5% 90%, rgba(229, 72, 77, .16), transparent 70%);
}
.lp-grid { display: grid; gap: 48px; align-items: center; }
.lp-badge {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 4px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13.5px;
}
.lp-badge b { color: var(--ok); }
.lp-copy h1 { font-size: clamp(34px, 5.2vw, 62px); font-weight: 800; line-height: 1.08; letter-spacing: -.03em; text-wrap: balance; }
.lp-copy h1 em { font-style: normal; color: var(--signal); }
.lp-lead { margin-top: 16px; max-width: 52ch; font-size: 18px; color: var(--muted); }
.lp-stats { display: flex; flex-wrap: wrap; gap: 28px 40px; margin: 40px 0 0; }
.lp-stats dt { font: 800 28px/1 var(--font-head); font-variant-numeric: tabular-nums; }
.lp-stats dd { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }

.lp-stack { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 480px; width: 100%; }
.lp-stack li:nth-child(2), .lp-stack li:nth-child(5) { transform: translateY(26px); }
.lp-poster {
  position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden; border-radius: var(--radius);
  background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .25s;
}
.lp-poster:hover { transform: translateY(-4px); }
.lp-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lp-poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .78), transparent 55%); }
.lp-poster span {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 1; color: #fff; font: 700 13px/1.25 var(--font-head);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.lp-section { padding: 72px 0; }
.lp-section .section:first-child { margin-top: 0; }
.lp-alt { background: var(--surface); border-block: 1px solid var(--line); }
.lp-alt .card-img { background: linear-gradient(160deg, var(--raised), var(--bg)); }
.lp-head { max-width: 640px; margin-bottom: 40px; }
.lp-head h2 { font-size: clamp(26px, 3.4vw, 40px); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.lp-head p { margin-top: 12px; color: var(--muted); font-size: 18px; }
.lp-eyebrow { display: inline-block; margin-bottom: 12px; color: var(--signal); font: 600 13px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; }

.lp-cards { display: grid; gap: 20px; }
.lp-card {
  display: flex; flex-direction: column; gap: 10px; padding: 28px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--surface); transition: border-color .2s, transform .2s;
}
.lp-card:hover { border-color: color-mix(in srgb, var(--signal) 55%, transparent); transform: translateY(-3px); color: var(--text); }
.lp-card h3 { font-size: 20px; font-weight: 600; }
.lp-card p { color: var(--muted); }
.lp-count { margin-top: auto; padding-top: 8px; color: var(--signal); font-weight: 600; }
.lp-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 8px; border-radius: 14px; background: color-mix(in srgb, var(--signal) 14%, transparent); color: var(--signal); }
.lp-icon svg { width: 26px; height: 26px; }

.lp-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; max-width: 780px; }
.lp-rank a { display: flex; align-items: center; gap: 16px; min-height: 76px; padding: 10px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); transition: border-color .2s; }
.lp-rank a:hover { border-color: color-mix(in srgb, var(--signal) 55%, transparent); color: var(--text); }
.lp-rank-n { width: 30px; font: 800 26px/1 var(--font-head); color: var(--signal); font-variant-numeric: tabular-nums; }
.lp-rank-img { width: 40px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--raised); flex: none; }
.lp-rank-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lp-rank-t b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-rank-t small { color: var(--muted); }
.lp-score { color: var(--signal); font-weight: 700; font-variant-numeric: tabular-nums; }

.lp-cta { position: relative; isolation: isolate; overflow: hidden; text-align: center; padding: 64px 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.lp-cta::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(60% 80% at 50% 0%, color-mix(in srgb, var(--signal) 22%, transparent), transparent 70%); }
.lp-cta h2 { font-size: clamp(24px, 3.2vw, 38px); font-weight: 700; line-height: 1.2; text-wrap: balance; }
.lp-cta p { max-width: 52ch; margin: 14px auto 28px; color: var(--muted); font-size: 18px; }

@media (min-width: 640px) { .lp-cards { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) {
  .lp-hero { padding: 88px 0 96px; }
  .lp-grid { grid-template-columns: 1.1fr .9fr; }
}
@media (max-width: 640px) { .lp-section { padding: 48px 0; } .lp-hero { padding: 40px 0 56px; } .lp-stack { max-width: 360px; } }

/* ---------- Phòng xem chung ---------- */
.room-player { position: relative; }
.room-player video { object-fit: contain; }
.room-join {
  position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; max-width: 90%;
  padding: 16px 28px; border: 0; border-radius: 999px; background: var(--signal); color: var(--signal-ink);
  font: 700 17px/1.2 var(--font); cursor: pointer; box-shadow: var(--shadow);
}
.room-join[hidden] { display: none; }
.room-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: linear-gradient(0deg, rgba(0, 0, 0, .75), transparent); color: #fff; font-variant-numeric: tabular-nums; font-size: 13.5px;
}
.room-bar-spacer { flex: 1; }
.room-bar button { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 18px; cursor: pointer; }
.room-bar button:hover { background: rgba(255, 255, 255, .18); }
.room-status { margin-top: 10px; color: var(--muted); }
.room-status.bad { color: var(--danger); }
.room-ep {
  text-align: center; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font: inherit; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
button.room-ep { cursor: pointer; }
button.room-ep:hover { border-color: var(--signal); }
.room-ep[aria-current="true"] { background: var(--lamp); color: var(--lamp-ink); border-color: transparent; font-weight: 800; }

/* ---------- Chân trang ---------- */
.site-footer { margin-top: 64px; border-top: 1px solid var(--line); padding: 28px 0 36px; color: var(--muted); font-size: 13.5px; }
.site-footer .wrap { display: grid; gap: 6px; }

/* ---------- Màn hình nhỏ ---------- */
/* ---------- Form lấy mới (quản trị) ---------- */
.crawl-card { display: grid; gap: 22px; margin-top: 14px; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.crawl-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.crawl-field legend { font-weight: 600; padding: 0; margin-bottom: 10px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--raised); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 8px 20px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--signal); color: var(--signal-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.picker { display: flex; flex-direction: column; min-width: 0; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.picker-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.picker-head legend { float: left; padding: 0; font: 700 15px/1.2 var(--font-head); margin-right: auto; }
.picker-count { font-size: 12.5px; color: var(--muted); }
.picker-search { width: 100%; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 2px 8px; padding: 10px 12px; max-height: 232px; overflow: auto; align-content: start; }
.opt { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.opt:hover { background: var(--raised); }
.opt[hidden] { display: none; }
.picker[hidden] { display: none; }
.opt input { width: 16px; height: 16px; accent-color: var(--signal); flex: none; }

.crawl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: start; }
.crawl-grid .field input, .crawl-grid .field select { width: 100%; background: var(--bg); }
.crawl-grid .field label { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.crawl-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.estimate { color: var(--muted); }
.estimate strong { color: var(--text); }
.estimate.bad, .estimate.bad strong { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.check input { width: 16px; height: 16px; accent-color: var(--signal); }
@media (max-width: 800px) { .pickers { grid-template-columns: 1fr; } .crawl-card { padding: 16px; } }

/* Header ở cỡ trung: xuống hàng sớm để không bị chật */
@media (min-width: 901px) and (max-width: 1180px) {
  .header-row { flex-wrap: wrap; padding: 10px 0; }
  .search { order: 5; flex: 1 1 100%; }
}

@media (max-width: 900px) {
  .header-row { flex-wrap: wrap; padding: 10px 0; gap: 10px; }
  .search { order: 5; flex: 1 1 100%; }
  .nav { order: 4; overflow-x: auto; max-width: 100%; }
  .menu-panel { position: fixed; left: 12px; right: 12px; top: 120px; min-width: 0; max-height: 60vh; }
  .menu-right .menu-panel { left: 12px; right: 12px; }
  .detail-grid { grid-template-columns: 1fr; gap: 20px; }
  .detail-poster { width: 150px; }
  .stub { grid-template-columns: 1fr; }
  .stub-cell + .stub-cell { border-left: 0; border-top: 2px dashed var(--line); }
  .stub-cell + .stub-cell::before, .stub-cell + .stub-cell::after { top: -11px; bottom: auto; left: -11px; transform: none; border-radius: 50%; }
  .stub-cell + .stub-cell::after { left: auto; right: -11px; }
  .two-col { grid-template-columns: 1fr; }
  .hero { min-height: 420px; }
  .hero-body { margin-left: 16px; padding-bottom: 32px; }
  .rail > .card { flex-basis: 140px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 18px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---------- Danh sách phòng xem chung ---------- */
.room-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; margin-top: 16px; }
.room-main { min-width: 0; }
.room-side { position: relative; align-self: stretch; min-height: 420px; }
.room-chat-panel { position: absolute; inset: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.room-chat-head { font-size: 15px; font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line); margin: 0; }
.room-chat { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 90%; padding: 8px 12px; border-radius: 12px; background: var(--raised); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; background: var(--lamp); color: var(--lamp-ink); }
.chat-msg small { opacity: .65; }
.room-chat-err { margin: 0; padding: 6px 14px; color: var(--danger); font-size: 13px; }
.room-chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.room-chat-form input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }
.room-toolbar { display: flex; gap: 8px; margin-top: 8px; }
/* Chế độ rộng và màn hình hẹp: chat nằm dưới video */
.room-layout.theater { grid-template-columns: minmax(0, 1fr); }
.room-layout.theater .room-side { min-height: 0; height: 380px; }
.room-layout.theater .room-player { max-height: 82vh; }
@media (max-width: 900px) {
  .room-layout { grid-template-columns: minmax(0, 1fr); }
  .room-side { min-height: 0; height: 380px; }
}
.room-viewers { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.room-viewers li { padding: 4px 12px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13.5px; }
.nav-rooms { white-space: nowrap; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.room-card { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.room-card:hover { border-color: var(--signal); }
.room-thumb { flex: 0 0 84px; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--raised); }
.room-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.room-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 14px; }
.room-title { font-size: 16px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pill-live { color: var(--signal); border-color: var(--signal); }

/* Quản trị đánh giá */
.admin-reviews { display: grid; gap: 14px; }
.admin-review { max-width: none; }
.admin-review header > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.admin-review.is-hidden { opacity: .65; border-style: dashed; }
.admin-review .status { margin-left: 8px; }
.admin-actions { margin-top: 10px; }
.admin-actions summary { cursor: pointer; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.admin-actions form { margin-top: 8px; }
.admin-actions textarea { width: 100%; min-height: 80px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); resize: vertical; }
.admin-reply { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--signal); background: var(--bg); border-radius: 0 10px 10px 0; }
.admin-reply p { margin-top: 4px; }
.inline-form select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }

/* Lấy mới: ẩn các ô không dùng cho nguồn đang chọn */
.crawl-card [hidden] { display: none !important; }

/* Popup miễn trừ trách nhiệm */
dialog.disclaimer { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
dialog.disclaimer::backdrop { background: rgba(0, 0, 0, .65); }
dialog.disclaimer h2 { font-size: 22px; font-weight: 800; margin: 0 0 12px; }
dialog.disclaimer .disclaimer-body { display: grid; gap: 10px; line-height: 1.6; }
dialog.disclaimer .disclaimer-body a { text-decoration: underline; }
dialog.disclaimer .disclaimer-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
