:root {
  color-scheme: dark;
  font: 100%/1.5 "Segoe UI Variable Text","Segoe UI",system-ui,sans-serif;
  color: #f4f7f2;
  background: #101713;
  --accent: #a9edc8;
  --muted: #b1c0b6;
  --line: #3a4940;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 82% 0%, #254336, transparent 56%); }
.top, main { width: min(100% - 2.5rem, 78rem); margin: auto; }
.top { min-height: 5rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.brand strong { letter-spacing: -.045em; font-size: 1.4rem; }
.brand span { border-left: 1px solid var(--line); padding-left: .75rem; color: var(--muted); }
main { padding: clamp(1.5rem,6vw,5rem) 0 max(2rem,env(safe-area-inset-bottom)); }
.setup, #library { display: grid; gap: clamp(1.25rem,5vw,5rem); align-items: start; }
.setup { grid-template-columns: minmax(0,1fr) minmax(19rem,27rem); align-items: center; }
.intro { max-width: 34rem; }
h1, h2, p { margin: 0; overflow-wrap: anywhere; }
h1, h2 { line-height: 1.1; letter-spacing: -.045em; }
h1 { font-size: clamp(2rem,5vw,4.4rem); }
.intro p { max-width: 28rem; color: var(--muted); font-size: 1.14rem; margin-top: .85rem; }
.screen { width: 8rem; aspect-ratio: 16/10; border: 1px solid #84ae98; border-radius: .85rem; padding: .45rem; margin: 0 0 1.65rem; transform: rotate(-3deg); }
.screen span { display: block; height: 100%; border-radius: .45rem; background: repeating-linear-gradient(0deg, transparent 0 3px,#10171328 3px 4px),linear-gradient(90deg,#bde9c5 0 20%,#72c6a8 20% 40%,#4c997d 40% 60%,#376958 60% 80%,#254638 80%); }
form, aside { background: #18221d; border: 1px solid var(--line); border-radius: 1rem; padding: clamp(1rem,3vw,2rem); }
label { display: block; font-weight: 600; margin: 1rem 0 .4rem; }
form > label:first-child { margin-top: 0; }
input, select, button { font: inherit; }
input, select { width: 100%; min-width: 0; border: 1px solid #52685a; background: #101813; color: inherit; padding: .65rem .8rem; border-radius: .6rem; min-height: 2.875rem; }
input::file-selector-button { font: inherit; }
button { min-height: 2.8rem; border-radius: .65rem; padding: .5rem 1rem; border: 1px solid var(--line); background: #233329; color: inherit; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .65; cursor: progress; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.primary { background: var(--accent); color: #0e271b; font-weight: 700; margin-top: 1.5rem; width: 100%; }
small { display: block; margin-top: .9rem; color: var(--muted); }
[role=status]:not(:empty) { margin: .85rem 0; }
#sourceStatus, #playerStatus, #catalogStatus { color: #f1d2a1; }
#library { grid-template-columns: minmax(0,1.7fr) minmax(16rem,1fr); gap: 1.5rem; }
.stage { background: #080d0a; aspect-ratio: 16/9; border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; display: grid; place-items: center; }
#standby { text-align: center; color: var(--muted); }
.small { width: 3.75rem; border-radius: .4rem; padding: .2rem; margin: 0 auto .8rem; }
video { width: 100%; height: 100%; min-height: 0; }
.watch h1 { font-size: clamp(1.6rem,3vw,2.8rem); margin-top: 1rem; }
#back { margin-bottom: 1rem; }
.remember { display: flex; align-items: center; gap: .65rem; }
.remember input { width: 1.25rem; min-height: auto; height: 1.25rem; accent-color: var(--accent); }
#sections { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
#sections button { padding-inline: .65rem; }
#sections button[aria-pressed=true] { background: var(--accent); color: #0e271b; }
#count { color: var(--muted); font-size: .9rem; }
ul { list-style: none; padding: 0; margin: 0; }
#items { max-height: min(55vh,36rem); overflow-y: auto; }
li button { width: 100%; display: grid; border: 0; border-top: 1px solid var(--line); background: transparent; border-radius: 0; padding: .75rem .45rem; text-align: left; overflow-wrap: anywhere; }
li button:is(:hover,[aria-current=true]) { background: #283e30; color: var(--accent); }
li button:focus-visible { outline-offset: -3px; }
li small { margin: .15rem 0 0; }
#more { width: 100%; margin-top: .65rem; }
details { border-top: 1px solid var(--line); color: var(--muted); margin-top: clamp(2rem,6vw,5rem); padding-top: 1rem; }
summary { width: fit-content; cursor: pointer; padding: .6rem 0; }
details p { max-width: 54rem; margin: .5rem 0; }
#homeNav, .home-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
#homeNav button { border-color: transparent; background: transparent; }
#home {
  --tile: #dce3dd;
  --hero: #a4efd4;
  --edge: #a2afa7;
  color: #19231f;
  background: #f5f7f3;
  border-radius: 1rem;
  padding: clamp(1rem, 3vw, 2rem);
}
#home.dark-home { --tile: #263a30; --edge: #66796d; color: #f4f7f2; background: #18221d; }
#home h1 { font-size: clamp(1.6rem, 4vw, 2rem); margin-bottom: 1rem; }
.home-grid { display: grid; grid-template-columns: 4fr 3fr 3fr; grid-auto-rows: minmax(4.75rem, auto); gap: .55rem; }
.home-grid button {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: var(--tile);
  border: 1px solid var(--edge);
  border-radius: 1rem;
  text-align: left;
  font-weight: 650;
}
.home-grid button::after { content: "›"; margin-left: auto; }
.home-grid button span { font-size: 1.3em; }
.home-grid button:first-child { grid-row: span 2; background: var(--hero); color: #12352a; font-size: clamp(1.1rem, 3vw, 1.55rem); }
.home-actions, #appearance { margin-top: .9rem; }
.home-actions button, #appearance button { background: transparent; border-color: var(--edge); border-radius: 2rem; }
#home button:focus-visible { outline-color: #30826a; }
body:has(#home:not([hidden])) main { padding-top: 1.5rem; }
body:has(#home:not([hidden])) details, body:has(#library:not([hidden])) details { display: none; }
@media (max-width: 48rem) {
  .setup, #library { grid-template-columns: minmax(0,1fr); }
  .intro .screen { width: 4.5rem; margin-bottom: 1rem; }
  .top { min-height: 4.25rem; }
  #items { max-height: none; }
  .top { flex-wrap: wrap; }
  #homeNav { order: 1; width: 100%; }
}
@media (max-width: 38rem) {
  .home-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .home-grid button:first-child { grid-column: 1 / -1; grid-row: auto; min-height: 6rem; }
  .home-grid button:last-child { grid-column: 1 / -1; }
}
@media (max-width: 25rem) {
  .top, main { width: calc(100% - 1.5rem); }
  .brand span { display: none; }
}

:root:not(.dark) { color-scheme: light; background: #f5f7f3; color: #19231f; --line: #cbd5cd; --muted: #465b50; }
:root:not(.dark) body { background: #f5f7f3; }
:root:not(.dark) :is(button,form,aside,fieldset) { background: #edf2ec; }
:root:not(.dark) :is(input,select) { background: #fff; }
:root:not(.dark) :is(#sourceStatus,#catalogStatus,#playerStatus) { color: #764500; }
:root:not(.dark) :is(.primary,button[aria-pressed=true],button[aria-current=true]) { background: #a4efd4; color: #13392e; }
:root:not(.dark) li button:hover { background: #dceee5; color: #13392e; }
:root.dark #home { --tile: #263a30; --edge: #66796d; color: inherit; background: #18221d; }
.top-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
#theme { font-size: 1.35rem; padding-inline: .8rem; }
#library { grid-template-columns: minmax(0,2fr) minmax(13rem,1fr); }
#library:has(.watch[hidden]) { grid-template-columns: minmax(0,1fr); }
.catalog-layout { display: grid; grid-template-columns: minmax(8rem, 1fr) minmax(0, 2.25fr); gap: 1rem; }
.groups { padding: .65rem; border-radius: .75rem; }
.groups label:first-child { margin-top: 0; }
#groupLinks { display: grid; gap: .25rem; max-height: 57vh; overflow: auto; margin-top: .65rem; }
#groupLinks button { text-align: left; overflow-wrap: anywhere; padding: .35rem .55rem; }
#groupLinks button[aria-pressed=true] { background: var(--accent); color: #153629; }
.results { min-width: 0; }
.results h2 { font-size: 1.35rem; }
.poster-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,8.5rem),1fr)); gap: .65rem; }
.poster-grid button { align-content: start; height: 100%; border: 1px solid var(--line); border-radius: .8rem; padding: .55rem; }
.cover { width: 3.25rem; height: 2rem; object-fit: contain; border-radius: .35rem; margin-bottom: .35rem; }
.poster-grid .cover { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.watch h1 { font-size: clamp(1rem,2vw,1.45rem); }
.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.page-heading h1, #preferences h1 { font-size: clamp(1.6rem,4vw,2rem); }
#servers, .preferences-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,14rem),1fr)); gap: .75rem; margin-top: 1rem; }
#servers li, fieldset { border: 1px solid var(--line); border-radius: .85rem; padding: .75rem; min-width: 0; margin: 0; }
#servers button { border: 0; border-radius: .55rem; margin-top: .25rem; }
#servers legend, fieldset legend { font-weight: 650; }
.top-actions button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.watch-heading { display: flex; align-items: start; justify-content: space-between; gap: .5rem; margin-top: .45rem; }
.watch-heading h1 { margin-top: .4rem; }
#stopVideo { flex: none; }
.watch-tools { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.watch-tools button { padding-inline: .65rem; }
.app-notice { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1rem; margin-bottom: .8rem; border: 1px solid var(--line); border-radius: .8rem; padding: .75rem; }
.app-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .65rem; }
#installGuide { width: min(27rem, calc(100% - 2rem)); max-height: 85dvh; border: 0; border-radius: 1rem; color: inherit; background: transparent; padding: 0; }
#installGuide::backdrop { background: #080f0bb3; }
#installGuide li { margin-bottom: .55rem; }
@media (display-mode: standalone) {
  body { padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
  .top { padding-top: max(.35rem, env(safe-area-inset-top)); }
  main { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}
#castHelp { display: grid; gap: .5rem; margin-top: .55rem; padding: .65rem; border: 1px solid var(--line); border-radius: .65rem; }
#offlineNotice { border: 1px solid var(--line); border-radius: .6rem; padding: .65rem; }
#homeNav button:disabled, #sections button:disabled { cursor: default; opacity: .45; }
@media (max-width: 48rem) {
  #library { grid-template-columns: minmax(0,1fr); }
  #library:has(video:not([hidden])) .watch { order: -1; }
}
@media (max-width: 36rem) {
  .catalog-layout { grid-template-columns: minmax(0,1fr); }
  #groupLinks { display: none; }
  .top { padding-block: max(.35rem, env(safe-area-inset-top)) .25rem; gap: .2rem .35rem; }
  .brand { gap: .35rem; }
  .brand img { width: 1.85rem; height: 1.85rem; }
  .brand strong { font-size: 1.15rem; }
  .brand span, .action-label { display: none; }
  .top-actions { flex-wrap: nowrap; gap: .15rem; }
  .top-actions button { min-width: 2.75rem; padding-inline: .25rem; font-size: 1.2rem; }
  #homeNav { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .1rem; }
  #homeNav[hidden] { display: none; }
  #homeNav button { padding-inline: .2rem; }
  main, body:has(#home:not([hidden])) main { padding-top: .8rem; }
  #library { gap: .65rem; }
  .catalog-layout { gap: .6rem; }
  .groups { border: 0; background: transparent !important; padding: 0; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .35rem; }
  .groups label { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .groups :is(input,select) { padding-inline: .5rem; }
  #sections { display: none; }
  .watch:has(video[hidden]) { display: none; }
  .stage { border-radius: .65rem; }
  .live-playing .watch { scroll-margin-top: .4rem; }
  .watch-heading h1 { font-size: 1rem; }
  .poster-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .5rem; }
}
