:root {
  color-scheme: dark;
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  color: #ecf2ff;
  background: #0a1223;
  --border: #283b59;
  --surface: #101d32;
  --raised: #172944;
  --muted: #a9bbd6;
  --accent: #9fc7ff;
  --header: 4.4rem;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
h1, h2, p { margin: 0; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.topbar {
  min-height: var(--header);
  border-bottom: 1px solid var(--border);
  padding: .85rem clamp(1.1rem, 4vw, 2.75rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: inline-flex; gap: .72rem; align-items: center; color: inherit; text-decoration: none; font-weight: 750; letter-spacing: .14em; }
.brand-mark { display: flex; gap: 3px; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: .62rem; background: var(--accent); }
.brand-mark i, .signal i { display: block; width: 2px; height: 8px; border-radius: 4px; background: #142d52; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 11px; }
.user-panel { display: flex; min-width: 0; align-items: center; gap: .9rem; color: var(--muted); }
.user-panel span { overflow: hidden; max-width: 18ch; text-overflow: ellipsis; white-space: nowrap; }
.small-button {
  min-height: 2.35rem;
  padding: .38rem .72rem;
  border: 1px solid var(--border);
  border-radius: .55rem;
  background: var(--surface);
  white-space: nowrap;
  font-size: .875rem;
}
.small-button:not(:disabled):hover { background: var(--raised); border-color: #527aaa; }
.opening { margin: 4rem auto; text-align: center; padding: 1rem; color: var(--muted); }

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(0, 1fr);
  max-width: 64rem;
  margin: clamp(1.4rem, 9vh, 6rem) auto 2rem;
  width: calc(100% - clamp(2.2rem, 8vw, 5.5rem));
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  overflow: hidden;
  background: var(--surface);
}
.auth-art {
  min-height: 30rem;
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, #c4ddff0b 0 1px, transparent 1px 28px),
    repeating-linear-gradient(0deg, #c4ddff0b 0 1px, transparent 1px 28px),
    radial-gradient(ellipse at 52% 42%, #254d90 0%, #183461 60%, #102547 100%);
}
.orbit { position: absolute; aspect-ratio: 1; border: 1px solid #9fc7ff50; border-radius: 50%; }
.orbit-outer { width: 92%; }
.orbit-middle { width: 73%; border-style: dashed; border-color: #9fc7ff6b; }
.orbit-inner { width: 53%; background: #9fc7ff0c; }
.signal { display: flex; align-items: center; gap: clamp(.34rem, 1.1vw, .8rem); }
.signal i { width: clamp(.2rem, .65vw, .55rem); height: clamp(1.3rem, 4.5vw, 4rem); background: var(--accent); box-shadow: 0 0 2rem #7cafff8c; }
.signal i:nth-child(2), .signal i:nth-child(6) { height: clamp(.7rem, 3vw, 2.6rem); }
.signal i:nth-child(3) { height: clamp(2.2rem, 7vw, 5.7rem); }
.signal i:nth-child(4) { height: clamp(2.8rem, 9vw, 7rem); }
.signal i:nth-child(5) { height: clamp(1.6rem, 6vw, 4.8rem); }
.signal i:nth-child(7) { height: clamp(.5rem, 2vw, 1.5rem); }
.auth-content { align-self: center; padding: clamp(1.35rem, 5vw, 4.25rem); }
.auth h1, .catalog h1 { font-weight: 700; letter-spacing: -.055em; line-height: 1.02; overflow-wrap: anywhere; }
.auth h1 { font-size: clamp(2.25rem, 4.7vw, 3.8rem); }
.auth-content > p { margin-top: .85rem; color: var(--muted); line-height: 1.5; }
.auth form { display: grid; gap: .55rem; margin-top: 1.8rem; }
.auth label { font-size: .9rem; font-weight: 650; }
.auth input {
  width: 100%;
  height: 2.85rem;
  padding: .55rem .75rem;
  border: 1px solid #415b81;
  border-radius: .62rem;
  color: inherit;
  background: #0d182b;
}
.auth label:not(:first-child) { margin-top: .55rem; }
.password-field { position: relative; }
.password-field input { padding-right: 5rem; }
.text-button {
  color: var(--accent);
  background: transparent;
  border: 0;
  font-size: .875rem;
  right: .4rem;
  top: .2rem;
  position: absolute;
  min-height: 2.4rem;
  border-radius: .4rem;
}
.primary-button { min-height: 2.85rem; margin-top: .7rem; border: 0; border-radius: .62rem; background: var(--accent); color: #10264a; font-weight: 750; }
.primary-button:not(:disabled):hover { background: #c6deff; }
.form-error { padding: .75rem .9rem; color: #ffccc6; background: #402624; border: 1px solid #704641; border-radius: .65rem; line-height: 1.4; overflow-wrap: anywhere; }

.library { max-width: 110rem; margin: 0 auto; display: grid; grid-template-columns: minmax(14rem, 18.5rem) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; align-self: start; max-height: 100dvh; min-height: min(33rem, calc(100dvh - var(--header))); display: flex; flex-direction: column; gap: 1rem; border-right: 1px solid var(--border); padding: 1.55rem 1.1rem; }
.main-nav { display: grid; gap: .35rem; }
.nav-button {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr) auto;
  align-items: center;
  gap: .65rem;
  width: 100%;
  min-height: 2.66rem;
  border: 1px solid transparent;
  border-radius: .6rem;
  padding: .55rem .65rem;
  text-align: left;
  background: transparent;
  font-weight: 650;
}
.nav-button[aria-current], .category-button[aria-current] { background: #203a62; color: #dceaff; border-color: #3e6092; }
.nav-button:hover, .category-button:hover { background: var(--raised); }
.nav-button[aria-current]:hover, .category-button[aria-current]:hover { background: #294979; }
.nav-mark { color: var(--accent); }
.grid-mark { width: .95rem; height: .95rem; border-radius: .16rem; background: linear-gradient(90deg, transparent 43%, #162849 43% 57%, transparent 57%), linear-gradient(0deg, transparent 43%, #162849 43% 57%, transparent 57%), currentColor; }
.star-mark { font-size: 1.35rem; line-height: 1; }
.nav-count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.category-heading { display: flex; justify-content: space-between; align-items: center; margin-top: .35rem; padding: .15rem .35rem 0; }
.category-heading h2 { font-size: .95rem; letter-spacing: .02em; }
.mobile-toggle { display: none; }
.category-body { display: flex; flex-direction: column; gap: .72rem; min-height: 0; }
.categories { overflow: auto; padding: .2rem .2rem .2rem .22rem; scrollbar-width: thin; scrollbar-color: #415a82 transparent; }
.category-button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: center; color: var(--muted); width: 100%; min-height: 2.48rem; border: 1px solid transparent; border-radius: .5rem; padding: .43rem .55rem; background: transparent; text-align: left; font-size: .875rem; }
.category-button span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-empty { color: var(--muted); font-size: .875rem; padding: .45rem; }

.search-field { width: 100%; display: flex; position: relative; align-items: center; }
.search-field input { color: inherit; width: 100%; height: 2.65rem; background: var(--surface); border: 1px solid #344d73; border-radius: .65rem; padding: .5rem .65rem .5rem 2.32rem; }
.search-field input::placeholder { color: #9caecb; }
.search-icon { position: absolute; left: .82rem; width: .78rem; height: .78rem; border: 1.5px solid var(--muted); border-radius: 50%; pointer-events: none; }
.search-icon::after { content: ""; position: absolute; width: .4rem; height: 1.5px; border-radius: 1px; background: var(--muted); transform: rotate(47deg); left: .53rem; top: .65rem; }
.category-search input { font-size: .875rem; }
.catalog { padding: clamp(1.1rem, 3.8vw, 3.35rem); min-width: 0; }
.catalog-heading { display: grid; gap: .58rem; margin-bottom: 1.1rem; }
.catalog-total { font-size: .9rem; color: var(--accent); font-weight: 650; }
.catalog-total:empty { display: none; }
.catalog h1 { font-size: clamp(2.25rem, 5.15vw, 4.3rem); }
.channel-search { max-width: 32rem; margin-top: .66rem; }
.channel-search input { height: 3.15rem; }
.player-panel { border: 1px solid #344d73; background: var(--surface); border-radius: .8rem; margin: 1.25rem 0 .75rem; overflow: clip; scroll-margin-top: 1rem; }
.player-header, .player-footer { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: .75rem clamp(.7rem, 2.2vw, 1.25rem); }
.player-channel { min-width: 0; overflow-wrap: anywhere; }
.player-channel p { color: var(--accent); font-size: .81rem; margin-bottom: .16rem; }
.player-channel h2 { font-size: clamp(1rem, 3.2vw, 1.3rem); line-height: 1.25; }
.player-screen { display: grid; place-items: center; background: #060b16; }
.player-screen video { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 65vh; }
.player-footer { min-height: 2.8rem; color: var(--muted); font-size: .875rem; }
.player-footer p[data-live="true"] { color: var(--accent); }
.player-footer p[data-live="true"]::before { content: ""; display: inline-block; width: .48rem; height: .48rem; border-radius: 50%; background: currentColor; margin-right: .5rem; vertical-align: .07rem; }
.result-bar { min-height: 3.6rem; display: flex; align-items: center; justify-content: space-between; gap: .85rem; }
.result-bar p, .pagination { font-size: .875rem; color: var(--muted); }
.pagination { display: flex; gap: .5rem; align-items: center; font-variant-numeric: tabular-nums; }
#page-number { min-width: 5ch; white-space: nowrap; text-align: center; }
.channel-grid { display: grid; gap: .68rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
.channel-grid[aria-busy="true"] { opacity: .58; }
.channel-card { min-width: 0; min-height: 5.05rem; background: var(--surface); border: 1px solid var(--border); border-radius: .72rem; padding-right: .55rem; display: grid; grid-template-columns: minmax(0, 1fr) 2.55rem; align-items: center; }
.channel-card:hover, .channel-card:focus-within { border-color: #496b99; }
.channel-card:has(.channel-play[aria-pressed="true"]) { border-color: #6a96d1; background: #182d4d; }
.channel-play { width: 100%; height: 100%; min-width: 0; display: grid; grid-template-columns: 2.8rem minmax(0, 1fr); align-items: center; text-align: left; gap: .68rem; padding: .65rem; background: none; border: 0; border-radius: .55rem; }
.channel-play:focus-visible { outline-offset: -3px; }
.channel-play:hover .channel-name { color: var(--accent); }
.channel-symbol { display: grid; place-items: center; width: 2.8rem; aspect-ratio: 1; border-radius: .61rem; color: #b4d3ff; background: #233e68; }
.channel-symbol[data-tone="1"] { color: #c8dcff; background: #2b4167; }
.channel-symbol[data-tone="2"] { color: #c5ccff; background: #303f73; }
.channel-symbol[data-tone="3"] { color: #b5d9ff; background: #214876; }
.channel-symbol i { position: relative; width: 1.3rem; height: .95rem; border: 1.4px solid currentColor; border-radius: .2rem; }
.channel-symbol i::after { content: ""; position: absolute; width: .62rem; height: 1.4px; background: currentColor; bottom: -.32rem; left: .28rem; }
.channel-name { display: block; font-size: .96rem; font-weight: 700; line-height: 1.24; overflow-wrap: anywhere; }
.channel-category { display: block; color: var(--muted); margin-top: .21rem; font-size: .78rem; line-height: 1.3; overflow-wrap: anywhere; }
.favorite-button { width: 2.55rem; height: 2.55rem; display: grid; place-items: center; border: 1px solid transparent; background: transparent; border-radius: .55rem; color: #b0c2df; font-size: 1.45rem; line-height: 1; }
.favorite-button:hover { background: #22395b; color: #ffdd95; border-color: var(--border); }
.favorite-button[aria-pressed="true"] { color: #ffdc90; }
.empty { color: var(--muted); border: 1px dashed #435e88; border-radius: .75rem; padding: clamp(1.25rem, 5vw, 3rem); }
.empty h2 { color: #ecf2ff; font-size: 1.25rem; margin-bottom: .5rem; }
#library-error { margin-bottom: .75rem; }

@media (max-width: 760px) {
  .library { display: block; }
  .sidebar { position: static; min-height: auto; max-height: none; border: 0; border-bottom: 1px solid var(--border); padding: 1rem 1.1rem; gap: .6rem; }
  .main-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-heading { margin-top: 0; padding: 0 .15rem; }
  .mobile-toggle { display: block; }
  .category-body { display: none; }
  .category-body.is-open { display: flex; }
  .categories { max-height: 15rem; }
  .auth { grid-template-columns: 1fr; max-width: 32rem; }
  .auth-art { min-height: clamp(7rem, 26vw, 12rem); }
  .orbit-outer { width: 55%; }
  .orbit-middle { width: 43%; }
  .orbit-inner { width: 32%; }
  .auth-break { display: none; }
}

@media (max-width: 415px) {
  .result-bar { align-items: flex-start; padding: .45rem 0 .65rem; flex-direction: column; }
  .nav-button { gap: .38rem; font-size: .875rem; padding-inline: .48rem; }
}
