/* ---------- theme ---------- */
:root {
  color-scheme: dark;
  --bg: #0a0b0f;
  --bg-2: #101219;
  --surface: #161922;
  --surface-2: #1f2330;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f3f4f7;
  --muted: #9aa1b0;
  --accent: #ff6a3d;
  --accent-2: #ff3d7f;
  --accent-fg: #ffffff;
  --danger: #ff5a5f;
  --shade: 10, 11, 15;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f6f7fb; --bg-2: #eef0f6; --surface: #ffffff; --surface-2: #eceef5;
    --border: rgba(15, 20, 35, 0.1); --text: #12141c; --muted: #5d6475;
    --accent: #e8522a; --accent-2: #e02d6f; --shade: 246, 247, 251; --shadow: 0 12px 28px rgba(20, 25, 45, 0.12);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fb; --bg-2: #eef0f6; --surface: #ffffff; --surface-2: #eceef5;
  --border: rgba(15, 20, 35, 0.1); --text: #12141c; --muted: #5d6475;
  --accent: #e8522a; --accent-2: #e02d6f; --shade: 246, 247, 251; --shadow: 0 12px 28px rgba(20, 25, 45, 0.12);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
.wrap { width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 28px; } }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(var(--shade), 0.78); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; white-space: nowrap; }
.logo span:last-child { color: var(--accent); }
.logo-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; font-size: 12px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; height: 40px; padding: 0 14px 0 38px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.search-icon { position: absolute; left: 13px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
@media (max-width: 480px) { .logo { font-size: 0; gap: 0; } .logo-mark { font-size: 12px; } }

/* ---------- buttons, chips, badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent; font-weight: 650; cursor: pointer; white-space: nowrap; transition: transform 0.15s, filter 0.15s, background 0.15s; }
.btn-primary { color: var(--accent-fg); background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: color-mix(in srgb, var(--surface-2) 80%, transparent); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 550; }
button.chip { cursor: pointer; }
button.chip:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip.failed { opacity: 0.5; text-decoration: line-through; }
.badge { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, 0.66); backdrop-filter: blur(6px); }
.badge.score { left: auto; right: 8px; }
.badge.filler { left: auto; right: 8px; background: rgba(214, 120, 20, 0.9); }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { height: 34px; min-width: 60px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; font-weight: 650; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- hero ---------- */
.hero { position: relative; min-height: 420px; display: flex; align-items: flex-end; overflow: hidden; background: var(--bg-2); }
.hero-skel { min-height: 420px; }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg) 4%, rgba(var(--shade), 0.6) 45%, rgba(var(--shade), 0.15)), linear-gradient(90deg, rgba(var(--shade), 0.85), transparent 70%); }
.hero-body { position: relative; padding-top: 80px; padding-bottom: 36px; display: grid; gap: 12px; max-width: 1400px; }
.hero h1 { font-size: clamp(28px, 6vw, 52px); line-height: 1.05; letter-spacing: -0.03em; max-width: 760px; font-weight: 850; }
.eyebrow { justify-self: start; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-fg); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.hero-meta { color: var(--muted); font-weight: 600; }
.hero-desc { max-width: 640px; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: color-mix(in srgb, var(--text) 85%, transparent); }
@media (min-width: 768px) { .hero, .hero-skel { min-height: 520px; } }

/* ---------- rows & cards ---------- */
.row { margin: 28px 0; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.row h2, .sec-head h2, .page-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.scroller { display: grid; grid-auto-flow: column; grid-auto-columns: 42%; gap: 14px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; padding: 6px 2px 14px; scrollbar-width: thin; }
.scroller > * { scroll-snap-align: start; }
@media (min-width: 600px) { .scroller { grid-auto-columns: 28%; } }
@media (min-width: 900px) { .scroller { grid-auto-columns: 18%; } }
@media (min-width: 1200px) { .scroller { grid-auto-columns: calc((100% - 6 * 14px) / 7); } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.card { display: block; min-width: 0; border-radius: var(--radius); }
.poster { position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); transition: transform 0.22s ease, box-shadow 0.22s ease; }
.poster img, .poster-ph { width: 100%; height: 100%; object-fit: cover; }
.poster-ph { background: linear-gradient(135deg, var(--surface-2), var(--surface)); }
.card:hover .poster, .card:focus-visible .poster { transform: translateY(-4px); box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent); }
.card-title { margin-top: 10px; font-size: 14px; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.2); }
.progress span { display: block; height: 100%; background: var(--accent); }
.page { padding-top: 24px; padding-bottom: 48px; }
.page-title { margin-bottom: 18px; overflow-wrap: anywhere; }

/* ---------- skeletons, spinner, states ---------- */
.skel .poster, .skel-line, .skel.hero, .banner.skel, .detail-cover.skel, .ep.skel .ep-thumb { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skel .poster { box-shadow: none; }
.skel-line { height: 12px; margin-top: 10px; border-radius: 6px; width: 80%; }
.skel-line.short { width: 45%; }
.skel-line.wide { height: 28px; width: 70%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { display: inline-block; width: 22px; height: 22px; flex: none; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; align-self: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 12px; padding: 14px 0 18px; color: var(--muted); }
.state { display: grid; justify-items: center; gap: 10px; padding: 40px 16px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.state-title { font-size: 18px; font-weight: 750; }
.state-text { color: var(--muted); max-width: 520px; }
.state-retry { margin-top: 6px; }

/* ---------- detail ---------- */
.banner { height: 200px; background: var(--bg-2); position: relative; overflow: hidden; }
.banner img { width: 100%; height: 100%; object-fit: cover; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg), rgba(var(--shade), 0.2)); }
@media (min-width: 768px) { .banner { height: 320px; } }
.detail-head { position: relative; display: grid; gap: 20px; margin-top: -90px; z-index: 1; }
.detail-cover { width: 150px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface-2); }
.detail-info { display: grid; gap: 12px; align-content: start; min-width: 0; }
.detail-info h1 { font-size: clamp(24px, 4.5vw, 40px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 850; overflow-wrap: anywhere; }
.alt-title { color: var(--muted); }
.meta-list { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-weight: 600; font-size: 14px; }
.meta-list li:first-child { color: var(--accent); }
.genres { display: flex; flex-wrap: wrap; gap: 8px; }
.desc { max-width: 860px; color: color-mix(in srgb, var(--text) 85%, transparent); line-height: 1.65; }
@media (min-width: 768px) { .detail-head { grid-template-columns: 220px 1fr; gap: 32px; margin-top: -140px; } .detail-cover { width: 220px; } .detail-info { padding-top: 120px; } }
.episodes { margin-top: 36px; padding-bottom: 56px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
@media (min-width: 768px) { .ep-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); } }
.ep { display: block; border-radius: var(--radius-sm); min-width: 0; }
.ep-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: linear-gradient(135deg, var(--surface-2), var(--surface)); display: grid; place-items: center; transition: transform 0.2s, box-shadow 0.2s; }
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ep-big { font-size: 34px; font-weight: 850; color: var(--muted); opacity: 0.6; }
.ep:hover .ep-thumb, .ep:focus-visible .ep-thumb { transform: translateY(-3px); box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent); }
.ep-info { padding-top: 8px; }
.ep-info h3 { font-size: 14px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- watch ---------- */
.watch { display: grid; gap: 20px; padding-top: 16px; padding-bottom: 48px; }
@media (min-width: 1024px) { .watch { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; padding-top: 24px; } }
.watch-main { min-width: 0; display: grid; gap: 16px; }
.player { display: grid; gap: 12px; }
.stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stage:fullscreen { border-radius: 0; aspect-ratio: auto; }
.stage video { width: 100%; height: 100%; display: block; background: #000; }
.p-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; max-width: 90%; padding: 10px 16px; border-radius: 999px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 14px; pointer-events: none; }
.skip { position: absolute; right: 16px; bottom: 64px; height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(10, 10, 14, 0.75); color: #fff; font-weight: 700; cursor: pointer; backdrop-filter: blur(6px); }
.skip:hover { background: var(--accent); border-color: var(--accent); }
.p-error { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; text-align: center; color: #fff; background: rgba(0, 0, 0, 0.82); }
.p-error-title { font-size: 17px; font-weight: 750; }
.p-error p:not(.p-error-title) { color: #c7cad3; font-size: 14px; max-width: 460px; }
.p-bar { display: grid; gap: 10px; }
.servers { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.p-selects { display: flex; flex-wrap: wrap; gap: 10px; }
.sel { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sel select { height: 36px; max-width: 240px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.watch-info { display: grid; gap: 8px; }
.crumb { justify-self: start; color: var(--muted); font-weight: 600; font-size: 14px; }
.crumb:hover { color: var(--accent); }
.w-title { font-size: clamp(20px, 3vw, 28px); font-weight: 800; letter-spacing: -0.01em; }
.w-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.w-controls .btn { height: 40px; padding: 0 16px; }
.w-desc { color: var(--muted); max-width: 820px; }
.ep-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.ep-side h2 { font-size: 16px; font-weight: 800; margin: 2px 4px 10px; }
.side-list { position: relative; display: grid; gap: 4px; max-height: 420px; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 1024px) { .ep-side { position: sticky; top: 76px; } .side-list { max-height: calc(100vh - 150px); } }
.side-list a { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 14px; }
.side-list a:hover { background: var(--surface-2); }
.side-list a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.side-num { flex: none; min-width: 30px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-list a.active .side-num { color: var(--accent); }
.side-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list .badge { position: static; flex: none; }

/* ---------- subtitles ---------- */
video::cue { color: #fff; background: rgba(0, 0, 0, 0.62); font-family: var(--font); font-size: 1.05em; line-height: 1.35; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 100; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 14px; padding: 11px 16px; border-radius: 12px; background: rgba(20, 22, 30, 0.94); color: #fff; font-size: 14px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.08); animation: toast-in 0.22s ease; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.toast-btn { border: 0; background: transparent; color: #ff8a65; font-weight: 750; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }
}

/* ---------- progressive episode loading ---------- */
.more-src { display: inline-flex; align-items: center; gap: 8px; }
.sec-head .more-src { margin-right: auto; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 4px 10px; }
.side-head h2 { margin: 0; }
.ep-loading { display: grid; gap: 10px; padding: 6px 0 18px; color: var(--muted); }
.ep-side .ep-loading { padding: 4px 4px 12px; }
.ep-loading .lp-msg { color: var(--text); font-weight: 600; max-width: 560px; }
.ep-loading .lp-count { font-variant-numeric: tabular-nums; }
.lp-bar { position: relative; height: 3px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.lp-bar::before { content: ""; position: absolute; inset: 0; width: 35%; border-radius: inherit; background: var(--accent); animation: lp-slide 1.6s ease-in-out infinite; }
@keyframes lp-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .lp-bar { display: none; } }
.p-status { border-radius: 18px; }
.p-status-text { white-space: pre-line; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
