:root {
  --bg: #08090d;
  --ink: #f4efe8;
  --muted: #a39d95;
  --faint: rgba(244, 239, 232, .5);
  --line: rgba(255, 255, 255, .09);
  --glass: rgba(15, 16, 22, .62);
  --accent: #ff8a3d;
  --accent2: #63d6c8;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --pad: 28px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }

#stage { position: fixed; inset: 0; cursor: grab; touch-action: none; }
#stage:active { cursor: grabbing; }
#stage canvas { display: block; width: 100%; height: 100%; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label3d {
  position: absolute; left: 0; top: 0;
  margin: -24px 0 0 8px;
  font: 600 10px/1 var(--sans);
  letter-spacing: .06em;
  color: rgba(244, 239, 232, .78);
  padding: 3px 5px;
  border-radius: 5px;
  background: rgba(8, 9, 13, .55);
  white-space: nowrap;
  will-change: transform;
}
.label3d.on { color: #120b06; background: var(--accent); }
.label3d.lfe { color: var(--accent2); margin: 6px 0 0 -26px; background: transparent; letter-spacing: .1em; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}

/* header */
.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) var(--pad) 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: baseline; gap: 12px; color: var(--ink); text-decoration: none; }
.brand .mark { font-weight: 650; font-size: 12px; letter-spacing: .34em; }
.brand .sub { font-size: 12px; color: var(--muted); letter-spacing: .18em; }
.top-right { display: flex; align-items: center; gap: 12px; }
.tip { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.tip svg { width: 16px; height: 16px; color: var(--accent2); }
#track-select { background: var(--glass); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }

/* now playing */
.now { position: fixed; top: 74px; left: var(--pad); max-width: min(520px, 46vw); pointer-events: none; }
.eyebrow { margin: 0 0 10px; font-size: 11px; letter-spacing: .26em; color: var(--accent); }
h1 {
  margin: 0;
  font: italic 500 clamp(30px, 4.2vw, 56px)/1.04 var(--serif);
  letter-spacing: -.01em;
  text-wrap: balance;
}
.artist { margin: 10px 0 0; font-size: 13px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; padding: 0; }
.chips li { font-size: 11px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--faint); }
.chips li.lfe { color: var(--accent2); border-color: color-mix(in srgb, var(--accent2) 35%, transparent); }

/* object readout */
.inspect { position: fixed; top: 74px; right: var(--pad); width: 236px; padding: 14px 16px 12px; }
.inspect-head { display: flex; align-items: center; justify-content: space-between; }
.inspect-head b { font-size: 12px; letter-spacing: .12em; color: var(--accent); font-weight: 600; }
.inspect-head button { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; }
.inspect p { margin: 0; }
.inspect .where { margin-top: 8px; font: italic 500 22px/1.25 var(--serif); }
.inspect .height { margin-top: 4px; font-size: 13px; color: var(--ink); }
.inspect .level { margin-top: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.solo {
  margin-top: 12px; width: 100%; min-height: 40px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 11px; font-size: 13px; font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--ink);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
  transition: background .15s, color .15s, box-shadow .15s;
}
.solo svg { width: 17px; height: 17px; color: var(--accent); }
.solo.holding { background: var(--accent); color: #140b05; box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 55%, transparent); }
.solo.holding svg { color: #140b05; }
.solo.switch { border-color: var(--line); background: rgba(255, 255, 255, .03); color: var(--muted); font-weight: 500; font-size: 12px; }
.solo.switch svg { color: var(--accent2); }

/* start */
.start {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px 14px 14px;
  border-radius: 99px;
  text-align: left;
  opacity: .55;
  transition: opacity .3s, transform .3s;
}
.start.ready { opacity: 1; }
.start.ready:hover { transform: translate(-50%, -50%) scale(1.03); }
.start[hidden] { display: none; }
.start-icon { flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #140b05; display: grid; place-items: center; box-shadow: 0 0 34px color-mix(in srgb, var(--accent) 55%, transparent); }
.start-icon svg { width: 22px; height: 22px; fill: currentColor; stroke: none; margin-left: 3px; }
.start-text b { display: block; font-size: 16px; font-weight: 600; }
.start-text small { font-size: 12px; color: var(--muted); }

/* bottom: A/B + dock */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 var(--pad) calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none; }
.bottom > * { pointer-events: auto; }
.ab {
  position: fixed; right: var(--pad); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; padding: 5px; width: 212px;
}
.ab button {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid transparent; background: none; border-radius: 13px;
  padding: 11px 12px; text-align: left; color: var(--muted);
  transition: background .2s, color .2s, border-color .2s;
}
.ab button svg { width: 24px; height: 24px; flex: none; }
.ab button b { display: block; font-size: 14px; font-weight: 600; }
.ab button small { font-size: 11px; color: var(--muted); }
.ab button:hover { color: var(--ink); }
.ab button[aria-checked="true"] { color: var(--ink); background: rgba(255, 255, 255, .06); border-color: var(--line); }
.ab button[data-mode="binaural"][aria-checked="true"] svg,
.ab button[data-mode="realtime"][aria-checked="true"] svg { color: var(--accent2); }
.ab button[data-mode="stereo"][aria-checked="true"] svg { color: var(--ink); }
.ab button[hidden] { display: none; }
.ab button em {
  font-style: normal; font-size: 9px; font-weight: 600; letter-spacing: .08em;
  margin-left: 6px; padding: 1px 5px; border-radius: 4px; vertical-align: 2px;
  color: var(--accent2); border: 1px solid color-mix(in srgb, var(--accent2) 45%, transparent);
}
.ab button.loading { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }

.dock { width: min(1080px, 100%); padding: 14px 18px 10px; }
.transport { display: flex; align-items: center; gap: 16px; }
.play {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--accent); color: #140b05; display: grid; place-items: center;
  transition: transform .15s, opacity .2s;
}
.play:disabled { opacity: .35; }
.play:not(:disabled):active { transform: scale(.94); }
.play svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.play .i-play { margin-left: 2px; }
.play .i-pause, .play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }
#wave { flex: 1; min-width: 0; height: 40px; cursor: pointer; touch-action: none; border-radius: 6px; }
.clock { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tools { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 10px; }
.views { display: flex; gap: 4px; flex: none; }
.views button, .toggles label {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); background: rgba(255, 255, 255, .02);
  border-radius: 9px; padding: 6px 11px; min-height: 32px;
}
.views button[aria-pressed="true"] { color: var(--ink); border-color: rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .07); }
.meters { display: flex; align-items: flex-end; gap: 3px; min-width: 0; overflow: hidden; }
.meter { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; padding: 2px 1px; color: var(--muted); }
.meter i { position: relative; display: block; width: 8px; height: 24px; border-radius: 3px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.meter s { position: absolute; inset: 0; background: var(--accent); transform-origin: bottom; transform: scaleY(.04); border-radius: 3px; }
.meter span { font-size: 9px; line-height: 1; font-variant-numeric: tabular-nums; }
.meter.on span { color: var(--accent); }
.meter.on i { box-shadow: 0 0 0 1px var(--accent); }
.meter.lfe s { background: var(--accent2); }
.meter.lfe span { color: var(--accent2); }
.toggles { display: flex; align-items: center; gap: 6px; flex: none; }
.toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.toggles input[type="checkbox"] { accent-color: var(--accent); margin: 0; }
.vol input { width: 76px; accent-color: var(--accent); }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; min-height: 18px; }
.status { margin: 0; font-size: 11px; color: var(--muted); }
.about { position: relative; font-size: 11px; color: var(--muted); }
.about summary { cursor: pointer; list-style: none; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: " ＋"; }
.about[open] summary::after { content: " －"; }
.about-body {
  position: absolute; right: 0; bottom: calc(100% + 14px);
  width: min(420px, calc(100vw - 40px));
  padding: 14px 16px; border-radius: 14px;
  background: rgba(15, 16, 22, .94); border: 1px solid var(--line);
  color: var(--ink); line-height: 1.75;
}
.about-body p { margin: 0 0 8px; font-size: 12px; }
.about-body p:last-child { margin: 0; color: var(--muted); }

.hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: 168px; margin: 0; font-size: 11px; color: rgba(244, 239, 232, .38); pointer-events: none; white-space: nowrap; }

body[data-mode="stereo"] .eyebrow { color: var(--muted); }

/* tablet */
@media (max-width: 980px) {
  :root { --pad: 18px; }
  .ab { width: 180px; }
  .ab button small { display: none; }
  .meters { display: none; }
}

/* phone */
@media (max-width: 680px) {
  :root { --pad: 14px; }
  .top { padding-top: calc(12px + env(safe-area-inset-top)); }
  .brand .sub { display: none; }
  .now { top: 46px; max-width: calc(100vw - 28px); }
  .eyebrow { margin-bottom: 6px; font-size: 10px; }
  h1 { font-size: 30px; }
  .artist { margin-top: 6px; font-size: 11px; }
  .chips { margin-top: 10px; }
  .inspect { top: auto; bottom: 252px; right: var(--pad); left: var(--pad); width: auto; padding: 10px 14px; }
  .inspect .where { font-size: 18px; margin-top: 4px; }
  .bottom { gap: 8px; }
  .ab { position: static; transform: none; width: 100%; flex-direction: row; }
  .ab button { flex: 1; justify-content: center; padding: 9px 6px; gap: 6px; min-width: 0; }
  .ab button svg { width: 18px; height: 18px; }
  .ab button b { font-size: 12.5px; white-space: nowrap; }
  .ab button em { display: none; }
  .dock { padding: 12px 12px 8px; }
  .transport { gap: 10px; }
  .play { width: 42px; height: 42px; }
  .clock { font-size: 11px; }
  #wave { height: 34px; }
  .tools { gap: 8px; }
  .views button { padding: 5px 9px; }
  .toggles .vol { display: none; }
  .toggles label { padding: 5px 8px; }
  .hint { bottom: auto; top: 50%; display: none; }
  .start { top: 46%; width: max-content; max-width: calc(100vw - 40px); padding-right: 20px; }
  .start-text small { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.toggles label[hidden] { display: none; }

.notice { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 20; width: min(380px, calc(100vw - 32px)); padding: 22px 22px 18px; border-radius: 18px; background: rgba(15, 16, 22, .94); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.notice[hidden] { display: none; }
.notice b { display: block; font-size: 17px; font-weight: 600; }
.notice p { margin: 10px 0 18px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.notice-actions { display: flex; gap: 8px; justify-content: flex-end; }
.notice-actions button { border: 1px solid var(--line); background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 9px 16px; font-size: 13px; }
.notice-actions .primary { background: var(--accent2); color: #06201d; border-color: transparent; font-weight: 600; }
/* notice: gradient card that fades and rises in */
.notice {
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--accent2) 30%, transparent), transparent 60%),
    radial-gradient(120% 90% at 100% 100%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%),
    linear-gradient(160deg, rgba(24, 26, 34, .96), rgba(12, 13, 18, .96));
  border: 1px solid color-mix(in srgb, var(--accent2) 30%, rgba(255, 255, 255, .08));
  animation: notice-in .9s cubic-bezier(.2, .8, .2, 1);
}
@keyframes notice-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 14px)) scale(.96); filter: blur(4px); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
}
@media (prefers-reduced-motion: reduce) { .notice { animation: none; } }
.notice.closing { animation: notice-out .7s ease forwards; }
@keyframes notice-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
  to { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(.97); filter: blur(4px); }
}

/* auto-rotate switch: its own small box on the left */
.rotate-box {
  position: fixed; left: var(--pad); top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 7px;
  padding: 9px 13px; border-radius: 12px;
  font-size: 12px; color: var(--muted); cursor: pointer; -webkit-user-select: none; user-select: none;
}
.rotate-box input { accent-color: var(--accent); margin: 0; }
.rotate-box[hidden] { display: none; }
@media (max-width: 680px) { .rotate-box { top: 168px; transform: none; padding: 7px 11px; } }
@media (max-width: 680px) {
  .brand { flex-direction: column; gap: 3px; }
  .brand .sub { display: block; font-size: 10px; letter-spacing: .08em; }
  .tip { display: none; }
}

/* song picker: full select on desktop, a compact "更多歌曲" button on phones */
.track-more { position: relative; display: flex; align-items: center; }
.track-more[hidden] { display: none; }
.track-more > span { display: none; }
@media (max-width: 680px) {
  .track-more > span {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--ink); white-space: nowrap;
    padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass);
  }
  .track-more > span::after { content: "⌃⌄"; font-size: 9px; letter-spacing: -1px; color: var(--muted); }
  .track-more select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
  /* phones: drop the big title and artist (they are on the 3D screen); lead with the brand line */
  .now { top: calc(68px + env(safe-area-inset-top)); }
  .now h1, .now .artist { display: none; }
  .eyebrow { margin-bottom: 0; }
  .chips { margin-top: 10px; }
  .brand .mark { font-size: 13px; }
  .brand .sub { font-size: 11px; color: var(--ink); opacity: .8; }
  .rotate-box { top: calc(138px + env(safe-area-inset-top)); }
}

.solo-tip { margin: 8px 0 0 !important; font-size: 11px; color: var(--muted); text-align: center; }
.solo-tip[hidden] { display: none; }
@media (max-width: 680px) {
  /* object card: small, top-right, essentials only */
  .inspect { top: calc(120px + env(safe-area-inset-top)); bottom: auto; left: auto; right: var(--pad); width: 172px; padding: 10px 12px 10px; border-radius: 14px; }
  .inspect-head b { font-size: 11px; }
  .inspect .where { font-size: 16px; margin-top: 4px; }
  .inspect .height { font-size: 11px; margin-top: 2px; }
  .inspect .level, .solo-tip { display: none !important; }
  .solo { margin-top: 8px; min-height: 34px; font-size: 12px; gap: 6px; }
  .solo svg { width: 14px; height: 14px; }
}

.rt-hint {
  margin: 12px 0 0; max-width: 300px; padding: 8px 11px; border-radius: 10px;
  font-size: 12px; line-height: 1.55; color: var(--ink);
  background: color-mix(in srgb, var(--accent2) 12%, rgba(15, 16, 22, .6));
  border: 1px solid color-mix(in srgb, var(--accent2) 35%, transparent);
  pointer-events: none;
}
.rt-hint b { color: var(--accent2); font-weight: 600; }
.rt-hint[hidden] { display: none; }
@media (max-width: 680px) { .rt-hint { margin-top: 8px; max-width: 190px; font-size: 11px; padding: 6px 9px; } }

/* buffering: a spinning ring around the play button */
.play { position: relative; }
.play.buffering::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--accent); border-right-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.start:not(.ready) .start-icon { animation: pulse 1s ease-in-out infinite alternate; }
