:root {
    --bg: #0a0c10;
    --surface: #12151c;
    --surface-2: #191d26;
    --surface-3: #232936;
    --accent: #ff304f;
    --accent-2: #ff6a45;
    --text: #fff;
    --muted: #9da5b4;
    --line: rgba(255,255,255,.08);
    --page-x: clamp(16px, 4vw, 72px);
    --topbar: 70px;
    --radius: 12px;
    --shadow: 0 20px 55px rgba(0,0,0,.48);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: dark; background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); overflow-x: hidden; }
body.modal-open { overflow: hidden; }
button, input, a { font: inherit; }
button { border: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(255,48,79,.55);
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 900; letter-spacing: -.035em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 24px rgba(255,48,79,.22); }
.brand--login { font-size: 2rem; }
.brand--login .brand-mark { width: 52px; height: 52px; border-radius: 15px; }

.eyebrow { color: #ff7589; font-size: .72rem; font-weight: 850; letter-spacing: .14em; }
.muted { color: var(--muted); }
.alert { margin: 18px 0; padding: 12px 14px; color: #fff; background: rgba(255,65,91,.13); border: 1px solid rgba(255,65,91,.32); border-radius: 9px; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 18px; border-radius: 9px; color: #fff; font-weight: 780; cursor: pointer; transition: transform .15s ease, background .15s ease, opacity .15s ease; }
.button:active { transform: scale(.98); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button--primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.button--light { background: #fff; color: #090a0d; }
.button--glass { background: rgba(28,32,41,.68); border: 1px solid rgba(255,255,255,.13); backdrop-filter: blur(12px); }
.button--ghost { background: var(--surface-2); }
.button--full { width: 100%; }

.login-shell, .not-found { min-height: 100svh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 17% 8%, rgba(255,48,79,.16), transparent 30%), linear-gradient(160deg, #121620, #08090c 70%); }
.login-panel { width: min(100%, 450px); padding: clamp(28px, 5vw, 50px); border-radius: 18px; background: rgba(10,12,16,.88); border: 1px solid rgba(255,255,255,.08); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.login-panel h1 { margin: 10px 0 5px; font-size: clamp(2rem, 7vw, 3.1rem); letter-spacing: -.05em; }
.login-form { display: grid; gap: 12px; margin-top: 22px; }
.login-form label { display: grid; gap: 7px; color: #e8e8e8; font-size: .9rem; font-weight: 700; }
.login-form input { min-height: 52px; padding: 0 14px; color: #fff; background: #151821; border: 1px solid #343947; border-radius: 9px; outline: 0; }

.topbar { position: fixed; inset: 0 0 auto; z-index: 1000; min-height: var(--topbar); display: flex; align-items: center; gap: clamp(14px, 3vw, 34px); padding: max(10px, env(safe-area-inset-top)) var(--page-x) 10px; background: linear-gradient(180deg, rgba(4,5,7,.88), rgba(4,5,7,.35), transparent); transition: background .2s ease, backdrop-filter .2s ease; }
.topbar.is-solid { background: rgba(10,12,16,.95); backdrop-filter: blur(15px); border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; gap: clamp(10px, 1.8vw, 24px); }
.nav a { color: #bec4cf; font-size: .92rem; white-space: nowrap; }
.nav a:hover, .nav a.is-active { color: #fff; font-weight: 750; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.search-box { width: clamp(42px, 20vw, 260px); min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: rgba(8,9,12,.62); border: 1px solid rgba(255,255,255,.24); border-radius: 9px; }
.search-box input { width: 100%; min-width: 0; color: #fff; background: transparent; border: 0; outline: 0; }
.account-menu { position: relative; }
.account-menu summary { list-style: none; cursor: pointer; }
.account-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--line); font-weight: 850; }
.account-popover { position: absolute; right: 0; top: 48px; width: 220px; display: grid; gap: 8px; padding: 16px; border-radius: 12px; background: rgba(18,21,28,.98); border: 1px solid var(--line); box-shadow: var(--shadow); }
.account-popover small { color: var(--muted); }

.hero { position: relative; min-height: clamp(500px, 72svh, 920px); display: flex; align-items: flex-end; overflow: clip; background: linear-gradient(135deg, #1b202b, #08090c 70%); }
.hero-image { position: absolute; inset: 0; background-position: center 30%; background-size: cover; transform: scale(1.01); }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,12,16,.97) 0%, rgba(10,12,16,.74) 34%, rgba(10,12,16,.16) 68%), linear-gradient(0deg, var(--bg) 0%, rgba(10,12,16,.84) 9%, transparent 44%); }
.hero-content { position: relative; z-index: 2; width: min(760px, 88vw); padding: 0 var(--page-x) clamp(78px, 10vw, 140px); }
.hero h1 { margin: 10px 0; max-width: 14ch; font-size: clamp(2.6rem, 7vw, 6.6rem); line-height: .94; letter-spacing: -.055em; text-wrap: balance; }
.meta-line { display: flex; flex-wrap: wrap; gap: 9px; color: #cbd0d9; font-size: .92rem; font-weight: 650; }
.hero-description { max-width: 62ch; color: #dfe2e7; line-height: 1.55; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.hero-actions { display: flex; gap: 10px; margin-top: 20px; }

.catalog, .search-results { position: relative; z-index: 5; margin-top: clamp(-72px, -7vw, -44px); padding-bottom: 70px; }
.row-section { margin-bottom: clamp(22px, 3vw, 42px); }
.row-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 0 var(--page-x); margin-bottom: 9px; }
.row-title { margin: 0; font-size: clamp(1.05rem, 2vw, 1.5rem); letter-spacing: -.025em; }
.row-count { color: var(--muted); font-size: .82rem; }
.media-row { display: grid; grid-auto-flow: column; grid-auto-columns: clamp(160px, 18vw, 315px); gap: clamp(7px, .9vw, 12px); padding: 9px var(--page-x) 28px; overflow-x: auto; overflow-y: visible; scroll-padding-inline: var(--page-x); scroll-snap-type: x proximity; scrollbar-width: none; }
.media-row::-webkit-scrollbar { display: none; }

.media-card { position: relative; min-width: 0; border-radius: var(--radius); background: var(--surface); cursor: pointer; scroll-snap-align: start; transform-origin: center; transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease; }
.media-card__image { position: relative; aspect-ratio: 16/9; overflow: hidden; border-radius: var(--radius); background: linear-gradient(135deg, #272d38, #151820); }
.media-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.media-card__fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; color: #bbc1ca; text-align: center; font-weight: 800; }
.media-card__favorite { position: absolute; z-index: 3; right: 8px; top: 8px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(5,6,8,.68); border: 1px solid rgba(255,255,255,.16); cursor: pointer; backdrop-filter: blur(8px); }
.media-card__favorite.is-active { background: var(--accent); }
.media-card__body { padding: 10px 10px 12px; }
.media-card__title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.media-card__meta { margin-top: 5px; color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (hover:hover) and (pointer:fine) {
    .media-card:hover { z-index: 20; transform: scale(1.065) translateY(-2px); box-shadow: var(--shadow); }
}

.loading, .empty { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 12px; padding: 30px var(--page-x); color: var(--muted); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #303541; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.player-modal, .install-help { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: clamp(0px, 2vw, 24px); }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,3,5,.86); backdrop-filter: blur(8px); }
.player-panel { position: relative; z-index: 1; width: min(1180px, 100%); max-height: 95svh; overflow: auto; border-radius: 16px; background: #0b0d11; border: 1px solid var(--line); box-shadow: var(--shadow); }
.player-header { position: sticky; top: 0; z-index: 5; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 17px; background: rgba(11,13,17,.95); backdrop-filter: blur(12px); }
.player-header h2 { margin: 3px 0 0; font-size: clamp(1.1rem, 2vw, 1.55rem); }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: #252a35; color: #fff; font-size: 1.6rem; cursor: pointer; }
.video-stage { position: relative; aspect-ratio: 16/9; background: #000; }
.video-stage video { width: 100%; height: 100%; display: block; background: #000; }
.player-status { position: absolute; inset: auto 15px 15px; padding: 11px 13px; border-radius: 9px; background: rgba(10,12,16,.88); border: 1px solid var(--line); }
.player-info { padding: 18px; }
.player-info__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.episodes { display: grid; gap: 8px; margin-top: 18px; }
.episode { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px; color: #fff; background: var(--surface); border-radius: 9px; cursor: pointer; text-align: left; }
.episode:hover { background: var(--surface-2); }

.install-help__panel { position: relative; z-index: 1; width: min(500px, calc(100% - 28px)); padding: 28px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.install-help__close { position: absolute; right: 12px; top: 12px; }
.install-help__panel h2 { margin: 24px 0 8px; }

.toast { position: fixed; z-index: 3000; right: max(17px, env(safe-area-inset-right)); bottom: max(17px, env(safe-area-inset-bottom)); width: min(420px, calc(100vw - 34px)); padding: 12px 14px; border-radius: 10px; background: #242936; border: 1px solid var(--line); box-shadow: var(--shadow); }
.not-found { text-align: center; }
.not-found h1 { margin: 22px 0 0; font-size: clamp(5rem, 20vw, 12rem); line-height: .9; }

@media (max-width: 900px) {
    :root { --topbar: 60px; }
    .nav { position: fixed; inset: auto 0 0; z-index: 1100; height: calc(60px + env(safe-area-inset-bottom)); justify-content: space-around; padding: 0 6px env(safe-area-inset-bottom); background: rgba(10,12,16,.97); border-top: 1px solid var(--line); }
    .nav a { min-width: 58px; min-height: 50px; display: grid; place-items: center; font-size: .73rem; }
    .topbar .brand > span:last-child { display: none; }
    .search-box { width: min(42vw, 210px); }
    #installButton { display: none !important; }
    .hero { min-height: 68svh; }
    .hero-content { width: 100%; padding-bottom: 90px; }
    .catalog, .search-results { padding-bottom: 90px; }
    .media-row { grid-auto-columns: clamp(155px, 42vw, 240px); }
}

@media (max-width: 520px) {
    .search-box { width: 42px; transition: width .18s ease; }
    .search-box input { opacity: 0; pointer-events: none; }
    .search-box:focus-within { position: absolute; right: 58px; width: calc(100vw - 126px); background: #11141a; }
    .search-box:focus-within input { opacity: 1; pointer-events: auto; }
    .hero h1 { font-size: clamp(2.35rem, 12vw, 4rem); }
    .hero-description { -webkit-line-clamp: 2; }
    .hero-actions .button { flex: 1; padding-inline: 9px; }
    .player-modal { padding: 0; }
    .player-panel { min-height: 100svh; max-height: 100svh; border-radius: 0; }
    .episode { grid-template-columns: auto 1fr; }
}

@media (min-width: 1800px) {
    :root { --page-x: clamp(72px, 4vw, 120px); }
    .media-row { grid-auto-columns: clamp(280px, 15vw, 420px); }
}

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