:root {
    color-scheme: dark;
    --bg: #090c14;
    --panel: #111725;
    --panel-raised: #171f2e;
    --line: rgba(255, 255, 255, .09);
    --text: #f3f5fa;
    --muted: #9aa6b9;
    --accent: #ff426d;
    --accent-soft: rgba(255, 66, 109, .14);
    --gold: #ffc767;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html {
    min-height: 100%;
    background: var(--bg);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}
body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    background: radial-gradient(ellipse at 15% -20%, #20263a 0, transparent 45%), var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}
body, button, input, select, textarea { font-family: inherit; }
button, a, input, select { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
img, video { max-width: 100%; }
.wrap { width: min(1180px, calc(100% - 36px)); margin-inline: auto; }
.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 12, 20, .92);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}
.topbar-inner { padding-block: 10px; }
.topbar-main { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { min-width: 0; overflow: hidden; font-size: 19px; font-weight: 850; letter-spacing: .01em; text-overflow: ellipsis; white-space: nowrap; }
.brand b { color: var(--accent); }
.userlinks { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.balance-link { display: flex; align-items: center; gap: 7px; }
.user-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-link { display: inline-flex; font-size: 11px; }
.btn, .search button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(115deg, var(--accent), #ff7958);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
    transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}
.btn { padding: 0 16px; }
.btn:active, .search button:active { transform: scale(.98); filter: brightness(.95); }
.btn[disabled], button[disabled] { opacity: .6; cursor: wait; }
.register-link { min-height: 36px; padding-inline: 13px; }
.search { display: flex; gap: 8px; margin-top: 10px; }
.search input, .field {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    outline: none;
    background: #101725;
    color: var(--text);
    padding: 10px 13px;
    font-size: 16px;
}
.search input:focus, .field:focus { border-color: rgba(255, 66, 109, .65); box-shadow: 0 0 0 3px rgba(255, 66, 109, .12); }
.search button { width: 46px; min-width: 46px; min-height: 44px; font-size: 22px; }
main.wrap { min-height: 55vh; padding-bottom: 28px; }
.hero { padding: 25px 0 16px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
.hero h1 { margin: 8px 0 7px; font-size: clamp(26px, 7vw, 38px); line-height: 1.2; letter-spacing: -.035em; }
.hero p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 24px 0 13px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head > span { font-size: 12px; }
.muted { color: var(--muted); }
.gold { color: var(--gold); font-weight: 800; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
.card { display: block; min-width: 0; }
.poster { position: relative; overflow: hidden; aspect-ratio: 3 / 4; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, #252e42, #111725); box-shadow: 0 8px 22px rgba(0, 0, 0, .18); }
.poster img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.poster .tag { position: absolute; top: 8px; left: 8px; max-width: calc(100% - 16px); overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: rgba(8, 11, 18, .78); padding: 5px 8px; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.card-title { overflow: hidden; margin: 9px 0 4px; font-size: 14px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.card-sub, .card-price { font-size: 11px; }
.card-sub { color: var(--muted); }
.card-price { margin-top: 5px; color: var(--gold); }
.empty { padding: 56px 15px; color: var(--muted); text-align: center; }
.footer { padding: 22px 0 calc(86px + var(--safe-bottom)); color: #667186; font-size: 11px; text-align: center; }
.mobile-bottom-nav {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
    background: rgba(15, 20, 31, .96);
    padding: 7px 12px calc(7px + var(--safe-bottom));
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}
.mobile-bottom-nav a { display: grid; min-height: 48px; align-content: center; justify-items: center; gap: 2px; color: var(--muted); font-size: 10px; }
.mobile-bottom-nav a:active { color: #fff; }
.nav-icon { font-size: 20px; line-height: 1; }
.crumb { overflow: hidden; padding: 16px 0 12px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.detail { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 13px; padding: 12px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(130deg, rgba(255,255,255,.065), rgba(255,255,255,.015)); }
.detail-cover { display: block; width: 88px; aspect-ratio: 3 / 4; object-fit: cover; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-raised); }
.detail h1 { margin: 5px 0 8px; font-size: 19px; line-height: 1.3; overflow-wrap: anywhere; }
.detail .eyebrow { font-size: 9px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: 11px; }
.chip { border-radius: 99px; background: var(--panel-raised); padding: 5px 8px; }
.desc { max-height: 94px; overflow: auto; margin: 10px 0; color: #b6c0cf; font-size: 12px; line-height: 1.65; white-space: pre-line; -webkit-overflow-scrolling: touch; }
.package-box { display: grid; gap: 10px; margin: 14px 0; border: 1px solid rgba(255,66,109,.28); border-radius: 14px; background: var(--accent-soft); padding: 13px; }
.package-box > div:first-child strong { display: block; margin-bottom: 4px; font-size: 14px; }
.package-box .muted { font-size: 11px; line-height: 1.5; }
.package-box > div:last-child { display: flex; align-items: center; gap: 10px; }
.package-box .btn { min-height: 40px; margin-left: auto; }
.episodes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.episode { display: flex; min-width: 0; min-height: 54px; align-items: center; justify-content: space-between; gap: 7px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 9px 10px; font-size: 11px; }
.episode > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.episode > span:last-child { flex: 0 0 auto; font-size: 10px; }
.episode:active { border-color: rgba(255,66,109,.6); background: var(--panel-raised); }
.lock { color: var(--gold); }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.play-layout > section { min-width: 0; }
.player { position: relative; overflow: hidden; width: calc(100% + 24px); max-width: none; aspect-ratio: 16 / 9; margin: 0 -12px 17px; background: #000; }
.player video { display: block; width: 100%; height: 100%; background: #000; object-fit: contain; }
.locked { display: grid; min-height: 100%; place-items: center; background: radial-gradient(ellipse, #293047, #080a10); padding: 16px; text-align: center; }
.locked > div { max-width: 320px; }
.locked h2 { margin: 6px 0; font-size: 18px; }
.locked p { margin: 8px 0 13px; color: var(--muted); font-size: 12px; }
.locked .btn { min-height: 42px; }
.locked p:has(button) { margin-top: 8px; }
.play-layout h1 { margin: 0 0 7px; font-size: 19px; line-height: 1.4; overflow-wrap: anywhere; }
.play-layout h1 .muted { font-size: 13px; }
.play-layout > section > p { margin-top: 0; font-size: 12px; }
.list-panel, .panel { min-width: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); padding: 14px; }
.list-panel h3 { margin: 0 0 12px; font-size: 15px; }
.play-episodes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: none; overflow: visible; }
.play-episodes a { min-width: 0; overflow: hidden; border: 1px solid transparent; border-radius: 10px; background: #182131; padding: 11px 9px; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.play-episodes a.current { border-color: rgba(255,66,109,.45); background: var(--accent-soft); color: #ff8aa5; }
.form-card { width: min(100%, 440px); margin: 24px auto; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 22px 18px; }
.form-card h1 { margin: 0 0 8px; font-size: 23px; }
.form-card p { font-size: 13px; }
.form-card label { display: block; margin: 15px 0 7px; color: var(--muted); font-size: 12px; }
.form-card .field { width: 100%; }
.form-card .btn { width: 100%; min-height: 46px; margin-top: 18px; }
.notice { margin: 12px 0; border-radius: 9px; background: rgba(255,66,109,.1); padding: 10px; color: #ff9bb0; font-size: 13px; }
.wallet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wallet-card { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 13px; }
.wallet-card strong { display: block; margin: 5px 0; color: var(--gold); font-size: 19px; }
.wallet-card .muted, .wallet-card .card-sub { font-size: 11px; }
.wallet-card .btn { width: 100%; min-height: 42px; }
.table-scroll { overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.table { width: 100%; min-width: 500px; border-collapse: collapse; font-size: 12px; }
.table td, .table th { border-bottom: 1px solid var(--line); padding: 11px 9px; text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; }
.pagination { display: flex; justify-content: center; gap: 8px; padding: 22px 0; }

/* The public site is intentionally phone-only. Keep the administrator routes available on desktop. */
@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
    html:has(body.public-site), body.public-site { background: #fff !important; }
    body.public-site > * { display: none !important; }
}

@media (min-width: 390px) and (max-width: 768px) {
    .wrap { width: calc(100% - 30px); }
    .topbar-inner { padding-block: 11px; }
    .brand { font-size: 20px; }
    .grid { gap: 18px 14px; }
    .card-title { font-size: 15px; }
    .detail { grid-template-columns: 102px minmax(0, 1fr); gap: 15px; padding: 14px; }
    .detail-cover { width: 102px; }
    .detail h1 { font-size: 21px; }
    .player { width: calc(100% + 30px); margin-inline: -15px; }
    .list-panel, .panel { padding: 16px; }
}

@media (max-width: 360px) {
    .wrap { width: calc(100% - 20px); }
    .brand { font-size: 17px; }
    .userlinks { gap: 7px; font-size: 12px; }
    .register-link { min-height: 33px; padding-inline: 10px; }
    .detail { grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 10px; }
    .detail-cover { width: 76px; }
    .detail h1 { font-size: 17px; }
    .package-box { padding: 10px; }
    .package-box .btn { padding-inline: 10px; font-size: 12px; }
    .episodes, .play-episodes { gap: 6px; }
    .episode { min-height: 50px; padding: 8px; font-size: 10px; }
    .wallet-grid { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 900px) {
    .topbar { position: relative; }
    .player { width: min(100%, calc((100dvh - 24px) * 16 / 9)); margin-inline: auto; }
    .player:has(video:fullscreen) { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
