/* KW 5.1 — 10-foot UI. Sizes scale with the screen so it reads from the couch. */
:root {
  --bg: #030406;
  --panel: rgba(12, 15, 22, 0.72);
  --panel-solid: #0c0f16;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef1f7;
  --muted: #9aa3b5;
  --dim: #646d80;
  --accent: #f5b84a;
  --accent-2: #7cc7ff;
  --ok: #5fd38a;
  --warn: #f2b24c;
  --bad: #ff6b6b;
  --radius: 14px;
  --focus: 0 0 0 3px rgba(245, 184, 74, 0.95), 0 0 28px rgba(245, 184, 74, 0.45);
  --font: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Inter, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { font-size: clamp(14px, 1.04vw, 30px); }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; }
body { -webkit-font-smoothing: antialiased; user-select: none; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }
::selection { background: rgba(245, 184, 74, 0.35); }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; touch-action: none; }
#video { position: fixed; inset: 0; width: 100vw; height: 100vh; background: #000; z-index: 1; display: none; object-fit: contain; }
#video.on { display: block; }
/* a song's music video: always laid out (it keeps playing for the TV in the room), shown in the visualizer's place */
#musicvideo { position: fixed; inset: 0; width: 100vw; height: 100vh; background: #000; z-index: 1; object-fit: contain;
  opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }
#musicvideo.on { opacity: 1; }
#ui { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
#ui > .screen { pointer-events: auto; }
#toasts { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 6; display: flex; flex-direction: column; gap: 0.6rem; pointer-events: none; }

/* ------------------------------------------------------------------ splash */
.splash { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #121a2b 0%, #04060a 60%, #000 100%); transition: opacity 0.7s ease; }
.splash.hide { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1.4rem; }
.brand-mark { font-weight: 200; letter-spacing: 0.55em; font-size: 4.4rem; padding-left: 0.55em; color: #f6f2ea;
  text-shadow: 0 0 30px rgba(245, 184, 74, 0.35); }
.splash-sub { color: var(--muted); letter-spacing: 0.3em; text-transform: uppercase; font-size: 0.95rem; }
.splash-hint { color: var(--dim); font-size: 0.85rem; }

/* ------------------------------------------------------------------ buttons & focus */
.btn { display: inline-flex; align-items: center; gap: 0.6em; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  color: var(--text); border-radius: 999px; padding: 0.65em 1.25em; cursor: pointer; font-size: 1rem; line-height: 1;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #1a1205; border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: #ffc965; }
.btn-xl { font-size: 1.3rem; padding: 0.8em 2.2em; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-icon { padding: 0.6em; border-radius: 50%; }
.btn svg { width: 1.2em; height: 1.2em; flex: none; }
.btn.small { font-size: 0.85rem; padding: 0.5em 0.9em; }
.btn.active { background: rgba(245, 184, 74, 0.18); border-color: rgba(245, 184, 74, 0.6); }
:focus { outline: none; }
:focus-visible, .focus { box-shadow: var(--focus) !important; outline: none; }
.card:focus-visible { transform: scale(1.03); }

/* ------------------------------------------------------------------ screens */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; animation: fadeIn 0.35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen.scrim { background: linear-gradient(180deg, rgba(3, 4, 6, 0.86) 0%, rgba(3, 4, 6, 0.78) 50%, rgba(3, 4, 6, 0.92) 100%);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 1.6rem 2.6rem 0.8rem; flex: none; }
.topbar h1 { margin: 0; font-weight: 300; letter-spacing: 0.32em; text-transform: uppercase; font-size: 1.6rem; }
.topbar .spacer { flex: 1; }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0.6rem 2.6rem 4rem; scroll-behavior: smooth; }
.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 5px; }
.section-title { margin: 1.8rem 0 0.9rem; font-size: 0.85rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.empty { color: var(--muted); padding: 2rem 0; line-height: 1.6; max-width: 46rem; }
.empty code, .help code { font-family: var(--mono); background: rgba(255, 255, 255, 0.07); padding: 0.1em 0.4em; border-radius: 5px; font-size: 0.9em; }

/* ------------------------------------------------------------------ home */
#ui > .screen.home { justify-content: flex-end; pointer-events: none; }
.home > * { pointer-events: auto; }
.home .brand { position: absolute; top: 1.8rem; left: 2.6rem; pointer-events: none; }
.home .brand .brand-mark { font-size: 2rem; letter-spacing: 0.5em; padding-left: 0; text-align: left; }
.home .brand .room-name { color: var(--muted); letter-spacing: 0.25em; text-transform: uppercase; font-size: 0.8rem; margin-top: 0.35rem; }
.dock { display: flex; justify-content: center; gap: 1.2rem; padding: 0 2rem 2.4rem; }
.dock-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.55rem; width: 9.5rem; height: 7.2rem;
  border-radius: 20px; background: rgba(10, 13, 20, 0.62); border: 1px solid var(--line); cursor: pointer;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); color: var(--text); transition: transform 0.18s, background 0.18s; }
.dock-item svg { width: 2.1rem; height: 2.1rem; opacity: 0.92; }
.dock-item span { letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.85rem; }
.dock-item:hover, .dock-item:focus-visible { background: rgba(28, 33, 46, 0.8); transform: translateY(-4px); }
.room-tag { position: absolute; transform: translate(-50%, -120%); padding: 0.45em 0.9em; border-radius: 999px; background: rgba(8, 10, 16, 0.82);
  border: 1px solid var(--line); font-size: 0.85rem; white-space: nowrap; pointer-events: none; transition: opacity 0.2s; }
.room-tag .sub { color: var(--muted); margin-left: 0.5em; }
.room-hint { position: absolute; top: 2rem; right: 2.6rem; color: var(--dim); font-size: 0.85rem; letter-spacing: 0.06em; text-align: right; line-height: 1.6; }
.demo-banner { position: absolute; top: 1.8rem; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem 0.8rem 0.7rem 1.4rem; border-radius: 999px; background: rgba(8, 10, 16, 0.8); border: 1px solid var(--line);
  backdrop-filter: blur(12px); }
.demo-banner .title { letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.9rem; }
.demo-banner .status { color: var(--muted); font-size: 0.85rem; min-width: 10rem; }
.nowplaying { position: absolute; left: 2.6rem; bottom: 2.4rem; display: flex; align-items: center; gap: 0.9rem; padding: 0.6rem 0.9rem 0.6rem 0.6rem;
  border-radius: 16px; background: rgba(8, 10, 16, 0.75); border: 1px solid var(--line); max-width: 26rem; backdrop-filter: blur(12px); }
.nowplaying img, .nowplaying .cover-art { width: 3rem; height: 3rem; border-radius: 8px; object-fit: cover; flex: none; }
.nowplaying .np-text { min-width: 0; }
.nowplaying .np-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nowplaying .np-sub { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ cards & grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr)); gap: 1.4rem; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.card { position: relative; display: flex; flex-direction: column; border-radius: var(--radius); background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line); overflow: hidden; cursor: pointer; text-align: left; padding: 0; color: var(--text);
  transition: transform 0.18s, background 0.18s, box-shadow 0.18s; }
.card:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-3px); }
.card .thumb { position: relative; aspect-ratio: 16 / 9; background: #0b0e15 center / cover no-repeat; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .badges { position: absolute; left: 0.6rem; bottom: 0.6rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.card .body { padding: 0.85rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.card .title { font-size: 1.05rem; font-weight: 500; line-height: 1.25; }
.card .meta { color: var(--muted); font-size: 0.82rem; }
.card.poster .thumb { aspect-ratio: 2 / 3; }
.badge { display: inline-flex; align-items: center; gap: 0.3em; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.3em 0.55em; border-radius: 6px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(255, 255, 255, 0.16); color: #e9edf5; font-weight: 600; }
.badge.ok { color: var(--ok); border-color: rgba(95, 211, 138, 0.4); }
.badge.warn { color: var(--warn); border-color: rgba(242, 178, 76, 0.45); }
.badge.bad { color: var(--bad); border-color: rgba(255, 107, 107, 0.45); }
.badge.gold { color: var(--accent); border-color: rgba(245, 184, 74, 0.5); }
.badge svg { width: 1.15em; height: 1.15em; flex: none; }
/* audio quality (core/quality.js): hi-res gold, lossless blue, lossy plain; the numbers keep their case (kbps) */
.badge.q { gap: 0.5em; }
.badge .q-detail { text-transform: none; letter-spacing: 0.03em; font-weight: 500; opacity: 0.85; font-variant-numeric: tabular-nums; }
.badge.q-hires { color: var(--accent); border-color: rgba(245, 184, 74, 0.65);
  background: linear-gradient(135deg, rgba(245, 184, 74, 0.22), rgba(0, 0, 0, 0.6) 70%); box-shadow: 0 0 14px rgba(245, 184, 74, 0.2); }
.badge.q-lossless { color: var(--accent-2); border-color: rgba(124, 199, 255, 0.45); }
.badge.q-lossy { color: var(--muted); border-color: rgba(255, 255, 255, 0.12); font-weight: 500; }
.badge.q-video { color: #dfe5f0; font-weight: 500; text-transform: none; letter-spacing: 0.04em; }
.badges { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }

/* demos: one card style for shows and setup */
.section-head { display: flex; align-items: baseline; gap: 1rem; margin: 1.8rem 0 0.9rem; }
.section-head .section-title { margin: 0; }
.section-sub { color: var(--dim); font-size: 0.85rem; }
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr)); gap: 1.1rem; }
.demo-card { padding: 1.15rem 1.25rem 1rem; gap: 0.35rem; min-height: 10rem; }
.demo-card .ico { width: 2.6rem; height: 2.6rem; border-radius: 10px; display: grid; place-items: center; margin-bottom: 0.5rem;
  background: rgba(245, 184, 74, 0.1); color: var(--accent); }
.demo-card .ico svg { width: 1.6rem; height: 1.6rem; }
.demo-card .title { font-size: 1.12rem; }
.demo-card .line { color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.demo-card .meta { margin-top: auto; padding-top: 0.6rem; display: flex; gap: 0.45rem; color: var(--dim); font-size: 0.78rem; }

.xp { background: transparent; }
.xp.idle { cursor: none; }
.xp-title { position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none; transition: opacity 2.2s ease, transform 2.2s ease; }
.xp-title.hide { opacity: 0; transform: translateY(-8px); }
.xp-t1 { font-size: 3.4rem; font-weight: 200; letter-spacing: 0.3em; padding-left: 0.3em; text-transform: uppercase; color: #f4f1ea;
  text-shadow: 0 0 40px rgba(0, 0, 0, 0.8); }
.xp-t2 { margin-top: 0.9rem; font-size: 1.05rem; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(230, 236, 248, 0.62); }
.xp-load { margin: 2.2rem auto 0; width: 22rem; display: flex; flex-direction: column; gap: 0.7rem; align-items: center; }
.xp-load-track { width: 100%; height: 2px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; }
.xp-load-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.xp-load-text { color: var(--dim); font-size: 0.8rem; letter-spacing: 0.08em; }
.xp-controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 3.5rem 2.4rem 1.6rem; display: flex; flex-direction: column; gap: 0.8rem;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72)); transition: opacity 0.6s; }
.xp-row { display: flex; align-items: center; gap: 1rem; }
.xp-row .spacer { flex: 1; }
.xp-name { display: flex; flex-direction: column; gap: 0.2rem; }
.xp-name > div:first-child { letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.95rem; }
.xp-chapter { color: var(--accent); font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; min-height: 1em; }
.xp-bar { cursor: default; }
.xp-bar:hover { height: 0.5rem; }
.xp-map { position: absolute; right: 2rem; top: 1.6rem; width: 9.5rem; padding: 0.6rem; border-radius: 14px; background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line); transition: opacity 0.6s; pointer-events: none; }
.speaker-map { width: 100%; display: block; }
.speaker-map circle { filter: blur(2.5px); }
.xp.idle .xp-controls, .xp.idle .xp-map { opacity: 0; pointer-events: none; }
.xp .end-card { background: rgba(0, 0, 0, 0.55); }

.home .brand, .home .room-hint, .home .dock, .home .nowplaying { transition: opacity 2.6s ease; }
.home.immersive .brand, .home.immersive .room-hint, .home.immersive .dock, .home.immersive .nowplaying,
.home.immersive .room-tag, .home.immersive .demo-banner { opacity: 0; pointer-events: none; }
.xp-pill { position: absolute; top: 1.6rem; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 1rem;
  padding: 0.55rem 0.6rem 0.55rem 1.3rem; border-radius: 999px; background: rgba(8, 10, 16, 0.7); border: 1px solid var(--line);
  backdrop-filter: blur(12px); opacity: 0; pointer-events: none; transition: opacity 0.5s; }
.xp-pill.on { opacity: 1; pointer-events: auto; }
.xp-pill .title { letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.85rem; }

/* ------------------------------------------------------------------ detail */
.hero { position: relative; flex: none; padding: 1rem 2.6rem 1.6rem; display: flex; gap: 2rem; align-items: flex-end; min-height: 20rem; }
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center 30%; opacity: 0.35; filter: blur(2px) saturate(1.1);
  mask-image: linear-gradient(180deg, #000 30%, transparent 100%); -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent 100%); }
.hero-info { position: relative; display: flex; flex-direction: column; gap: 0.8rem; max-width: 60rem; }
.hero-title { font-size: 2.8rem; font-weight: 300; letter-spacing: 0.04em; margin: 0; line-height: 1.1; }
.hero-meta { color: var(--muted); display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 0.4rem; }
.notice { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.9rem 1.1rem; border-radius: 12px; line-height: 1.45; font-size: 0.92rem;
  background: rgba(242, 178, 76, 0.08); border: 1px solid rgba(242, 178, 76, 0.35); max-width: 60rem; }
.notice.ok { background: rgba(95, 211, 138, 0.07); border-color: rgba(95, 211, 138, 0.35); }
.notice svg { width: 1.3rem; height: 1.3rem; flex: none; margin-top: 0.05rem; }
.notice code { font-family: var(--mono); font-size: 0.85em; background: rgba(255, 255, 255, 0.07); padding: 0.1em 0.35em; border-radius: 4px; }

.scene-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: 1.2rem; }
.scene .thumb .time, .trailer .thumb .time { position: absolute; right: 0.6rem; bottom: 0.6rem; }
/* trailers: bigger posters than the movie grid, a line about each under the title */
.trailer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(24rem, 100%), 1fr)); gap: 1.4rem; }
.trailer .title { font-size: 1.15rem; }
.trailer .line { color: var(--muted); font-size: 0.86rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scene .star { position: absolute; top: 0.6rem; right: 0.6rem; color: var(--accent); }
.scene .note { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.chapters { display: flex; flex-direction: column; gap: 0.3rem; max-width: 50rem; }
.chapter { display: flex; gap: 1rem; padding: 0.6rem 0.9rem; border-radius: 10px; background: rgba(255, 255, 255, 0.03); cursor: pointer; border: 1px solid transparent; text-align: left; color: var(--text); }
.chapter:hover { background: rgba(255, 255, 255, 0.07); }
.chapter .t { color: var(--muted); font-family: var(--mono); min-width: 6rem; }

.editor { display: flex; flex-direction: column; gap: 0.6rem; max-width: 70rem; }
.edit-row { display: grid; grid-template-columns: 2.2rem 1fr 8rem 8rem auto auto; gap: 0.6rem; align-items: center; padding: 0.5rem;
  border-radius: 10px; background: rgba(255, 255, 255, 0.035); }
.edit-row .n { color: var(--dim); text-align: center; }
.input { background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); border-radius: 8px; padding: 0.55em 0.7em; width: 100%; user-select: text; }
.input:focus { border-color: rgba(245, 184, 74, 0.7); box-shadow: var(--focus); }
.input.mono { font-family: var(--mono); }
.input.invalid { border-color: var(--bad); }

/* ------------------------------------------------------------------ player */
.player { background: transparent; }
.player .overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; transition: opacity 0.35s;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.7) 0%, transparent 22%, transparent 70%, rgba(0, 0, 0, 0.8) 100%); }
.player.idle .overlay { opacity: 0; cursor: none; pointer-events: none; }
.player.idle { cursor: none; }
.player .p-top { padding: 1.6rem 2.4rem; display: flex; align-items: center; gap: 1rem; }
.player .p-title { font-size: 1.4rem; font-weight: 300; }
.player .p-scene { color: var(--accent); letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.85rem; }
.player .p-bottom { padding: 0 2.4rem 1.8rem; display: flex; flex-direction: column; gap: 0.9rem; }
.timeline { position: relative; height: 0.5rem; border-radius: 4px; background: rgba(255, 255, 255, 0.18); cursor: pointer; }
.timeline:hover { height: 0.7rem; }
.timeline .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.timeline .buf { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.22); border-radius: 4px; }
.timeline .mark { position: absolute; top: -0.35rem; bottom: -0.35rem; width: 3px; background: var(--accent-2); border-radius: 2px; transform: translateX(-1px); }
.timeline .span { position: absolute; top: 0; bottom: 0; background: rgba(124, 199, 255, 0.28); }
.controls { display: flex; align-items: center; gap: 0.7rem; }
.controls .time { font-family: var(--mono); color: var(--muted); font-size: 0.9rem; min-width: 11rem; }
.v-quality { display: inline-flex; align-items: center; }
.controls .spacer { flex: 1; }
.vol { width: 8rem; accent-color: var(--accent); }
.vol-icon { width: 1.3rem; height: 1.3rem; flex: none; }
.fade-black { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.6s; }
.end-card { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.75); }
.end-card .box { text-align: center; display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.end-card .box h2 { font-weight: 300; letter-spacing: 0.08em; margin: 0; }
.spinner { position: absolute; left: 50%; top: 50%; width: 3.2rem; height: 3.2rem; margin: -1.6rem; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent); animation: spin 0.9s linear infinite; display: none; }
.spinner.on { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ music */
.album { display: grid; grid-template-columns: 11rem 1fr; gap: 1.6rem; margin-bottom: 2.4rem; }
.cover-art { width: 100%; aspect-ratio: 1; border-radius: 12px; object-fit: cover; background: #10131b; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.album h2 { margin: 0 0 0.2rem; font-weight: 400; font-size: 1.4rem; }
.tracks { display: flex; flex-direction: column; margin-top: 0.8rem; }
.track { display: grid; grid-template-columns: 2.4rem 1fr auto 5rem; gap: 1rem; align-items: center; padding: 0.7rem 0.8rem; border-radius: 10px;
  cursor: pointer; text-align: left; background: transparent; border: 1px solid transparent; color: var(--text); }
.track:hover { background: rgba(255, 255, 255, 0.06); }
.track.playing { background: rgba(245, 184, 74, 0.1); }
.track .no { color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.track .dur { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.track .tt { min-width: 0; }
.track .tt div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .tt .sub { color: var(--muted); font-size: 0.8rem; }

/* ------------------------------------------------------------------ visualizer */
.vizscreen { background: transparent; }
.vizscreen.idle { cursor: none; }
.vizscreen .v-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; transition: opacity 0.5s; }
.vizscreen.idle .v-overlay { opacity: 0; pointer-events: none; }
.vizscreen .v-bar { padding: 0 2.4rem 1.8rem; display: flex; flex-direction: column; gap: 0.8rem;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.65)); padding-top: 4rem; }
.titlecard { position: absolute; left: 3rem; bottom: 22%; pointer-events: none; transition: opacity 1.2s ease, transform 1.2s ease; }
.titlecard.hide { opacity: 0; transform: translateY(10px); }
.titlecard .t1 { font-size: 3.6rem; font-weight: 200; letter-spacing: 0.06em; text-shadow: 0 2px 30px rgba(0, 0, 0, 0.7); }
.titlecard .t2 { font-size: 1.3rem; color: rgba(255, 255, 255, 0.75); letter-spacing: 0.2em; text-transform: uppercase; margin-top: 0.4rem; }
.titlecard .t3 { font-size: 0.9rem; color: rgba(255, 255, 255, 0.5); letter-spacing: 0.25em; text-transform: uppercase; margin-top: 0.9rem; }
.sections { position: relative; height: 0.55rem; border-radius: 4px; overflow: hidden; background: rgba(255, 255, 255, 0.1); cursor: pointer; }
.sections .seg { position: absolute; top: 0; bottom: 0; border-right: 1px solid rgba(0, 0, 0, 0.6); }
.sections .head { position: absolute; top: -0.2rem; bottom: -0.2rem; width: 3px; background: #fff; box-shadow: 0 0 8px #fff; }
.hud { position: absolute; top: 1.4rem; right: 1.4rem; padding: 1rem 1.2rem; border-radius: 12px; background: rgba(0, 0, 0, 0.62);
  font-family: var(--mono); font-size: 0.78rem; line-height: 1.55; color: #cfd7e6; min-width: 19rem; pointer-events: none; white-space: pre; }
.hud .beat { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.live-badge { position: absolute; top: 1.5rem; left: 1.5rem; }

/* ------------------------------------------------------------------ settings */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(26rem, 100%), 1fr)); gap: 1.4rem; align-items: start; }
.panel { border-radius: var(--radius); background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); padding: 1.3rem 1.4rem; display: flex; flex-direction: column; gap: 0.9rem; }
.panel h3 { margin: 0; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.85rem; color: var(--muted); }
.row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.row .label { flex: 1; min-width: 10rem; }
.row .label small { display: block; color: var(--dim); font-size: 0.78rem; margin-top: 0.15rem; line-height: 1.35; }
.seg-ctl { display: inline-flex; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); padding: 0.2rem; }
.seg-ctl button { border: 0; background: transparent; padding: 0.45em 0.9em; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.seg-ctl button.on { background: rgba(245, 184, 74, 0.2); color: var(--accent); }
.range { accent-color: var(--accent); width: 12rem; }
.codec-table { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 1rem; font-size: 0.9rem; }
.codec-table .k { color: var(--muted); }
.speaker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(8.5rem, 100%), 1fr)); gap: 0.6rem; }
.speaker-grid .btn { justify-content: center; border-radius: 12px; min-width: 0; white-space: normal; text-align: center; }
.sync-flash { width: 5rem; height: 5rem; border-radius: 50%; background: #222; transition: background 0.03s; flex: none; }
.sync-flash.on { background: #fff; box-shadow: 0 0 40px #fff; }
.help { color: var(--muted); font-size: 0.85rem; line-height: 1.55; }

/* ------------------------------------------------------------------ performance overlay */
.perf { position: fixed; left: 0.6rem; top: 0.6rem; z-index: 7; pointer-events: none; white-space: pre; font-family: var(--mono);
  font-size: 0.72rem; line-height: 1.5; color: #d6dded; background: rgba(0, 0, 0, 0.72); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.55rem 0.75rem; max-width: calc(100vw - 1.2rem); overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ toasts */
.toast { pointer-events: auto; background: rgba(12, 15, 22, 0.92); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1.1rem;
  max-width: 26rem; font-size: 0.92rem; line-height: 1.4; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); animation: fadeIn 0.3s ease both; }
.toast.warn { border-color: rgba(242, 178, 76, 0.5); }
.toast.bad { border-color: rgba(255, 107, 107, 0.5); }

@media (max-width: 800px) {
  html { font-size: 14px; }
  .dock { gap: 0.6rem; flex-wrap: wrap; }
  .dock-item { width: 6.6rem; height: 5.6rem; }
  .album { grid-template-columns: 6rem 1fr; }
  .edit-row { grid-template-columns: 1fr 1fr; }
  .hero-title { font-size: 2rem; }
}
/* ------------------------------------------------------------------ phones */
.xp-rotate { display: none; }
@media (max-width: 640px) {
  .topbar { padding: 1rem 1rem 0.6rem; gap: 0.6rem; }
  .topbar h1 { font-size: 1.15rem; letter-spacing: 0.22em; white-space: nowrap; }
  .topbar .btn .lbl { display: none; }
  .scroll { padding: 0.4rem 1rem 3rem; }
  .section-head { flex-direction: column; gap: 0.2rem; margin: 1.4rem 0 0.7rem; }
  /* demos: a compact list, icon beside the text */
  .demo-grid { gap: 0.7rem; }
  .demo-card { display: grid; grid-template-columns: 2.6rem 1fr; column-gap: 0.9rem; row-gap: 0.15rem; align-items: center;
    min-height: 0; padding: 0.85rem 1rem; }
  .demo-card .ico { grid-row: 1 / span 3; margin: 0; }
  .demo-card .meta { padding-top: 0.15rem; }
  /* home */
  .home .brand { top: 1.1rem; left: 1.1rem; }
  .home .brand .brand-mark { font-size: 1.35rem; letter-spacing: 0.42em; }
  .home .brand .room-name { font-size: 0.68rem; }
  .room-hint { top: auto; left: 0; right: 0; bottom: calc(6.8rem + env(safe-area-inset-bottom)); text-align: center; font-size: 0.75rem; }
  .demo-banner, .xp-pill { top: 4.3rem; left: 1rem; right: 1rem; transform: none; justify-content: space-between; gap: 0.6rem;
    padding: 0.45rem 0.45rem 0.45rem 1rem; }
  .demo-banner .status { min-width: 0; flex: 1; }
  .dock { gap: 0.5rem; padding: 0 0.8rem calc(1.1rem + env(safe-area-inset-bottom)); flex-wrap: nowrap; }
  .dock-item { flex: 1; width: auto; height: 4.6rem; border-radius: 14px; gap: 0.4rem; }
  .dock-item svg { width: 1.5rem; height: 1.5rem; }
  .dock-item span { font-size: 0.62rem; letter-spacing: 0.12em; }
  .nowplaying { left: 0.8rem; right: 0.8rem; bottom: calc(6.3rem + env(safe-area-inset-bottom)); }
  #toasts { left: 0.8rem; right: 0.8rem; top: calc(0.8rem + env(safe-area-inset-top)); bottom: auto; }
  .toast { max-width: none; }
  /* music: cover and title side by side, the tracks full width underneath */
  .album { grid-template-columns: 4.2rem 1fr; column-gap: 0.9rem; row-gap: 0.1rem; align-items: center; margin-bottom: 1.6rem; }
  .album > div:not(.cover-art) { display: contents; }
  .album > :first-child { grid-row: 1 / span 2; font-size: 1.6rem !important; }
  .album h2 { grid-column: 2; font-size: 1.15rem; align-self: end; }
  .album > div > .muted { grid-column: 2; align-self: start; }
  .album .tracks { grid-column: 1 / -1; }
  .track { grid-template-columns: 1.4rem 1fr auto 2.8rem; gap: 0.5rem; padding: 0.65rem 0.3rem; }
  /* room for the title: quality stays, the video badge keeps its icon, the analysis status goes */
  .track .badges .st, .track .q-video .lbl { display: none; }
  .badge .q-detail { display: none; }
  /* full-screen pieces */
  .xp-title { top: 34%; }
  .xp-t1 { font-size: 1.6rem; letter-spacing: 0.16em; padding: 0 1rem; }
  .xp-t2 { font-size: 0.72rem; letter-spacing: 0.12em; padding: 0 1.5rem; line-height: 1.5; }
  .xp-controls { padding: 2.4rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
  .xp-controls .badge { display: none; }
  .xp-map { width: 6rem; right: 0.8rem; top: 0.8rem; }
  /* movie player and visualizer */
  .player .p-top { padding: 1rem; }
  .player .p-title { font-size: 1.05rem; }
  .player .p-bottom { padding: 0 1rem calc(1rem + env(safe-area-inset-bottom)); }
  .controls { flex-wrap: wrap; gap: 0.4rem; }
  .controls .time { min-width: 0; font-size: 0.8rem; }
  .vizscreen .v-bar { padding: 3rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
  .titlecard { left: 1.2rem; right: 1.2rem; bottom: 26%; }
  .titlecard .t1 { font-size: 2.2rem; }
  .titlecard .t2 { font-size: 0.9rem; }
  .hud { left: 0.8rem; right: 0.8rem; min-width: 0; font-size: 0.66rem; }
}
/* touch devices: iOS and Android ignore a page's volume (the side buttons set it) */
@media (hover: none) and (pointer: coarse) {
  .vol, .vol-icon { display: none; }
}
/* the full-screen pieces are composed for a wide screen */
@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  .xp-rotate { display: block; margin-top: 1.6rem; font-size: 0.75rem; letter-spacing: 0.12em; color: rgba(230, 236, 248, 0.5); }
}
/* phones held sideways: short screens, and keep clear of the notch */
@media (max-height: 500px) and (orientation: landscape) {
  .home .brand { top: 0.8rem; left: max(1.2rem, env(safe-area-inset-left)); }
  .room-hint { display: none; }
  .dock { padding-bottom: 0.8rem; }
  .dock-item { height: 4.2rem; width: 7rem; gap: 0.35rem; }
  .dock-item svg { width: 1.4rem; height: 1.4rem; }
  .demo-banner, .xp-pill { top: 0.8rem; }
  .topbar { padding: 0.8rem max(1.2rem, env(safe-area-inset-right)) 0.4rem max(1.2rem, env(safe-area-inset-left)); }
  .scroll { padding-left: max(1.2rem, env(safe-area-inset-left)); padding-right: max(1.2rem, env(safe-area-inset-right)); }
  .xp-title { top: 28%; }
  .xp-t1 { font-size: 2rem; }
  .xp-controls { padding: 1.2rem max(1.2rem, env(safe-area-inset-right)) 0.8rem max(1.2rem, env(safe-area-inset-left)); }
  .xp-map { width: 6.5rem; }
  .player .p-top, .player .p-bottom, .vizscreen .v-bar { padding-left: max(1.2rem, env(safe-area-inset-left)); padding-right: max(1.2rem, env(safe-area-inset-right)); }
  .player .p-top { padding-top: 0.8rem; padding-bottom: 0.4rem; }
  .player .p-bottom, .vizscreen .v-bar { padding-bottom: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
