:root {
  --bg: #090a0c;
  --surface: #111317;
  --surface-2: #181b20;
  --surface-3: #22262d;
  --text: #f5f7f6;
  --muted: #9da4a3;
  --muted-2: #69706f;
  --accent: #d6ff3f;
  --accent-ink: #111408;
  --danger: #ff6b6b;
  --border: rgba(255,255,255,.1);
  --radius: 18px;
  --shadow: 0 24px 80px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100dvh; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 1000; padding: 12px 18px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; transition: top .2s ease; }
.skip-link:focus { top: 16px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.topbar { position: fixed; inset: 0 0 auto; z-index: 50; height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 5vw, 72px); border-bottom: 1px solid var(--border); background: rgba(9,10,12,.8); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-size: 18px; font-weight: 760; letter-spacing: -.04em; }
.brand > span:last-child > span { color: var(--accent); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid rgba(214,255,63,.3); border-radius: 11px; background: rgba(214,255,63,.1); color: var(--accent); }
.brand-mark svg { width: 19px; fill: currentColor; stroke: none; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.secure-pill { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 13px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 620; }
.secure-pill svg { width: 15px; }
.icon-button, .close-button { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; transition: background .2s ease, border-color .2s ease; }
.icon-button:hover, .close-button:hover { background: var(--surface-3); border-color: rgba(255,255,255,.2); }

.connect-view { position: relative; isolation: isolate; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 500px); align-items: center; gap: clamp(48px, 8vw, 128px); min-height: 100dvh; padding: 120px clamp(20px, 7vw, 112px) 56px; }
.connect-view::before { content: ""; position: absolute; inset: 76px 0 0; z-index: -3; opacity: .22; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 80px 80px; mask-image: linear-gradient(to right, #000, transparent 65%); }
.ambient { position: absolute; z-index: -2; border-radius: 50%; filter: blur(110px); pointer-events: none; }
.ambient-one { width: 440px; height: 440px; left: -160px; top: 22%; background: rgba(214,255,63,.1); }
.ambient-two { width: 330px; height: 330px; right: 10%; bottom: -160px; background: rgba(89,68,255,.11); }
.intro-copy { max-width: 680px; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin: 0 0 28px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow span { width: 30px; height: 1px; background: var(--accent); }
h1 { margin: 0; font-size: clamp(58px, 7vw, 108px); line-height: .9; letter-spacing: -.075em; font-weight: 720; }
h1 em { color: transparent; -webkit-text-stroke: 1px rgba(245,247,246,.68); font-style: normal; font-weight: 560; }
.intro-body { max-width: 570px; margin: 34px 0 28px; color: var(--muted); font-size: clamp(16px, 1.5vw, 19px); line-height: 1.72; }
.feature-row { display: flex; flex-wrap: wrap; gap: 12px 28px; color: #c6cccb; font-size: 13px; }
.feature-row span { display: inline-flex; align-items: center; gap: 8px; }
.feature-row svg { width: 16px; color: var(--accent); }

.connect-card { padding: clamp(24px, 4vw, 42px); border: 1px solid var(--border); border-radius: 24px; background: linear-gradient(145deg, rgba(25,28,33,.96), rgba(14,16,19,.96)); box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 32px; }
.step { display: grid; place-items: center; flex: 0 0 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; }
.card-heading h2 { margin: 0 0 5px; font-size: 21px; letter-spacing: -.025em; }
.card-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.source-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 22px; padding: 5px; border: 1px solid var(--border); border-radius: 12px; background: rgba(4,5,6,.45); }
.source-tab { min-height: 42px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; transition: background .2s ease, color .2s ease; }
.source-tab:hover { color: var(--text); }
.source-tab.active { background: var(--surface-3); color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.22); }
.field { margin-bottom: 19px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: block; }
.field > label { margin: 0 0 8px; color: #cdd2d1; font-size: 12px; font-weight: 650; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: 14px; width: 18px; color: var(--muted-2); pointer-events: none; }
input { width: 100%; min-height: 50px; padding: 0 45px; border: 1px solid var(--border); border-radius: 12px; background: rgba(4,5,6,.55); color: var(--text); font-size: 14px; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease; }
input::placeholder { color: #5e6564; }
input:hover { border-color: rgba(255,255,255,.2); }
input:focus { border-color: rgba(214,255,63,.7); outline: none; box-shadow: 0 0 0 3px rgba(214,255,63,.1); background: #0a0c0e; }
.field small { display: block; margin-top: 7px; color: var(--muted-2); font-size: 11px; line-height: 1.4; }
.password-toggle { position: absolute; right: 4px; display: grid; place-items: center; width: 42px; height: 42px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.password-toggle svg { width: 18px; }
.form-error { min-height: 20px; margin: -5px 0 9px; color: #ff8989; font-size: 12px; line-height: 1.5; }
.primary-button, .demo-button { width: 100%; min-height: 52px; border-radius: 12px; cursor: pointer; font-weight: 760; transition: background .2s ease, transform .15s ease, opacity .2s ease; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; background: var(--accent); color: var(--accent-ink); }
.primary-button svg { width: 18px; transition: transform .2s ease; }
.primary-button:hover svg { transform: translateX(3px); }
.primary-button:active, .demo-button:active { transform: scale(.985); }
.primary-button:disabled { cursor: wait; opacity: .55; }
.primary-button.loading svg { animation: spin .8s linear infinite; }
.demo-button { margin-top: 10px; border: 1px solid var(--border); background: transparent; color: #cbd0cf; }
.demo-button:hover { background: rgba(255,255,255,.04); }
.privacy-note { display: flex; align-items: flex-start; justify-content: center; gap: 7px; margin: 22px 0 0; color: var(--muted-2); font-size: 10px; line-height: 1.5; text-align: center; }
.privacy-note svg { flex: 0 0 auto; width: 14px; }

.app-view { min-height: 100dvh; padding-top: 76px; }
.sidebar { position: fixed; inset: 76px auto 0 0; z-index: 30; display: flex; flex-direction: column; justify-content: space-between; width: 230px; padding: 28px 18px 24px; border-right: 1px solid var(--border); background: #0c0e10; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 48px; padding: 0 14px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; text-align: left; font-size: 14px; font-weight: 600; transition: background .2s ease, color .2s ease; }
.nav-item svg { width: 20px; }
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active { background: rgba(214,255,63,.1); color: var(--accent); }
.profile-card { display: flex; align-items: center; gap: 11px; padding: 13px; border-top: 1px solid var(--border); }
.profile-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-3); color: var(--accent); font-size: 11px; font-weight: 800; }
.profile-card strong, .profile-card span { display: block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card strong { font-size: 12px; }
.profile-card span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.catalog-shell { margin-left: 230px; padding: 42px clamp(22px, 4vw, 64px) 80px; }
.catalog-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.breadcrumb { margin: 0 0 8px; color: var(--muted-2); font-size: 10px; font-weight: 750; letter-spacing: .15em; }
.breadcrumb span { color: var(--accent); }
.catalog-topbar h2 { margin: 0; font-size: clamp(30px, 4vw, 48px); letter-spacing: -.05em; }
.search-box { position: relative; width: min(100%, 340px); }
.search-box svg { position: absolute; top: 14px; left: 14px; width: 18px; color: var(--muted); }
.search-box input { min-height: 48px; padding-left: 44px; }
.category-strip { display: flex; gap: 8px; margin: 34px 0 22px; overflow-x: auto; scrollbar-width: none; }
.category-strip::-webkit-scrollbar { display: none; }
.category-chip { flex: 0 0 auto; min-height: 40px; padding: 0 17px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 650; transition: all .2s ease; }
.category-chip:hover { border-color: rgba(255,255,255,.25); color: var(--text); }
.category-chip.active { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.content-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.content-meta p { margin: 0; color: var(--muted); font-size: 12px; }
.content-meta span { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
.media-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); cursor: pointer; transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease; }
.media-card:hover { transform: translateY(-4px); border-color: rgba(214,255,63,.45); box-shadow: 0 16px 34px rgba(0,0,0,.3); }
.poster { position: relative; aspect-ratio: 16/10; overflow: hidden; background: linear-gradient(135deg, #252b2c, #111315); }
.media-card[data-kind="vod"] .poster, .media-card[data-kind="series"] .poster { aspect-ratio: 2/3; }
.poster img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.media-card:hover .poster img { transform: scale(1.035); }
.poster::after { content: ""; position: absolute; inset: auto 0 0; height: 50%; background: linear-gradient(transparent, rgba(0,0,0,.65)); pointer-events: none; }
.poster-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.16); }
.poster-fallback svg { width: 45px; height: 45px; }
.play-badge { position: absolute; z-index: 2; right: 10px; bottom: 10px; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); box-shadow: 0 5px 18px rgba(0,0,0,.3); }
.play-badge svg { width: 15px; fill: currentColor; stroke: none; margin-left: 2px; }
.favorite-button { position: absolute; z-index: 3; top: 9px; right: 9px; display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; background: rgba(8,9,10,.7); color: #fff; cursor: pointer; backdrop-filter: blur(8px); opacity: 0; transition: opacity .2s ease, color .2s ease; }
.media-card:hover .favorite-button, .favorite-button.active, .favorite-button:focus-visible { opacity: 1; }
.favorite-button.active { color: var(--accent); }
.favorite-button.active svg { fill: currentColor; }
.card-copy { padding: 13px 13px 14px; }
.card-copy h3 { margin: 0; overflow: hidden; color: #eef0ef; font-size: 13px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.card-copy p { margin: 6px 0 0; color: var(--muted-2); font-size: 10px; }
.skeleton { min-height: 220px; border-radius: 15px; background: linear-gradient(90deg, var(--surface) 20%, var(--surface-2) 40%, var(--surface) 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.empty-state { grid-column: 1/-1; display: grid; place-items: center; min-height: 340px; padding: 32px; border: 1px dashed var(--border); border-radius: 18px; color: var(--muted); text-align: center; }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 13px; color: var(--muted-2); }
.empty-state h3 { margin: 0 0 8px; color: var(--text); }
.empty-state p { max-width: 420px; margin: 0; font-size: 13px; line-height: 1.6; }

.player-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.82); backdrop-filter: blur(14px); }
.player-panel { position: relative; width: min(100%, 1050px); overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: #0c0e10; box-shadow: var(--shadow); }
.close-button { position: absolute; top: 14px; right: 14px; z-index: 5; background: rgba(0,0,0,.6); }
.video-wrap { aspect-ratio: 16/9; background: #000; }
.video-wrap video { display: block; width: 100%; height: 100%; }
.episode-panel { min-height: 300px; max-height: 62vh; padding: 28px 24px; overflow-y: auto; }
.episode-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.episode-heading h3 { margin: 0; font-size: 18px; }
.episode-heading span { color: var(--muted); font-size: 11px; }
.episode-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.episode-button { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); cursor: pointer; text-align: left; transition: border-color .2s ease, background .2s ease; }
.episode-button:hover { border-color: rgba(214,255,63,.5); background: var(--surface-2); }
.episode-number { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border-radius: 8px; background: rgba(214,255,63,.1); color: var(--accent); font-size: 11px; font-weight: 800; }
.episode-button strong, .episode-button small { display: block; }
.episode-button strong { max-width: 130px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.episode-button small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.player-info { display: flex; align-items: center; gap: 13px; padding: 20px 24px 8px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff4d4d; box-shadow: 0 0 0 5px rgba(255,77,77,.12); }
.player-info p { margin: 0 0 3px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.player-info h2 { margin: 0; font-size: 18px; }
.player-message { min-height: 18px; margin: 0; padding: 0 24px 20px 46px; color: var(--muted); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 200; max-width: min(360px, calc(100vw - 32px)); padding: 14px 17px; border: 1px solid var(--border); border-radius: 12px; background: #20242a; color: var(--text); box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .connect-view { grid-template-columns: 1fr; max-width: 680px; margin: 0 auto; padding-top: 120px; }
  .intro-copy { text-align: center; }
  .eyebrow, .feature-row { justify-content: center; }
  .intro-body { margin-inline: auto; }
  .sidebar { inset: auto 0 0; width: 100%; height: 68px; padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border: 1px solid var(--border); background: rgba(12,14,16,.96); backdrop-filter: blur(16px); }
  .sidebar nav { grid-template-columns: repeat(4, 1fr); }
  .sidebar nav.m3u-mode { grid-template-columns: repeat(2, 1fr); }
  .nav-item { flex-direction: column; justify-content: center; gap: 3px; min-height: 51px; padding: 2px 4px; font-size: 9px; }
  .nav-item svg { width: 19px; }
  .profile-card { display: none; }
  .catalog-shell { margin-left: 0; padding-bottom: 100px; }
}

@media (max-width: 620px) {
  .topbar { height: 66px; padding-inline: 16px; }
  .secure-pill { font-size: 0; padding: 0; width: 38px; justify-content: center; }
  .connect-view { padding: 102px 16px 40px; gap: 38px; }
  h1 { font-size: clamp(50px, 17vw, 74px); }
  .intro-body { margin-block: 25px 22px; font-size: 16px; }
  .connect-card { padding: 22px 18px; border-radius: 18px; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .app-view { padding-top: 66px; }
  .catalog-shell { padding: 28px 16px 96px; }
  .catalog-topbar { align-items: stretch; flex-direction: column; gap: 20px; }
  .search-box { width: 100%; }
  .category-strip { margin-top: 24px; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .media-card:hover { transform: none; }
  .favorite-button { opacity: 1; }
  .player-modal { padding: 0; }
  .player-panel { width: 100%; border-radius: 0; }
  .episode-list { grid-template-columns: 1fr; }
}

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