:root {
  color-scheme: dark;
  --page: #0b0c15;
  --surface: #131521;
  --surface-raised: #1b1e2d;
  --field: #10121d;
  --ink: #f4f3fb;
  --muted: #b4b6c9;
  --line: #343547;
  --accent: #78efdc;
  --on-accent: #0a2325;
  --violet: #a89bff;
  --nav-w: clamp(11rem, 18vw, 15rem);
  --radius: 18px;
  --space: clamp(16px, 2.5vw, 36px);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
:root[data-theme="light"], body[data-theme="light"] {
  color-scheme: light;
  --page: #f0f1f7;
  --surface: #fff;
  --surface-raised: #f4f4fc;
  --field: #fff;
  --ink: #171923;
  --muted: #50536d;
  --line: #ccd0df;
  --accent: #157c72;
  --on-accent: #fff;
  --violet: #5445a6;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 6rem; }
body {
  margin: 0; min-height: 100vh; padding: 0;
  color: var(--ink); font: 1rem/1.5 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(ellipse at 75% 0, color-mix(in srgb, var(--violet) 9%, transparent), transparent 43rem), var(--page);
}
button, input, select, textarea { font: inherit; }
a { color: var(--ink); }
a:hover { color: var(--violet); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
[hidden] { display: none !important; }
header {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px 24px;
  min-height: 68px; padding: 10px var(--space);
  color: var(--ink); background: var(--surface); border-bottom: 1px solid var(--line);
}
header .brand, header > b {
  display: inline-flex; align-items: center; gap: .65rem;
  font: 800 clamp(1.03rem, 2vw, 1.42rem)/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: -.045em; text-transform: uppercase; text-decoration: none;
}
header > b::before {
  content: ""; width: 40px; aspect-ratio: 1; border-radius: 11px;
  background: url('/mark.png') center/contain no-repeat;
}
header:has(> img:not([hidden])) > b::before { display: none; }
.brand img, header #brandLogo { display: block; width: auto; height: 40px; object-fit: contain; }
#state {
  display: inline-flex; align-items: center; gap: .6rem; font-weight: 600;
  color: var(--muted); font-size: .86rem; letter-spacing: .02em;
}
#state:not(:empty)::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
body[data-playing="true"] #state { color: var(--accent); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { color: inherit; font-weight: 700; line-height: 1.13; letter-spacing: -.045em; }
h1 { font-size: clamp(1.9rem, 4vw, 3.25rem); }
h2 { font-size: clamp(1.3rem, 2.6vw, 2rem); }
small { color: var(--muted); font-weight: 650; font-size: .72rem; letter-spacing: .11em; }
#inside.studio, .app-shell {
  display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr);
  grid-template-rows: auto; gap: 18px clamp(18px, 2.6vw, 36px);
  width: min(100%, 1570px); min-height: auto; margin: 0 auto;
  padding: var(--space); align-items: start; background: transparent;
}
#inside.studio:not(:has(#navigation)), .app-shell:not(:has(#navigation)) { grid-template-columns: minmax(0,1fr); }
#navigation {
  display: flex; flex-direction: column; align-items: stretch; justify-content: start;
  gap: 3px; grid-column: 1; grid-row: 1 / span 6;
  position: sticky; top: 6.2rem; align-self: start; min-width: 0;
  max-height: calc(100dvh - 7.3rem); overflow: auto; scrollbar-width: thin;
  padding: .35rem .6rem .35rem 0;
}
#navigation :is(a, button) {
  display: flex; align-items: center; gap: .65rem; padding: .49rem .8rem; min-height: 38px;
  background: transparent; color: var(--muted); box-shadow: none;
  border: 1px solid transparent; border-radius: 9px; text-align: start;
  text-decoration: none; font-size: .91rem; font-weight: 570; letter-spacing: 0;
}
#navigation :is(a, button):hover { color: var(--ink); background: var(--surface-raised); }
#navigation :is([aria-current="page"], [aria-selected="true"], .active) {
  color: var(--ink); font-weight: 700; border-color: var(--line);
  background: linear-gradient(95deg, color-mix(in srgb, var(--violet) 19%, var(--surface)), var(--surface));
}
#navigation :is(a,button) svg { flex: 0 0 1.1rem; width: 1.1rem; height: 1.1rem; }
#inside > :is(.player,.hero,#notes,#section,.console,.content), .app-shell > :is(.player,.hero,#notes,#section,.console,.content) { grid-column: -2 / -1; min-width: 0; }
.panel, .card, .console, #section, #notes, #gate, .metric, .entry {
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 28px #05071518; backdrop-filter: none;
}
.panel, .card, .console, #section, #notes { padding: clamp(16px, 2.5vw, 30px); }
#section > :first-child, .console > :first-child, .card > :first-child { margin-top: 0; }
#section > :last-child, .console > :last-child, .card > :last-child { margin-bottom: 0; }
#section:empty { display: none; }
#section p, #section time { color: var(--muted); }
#section article + article, .console article + article { border-top: 1px solid var(--line); }
#section article { padding-block: .8rem; }
#section :is(img:not([width]),video) { max-width: 100%; height: auto; }
.hero, #inside .player, #home .player {
  position: relative; overflow: hidden; isolation: isolate;
  color: #fff; border-color: #48435e; border-radius: var(--radius);
  background-color: #1a1c38;
  background-image: linear-gradient(90deg, #101228e0 0%, #191932b0 40%, #1b1a3500 76%), url('/hero.webp');
  background-size: cover; background-position: center; background-repeat: no-repeat;
}
#inside .player, #home .player { padding: clamp(22px, 3.8vw, 52px); }
.player > small:first-child, .hero .eyebrow {
  color: #a5f4e7; font-weight: 750; letter-spacing: .16em; font-size: .73rem;
}
.player > small:first-child::before {
  content: ""; display: inline-block; width: 20px; height: 3px;
  vertical-align: middle; margin-right: .6rem; background: #80efda; border-radius: 3px;
}
#track {
  max-width: 19ch; margin: .65rem 0 .6rem;
  font: 720 clamp(1.85rem, 4.1vw, 4rem)/1.03 "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -.062em; text-wrap: balance; color: #f9f8ff;
}
.player > :is(.artist,#artist,#presenter,#show) { max-width: 65%; color: #d8d7ee; }
#wave {
  display: block; width: min(65%, 440px); max-width: 100%; height: clamp(32px, 5vw, 54px);
  margin: .9rem 0; opacity: .94;
}
.controls, .actions, .toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
button, .button {
  display: inline-flex; justify-content: center; align-items: center; gap: .45rem;
  min-height: 42px; padding: .58rem .95rem; cursor: pointer;
  color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line);
  border-radius: 9px; font-size: .91rem; line-height: 1.25; font-weight: 660;
}
button:hover, .button:hover { background: color-mix(in srgb, var(--violet) 14%, var(--surface-raised)); }
button:active { transform: translateY(1px); }
button[disabled] { cursor: not-allowed; opacity: .57; }
#play, #accept, button.primary, button[type="submit"], #form button {
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent;
}
#play {
  min-width: 9.6rem; padding: .7rem 1.25rem; min-height: 46px; letter-spacing: -.01em;
  border-radius: 999px; font-size: 1rem; background: #80efdb; color: #102423;
}
#play:hover { background: #a6f7e7; }
#reconnect { color: #f1ebff; background: #212339cc; border-color: #716a89; }
.player .volume {
  color: #d6d3e7; display: flex; align-items: center; gap: .7rem; max-width: 19rem;
  font-size: .85rem; margin: .8rem 0 .25rem;
}
input[type="range"] { accent-color: var(--accent); touch-action: manipulation; }
.player input[type="range"] { flex: 1; accent-color: #80efdb; }
#feedback, #listeners, .player small:last-child { color: #d1ccdf; }
#feedback { margin: .4rem 0; }
#listeners:empty, #state:empty, #sent:empty { display: none; }
.player small:last-child { display: block; margin-top: .35rem; font-size: .65rem; }
#gate.panel {
  position: relative; isolation: isolate; width: min(calc(100% - 2 * var(--space)), 1120px);
  max-width: 1120px !important; min-height: 24rem;
  margin: clamp(24px, 5vw, 78px) auto; padding: clamp(28px, 5vw, 74px);
  background: linear-gradient(90deg, #14152a 0, #191831b8 50%, transparent 80%), url('/hero.webp') center/cover;
  color: #f8f7fd; border-color: #4a465e;
}
#gate h1 { max-width: 18ch; margin: 0 0 1rem; font-size: clamp(2.25rem, 5vw, 4.6rem); line-height: 1.02; }
#gate :is(p,form) { max-width: min(100%, 36ch); }
#gate p { color: #e1ddee; }
#gate :is(input, select) { width: 100%; }
#gate button { margin: .45rem .4rem .25rem 0; }
.cards, .summary-grid, .metrics {
  display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 13rem),1fr)); gap: .85rem;
}
.card, .metric, .entry { background: var(--surface-raised); }
.card h3, .metric b { margin: 0 0 .35rem; }
.metric strong { color: var(--accent); }
.console { min-width: 0; }
.console section + section { margin-top: 1rem; }
.console .toolbar { margin-block: .8rem; }
form { display: grid; align-content: start; gap: .7rem; }
form button { justify-self: start; }
label { color: var(--muted); font-size: .91rem; }
input:not([type="range"],[type="checkbox"],[type="radio"],[type="color"]),
select, textarea, .sub input:not([type="checkbox"],[type="radio"]), .sub textarea {
  display: block; width: 100%; min-width: 0; min-height: 42px;
  color: var(--ink); background: var(--field); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .75rem; line-height: 1.4;
}
label > :is(input, select, textarea) { margin-top: .3rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }
input[type="color"] { width: 3.2rem; min-height: 40px; }
textarea { resize: vertical; }
#notes { grid-column: auto; align-self: start; }
#notes summary { cursor: pointer; font-weight: 690; min-height: 32px; padding: .15rem 0; }
#notes[open] summary { margin-bottom: .65rem; }
#notes label { display: block; }
.hint, #sent, .description { color: var(--muted); font-size: .88rem; }
.table-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .82rem; }
#section .table-scroll :is(th,td) { min-width: 5rem; }
#section :is(.pending,.warning), [role="alert"] { color: var(--ink); border-inline-start: 3px solid #dcad72; padding-inline-start: .6rem; }
@media (min-width: 1400px) {
  #inside.studio { --space: 38px; }
}
@media (max-width: 780px) {
  html { scroll-padding-top: 1rem; }
  header { position: static; min-height: 56px; gap: 8px 12px; }
  #inside.studio, .app-shell { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
  #inside.studio > *, .app-shell > * { width: 100%; }
  #navigation {
    position: static; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: .15rem;
    max-height: none; padding: 0 0 .32rem; overflow-x: auto; white-space: nowrap;
  }
  #navigation :is(a,button) { flex: none; min-height: 42px; }
  #gate.panel { width: calc(100% - 24px); margin: 18px auto; padding: 28px 20px; min-height: 17rem; }
  .hero, #inside .player { background-position: 61% center; }
  #track { max-width: 15ch; }
  #section, #notes, .console { padding: 16px; }
}
@media (max-width: 460px) {
  header { padding: 10px 14px; }
  header .brand img, header > b::before { width: 32px; height: 32px; }
  #state { font-size: .76rem; }
  #inside .player, #home .player { padding: 22px 16px; }
  #inside .player, .hero, #gate.panel {
    background-image: linear-gradient(90deg, #15162af2 0%, #17182fe5 46%, #19193178), url('/hero.webp');
    background-position: 63% center;
  }
  #wave { width: 72%; height: 30px; margin: .5rem 0; }
  #gate h1 { font-size: 2.4rem; }
  .player .volume { max-width: 16rem; }
  th, td { padding: .45rem; }
}
@media (prefers-reduced-motion: no-preference) {
  button, .button, #navigation a { transition: background-color .16s, color .16s, border-color .16s; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
/* The studio opens on its controls, with the same live audio element kept mounted. */
body[data-page="admin"] #inside > #section { grid-row: 1; background: transparent; padding: 0; border: 0; box-shadow: none; }
body[data-page="admin"] #inside > .player { grid-row: 2; }
#adminTabs { display: flex; flex-wrap: wrap; gap: .42rem; margin-bottom: 1rem; }
#adminTabs a { display: inline-flex; align-items: center; padding: .48rem .7rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--surface-raised); color: var(--muted); font-size: .85rem; text-decoration: none; }
#adminTabs a[aria-current="page"] { color: var(--ink); border-color: var(--violet); background: color-mix(in srgb,var(--violet) 16%,var(--surface)); }
#adminOutput:empty { display: none; }
#adminPanel > .module-title { margin: 1.4rem 0 1rem; font-size: clamp(1.3rem,2vw,2rem); }
.console .summary-grid .card { padding: .9rem 1rem; }
.console .summary-grid h3 { font-size: .82rem; font-weight: 500; color: var(--muted); letter-spacing: normal; }
.console .summary-grid strong { font-size: 1.22rem; }
.console .admin-block { padding: .95rem 0; border-top: 1px solid var(--line); }
.console .admin-block > h3 { margin-top: 0; }
.console fieldset { min-width: 0; border: 1px solid var(--line); border-radius: .7rem; }
.console .check { display: flex; align-items: center; gap: .55rem; }
.console code { overflow-wrap: anywhere; }
#coverArt { width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: .5rem; }
#artistLine:empty, #showLine:empty { display: none; }
@media(max-width:780px){
  body[data-page="admin"] #section { order: 1; }
  body[data-page="admin"] #inside > .player,body[data-page="admin"] #notes { order: 2; }
  #adminTabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .3rem; }
  #adminTabs a { flex-shrink: 0; }
  .console .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .4rem; }
  .console .summary-grid .card { padding: .7rem; overflow-wrap: anywhere; }
}

.skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#navigation { order: 0; }
.top-tools { display: flex; align-items: center; gap: .6rem; }
#micMeter { display: block; width: min(100%,24rem); height: 1.4rem; margin-bottom: .45rem; }
#coverArt[hidden] { display: none; }
@media(max-width:780px){ #adminTabs { order: 0; } }
