*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-sans);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

body { margin: 0; min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: default; opacity: .55; }
img, video { display: block; max-width: 100%; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { color: var(--accent-ink); background: var(--accent); }

.mono { font-family: var(--font-mono); }
.mono, .tabular { font-variant-numeric: tabular-nums; }

.slider-control {
  --slider-progress: 0%;
  --slider-thumb-size: 12px;
  position: relative;
  display: block;
  min-width: 0;
  height: 32px;
}

.slider-rail, .slider-fill, .slider-thumb, .slider-input {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.slider-rail, .slider-fill, .slider-thumb {
  inset-inline: calc(var(--slider-thumb-size) / 2);
  pointer-events: none;
}

.slider-rail, .slider-fill {
  height: 3px;
  border-radius: 2px;
}

.slider-rail { background: var(--line-strong); }
.slider-fill { background: var(--accent); clip-path: inset(0 calc(100% - var(--slider-progress)) 0 0); }
.slider-thumb { height: var(--slider-thumb-size); }
.slider-thumb::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: var(--slider-progress);
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
  margin-left: calc(var(--slider-thumb-size) / -2);
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.slider-input {
  appearance: none;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
}
.slider-input::-webkit-slider-thumb { appearance: none; width: var(--slider-thumb-size); height: var(--slider-thumb-size); }
.slider-input::-moz-range-thumb { box-sizing: border-box; border: 0; width: var(--slider-thumb-size); height: var(--slider-thumb-size); }
.slider-control:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.live-dot {
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.live-dot[data-live="false"] { background: var(--ink-muted); box-shadow: none; }

.toast {
  position: fixed;
  z-index: 20;
  inset-inline-end: max(16px, env(safe-area-inset-right));
  inset-block-end: max(16px, env(safe-area-inset-bottom));
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  overflow-wrap: anywhere;
}

.theme-switcher { display: inline-flex; gap: 5px; align-items: center; }
.theme-switcher button {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
}
.theme-switcher button::before {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--swatch, var(--accent));
}
.theme-switcher button:is([data-theme="jade"], [data-theme-id="jade"]) { --swatch: var(--jade); }
.theme-switcher button:is([data-theme="ado"], [data-theme-id="ado"]) { --swatch: var(--ado); }
.theme-switcher button:is([data-theme="terracotta"], [data-theme-id="terracotta"]) { --swatch: var(--terracotta); }
.theme-switcher button:hover { background: var(--surface-hover); }
.theme-switcher button:is([aria-pressed="true"], [aria-current="true"], .is-active) { border-color: var(--swatch, var(--accent)); }

.cover-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--bg);
}

/* Set --cover-image to url("…") on the stage. */
.cover-stage::before, .cover-stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -18%;
  pointer-events: none;
  background: center / cover no-repeat var(--cover-image, none);
  will-change: transform;
}
.cover-stage::before {
  filter: blur(40px) brightness(.42) saturate(.8);
  animation: ambientDriftA 26s ease-in-out infinite alternate;
}
.cover-stage::after {
  opacity: .46;
  filter: blur(68px) brightness(.64);
  animation: ambientDriftB 22s ease-in-out infinite alternate;
}
.cover-frame {
  position: relative;
  isolation: isolate;
  border-radius: var(--radius-panel);
}
.cover-frame::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 5%;
  border-radius: inherit;
  background: var(--accent);
  opacity: calc(.12 + clamp(0, var(--audio-energy), 1) * .17);
  filter: blur(30px);
  transform: scale(calc(1.05 + clamp(0, var(--audio-energy), 1) * .12));
  pointer-events: none;
}
.cover-frame > img, .cover-frame-image {
  border-radius: inherit;
  animation: coverBreath 18s ease-in-out infinite alternate;
}
@keyframes ambientDriftA {
  from { transform: translate3d(-4%, 2%, 0) scale(1.06); }
  to { transform: translate3d(4%, -3%, 0) scale(1.22); }
}
@keyframes ambientDriftB {
  from { transform: translate3d(4%, -3%, 0) scale(1.18); }
  to { transform: translate3d(-4%, 3%, 0) scale(1.07); }
}
@keyframes coverBreath {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(0, -1%, 0) scale(1.035); }
}

.lyric-sung { color: var(--ink); }
.lyric-upcoming { color: color-mix(in srgb, var(--ink) 56%, transparent); }
.lyric-sweep {
  position: relative;
  display: inline-block;
  background: linear-gradient(90deg, var(--ink) var(--sweep, 0%), color-mix(in srgb, var(--ink) 56%, transparent) 0);
  background-clip: text;
  color: transparent;
  text-shadow: none;
}
.lyric-sweep::before {
  content: "";
  position: absolute;
  inset: auto 0 -2px;
  height: 2.5px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--sweep, 0%), var(--line-strong) 0);
}
.lyric-interlude { color: var(--ink-secondary); }
.beat-dots { display: inline-flex; align-items: center; gap: 9px; }
.beat-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-strong);
}
.beat-dot:is(.is-active, .lit, .current) { background: var(--accent); }
.beat-dot.current { transform: scale(1.25); }

@media (prefers-reduced-motion: reduce) {
  .cover-stage::before, .cover-stage::after, .cover-frame > img, .cover-frame-image { animation: none; }
  .cover-frame::before { transform: none; }
}
