:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #090c12;
  color: #f3f0e9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --red: #d8b16e;
  --muted: #a0a5af;
  --panel: #171b24;
  --line: #2a303c;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #090c12; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; gap: 34px; min-height: 72px; padding: 0 4.2vw; background: linear-gradient(180deg, #090c12f5, #090c12e8); border-bottom: 1px solid #ffffff0b; backdrop-filter: blur(14px); }
.brand { display: inline-flex; gap: 1px; align-items: center; color: white; font-size: 23px; font-weight: 900; letter-spacing: -.8px; text-decoration: none; }
.brand strong { color: var(--red); }
.main-nav { display: flex; align-items: center; gap: 23px; flex: 1; }
.nav-link, .icon-button { border: 0; background: transparent; color: #c4c4ca; cursor: pointer; }
.nav-link { padding: 26px 0 23px; font-size: 14px; border-bottom: 2px solid transparent; }
.nav-link:hover, .nav-link.active { color: white; }
.nav-link.active { border-color: var(--red); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.icon-button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.icon-button:hover { border-color: #777; }
.hidden { display: none !important; }
.hero { position: relative; display: flex; align-items: flex-end; min-height: min(69vh, 640px); padding: 5vw 6vw 62px; overflow: hidden; background: #171b24; background-image: var(--hero-image); background-position: center 32%; background-size: cover; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(90deg, #090c12f2 0%, #090c12b8 44%, #090c1219 100%), linear-gradient(0deg, #090c12 0%, transparent 58%); }
.hero-content { position: relative; max-width: 580px; }
.eyebrow { color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: 1.7px; }
.hero h1 { margin: 15px 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(36px, 5vw, 66px); line-height: 1.03; letter-spacing: -1.2px; }
.hero p { display: -webkit-box; max-width: 530px; overflow: hidden; color: #d3d3d8; font-size: 16px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 24px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 12px; cursor: pointer; font-weight: 700; text-decoration: none; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--red); color: #17130b; }
.button-primary:hover { background: #e5c183; }
.button-quiet, .button-secondary { border-color: #ffffff33; background: #ffffff16; color: white; }
.button-quiet:hover, .button-secondary:hover { background: #ffffff27; }
.shelf { padding: 10px 4.2vw 24px; }
.shelf-heading { display: flex; align-items: center; justify-content: space-between; }
.shelf h2, .shelf-heading h2 { margin: 12px 0 14px; font-size: 21px; }
.movie-row { display: flex; gap: 15px; overflow-x: auto; padding: 3px 1px 14px; scrollbar-color: #424249 transparent; }
.movie-card { flex: 0 0 clamp(130px, 14vw, 192px); min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.poster-wrap { position: relative; display: block; overflow: hidden; aspect-ratio: 2/3; border-radius: 12px; background: #171b24; }
.poster-wrap img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.movie-card:hover .poster-wrap img { transform: scale(1.05); }
.poster-placeholder { display: grid; width: 100%; height: 100%; place-items: center; color: #555; font-size: 50px; font-weight: 900; }
.rating { position: absolute; right: 7px; bottom: 7px; padding: 4px 7px; border-radius: 8px; background: #090c12cc; font-size: 12px; }
.rating::first-letter { color: var(--red); }
.movie-title { display: block; overflow: hidden; margin-top: 9px; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.movie-year { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.home-shortcuts { display: flex; flex-wrap: wrap; gap: 12px; padding: 14px 4.2vw 50px; }
.shortcut { display: flex; align-items: center; gap: 12px; min-width: 170px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 20px; cursor: pointer; }
.shortcut span { font-size: 14px; font-weight: 700; }
.page-shell { max-width: 1500px; min-height: calc(100vh - 72px); margin: 0 auto; padding: 44px 4.2vw 80px; }
.narrow-shell { max-width: 900px; }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 7px 0; font-size: clamp(30px, 4vw, 44px); letter-spacing: -1px; }
.page-heading p, .muted, .fine-print { color: var(--muted); }
.search-form { display: flex; gap: 10px; max-width: 740px; margin-bottom: 28px; }
.search-form input, .channel-heading input, .source-field input, .stack-form input { width: 100%; min-width: 0; padding: 12px 14px; border: 1px solid #3a3a43; border-radius: 6px; background: #16161b; color: white; }
.search-form input:focus, .channel-heading input:focus, .source-field input:focus, .stack-form input:focus { border-color: #999; outline: none; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 25px 16px; }
.genre-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 13px; }
.genre-tile { display: flex; align-items: center; justify-content: space-between; min-height: 73px; padding: 0 18px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(120deg, #202633, #171b24); font-size: 17px; font-weight: 700; text-align: left; cursor: pointer; }
.genre-tile:hover { border-color: #777; background: #25252c; }
.genre-tile span { color: var(--red); font-size: 24px; }
.history-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 14px 0 32px; }
.chip { padding: 7px 11px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); cursor: pointer; }
.empty-state, .error-panel { padding: 35px 20px; border: 1px solid var(--line); border-radius: 12px; background: #11151e; text-align: center; }
.empty-state h2, .error-panel h2 { margin-top: 0; }
.error-text { color: #ff8e93; }
.loading-state { display: flex; min-height: 300px; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.loading-state.compact { min-height: 130px; }
.spinner { width: 30px; height: 30px; border: 3px solid #ffffff30; border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; overflow: auto; place-items: center; padding: 25px; background: #000c; }
.detail-modal, .player-modal { position: relative; width: min(920px, 100%); max-height: min(92vh, 1000px); overflow: auto; border: 1px solid #ffffff1a; border-radius: 16px; background: #11151d; box-shadow: 0 24px 80px #000b; }
.detail-hero { height: 290px; background: linear-gradient(0deg, #11151d, #11151d00 65%), var(--detail-image) center 30%/cover, #222; }
.detail-body { padding: 0 30px 32px; }
.detail-body h1 { margin: 10px 0; font-size: 38px; }
.detail-body > p { max-width: 780px; color: #d0d0d4; line-height: 1.65; }
.detail-body h2 { margin-top: 35px; }
.modal-close { position: absolute; z-index: 2; top: 12px; right: 13px; display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 50%; background: #090c12d9; font-size: 26px; cursor: pointer; }
.source-field { display: block; max-width: 650px; margin-top: 26px; color: var(--muted); font-size: 13px; }
.source-field div { display: flex; gap: 8px; margin-top: 8px; }
.player-modal { width: min(1050px, 100%); padding: 14px; }
.player-heading { display: flex; align-items: center; justify-content: space-between; min-height: 35px; padding: 0 46px 8px 5px; }
.player-heading .modal-close { top: 9px; right: 10px; }
.player-modal video { display: block; width: 100%; max-height: 72vh; aspect-ratio: 16/9; background: black; }
.player-note { margin: 9px 4px 1px; font-size: 12px; }
.iptv-layout { display: grid; grid-template-columns: minmax(270px, .75fr) minmax(400px, 1.25fr); gap: 18px; align-items: start; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.panel h2 { margin: 0 0 18px; font-size: 19px; }
.stack-form { display: grid; gap: 14px; }
.stack-form label, .source-field { display: grid; gap: 7px; }
.stack-form label { color: #d5d5da; font-size: 13px; }
.separator { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.separator::before, .separator::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.file-picker { display: flex; min-height: 42px; align-items: center; justify-content: center; border: 1px dashed #555; border-radius: 6px; cursor: pointer; }
.file-picker input { display: none; }
.fine-print { font-size: 12px; line-height: 1.55; }
.channel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.channel-heading h2 { margin: 0 0 4px; }
.channel-heading input { max-width: 270px; }
.channel-row { display: flex; width: 100%; align-items: center; gap: 12px; padding: 9px 5px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.channel-row:hover { background: #ffffff0a; }
.channel-logo { display: grid; width: 44px; height: 44px; flex: 0 0 44px; overflow: hidden; place-items: center; border-radius: 6px; background: #24242b; color: #d4d4d8; font-size: 11px; font-weight: 800; }
.channel-logo img { width: 100%; height: 100%; object-fit: contain; }
.channel-copy { display: grid; min-width: 0; gap: 4px; }
.channel-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-copy small { color: var(--muted); }
.channel-play { margin-left: auto; color: var(--red); }
.profile-button { display: flex; width: 100%; justify-content: space-between; margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: #101014; cursor: pointer; }
.profile-button span { color: var(--muted); }
.settings-group { margin: 14px 0; }
.settings-group p { line-height: 1.6; }
.select-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.select-row select { min-width: 160px; padding: 9px; border: 1px solid var(--line); border-radius: 5px; background: #101014; color: white; }
.check-row { display: flex !important; align-items: center; gap: 9px !important; }
.check-row input { width: auto !important; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.archive-card { display: grid; grid-template-columns: 90px 1fr; gap: 13px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.archive-card img { width: 90px; aspect-ratio: 2/3; border-radius: 4px; object-fit: cover; background: #222; }
.archive-card h3 { margin: 0; font-size: 14px; }
.archive-card p { color: var(--muted); font-size: 12px; }
#toast { position: fixed; z-index: 80; right: 22px; bottom: 20px; max-width: min(440px, calc(100vw - 40px)); padding: 12px 16px; transform: translateY(20px); border: 1px solid #ffffff24; border-radius: 8px; background: #24242b; color: white; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.visible { transform: translateY(0); opacity: 1; }

@media (max-width: 760px) {
  .topbar { min-height: 62px; flex-wrap: wrap; gap: 12px; padding: 0 16px; }
  .brand { font-size: 20px; }
  .main-nav { order: 3; width: 100%; gap: 20px; overflow-x: auto; }
  .nav-link { padding: 8px 0 12px; white-space: nowrap; }
  .top-actions { margin-left: auto; }
  .hero { min-height: 510px; padding: 40px 22px; background-position: 58% center; }
  .hero-shade { background: linear-gradient(0deg, #090c12 0%, #090c12d9 37%, #090c1225 100%); }
  .hero-content { margin-top: auto; }
  .hero h1 { font-size: 42px; }
  .hero p { font-size: 14px; }
  .shelf { padding: 8px 17px 18px; }
  .shelf h2, .shelf-heading h2 { font-size: 18px; }
  .movie-card { flex-basis: 132px; }
  .page-shell { padding: 30px 17px 60px; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 19px 12px; }
  .iptv-layout { grid-template-columns: 1fr; }
  .channel-heading { align-items: stretch; flex-direction: column; }
  .channel-heading input { max-width: none; }
  .detail-body { padding: 0 18px 25px; }
  .detail-hero { height: 220px; }
  .detail-body h1 { font-size: 29px; }
  .source-field div { flex-direction: column; }
  .modal-backdrop { padding: 10px; }
}

.nav-icon { display: none; width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.top-actions .icon-button { border-radius: 12px; }
.search-form input, .channel-heading input, .source-field input, .stack-form input,
.select-row select {
  border-color: #343b49;
  border-radius: 12px;
  background: #11151d;
  color: #f3f0e9;
}
.search-form input:focus, .channel-heading input:focus, .source-field input:focus, .stack-form input:focus,
.select-row select:focus { border-color: var(--red); outline: none; }
.panel { border-color: #252c39; border-radius: 16px; background: #11151d; }
.shortcut { border-color: #2a303c; border-radius: 14px; background: #171b24; }
.channel-row { border-radius: 10px; }
.channel-row:hover { background: #ffffff0c; }
.channel-logo { border-radius: 10px; background: #202633; }
.profile-button { border-radius: 10px; background: #11151d; }
.chip { border-radius: 20px; }
#toast { border-color: #3a3f49; border-radius: 12px; background: #171b24; }

@media (max-width: 760px) {
  #view { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .topbar {
    min-height: 60px;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 0 16px;
    background: #090c12f5;
    backdrop-filter: none;
  }
  .brand { font-size: 20px; }
  .main-nav {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    width: 100%;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    order: initial;
    overflow: visible;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid #ffffff12;
    background: #11151df5;
    backdrop-filter: blur(18px);
  }
  .nav-link {
    display: flex;
    min-width: 0;
    min-height: 58px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 1px;
    border: 0;
    border-radius: 12px;
    color: #a0a5af;
    font-size: 10px;
    line-height: 1.15;
    white-space: normal;
  }
  .nav-link > span { overflow: hidden; max-width: 100%; text-overflow: ellipsis; }
  .nav-icon { display: block; flex: 0 0 23px; }
  .nav-link:hover, .nav-link.active { color: var(--red); }
  .nav-link.active { border: 0; background: #d8b16e16; }
  .top-actions { margin-left: auto; }
  .hero { min-height: 390px; padding: 28px 22px 24px; background-position: 58% center; }
  .hero-shade { background: linear-gradient(0deg, #090c12 0%, #090c12d9 37%, #090c1225 100%); }
  .hero-content { margin-top: auto; }
  .hero h1 { font-size: 32px; }
  .hero p { font-size: 13px; line-height: 1.5; }
  .shelf { padding: 8px 16px 18px; }
  .shelf h2, .shelf-heading h2 { font-size: 18px; }
  .movie-row { gap: 10px; }
  .movie-card { flex-basis: 132px; }
  .page-shell { padding: 28px 16px 42px; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 19px 12px; }
  .iptv-layout { grid-template-columns: 1fr; }
  .channel-heading { align-items: stretch; flex-direction: column; }
  .channel-heading input { max-width: none; }
  .detail-body { padding: 0 18px 25px; }
  .detail-hero { height: 220px; }
  .detail-body h1 { font-size: 29px; }
  .source-field div { flex-direction: column; }
  .modal-backdrop { padding: 10px; }
}
