:root {
    --bg: #0a0b14;
    --surface: #13142a;
    --surface-2: #1c1d38;
    --text: #eaeaf0;
    --text-muted: #7d7f96;
    --accent: #ff4d6d;
    --accent-glow: rgba(255,77,109,.25);
    --border: rgba(255,255,255,.07);
    --radius: 10px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }

/* ════ Topbar ════ */
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(10,11,20,.88); border-bottom: 1px solid var(--border); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 900; color: var(--accent); white-space: nowrap; letter-spacing: -.5px; }
.brand-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: var(--accent); color: #fff; border-radius: 8px; font-size: 14px; }
.search-wrap { flex: 1; position: relative; max-width: 440px; margin-left: auto; }
.search-input { width: 100%; height: 40px; border: 1.5px solid var(--border); border-radius: 10px; padding: 0 14px 0 40px; font-size: 14px; outline: none; background: var(--surface); color: var(--text); transition: border .2s, background .2s; }
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); background: var(--surface-2); }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.lang-wrap { flex-shrink: 0; }
.lang-select { height: 40px; border: 1.5px solid var(--border); border-radius: 10px; padding: 0 10px; font-size: 13px; font-weight: 700; color: var(--text); background: var(--surface); cursor: pointer; outline: none; }
.lang-select:focus { border-color: var(--accent); }

/* ════ Search Dropdown ════ */
.search-dropdown { display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.5); max-height: 460px; overflow-y: auto; z-index: 100; }
.search-dropdown.open { display: block; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.search-item { display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background .12s; }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--surface-2); }
.search-item img { width: 48px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.search-meta h4 { font-size: 13px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
.search-meta p { font-size: 11px; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.search-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ════ Provider Bar ════ */
.provider-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
/* Same width/gutters as the topbar and content rows: the chip strip scrolls inside this box */
.provider-bar-inner { max-width: 1480px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 12px; }
.prov-select-wrap { flex-shrink: 0; }
.prov-select { height: 38px; max-width: 190px; border: 1.5px solid var(--border); border-radius: 24px; padding: 0 34px 0 16px; font-size: 13px; font-weight: 700; color: var(--text); background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d7f96' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center; -webkit-appearance: none; appearance: none; cursor: pointer; outline: none; }
.prov-select:focus { border-color: var(--accent); }
.prov-select option { background: var(--surface); color: var(--text); }
.prov-scroll-wrap { position: relative; flex: 1; min-width: 0; }
.prov-scroll { position: relative; display: flex; gap: 8px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 0; }
.prov-scroll::-webkit-scrollbar { display: none; }
/* Fade the strip's edges only on the side(s) that have more chips */
.prov-scroll-wrap.can-right .prov-scroll { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); }
.prov-scroll-wrap.can-left .prov-scroll { -webkit-mask-image: linear-gradient(to right, transparent, #000 56px); mask-image: linear-gradient(to right, transparent, #000 56px); }
.prov-scroll-wrap.can-left.can-right .prov-scroll { -webkit-mask-image: linear-gradient(to right, transparent, #000 56px, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(to right, transparent, #000 56px, #000 calc(100% - 56px), transparent); }
.prov-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); display: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.prov-arrow:hover { border-color: rgba(255,255,255,.25); }
.prov-arrow.prev { left: 0; }
.prov-arrow.next { right: 0; }
.prov-scroll-wrap.can-left .prov-arrow.prev, .prov-scroll-wrap.can-right .prov-arrow.next { display: flex; }
.prov-chip { padding: 8px 18px; border-radius: 24px; font-size: 13px; font-weight: 700; color: var(--text-muted); background: transparent; border: 1.5px solid var(--border); transition: all .18s; flex-shrink: 0; }
.prov-chip:hover { color: var(--text); border-color: rgba(255,255,255,.2); background: var(--surface-2); }
.prov-chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ════ Content ════ */
.content { max-width: 1480px; margin: 0 auto; padding: 8px 0 48px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 80px 24px; font-size: 15px; }

/* ════ Row Sections ════ */
.row-section { padding: 20px 0 8px; }
.row-header { display: flex; align-items: baseline; gap: 12px; padding: 0 24px 14px; }
.row-title { font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.row-provider { font-size: 12px; font-weight: 700; color: var(--accent); opacity: .8; }

/* ════ Carousel ════ */
.carousel { position: relative; }
.carousel-track { display: flex; gap: 12px; overflow-x: auto; scroll-behavior: smooth; padding: 4px 24px 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-arrow { position: absolute; top: 4px; bottom: 16px; width: 44px; z-index: 5; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 300; color: #fff; opacity: 0; transition: opacity .2s; }
.carousel-arrow.left { left: 0; background: linear-gradient(to right, rgba(10,11,20,.85), transparent); border-radius: 8px 0 0 8px; }
.carousel-arrow.right { right: 0; background: linear-gradient(to left, rgba(10,11,20,.85), transparent); border-radius: 0 8px 8px 0; }
.carousel:hover .carousel-arrow:not(.hidden) { opacity: 1; }
.carousel-arrow.hidden { pointer-events: none; opacity: 0 !important; }

/* ════ Cards ════ */
.card { flex-shrink: 0; width: 155px; display: flex; flex-direction: column; transition: transform .22s ease; }
.card:hover { transform: translateY(-6px) scale(1.04); }
.card-poster { position: relative; width: 100%; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.card-poster img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.card:hover .card-poster img { transform: scale(1.08); }
.card-poster.no-img { background: linear-gradient(135deg, var(--surface), var(--surface-2)); }
.card-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .22s; border-radius: var(--radius); }
.card:hover .card-overlay { opacity: 1; }
.card-title { display: block; padding: 8px 2px 4px; font-size: 12px; font-weight: 600; line-height: 1.35; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ════ Skeletons ════ */
.skel-bar, .card.skel .card-poster { background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { to { background-position: -200%; } }
.card.skel { pointer-events: none; }


/* ════ Modal ════ */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.7); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 440px; box-shadow: 0 24px 60px rgba(0,0,0,.5); animation: fadeIn .15s ease; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 800; }
.modal-close { font-size: 24px; color: var(--text-muted); line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.modal-input-row { display: flex; gap: 8px; }
.modal-input-row input { flex: 1; height: 42px; border: 1.5px solid var(--border); border-radius: 10px; padding: 0 14px; font-size: 14px; font-family: monospace; background: var(--bg); color: var(--text); outline: none; transition: border .2s; }
.modal-input-row input:focus { border-color: var(--accent); }
.modal-save-btn { height: 42px; padding: 0 20px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 800; transition: opacity .15s; }
.modal-save-btn:hover { opacity: .85; }
.modal-save-btn:disabled { opacity: .5; cursor: not-allowed; }
.modal-status { font-size: 12px; font-weight: 600; margin-top: 10px; min-height: 18px; }
.modal-status.ok { color: #22c55e; }
.modal-status.err { color: #ef4444; }
.modal-status.warn { color: #eab308; }
.modal-license-info { margin-top: 16px; background: var(--bg); border-radius: 10px; padding: 14px 16px; }
.license-info-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; }
.license-info-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.license-info-row span:first-child { color: var(--text-muted); font-weight: 600; }
.li-valid { color: #22c55e; font-weight: 700; }
.li-invalid { color: #ef4444; font-weight: 700; }

/* ════ License Gate ════ */
.license-gate { position: fixed; inset: 0; z-index: 150; background: rgba(10,11,20,.92); backdrop-filter: blur(20px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.license-gate-box { text-align: center; max-width: 420px; width: 100%; }
.license-gate-icon { color: var(--accent); margin-bottom: 20px; }
.license-gate-box h2 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.license-gate-box > p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; line-height: 1.5; }
.license-gate-input { display: flex; gap: 8px; margin-bottom: 12px; }
.license-gate-input input { flex: 1; height: 46px; border: 1.5px solid var(--border); border-radius: 10px; padding: 0 16px; font-size: 14px; font-family: monospace; background: var(--surface); color: var(--text); outline: none; text-align: center; letter-spacing: .5px; }
.license-gate-input input:focus { border-color: var(--accent); }
.license-gate-input button { height: 46px; padding: 0 24px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 800; flex-shrink: 0; transition: opacity .15s; }
.license-gate-input button:hover { opacity: .85; }
.license-gate-input button:disabled { opacity: .5; }
.license-gate-status { font-size: 12px; font-weight: 600; min-height: 18px; margin-bottom: 16px; }
.license-gate-status.err { color: #ef4444; }
.license-gate-back { display: inline-block; color: var(--text-muted); font-size: 13px; font-weight: 600; transition: color .15s; }
.license-gate-back:hover { color: var(--text); }

/* ════ Footer ════ */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 32px 24px; text-align: center; }
.footer-brand { font-size: 16px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.footer-muted { font-size: 12px; color: var(--text-muted); }

/* ══════════════════════════════════════════
   Player Page (watch.html)
   ══════════════════════════════════════════ */
.player-page { background: #0a0a0a; min-height: 100vh; }
.player-page .topbar { background: rgba(10,10,10,.97); border-color: #1a1a1a; }
.player-page .brand { color: #fff; }
.nav-title { color: #888; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 8px; }
.player-shell { max-width: 1400px; margin: 0 auto; display: grid; grid-template-columns: 200px 1fr 260px; min-height: calc(100vh - 61px); }
.episode-sidebar { background: #111; border-right: 1px solid #1a1a1a; overflow-y: auto; max-height: calc(100vh - 61px); scrollbar-width: thin; scrollbar-color: #333 transparent; }
.side-head { color: #fff; font-size: 14px; font-weight: 800; padding: 16px; border-bottom: 1px solid #1a1a1a; letter-spacing: .3px; }
.ep-list { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.ep-item { display: block; padding: 10px 14px; color: #777; font-size: 13px; font-weight: 700; border-radius: 8px; cursor: pointer; transition: all .15s; }
.ep-item:hover { background: #1a1a2e; color: #ccc; }
.ep-item.active { background: var(--accent); color: #fff; }
.stage-wrap { display: flex; justify-content: center; align-items: center; background: #000; min-height: calc(100vh - 61px); }
.stage { position: relative; width: 100%; max-width: calc((100vh - 61px) * 9 / 16); aspect-ratio: 9/16; background: #000; overflow: hidden; }
.stage video { width: 100%; height: 100%; object-fit: contain; }
.hud { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; opacity: 0; transition: opacity .3s; z-index: 5; pointer-events: none; }
.hud > * { pointer-events: auto; }
.stage:hover .hud, .hud.show { opacity: 1; }
.hud-top { padding: 14px 16px; color: #fff; font-size: 13px; font-weight: 700; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.hud-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); cursor: pointer; opacity: .85; transition: opacity .2s, transform .2s; filter: drop-shadow(0 2px 8px rgba(0,0,0,.5)); }
.hud-center:hover { opacity: 1; transform: translate(-50%,-50%) scale(1.1); }
.hud-center.hidden { display: none; }
.hud-bottom { padding: 10px 14px 14px; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.seek { width: 100%; height: 4px; -webkit-appearance: none; appearance: none; background: rgba(255,255,255,.2); border-radius: 2px; outline: none; cursor: pointer; margin-bottom: 8px; transition: height .15s; }
.seek:hover { height: 6px; }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; background: var(--accent); border-radius: 50%; cursor: pointer; box-shadow: 0 0 6px rgba(255,77,109,.4); }
.hud-controls { display: flex; justify-content: space-between; align-items: center; color: #fff; font-size: 11px; font-weight: 600; }
.hud-right { display: flex; gap: 6px; align-items: center; }
.hud-btn { background: rgba(255,255,255,.12); border: none; color: #fff; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 800; cursor: pointer; transition: background .15s; }
.hud-btn:hover { background: rgba(255,255,255,.25); }
.hud-btn.active { background: var(--accent); }
.hud-select { background: #1a1a1a; color: #fff; border: 1px solid #333; border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer; }
.info-sidebar { background: #111; border-left: 1px solid #1a1a1a; padding: 20px; overflow-y: auto; max-height: calc(100vh - 61px); }
.info-poster { width: 100%; border-radius: 12px; margin-bottom: 14px; aspect-ratio: 3/4; object-fit: cover; }
.info-title { color: #fff; font-size: 17px; font-weight: 800; margin-bottom: 8px; line-height: 1.3; }
.info-desc { color: #777; font-size: 12px; line-height: 1.6; }

/* ════ Responsive ════ */
@media (max-width: 1100px) {
    .player-shell { grid-template-columns: 180px 1fr; }
    .info-sidebar { display: none; }
    .card { width: 140px; }
}
@media (max-width: 768px) {
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
    .brand { order: 1; font-size: 18px; }
    .brand-icon { width: 28px; height: 28px; font-size: 12px; }
    .lang-wrap { order: 2; margin-left: auto; }
    .search-wrap { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
    .search-input { height: 38px; }
    .lang-select { height: 36px; font-size: 12px; }
    .provider-bar-inner { padding: 10px 16px; gap: 8px; }
    .prov-scroll { gap: 6px; }
    .prov-chip { padding: 6px 14px; font-size: 12px; }
    .prov-select { height: 32px; max-width: 132px; font-size: 12px; padding: 0 28px 0 12px; background-position: right 10px center; }
    .prov-arrow { display: none !important; }   /* touch: swipe the strip */
    .row-header { padding: 0 16px 12px; }
    .carousel-track { padding: 4px 16px 12px; gap: 10px; }
    .carousel-arrow { display: none; }
    .card { width: 120px; }
    .card-title { font-size: 11px; }
    .row-title { font-size: 16px; }
    .player-shell { grid-template-columns: 1fr; }
    .episode-sidebar { max-height: none; border-right: none; border-top: 1px solid #1a1a1a; order: 2; }
    .ep-list { flex-direction: row; overflow-x: auto; padding: 8px; -webkit-overflow-scrolling: touch; }
    .ep-list::-webkit-scrollbar { display: none; }
    .ep-item { white-space: nowrap; padding: 8px 12px; font-size: 12px; flex-shrink: 0; }
    .stage-wrap { min-height: 60vh; order: 1; }
    .stage { max-width: 100%; }
    .player-page .topbar-inner { flex-wrap: nowrap; gap: 8px; }
    .player-page .nav-title { display: none; }
    .player-page .lang-wrap { margin-left: auto; }
}
@media (max-width: 480px) {
    .topbar-inner { padding: 8px 12px; gap: 8px; }
    .brand { font-size: 16px; }
    .brand-icon { width: 26px; height: 26px; font-size: 11px; border-radius: 7px; }
    .search-input { height: 36px; font-size: 13px; padding-left: 36px; }
    .search-icon { left: 11px; width: 16px; height: 16px; }
    .provider-bar-inner { padding: 8px 12px; gap: 6px; }
    .prov-scroll { gap: 5px; }
    .prov-chip { padding: 5px 12px; font-size: 11px; }
    .prov-select { height: 30px; max-width: 112px; font-size: 11px; }
    .row-header { padding: 0 12px 10px; }
    .row-title { font-size: 14px; }
    .carousel-track { padding: 4px 12px 10px; gap: 8px; }
    .card { width: 110px; }
    .card-poster { border-radius: 8px; }
    .card-title { font-size: 11px; padding: 6px 1px 2px; }
    .card-overlay { display: none; }
    .content { padding: 4px 0 32px; }
    .site-footer { padding: 24px 12px; }
    .stage-wrap { min-height: 50vh; }
    .hud-controls { flex-wrap: wrap; gap: 6px; }
    .hud-btn { padding: 4px 8px; font-size: 10px; }
    .hud-select { font-size: 10px; padding: 3px 6px; }
    .side-head { padding: 12px; font-size: 13px; }
}

/* Video error overlay */
#video-error-overlay {
    position: absolute; inset: 0; z-index: 50;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,.85);
}
.video-error-box {
    text-align: center; max-width: 360px; padding: 32px;
}
.video-error-icon { font-size: 48px; margin-bottom: 12px; }
.video-error-title {
    font-size: 18px; font-weight: 600; color: #fff; margin-bottom: 8px;
}
.video-error-msg {
    font-size: 13px; color: #aaa; line-height: 1.5; margin-bottom: 20px;
}
.video-error-actions { display: flex; gap: 10px; justify-content: center; }
.ve-btn {
    padding: 8px 20px; border: none; border-radius: 6px;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .2s;
}
.ve-btn:hover { opacity: .85; }
.ve-retry { background: var(--accent); color: #fff; }
.ve-next { background: rgba(255,255,255,.15); color: #fff; }

/* Locked episodes */
.ep-item.locked { opacity: .5; }
.ep-item.locked:hover { opacity: .7; }
.ep-item.locked .lock-icon { margin-left: 2px; vertical-align: -1px; opacity: .7; }
.hud-btn svg { display: block; }

/* Subtitle position menu */
.sub-pos-wrap { position: relative; display: inline-flex; }
.sub-pos-menu { display: none; position: absolute; bottom: calc(100% + 8px); right: 0; background: rgba(20,20,20,.96); border: 1px solid #333; border-radius: 8px; padding: 6px; min-width: 150px; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.sub-pos-menu.open { display: block; }
.sub-pos-head { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #888; padding: 4px 8px 6px; }
.sub-pos-menu button { display: block; width: 100%; text-align: left; background: none; border: none; color: #ddd; font-size: 13px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.sub-pos-menu button:hover { background: rgba(255,255,255,.1); }
.sub-pos-menu button.active { color: #fff; background: var(--accent); }

/* AI subtitle progress chip */
.ai-sub-status { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 6; pointer-events: none; max-width: calc(100% - 32px); padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.72); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .25s; }
.ai-sub-status.show { opacity: 1; }
.ai-sub-status.ok { background: rgba(22,128,61,.85); }
.ai-sub-status.err { background: rgba(185,28,28,.85); }
.sub-pos-menu { min-width: 200px; }
.sub-pos-head:not(:first-child) { margin-top: 6px; border-top: 1px solid #2a2a2a; padding-top: 10px; }
.sub-opt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.sub-pos-menu .sub-opt-row button { text-align: center; padding: 7px 6px; font-size: 12px; }

/* Subtitle overlay (cues drawn by the page; see renderCues in player.js) */
.sub-overlay { position: absolute; z-index: 4; pointer-events: none; --sub-base: 16px; --sub-scale: 1; }
.sub-box { position: absolute; left: 5%; right: 5%; bottom: 7%; text-align: center; transition: bottom .2s, top .2s; }
.sub-line { display: inline; background: rgba(0,0,0,.72); color: #fff; font-size: calc(var(--sub-base) * var(--sub-scale)); font-weight: 500; line-height: 1.4; padding: .08em .35em; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; text-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: pre-line; overflow-wrap: anywhere; }
.sub-overlay[data-pos="raised"] .sub-box { bottom: 22%; }
.sub-overlay[data-pos="middle"] .sub-box { bottom: auto; top: 50%; transform: translateY(-50%); }
.sub-overlay[data-pos="top"] .sub-box { bottom: auto; top: 7%; }
/* Keep bottom subtitles clear of the control bar while it is visible */
.stage:hover .sub-overlay[data-pos="bottom"] .sub-box,
.hud.show ~ .sub-overlay[data-pos="bottom"] .sub-box { bottom: max(7%, 76px); }

/* Search results page (Enter in the search box) */
.search-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; padding: 20px 24px 16px; }
.search-count { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.search-clear-btn { margin-left: auto; background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 700; cursor: pointer; }
.search-clear-btn:hover { color: var(--text); border-color: rgba(255,255,255,.2); }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 16px; padding: 0 24px; }
.search-grid .card { width: auto; }
.search-all { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; border: none; border-top: 1px solid var(--border); background: transparent; color: var(--accent); font-size: 13px; font-weight: 700; cursor: pointer; }
.search-all:hover { background: var(--surface-2); }
.search-all kbd { font: 600 10px/1 inherit; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 3px 5px; }
@media (max-width: 768px) {
    .search-head { padding: 16px 16px 12px; }
    .search-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 16px 10px; padding: 0 16px; }
}
@media (max-width: 480px) {
    .search-head { padding: 14px 12px 10px; }
    .search-grid { grid-template-columns: repeat(3, 1fr); gap: 14px 8px; padding: 0 12px; }
}

/* ══════════════════════════════════════════
   Subscription edition: header actions, forms, pages
   ══════════════════════════════════════════ */
:root {
    --ok: #22c55e;
    --warn: #eab308;
    --err: #ef4444;
    --focus: #ffb3c1;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 300; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.skip-link:focus { top: 10px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 20px; border-radius: 10px; font-size: 14px; font-weight: 800; line-height: 1.2; text-align: center; border: 1.5px solid transparent; transition: opacity .15s, background .15s, border-color .15s, color .15s; cursor: pointer; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: rgba(255,255,255,.2); }
.btn-danger { background: transparent; color: #fca5a5; border-color: rgba(239,68,68,.45); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.12); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }
.link { color: var(--accent); font-weight: 700; }
.link:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }

/* ── Header actions (Pricing + Sign in / account menu) ── */
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-actions.push { margin-left: auto; }
.nav-link { font-size: 14px; font-weight: 700; color: var(--text-muted); padding: 8px 6px; border-radius: 8px; white-space: nowrap; transition: color .15s; }
.nav-link:hover, .nav-link.active { color: var(--text); }
.acct-menu { position: relative; }
.acct-btn { display: flex; align-items: center; gap: 4px; height: 40px; padding: 0 6px 0 4px; border-radius: 10px; color: var(--text-muted); transition: background .15s, color .15s; }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.acct-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); border: 1.5px solid var(--border); color: var(--text); font-size: 14px; font-weight: 800; text-transform: uppercase; }
.acct-dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.5); padding: 6px; z-index: 120; animation: fadeIn .15s ease; }
.acct-email { padding: 10px 12px 8px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-dropdown [role="menuitem"] { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text); }
.acct-dropdown [role="menuitem"]:hover, .acct-dropdown [role="menuitem"]:focus-visible { background: var(--surface-2); }
.player-page .lang-wrap { margin-left: auto; }
.player-page .nav-link { color: #888; }
.player-page .nav-link:hover { color: #fff; }

/* ── Footer links ── */
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 14px 0 10px; font-size: 13px; }
.footer-links a { color: var(--text-muted); font-weight: 600; }
.footer-links a:hover { color: var(--text); }

/* ── Page shell ── */
.page { max-width: 1040px; margin: 0 auto; padding: 36px 24px 64px; min-height: calc(100vh - 61px - 160px); }
.page-narrow { max-width: 460px; }
.page-mid { max-width: 760px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 28px; font-weight: 900; letter-spacing: -.5px; line-height: 1.2; }
.page-head p { color: var(--text-muted); font-size: 15px; margin-top: 8px; line-height: 1.55; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; margin-bottom: 18px; }
.panel h2 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 0; }
.notice { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; font-size: 14px; line-height: 1.55; margin-bottom: 18px; }
.notice.ok { border-color: rgba(34,197,94,.35); }
.notice.warn { border-color: rgba(234,179,8,.4); }
.notice.err { border-color: rgba(239,68,68,.45); }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }

/* ── Forms ── */
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.auth-card h1 { font-size: 24px; font-weight: 900; letter-spacing: -.4px; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; line-height: 1.5; }
.auth-alt { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: 18px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 7px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field-row a { font-size: 13px; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 15px; font-family: inherit; background: var(--bg); color: var(--text); outline: none; transition: border .2s; }
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--err); }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }
.field-error { font-size: 12px; font-weight: 600; color: #fca5a5; margin-top: 6px; }
.field-error:empty { display: none; }
.form-msg { display: none; font-size: 13px; font-weight: 600; line-height: 1.45; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.form-msg.show { display: block; }
.form-msg.err { color: #fecaca; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); }
.form-msg.ok { color: #bbf7d0; background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-fine { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 14px; }
.form-fine a { color: var(--text); text-decoration: underline; }

/* ── Badges & key/value rows ── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .2px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { color: #4ade80; border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.08); }
.badge-warn { color: #facc15; border-color: rgba(234,179,8,.35); background: rgba(234,179,8,.08); }
.badge-err { color: #f87171; border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.08); }
.badge-accent { color: #fff; background: var(--accent); border-color: var(--accent); }
.badge-accent::before { display: none; }
.kv { display: grid; grid-template-columns: minmax(110px, 180px) 1fr; gap: 0; font-size: 14px; }
.kv > dt, .kv > dd { padding: 10px 0; border-bottom: 1px solid var(--border); }
.kv > dt { color: var(--text-muted); font-weight: 600; }
.kv > dd { overflow-wrap: anywhere; }
.kv > dt:last-of-type, .kv > dd:last-of-type { border-bottom: none; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 180px; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table a { color: var(--accent); font-weight: 700; }
.table-empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ── Pricing ── */
.pricing-head { text-align: center; max-width: 620px; margin: 0 auto 30px; }
.pricing-head h1 { font-size: 34px; font-weight: 900; letter-spacing: -.8px; line-height: 1.15; }
.pricing-head p { color: var(--text-muted); font-size: 16px; margin-top: 10px; line-height: 1.55; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; max-width: 760px; margin: 0 auto; }
.plan-card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px; padding: 26px 22px 22px; }
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.plan-card .badge-accent { position: absolute; top: -12px; right: 18px; }
.plan-name { font-size: 15px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; }
.plan-price { margin-top: 10px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.plan-price strong { font-size: 40px; font-weight: 900; letter-spacing: -1px; }
.plan-price span { color: var(--text-muted); font-size: 14px; font-weight: 600; }
.plan-note { color: var(--text-muted); font-size: 13px; margin-top: 6px; min-height: 20px; }
.plan-note b { color: #4ade80; }
.plan-features { list-style: none; margin: 18px 0 22px; font-size: 14px; line-height: 1.5; flex: 1; }
.plan-features li { position: relative; padding-left: 24px; margin-bottom: 8px; }
.plan-features li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 10px; height: 6px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }
.plan-cta { min-height: 48px; }
.paypal-slot { min-height: 48px; }
.pricing-msg { max-width: 760px; margin: 0 auto 18px; }
.pricing-fine { max-width: 640px; margin: 26px auto 0; text-align: center; color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.pricing-fine a { color: var(--text); text-decoration: underline; }
.skel-block { border-radius: 12px; background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200%; animation: shimmer 1.5s infinite; }

/* ── Spinner ── */
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin .9s linear infinite; margin: 0 auto 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .skel-block { animation: none; } }

/* ── Dialog ── */
.dialog { margin: auto; width: calc(100% - 32px); max-width: 460px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 0; box-shadow: 0 24px 60px rgba(0,0,0,.6); }
.dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.dialog-body { padding: 22px; }
.dialog-body h2 { font-size: 18px; font-weight: 800; margin-bottom: 10px; }
.dialog-body p { color: var(--text-muted); font-size: 14px; line-height: 1.55; margin-bottom: 12px; }
.dialog-body p strong { color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ── Legal pages ── */
.legal { line-height: 1.7; font-size: 15px; color: #d4d5de; }
.legal h1 { font-size: 30px; font-weight: 900; letter-spacing: -.5px; color: var(--text); line-height: 1.2; }
.legal .updated { color: var(--text-muted); font-size: 13px; margin: 8px 0 28px; }
.legal h2 { font-size: 18px; font-weight: 800; color: var(--text); margin: 30px 0 10px; }
.legal p, .legal ul, .legal ol { margin-bottom: 14px; }
.legal ul, .legal ol { padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal a { color: var(--accent); font-weight: 600; }
.legal a:hover { text-decoration: underline; }
.legal strong { color: var(--text); }

/* ── Paywall (watch page; replaces the license gate) ── */
.license-gate[role="dialog"] { overflow-y: auto; }
.paywall-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 30px 24px 22px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.paywall-box h2 { font-size: 22px; font-weight: 900; margin-bottom: 10px; }
.paywall-box > p { color: var(--text-muted); font-size: 14px; line-height: 1.55; margin-bottom: 8px; }
.paywall-box .paywall-note { color: var(--text); font-weight: 600; margin-bottom: 22px; }
.gate-actions { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 14px; }
.paywall-fine { color: var(--text-muted); font-size: 12px; margin-bottom: 16px; }
.gate-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; }
.gate-links button, .gate-links a { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.gate-links button:hover, .gate-links a:hover { color: var(--text); }

/* ── Admin ── */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.admin-nav a { padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-muted); border: 1.5px solid var(--border); }
.admin-nav a:hover { color: var(--text); border-color: rgba(255,255,255,.2); }
.admin-nav a[aria-current="page"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; }
.stat .v { font-size: 26px; font-weight: 900; margin-top: 4px; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin-bottom: 0; flex: 1; min-width: 160px; }
.toolbar .field.shrink { flex: 0 1 200px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--text-muted); }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.action-grid .panel { margin-bottom: 0; }
.action-grid p { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin-bottom: 12px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 90px; }
pre.json { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 12px; overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-word; }
details.row-details summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: 12px; }

@media (max-width: 768px) {
    .topbar-actions { order: 2; gap: 6px; }
    .page { padding: 24px 16px 48px; }
    .page-head h1, .legal h1 { font-size: 24px; }
    .pricing-head h1 { font-size: 27px; }
    .panel { padding: 18px 16px; }
    .auth-card { padding: 24px 18px; }
    .kv { grid-template-columns: 1fr; }
    .kv > dt { border-bottom: none; padding-bottom: 0; }
    .kv > dd { padding-top: 4px; }
}
@media (max-width: 480px) {
    .nav-link { font-size: 13px; padding: 6px 4px; }
    .topbar-actions .btn-sm { min-height: 34px; padding: 0 12px; }
    .acct-btn svg { display: none; }
    .plan-price strong { font-size: 34px; }
    .page { padding: 20px 12px 40px; }
    .dialog-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 380px) {
    .brand { font-size: 15px; gap: 7px; }
    .lang-select { padding: 0 6px; }
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; margin: -4px 0 16px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.result-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 26px; font-weight: 900; }
.result-icon.ok { background: rgba(34,197,94,.12); color: #4ade80; }
.result-icon.err { background: rgba(239,68,68,.12); color: #f87171; }
.result-icon.wait { background: var(--surface-2); color: var(--text-muted); }
.plan-skel { min-height: 360px; }
.span-all { grid-column: 1 / -1; }
.spinner-inline { display: inline-block; width: 18px; height: 18px; border-width: 2px; margin: 0 8px 0 0; vertical-align: -3px; }
.mt { margin-top: 18px; }
.panel-text { color: var(--text-muted); font-size: 14px; line-height: 1.55; margin-bottom: 14px; }
.legal .mt0 { margin-top: 0; }
.dialog-wide { max-width: 760px; }
.subhead { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px; }
.toolbar .check { margin: 0 0 12px; }
