/* ==========================================================================
   Karaoke Studio — 我喜歡你 · 芒果醬 Mango Jump
   Design tokens derived from the single artwork (pink / cyan / cream yellow)
   ========================================================================== */
:root {
  /* Surfaces */
  --bg: #0a0b12;
  --surface: rgba(18, 20, 31, 0.66);
  --surface-strong: rgba(14, 16, 26, 0.88);
  --fill-1: rgba(255, 255, 255, 0.05);
  --fill-2: rgba(255, 255, 255, 0.09);
  --fill-3: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  /* Text */
  --text: #f6f7fb;
  --text-2: rgba(236, 238, 246, 0.74);
  --text-3: rgba(236, 238, 246, 0.52);

  /* Brand */
  --pink: #ff8fd6;
  --pink-strong: #ff66c4;
  --pink-soft: rgba(255, 143, 214, 0.16);
  --cyan: #63e4ee;
  --cyan-soft: rgba(99, 228, 238, 0.14);
  --cream: #ffe28a;

  --accent: var(--pink);
  --on-accent: #1a0b16;
  --ruby: var(--cream);
  --sung: var(--pink);
  --unsung: rgba(255, 255, 255, 0.94);

  /* Type */
  --font-ui: 'Plus Jakarta Sans', 'Noto Sans TC', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-cjk: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.18);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.3);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --dur-fast: 150ms;
  --dur-base: 240ms;
  --dur-slow: 420ms;

  /* Layout */
  --topbar-h: 64px;
  --dock-h: 92px;
  --side-w: 360px;
  --gutter: 24px;

  /* Z-index scale */
  --z-ambient: 0;
  --z-content: 10;
  --z-chrome: 40;
  --z-popover: 60;
  --z-toast: 80;

  /* User font scale (set by JS) */
  --font-scale: 1;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;

  display: grid;
  height: 100dvh;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr) var(--dock-h);
  grid-template-areas:
    "top   top"
    "side  stage"
    "dock  dock";
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

svg {
  display: block;
  flex-shrink: 0;
}

[hidden] {
  display: none !important;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ==========================================================================
   Ambient Backdrop
   ========================================================================== */
.ambient {
  position: fixed;
  inset: 0;
  z-index: var(--z-ambient);
  overflow: hidden;
  pointer-events: none;
}

.ambient-art {
  position: absolute;
  inset: -12%;
  background-size: cover;
  background-position: center;
  filter: blur(90px) saturate(1.6) brightness(0.42);
  transform: scale(1.1);
  animation: ambient-drift 40s ease-in-out infinite alternate;
}

.ambient-glow {
  position: absolute;
  width: 44vmax;
  height: 44vmax;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.22;
  transition: opacity 1.2s var(--ease-out);
}

.glow-pink {
  top: -14vmax;
  right: -8vmax;
  background: var(--pink-strong);
}

.glow-cyan {
  bottom: -18vmax;
  left: -10vmax;
  background: #1fb6c9;
}

body.is-playing .ambient-glow {
  opacity: 0.32;
}

.ambient-shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 70% 30%, transparent 0%, rgba(10, 11, 18, 0.55) 70%),
    linear-gradient(180deg, rgba(10, 11, 18, 0.35) 0%, rgba(10, 11, 18, 0.78) 100%);
}

@keyframes ambient-drift {
  from {
    transform: scale(1.1) translate3d(-2%, -1%, 0) rotate(0deg);
  }

  to {
    transform: scale(1.22) translate3d(2%, 2%, 0) rotate(4deg);
  }
}

/* ==========================================================================
   Shared Controls
   ========================================================================== */
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--text-2);
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  background: var(--fill-2);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ==========================================================================
   Top Bar
   ========================================================================== */
.topbar {
  grid-area: top;
  position: relative;
  z-index: var(--z-chrome);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 var(--gutter);
  padding-top: env(safe-area-inset-top);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--on-accent);
  background: linear-gradient(140deg, var(--pink) 0%, #ffb3e4 45%, var(--cyan) 130%);
  box-shadow: 0 6px 18px rgba(255, 102, 196, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-2);
  white-space: nowrap;
}

.brand-name b {
  font-weight: 800;
  color: var(--text);
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pill toggle with switch */
.pill-toggle {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 10px;
  border-radius: var(--r-full);
  background: var(--fill-1);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.pill-toggle:hover {
  background: var(--fill-2);
  color: var(--text);
}

.switch {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: var(--r-full);
  background: var(--fill-3);
  transition: background var(--dur-base) var(--ease-out);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform var(--dur-base) var(--ease-spring);
}

.pill-toggle[aria-pressed="true"] {
  color: var(--text);
  border-color: rgba(255, 226, 138, 0.28);
}

.pill-toggle[aria-pressed="true"] .switch {
  background: var(--cream);
}

.pill-toggle[aria-pressed="true"] .switch::after {
  transform: translateX(12px);
}

/* Stepper */
.stepper {
  height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-full);
  background: var(--fill-1);
  border: 1px solid var(--line);
  padding: 0 3px;
}

.stepper-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}

.stepper-btn svg {
  width: 16px;
  height: 16px;
}

.stepper-btn:hover:not(:disabled) {
  background: var(--fill-2);
  color: var(--text);
}

.stepper-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stepper-value {
  min-width: 46px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.icon-exit-fs {
  display: none;
}

body.is-fullscreen .icon-enter-fs {
  display: none;
}

body.is-fullscreen .icon-exit-fs {
  display: block;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  grid-area: side;
  position: relative;
  z-index: var(--z-content);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 8px 8px 24px var(--gutter);
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.artwork {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #1b1d2a;
  box-shadow: var(--shadow-3);
  flex-shrink: 0;
  transform: scale(0.97);
  transition: transform var(--dur-slow) var(--ease-out), box-shadow var(--dur-slow) var(--ease-out);
}

body.is-playing .artwork {
  transform: scale(1);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 40px rgba(255, 102, 196, 0.18);
}

.artwork img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.artwork::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.artwork-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--r-full);
  background: rgba(10, 11, 18, 0.62);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

/* Equalizer bars */
.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.eq i {
  width: 3px;
  height: 4px;
  border-radius: 2px;
  background: var(--pink);
  transform-origin: bottom;
}

body.is-playing .eq i {
  animation: eq 0.9s ease-in-out infinite alternate;
}

body.is-playing .eq i:nth-child(2) {
  animation-duration: 0.7s;
  animation-delay: -0.3s;
  background: var(--cream);
}

body.is-playing .eq i:nth-child(3) {
  animation-duration: 1.05s;
  animation-delay: -0.5s;
  background: var(--cyan);
}

body.is-playing .eq i:nth-child(4) {
  animation-duration: 0.8s;
  animation-delay: -0.15s;
}

@keyframes eq {
  from {
    height: 3px;
  }

  to {
    height: 12px;
  }
}

/* Track info */
.track-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px;
}

.track-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--r-full);
  color: var(--text-2);
  background: var(--fill-1);
  border: 1px solid var(--line);
}

.track-title {
  font-family: var(--font-cjk);
  font-size: 30px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.track-artist {
  font-size: 15px;
  font-weight: 700;
  color: var(--pink);
}

.track-artist span {
  font-weight: 500;
  color: var(--text-2);
}

.track-credits {
  font-size: 13px;
  color: var(--text-3);
}

/* Chapters */
.chapters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px;
}

.section-heading h2 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.section-heading-meta {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chapter-item {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px 0 10px;
  border-radius: var(--r-md);
  text-align: left;
  color: var(--text-2);
  overflow: hidden;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}

.chapter-item:hover {
  background: var(--fill-1);
  color: var(--text);
}

.chapter-index {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  text-align: center;
}

.chapter-name {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-time {
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}

.chapter-progress {
  position: absolute;
  left: 10px;
  right: 12px;
  bottom: 5px;
  height: 2px;
  border-radius: 2px;
  background: var(--fill-2);
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur-base) ease;
}

.chapter-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--pink);
  transform-origin: left;
  transform: scaleX(var(--chapter-p, 0));
}

.chapter-item.is-active {
  background: var(--fill-2);
  color: var(--text);
}

.chapter-item.is-active .chapter-progress {
  opacity: 1;
}

.chapter-item.is-active .chapter-index {
  color: var(--pink);
}

.chapter-item.is-past .chapter-name {
  color: var(--text-3);
}

/* ==========================================================================
   Stage & Lyrics
   ========================================================================== */
.stage {
  grid-area: stage;
  position: relative;
  z-index: var(--z-content);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lyrics-scroller {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 14%, #000 80%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 14%, #000 80%, transparent 100%);
}

.lyrics-scroller::-webkit-scrollbar {
  width: 6px;
}

.lyrics-scroller::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

.lyrics-container {
  max-width: 920px;
  padding: 34vh clamp(20px, 5vw, 72px) 46vh;
  user-select: none;
}

/* Section labels inline with lyrics */
.lyric-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 36px 0 10px 20px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text-3);
  transition: color var(--dur-slow) ease;
}

.lyric-section-label::after {
  content: "";
  flex: 0 0 40px;
  height: 1px;
  background: var(--line-strong);
}

.lyric-section-label:first-child {
  margin-top: 0;
}

.lyric-section-label.is-current {
  color: var(--pink);
}

/* Line */
.lyric-line {
  position: relative;
  padding: 10px 20px;
  margin: 2px 0;
  border-radius: var(--r-lg);
  cursor: pointer;
  opacity: 0.34;
  transform-origin: left center;
  transform: scale(0.96);
  filter: blur(0.6px);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out),
    filter var(--dur-slow) var(--ease-out),
    background var(--dur-fast) ease;
}

.lyric-line.near-1 {
  opacity: 0.6;
  filter: none;
}

.lyric-line.near-2 {
  opacity: 0.44;
  filter: blur(0.3px);
}

.lyric-line.is-past {
  opacity: 0.26;
}

.lyric-line.is-past.near-1 {
  opacity: 0.5;
}

.lyric-line:hover {
  opacity: 0.86;
  filter: none;
  background: var(--fill-1);
}

.lyric-line.active {
  opacity: 1;
  filter: none;
  transform: scale(1);
}

.lyric-line.active:hover {
  background: transparent;
}

.lyric-content {
  font-family: var(--font-cjk);
  font-size: calc(30px * var(--font-scale));
  font-weight: 800;
  line-height: 1.9;
  letter-spacing: 0.02em;
  color: var(--unsung);
  word-break: break-word;
}

body.pinyin-hidden .lyric-content {
  line-height: 1.5;
}

.lyric-line.english .lyric-content {
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.45;
}

.lyric-line.mandarin .lyric-content {
  letter-spacing: 0.06em;
}

.lyric-line.interlude .lyric-content,
.lyric-line.outro .lyric-content {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: calc(20px * var(--font-scale));
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-2);
}

.lyric-line.interlude .lyric-content::before,
.lyric-line.outro .lyric-content::before {
  content: "";
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  background: var(--cyan);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18V5l12-2v13'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Ccircle cx='18' cy='16' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18V5l12-2v13'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Ccircle cx='18' cy='16' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Karaoke sweep on the active line (inline box keeps a continuous sweep across wrapped lines) */
.lyric-line.active:not(.interlude):not(.outro) .lyric-content {
  --edge: calc(var(--p, 0) * 100%);
  background-image: linear-gradient(90deg,
      var(--sung) 0,
      var(--sung) calc(var(--edge) - 1.5%),
      var(--unsung) calc(var(--edge) + 1.5%),
      var(--unsung) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 102, 196, 0.28));
}

/* Ruby (Tâi-lô) */
ruby {
  ruby-align: center;
  ruby-position: over;
}

rt {
  font-family: var(--font-ui);
  font-size: 0.42em;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: var(--ruby);
  -webkit-text-fill-color: var(--ruby);
  opacity: 0.85;
  user-select: none;
}

.lyric-line.active rt {
  opacity: 1;
}

body.pinyin-hidden rt {
  display: none;
}

/* Loop indicator on active line */
.loop-badge {
  display: none;
}

body.loop-on .lyric-line.active .loop-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 14px;
  vertical-align: middle;
  white-space: nowrap;
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-full);
  background: var(--cyan-soft);
  border: 1px solid rgba(99, 228, 238, 0.4);
  color: var(--cyan);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  animation: badge-in var(--dur-base) var(--ease-out);
}

.loop-badge svg {
  width: 12px;
  height: 12px;
}

@keyframes badge-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* Resume follow button */
.btn-resume {
  position: absolute;
  left: 50%;
  bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px 0 14px;
  border-radius: var(--r-full);
  background: rgba(246, 247, 251, 0.95);
  color: #12131c;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
  z-index: 2;
}

.btn-resume svg {
  width: 18px;
  height: 18px;
}

.btn-resume.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.btn-resume:hover {
  background: #fff;
}

/* ==========================================================================
   Dock (Transport Bar)
   ========================================================================== */
.dock {
  grid-area: dock;
  position: relative;
  z-index: var(--z-chrome);
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 640px) minmax(200px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 var(--gutter);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface-strong);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border-top: 1px solid var(--line);
}

.dock-now {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.dock-thumb {
  width: 80px;
  height: 45px;
  border-radius: var(--r-sm);
  object-fit: cover;
  box-shadow: var(--shadow-1), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  background: #1b1d2a;
  flex-shrink: 0;
}

.dock-now-text {
  min-width: 0;
}

.dock-title {
  font-family: var(--font-cjk);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
}

.dock-sub .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

#dock-section {
  color: var(--text-2);
  font-weight: 600;
}

.dock-center {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.ctrl-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.ctrl-btn svg {
  width: 20px;
  height: 20px;
}

.ctrl-btn:hover {
  color: var(--text);
  background: var(--fill-1);
}

.ctrl-btn:active {
  transform: scale(0.92);
}

.ctrl-btn.ctrl-play {
  width: 48px;
  height: 48px;
  background: #fff;
  color: #11121a;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.ctrl-btn.ctrl-play svg {
  width: 22px;
  height: 22px;
}

.ctrl-btn.ctrl-play:hover {
  background: #fff;
  color: #11121a;
  transform: scale(1.05);
}

.ctrl-btn.ctrl-play:active {
  transform: scale(0.95);
}

.ctrl-play .icon-pause {
  display: none;
}

body.is-playing .ctrl-play .icon-play {
  display: none;
}

body.is-playing .ctrl-play .icon-pause {
  display: block;
}

.ctrl-toggle[aria-pressed="true"] {
  color: var(--cyan);
}

.ctrl-toggle[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: currentColor;
}

.ctrl-speed {
  width: auto;
  min-width: 52px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ctrl-speed.is-modified {
  color: var(--cream);
  border-color: rgba(255, 226, 138, 0.45);
  background: rgba(255, 226, 138, 0.08);
}

.ctrl-sm {
  width: 36px;
  height: 36px;
}

/* Timeline / Scrubber */
.timeline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time {
  min-width: 38px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}

.time:first-child {
  text-align: right;
}

.scrubber {
  position: relative;
  flex: 1;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  border-radius: var(--r-full);
}

.scrubber:focus-visible {
  outline-offset: 0;
}

.scrubber-rail {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--fill-3);
  overflow: hidden;
  transition: height var(--dur-fast) ease;
}

.scrubber:hover .scrubber-rail,
.scrubber.is-dragging .scrubber-rail {
  height: 6px;
}

.scrubber-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--pink-strong), var(--pink));
  transform-origin: left;
  transform: scaleX(0);
  will-change: transform;
}

.scrubber-markers span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: rgba(10, 11, 18, 0.75);
}

.scrubber-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease-out);
  pointer-events: none;
}

.scrubber:hover .scrubber-thumb,
.scrubber:focus-visible .scrubber-thumb,
.scrubber.is-dragging .scrubber-thumb {
  transform: scale(1);
}

.scrubber-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  background: rgba(246, 247, 251, 0.96);
  color: #12131c;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: var(--shadow-1);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) ease;
}

.scrubber-tooltip small {
  margin-left: 6px;
  font-weight: 600;
  color: #5b5d70;
}

.scrubber:hover .scrubber-tooltip,
.scrubber.is-dragging .scrubber-tooltip {
  opacity: 1;
}

/* Volume */
.dock-extra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.icon-muted {
  display: none;
}

body.is-muted .icon-muted {
  display: block;
}

body.is-muted .icon-vol {
  display: none;
}

body.vol-low .vol-wave-2 {
  display: none;
}

.volume {
  --vol: 100%;
  -webkit-appearance: none;
  appearance: none;
  width: 112px;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

.volume::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--text) var(--vol), var(--fill-3) var(--vol));
}

.volume::-moz-range-track {
  height: 4px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--text) var(--vol), var(--fill-3) var(--vol));
}

.volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transform: scale(0);
  transition: transform var(--dur-fast) ease;
}

.volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.volume:hover::-webkit-slider-thumb,
.volume:focus-visible::-webkit-slider-thumb {
  transform: scale(1);
}

.volume:hover::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--pink) var(--vol), var(--fill-3) var(--vol));
}

/* ==========================================================================
   Mobile-only components (hidden on desktop)
   ========================================================================== */
.np,
.lyrics-hero,
.mobile-only {
  display: none;
}

/* ==========================================================================
   Dialog & Toast
   ========================================================================== */
.sheet {
  margin: auto;
  width: min(440px, calc(100vw - 32px));
  padding: 8px 8px 12px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-strong);
  background: rgba(22, 24, 36, 0.98);
  color: var(--text);
  box-shadow: var(--shadow-3);
}

.sheet[open] {
  animation: sheet-in var(--dur-base) var(--ease-out);
}

.sheet::backdrop {
  background: rgba(4, 5, 10, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
}

.sheet-head h2 {
  font-size: 17px;
  font-weight: 800;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
}

.shortcut-list>div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 0 8px;
  border-top: 1px solid var(--line);
}

.shortcut-list dt {
  display: flex;
  gap: 6px;
}

.shortcut-list dd {
  font-size: 14px;
  color: var(--text-2);
}

kbd {
  min-width: 28px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--fill-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

/* Bottom sheet (手機版設定 / 段落) */
.bottom-sheet {
  padding: 0 0 max(16px, env(safe-area-inset-bottom));
}

.sheet-grabber {
  width: 40px;
  height: 5px;
  margin: 10px auto 2px;
  border-radius: var(--r-full);
  background: var(--fill-3);
}

.bottom-sheet .sheet-head {
  padding: 4px 10px 8px 20px;
}

.bottom-sheet .sheet-grabber,
.bottom-sheet .sheet-head {
  touch-action: none;
}

.setting-list {
  padding: 0 20px 4px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  border-top: 1px solid var(--line);
}

.setting-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.setting-name {
  font-size: 16px;
  font-weight: 700;
}

.setting-desc {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.switch-btn {
  flex-shrink: 0;
  width: 56px;
  height: 44px;
  display: grid;
  place-items: center;
}

.switch-btn .switch {
  width: 50px;
  height: 30px;
}

.switch-btn .switch::after {
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
}

.switch-btn[aria-checked="true"] .switch {
  background: var(--cream);
}

.switch-btn[aria-checked="true"] .switch::after {
  transform: translateX(20px);
}

.stepper-lg {
  flex-shrink: 0;
  height: 46px;
  padding: 0 4px;
}

.stepper-lg .stepper-btn {
  width: 54px;
  height: 40px;
  border-radius: var(--r-full);
}

.stepper-a {
  font-family: var(--font-ui);
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
}

.stepper-a.small {
  font-size: 14px;
}

.stepper-divider {
  width: 1px;
  height: 20px;
  background: var(--line-strong);
}

#chapter-list-sheet {
  padding: 0 12px 4px;
}

#chapter-list-sheet .chapter-item {
  min-height: 54px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 20px + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  padding: 10px 16px;
  border-radius: var(--r-full);
  background: rgba(246, 247, 251, 0.96);
  color: #12131c;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (min-width: 1440px) {
  :root {
    --side-w: 400px;
    --gutter: 32px;
  }

  .lyric-content {
    font-size: calc(34px * var(--font-scale));
  }
}

/* Tablet & phone: single column */
@media (max-width: 1023px) {
  :root {
    --gutter: 16px;
    --topbar-h: 64px;
  }

  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: calc(var(--topbar-h) + env(safe-area-inset-top)) minmax(0, 1fr);
    grid-template-areas:
      "top"
      "stage";
  }

  .sidebar,
  .brand,
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: inline-grid;
  }

  /* 正在播放列 */
  .topbar {
    gap: 12px;
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .np {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  /* 黑膠唱片：封面印在唱片上，播放時旋轉（由 player.js 驅動） */
  .np-vinyl {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  }

  .np-vinyl-disc {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--cover) 50% 46% / auto 100% no-repeat, #111;
    will-change: transform;
  }

  /* 標籤區分隔線 + 溝紋 + 黑色外圈 */
  .np-vinyl-disc::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
      radial-gradient(circle, transparent 0 30%, rgba(0, 0, 0, 0.28) 30.5% 31.5%, transparent 32%),
      repeating-radial-gradient(circle, rgba(0, 0, 0, 0.16) 0 0.6px, transparent 0.6px 1.6px),
      radial-gradient(circle, transparent 0 86%, #0b0b10 87% 100%);
  }

  /* 中心孔 */
  .np-vinyl-disc::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 13%;
    height: 13%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, #05060a 0 42%, #e9e2cf 45% 100%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  }

  /* 反光固定不轉，轉動時才看得出唱片在動 */
  .np-vinyl-sheen {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    background: conic-gradient(from 20deg, transparent 0 8%, rgba(255, 255, 255, 0.28) 13%, transparent 19% 50%,
        rgba(255, 255, 255, 0.16) 63%, transparent 69% 100%);
    mix-blend-mode: screen;
    -webkit-mask: radial-gradient(circle, transparent 0 18%, #000 19%);
    mask: radial-gradient(circle, transparent 0 18%, #000 19%);
  }

  .np-text {
    min-width: 0;
  }

  .np-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-cjk);
    font-size: 16px;
    font-weight: 800;
    line-height: 1.3;
    white-space: nowrap;
  }

  .np-title>span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 歌名旁迷你頻譜：依預算資料跳動，暫停時收成小圓點 */
  .np-bars {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
  }

  .np-bars i {
    width: 2.5px;
    height: 16%;
    min-height: 2.5px;
    border-radius: var(--r-full);
    background: linear-gradient(0deg, var(--pink-strong), var(--pink) 45%, var(--cream)) bottom / 100% 12px;
  }

  .np-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
  }

  .np-sub>span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .np-sub .dot {
    width: 3px;
    height: 3px;
    flex-shrink: 0;
    border-radius: 50%;
    background: currentColor;
  }

  #np-section {
    flex-shrink: 0;
    font-weight: 700;
    color: var(--pink);
  }

  .topbar-tools {
    gap: 6px;
  }

  .topbar .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--fill-1);
    border: 1px solid var(--line);
  }

  /* 歌詞開頭：封面主視覺 */
  .lyrics-scroller {
    -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 20px, #000 70%, rgba(0, 0, 0, 0.35) 100%);
    mask-image: linear-gradient(180deg, transparent 0, #000 20px, #000 70%, rgba(0, 0, 0, 0.35) 100%);
  }

  .btn-resume {
    bottom: calc(132px + env(safe-area-inset-bottom));
  }

  .lyrics-hero {
    display: block;
    padding: 12px var(--gutter) 0;
  }

  .hero-art {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 18px;
    overflow: hidden;
    background: #1b1d2a;
    box-shadow: var(--shadow-3);
  }

  .hero-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .hero-art::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  .lyrics-hero .track-tags {
    margin: 18px 0 10px;
  }

  .hero-title {
    font-family: var(--font-cjk);
    font-size: 30px;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: 0.02em;
  }

  .lyrics-hero .track-artist {
    margin-top: 4px;
  }

  .lyrics-hero .track-credits {
    margin-top: 2px;
  }

  .lyrics-container {
    padding: 32px var(--gutter) 40vh;
  }

  .lyric-line {
    padding: 8px 12px;
  }

  .lyric-section-label {
    margin-left: 12px;
  }

  /* 底部控制列：圓角毛玻璃面板（按鈕配置不變） */
  .dock {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    grid-area: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "timeline"
      "transport";
    gap: 4px;
    padding: 10px 14px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 26px;
    background: rgba(22, 24, 36, 0.55);
    backdrop-filter: blur(30px) saturate(1.6);
    -webkit-backdrop-filter: blur(30px) saturate(1.6);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  .dock-now,
  .dock-extra {
    display: none;
  }

  .dock-center {
    display: contents;
  }

  .timeline {
    grid-area: timeline;
  }

  .transport {
    grid-area: transport;
    justify-content: space-between;
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
    gap: 0;
  }

  .ctrl-btn {
    width: 48px;
    height: 48px;
  }

  .ctrl-btn svg {
    width: 22px;
    height: 22px;
  }

  .ctrl-btn.ctrl-play {
    width: 60px;
    height: 60px;
  }

  .ctrl-btn.ctrl-play svg {
    width: 26px;
    height: 26px;
  }

  .ctrl-speed {
    height: 36px;
    min-width: 56px;
  }

  .toast {
    bottom: calc(170px + env(safe-area-inset-bottom));
  }

  /* 底部抽屜 */
  .bottom-sheet {
    margin: auto 0 0;
    width: 100%;
    max-width: 100%;
    max-height: 82dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    background: rgba(24, 26, 38, 0.97);
    transition: transform var(--dur-base) var(--ease-out);
  }

  .bottom-sheet.is-dragging {
    transition: none;
  }

  .bottom-sheet[open] {
    animation: sheet-up var(--dur-slow) var(--ease-out);
  }

  .bottom-sheet.is-closing {
    animation: sheet-down 220ms ease-in forwards;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}

@media (max-width: 600px) {
  .lyric-content {
    font-size: calc(23px * var(--font-scale));
  }

  .lyric-line.interlude .lyric-content,
  .lyric-line.outro .lyric-content {
    font-size: calc(17px * var(--font-scale));
  }
}

/* Landscape phones: keep lyrics visible */
@media (max-height: 520px) and (orientation: landscape) {
  .lyrics-hero {
    display: none;
  }

  .lyrics-container {
    padding-top: 18vh;
    padding-bottom: 30vh;
  }

  .dock {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "timeline transport";
    gap: 16px;
    padding: 4px 14px;
    bottom: max(6px, env(safe-area-inset-bottom));
  }

  .transport {
    gap: 4px;
  }

  .ctrl-btn {
    width: 44px;
    height: 44px;
  }

  .ctrl-btn.ctrl-play {
    width: 48px;
    height: 48px;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .ambient-art {
    animation: none;
  }
}
