:root {
  --ink: #f8f7ff;
  --ink-muted: #b9b6d3;
  --canvas: #0b0a20;
  --surface: #11102b;
  --surface-raised: #19173a;
  --surface-active: #24204b;
  --line: #343057;
  --signal: #ffd35a;
  --signal-ink: #201b05;
  --cyan: #64d8ef;
  --violet: #a996ff;
  --danger: #ff8295;
  --radius-sm: 9px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-float: 0 14px 32px rgba(2, 2, 12, 0.34);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--signal);
  color: var(--signal-ink);
  font-weight: 750;
  text-decoration: none;
}

.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.is-hidden { display: none !important; }

.launch-required {
  width: min(1040px, calc(100% - 36px));
  min-height: 620px;
  margin: clamp(28px, 6vw, 86px) auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  place-items: center;
  gap: clamp(32px, 7vw, 92px);
  padding: clamp(32px, 6vw, 76px);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.launch-copy { min-width: 0; }
.launch-copy h1 { max-width: 12ch; }
.launch-copy > p:not(.kicker) { max-width: 62ch; color: var(--ink-muted); }
.launch-copy ol { margin: 28px 0; padding: 0; list-style: none; counter-reset: launch-step; }
.launch-copy li { counter-increment: launch-step; display: flex; align-items: center; gap: 13px; min-height: 48px; color: var(--ink); font-weight: 650; }
.launch-copy li::before { content: counter(launch-step); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--signal); color: var(--signal-ink); font-size: .78rem; font-weight: 800; flex: 0 0 auto; }
.launch-note { padding-top: 20px; border-top: 1px solid var(--line); font-size: .86rem; }
.launch-signal { position: relative; width: 210px; height: 210px; display: grid; place-items: center; }
.launch-signal span { position: absolute; border: 1px solid var(--line); border-radius: 50%; }
.launch-signal span:nth-child(1) { width: 130px; height: 130px; }
.launch-signal span:nth-child(2) { width: 208px; height: 208px; }
.launch-signal i { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: var(--signal); color: var(--signal-ink); font-size: 2rem; font-style: normal; font-weight: 900; box-shadow: 0 12px 26px rgba(2, 2, 12, 0.34); }

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(230px, 0.7fr) minmax(320px, 1.4fr) minmax(160px, 0.6fr);
  align-items: center;
  gap: 28px;
  min-height: 82px;
  padding: 14px clamp(18px, 3vw, 48px);
  background: rgba(17, 16, 43, 0.97);
  box-shadow: 0 10px 28px rgba(2, 2, 12, 0.28);
}
.launch-mode .masthead { grid-template-columns: 1fr; }
.launch-mode .global-search,
.launch-mode .privacy-chip { display: none; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--signal); color: var(--signal-ink); flex: 0 0 auto; }
.brand-mark svg { width: 32px; height: 32px; fill: currentColor; }
.brand-copy { display: grid; line-height: 1.08; }
.brand-copy strong { font-size: 1.08rem; letter-spacing: -0.015em; }
.brand-copy small { margin-top: 5px; color: var(--ink-muted); font-size: 0.75rem; }

.global-search label { display: block; margin-bottom: 5px; color: var(--ink-muted); font-size: 0.72rem; font-weight: 700; }
.search-field,
.compact-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  transition: border-color 160ms ease, background 160ms ease;
}
.search-field:focus-within,
.compact-search:focus-within { border-color: var(--cyan); background: #0f0d29; }
.search-field { min-height: 44px; padding: 0 11px 0 14px; }
.search-field svg,
.compact-search svg { width: 19px; height: 19px; fill: none; stroke: var(--ink-muted); stroke-width: 1.8; flex: 0 0 auto; }
.search-field input,
.compact-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field input::placeholder,
.compact-search input::placeholder { color: #8f8baa; opacity: 1; }
.search-field kbd { border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; color: var(--ink-muted); background: var(--surface-raised); font-family: inherit; font-size: 0.7rem; white-space: nowrap; }

.privacy-chip { justify-self: end; display: flex; align-items: center; gap: 8px; color: #d9f9ff; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.privacy-chip span { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 4px 10px rgba(100, 216, 239, 0.28); }

.app-shell { width: min(1760px, 100%); margin: 0 auto; padding: clamp(28px, 4vw, 56px) clamp(18px, 3vw, 48px) 56px; }

.library-bar { display: grid; grid-template-columns: minmax(230px, 0.55fr) minmax(620px, 1.45fr); gap: 36px; align-items: end; margin-bottom: 30px; }
.kicker,
.section-label { margin: 0 0 6px; color: var(--cyan); font-size: 0.74rem; font-weight: 750; letter-spacing: 0.045em; }
h1, h2, h3, p { text-wrap: pretty; }
h1 { margin: 0; font-size: clamp(2.2rem, 4vw, 4.4rem); line-height: 0.98; letter-spacing: -0.035em; }
h2 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.7rem); line-height: 1.13; letter-spacing: -0.025em; }
h3 { margin: 0; font-size: 1.18rem; line-height: 1.25; letter-spacing: -0.018em; }

.library-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 7px; border-radius: var(--radius-md); background: var(--surface); }
.library-tab { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; transition: background 180ms ease, color 180ms ease; }
.library-tab:hover { background: var(--surface-raised); }
.library-tab.is-active { background: var(--signal); color: var(--signal-ink); }
.library-tab > span:last-child { display: grid; min-width: 0; }
.library-tab strong { line-height: 1.15; }
.library-tab small { margin-top: 4px; color: var(--ink-muted); font-size: 0.74rem; white-space: nowrap; }
.library-tab.is-active small { color: #57480e; }
.tab-signal { width: 10px; height: 30px; border-radius: 4px; flex: 0 0 auto; background: var(--cyan); }
.tab-signal.movies { background: var(--violet); }
.tab-signal.series { background: var(--danger); }
.tab-signal.search { background: var(--signal); }
.library-tab.is-active .tab-signal { background: var(--signal-ink); }

.catalog-grid { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); min-height: 690px; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.category-panel { min-width: 0; padding: 24px 18px 18px; background: #0f0e27; }
.panel-heading,
.result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-heading { padding: 0 6px 18px; }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 26px; padding: 3px 8px; border-radius: 999px; background: var(--surface-active); color: var(--ink-muted); font-size: 0.73rem; font-weight: 750; }
.compact-search { min-height: 42px; padding: 0 12px; }
.category-panel > .compact-search { margin-bottom: 12px; }
.category-list { height: 578px; overflow-y: auto; padding: 2px 2px 20px 0; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }

.category-button { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; min-height: 46px; padding: 9px 10px 9px 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-muted); text-align: left; cursor: pointer; transition: background 140ms ease, color 140ms ease; }
.category-button:hover { background: var(--surface-raised); color: var(--ink); }
.category-button.is-active { background: var(--surface-active); color: var(--ink); }
.category-button.is-active .category-name { color: var(--signal); }
.category-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.category-total { font-size: 0.72rem; color: #9894b5; font-variant-numeric: tabular-nums; }

.result-panel { position: relative; min-width: 0; padding: 28px clamp(20px, 3vw, 38px) 26px; background: var(--surface); }
.result-heading { min-height: 74px; padding-bottom: 20px; }
.result-heading > div { min-width: 0; }
#result-subtitle { max-width: 68ch; margin: 7px 0 0; color: var(--ink-muted); font-size: 0.88rem; }
.item-search { width: min(310px, 42%); flex: 0 0 auto; }

.welcome-state { min-height: 500px; display: grid; place-items: center; align-content: center; grid-template-columns: 210px minmax(240px, 450px); gap: clamp(28px, 5vw, 72px); padding: 70px 30px; }
.welcome-state p { margin: 12px 0 0; max-width: 48ch; color: var(--ink-muted); }
.welcome-state .welcome-note { margin: 0 0 8px; color: var(--signal); font-weight: 750; }
.welcome-state h3 { font-size: clamp(1.8rem, 4vw, 3.5rem); line-height: 0.98; letter-spacing: -0.035em; }
.broadcast-orbit { position: relative; width: 190px; height: 190px; display: grid; place-items: center; }
.broadcast-orbit span { position: absolute; border: 1px solid var(--line); border-radius: 50%; }
.broadcast-orbit span:nth-child(1) { width: 62px; height: 62px; border-color: var(--signal); }
.broadcast-orbit span:nth-child(2) { width: 120px; height: 120px; }
.broadcast-orbit span:nth-child(3) { width: 188px; height: 188px; }
.broadcast-orbit i { width: 14px; height: 14px; border-radius: 50%; background: var(--signal); box-shadow: 0 8px 18px rgba(255, 211, 90, 0.3); }

.loading-state { min-height: 360px; display: flex; justify-content: center; align-items: center; gap: 8px; }
.loading-state span { width: 9px; height: 9px; border-radius: 50%; background: var(--signal); animation: signal 900ms var(--ease-out) infinite alternate; }
.loading-state span:nth-child(2) { animation-delay: 140ms; }
.loading-state span:nth-child(3) { animation-delay: 280ms; }
@keyframes signal { from { transform: translateY(0); opacity: .4; } to { transform: translateY(-11px); opacity: 1; } }

.empty-state { min-height: 350px; display: grid; place-content: center; text-align: center; }
.empty-state p { margin: 8px 0 0; color: var(--ink-muted); }

.item-list { display: grid; gap: 7px; }
.media-row { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; min-height: 58px; padding: 10px 14px; border-radius: 11px; background: #151331; transition: background 150ms ease, transform 180ms var(--ease-out); }
.media-row:hover { background: var(--surface-active); transform: translateX(2px); }
.media-copy { min-width: 0; }
.media-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.94rem; }
.media-copy small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); font-size: 0.74rem; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; padding-top: 24px; }
.pagination button { min-height: 39px; padding: 8px 14px; border: 0; border-radius: var(--radius-sm); background: var(--surface-active); cursor: pointer; }
.pagination button:hover:not(:disabled) { background: #34305f; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
#page-status { color: var(--ink-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(390px, calc(100vw - 44px)); transform: translateY(140%); opacity: 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--signal); color: var(--signal-ink); box-shadow: var(--shadow-float); font-size: 0.84rem; font-weight: 750; transition: transform 300ms var(--ease-out), opacity 200ms ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }

@media (max-width: 1050px) {
  .masthead { grid-template-columns: minmax(210px, .7fr) minmax(300px, 1.3fr); }
  .privacy-chip { display: none; }
  .library-bar { grid-template-columns: 1fr; align-items: stretch; gap: 22px; }
  .library-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-grid { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .masthead { position: static; grid-template-columns: 1fr; gap: 14px; padding: 16px 18px 18px; }
  .global-search label { display: none; }
  .search-field kbd { display: none; }
  .app-shell { padding: 28px 14px 42px; }
  h1 { font-size: clamp(2.4rem, 13vw, 4rem); }
  .library-tabs { grid-template-columns: 1fr; }
  .library-tab { min-height: 52px; }
  .tab-signal { height: 24px; }
  .catalog-grid { display: block; overflow: visible; background: transparent; }
  .category-panel, .result-panel { border-radius: var(--radius-lg); }
  .category-panel { margin-bottom: 14px; }
  .category-list { height: 320px; }
  .result-panel { padding: 22px 16px; }
  .result-heading { display: grid; }
  .item-search { width: 100%; }
  .welcome-state { min-height: 420px; grid-template-columns: 1fr; text-align: center; padding: 44px 18px; }
  .broadcast-orbit { width: 150px; height: 150px; justify-self: center; }
  .broadcast-orbit span:nth-child(3) { width: 148px; height: 148px; }
  .broadcast-orbit span:nth-child(2) { width: 98px; height: 98px; }
  .media-row { grid-template-columns: minmax(0, 1fr); }
  .launch-required { min-height: 0; grid-template-columns: 1fr; text-align: left; padding: 36px 24px; }
  .launch-signal { width: 150px; height: 150px; }
  .launch-signal span:nth-child(1) { width: 92px; height: 92px; }
  .launch-signal span:nth-child(2) { width: 148px; height: 148px; }
  .launch-copy h1 { max-width: none; font-size: clamp(2.15rem, 11vw, 3.5rem); }
}

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