:root {
  --bg: #000000;
  --bg-soft: #0a0a0c;
  --card: rgba(28, 28, 30, 0.72);
  --card-solid: #1c1c1e;
  --card-border: rgba(255, 255, 255, 0.08);
  --ink: #f5f5f7;
  --ink-secondary: rgba(235, 235, 245, 0.6);
  --muted: rgba(235, 235, 245, 0.45);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --now: rgba(10, 132, 255, 0.22);
  --now-ink: #64d2ff;
  --danger: #ff6961;
  --danger-bg: rgba(255, 105, 97, 0.14);
  --radius-xl: 28px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-card: 0 24px 80px rgba(0, 0, 0, 0.55);
  --touch-min: 2.75rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  padding: max(1rem, env(safe-area-inset-top)) 1rem calc(2rem + env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 520px at 50% -20%, rgba(10, 132, 255, 0.14), transparent 55%),
    radial-gradient(600px 400px at 100% 100%, rgba(255, 255, 255, 0.04), transparent 50%),
    var(--bg);
}

h1 {
  font-weight: 700;
  font-size: 1.65rem;
  margin: 0;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

p {
  color: var(--ink-secondary);
}

.muted,
.empty {
  color: var(--muted);
}

.flash-err,
.boot-error {
  color: #ffb4a8;
  background: var(--danger-bg);
  border: 1px solid rgba(255, 105, 97, 0.22);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ——— Sheet screens (boot, denied, library, test) ——— */

.sheet {
  max-width: 26rem;
  width: 100%;
  margin: 0 auto;
}

body:has(.sheet) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet--library {
  align-self: flex-start;
  margin-top: 0.5rem;
}

body:has(.sheet--library) {
  align-items: flex-start;
}

.sheet-card {
  background: var(--card);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 1.35rem 1.15rem 1.25rem;
  box-shadow: var(--shadow-card);
}

.sheet-card--state {
  text-align: center;
}

.sheet-head {
  margin-bottom: 0.85rem;
}

.sheet-head--compact {
  margin-bottom: 1rem;
}

.sheet-kicker {
  margin: 0 0 0.85rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-card--state .sheet-kicker {
  margin-bottom: 1.1rem;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sheet-message {
  margin: 0;
  font-size: 1rem;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.sheet-hint {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.sheet-empty {
  text-align: center;
  padding: 1.5rem 0.5rem 0.75rem;
}

.sheet-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.sheet-glyph svg {
  width: 1.65rem;
  height: 1.65rem;
  fill: var(--ink);
  opacity: 0.88;
}

.sheet-glyph--lock svg {
  width: 1.45rem;
  height: 1.45rem;
}

.sheet-glyph--pod svg {
  width: 1.75rem;
  height: 1.75rem;
}

.spinner {
  display: block;
  width: 1.65rem;
  height: 1.65rem;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.boot-status {
  margin: 0;
  font-size: 0.92rem;
}

.code-info {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-md);
  background: rgba(10, 132, 255, 0.12);
  border: 1px solid rgba(10, 132, 255, 0.28);
  color: var(--now-ink);
  font-size: 0.9rem;
}

.code-open {
  text-decoration: none;
  text-align: center;
  justify-content: center;
}

.code-form input[type="text"] {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 650;
  text-align: center;
}

.test-entry-link {
  margin: 1rem 0 0;
  text-align: center;
}

.test-entry-link .player-back {
  margin-left: 0;
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  margin-top: 0.5rem;
}

.sheet-form label.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-form--pick {
  margin-top: 0.25rem;
}

.pick-section-label {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.package-picker {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.15rem;
}

.package-option {
  display: block;
  cursor: pointer;
  position: relative;
}

.package-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.package-option-card {
  display: block;
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

.package-option:hover .package-option-card {
  background: rgba(255, 255, 255, 0.06);
}

.package-option:active .package-option-card {
  transform: scale(0.985);
}

.package-option:has(:checked) .package-option-card {
  border-color: rgba(10, 132, 255, 0.75);
  background: rgba(10, 132, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(10, 132, 255, 0.28);
}

.package-option-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.package-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  flex-shrink: 0;
  background: linear-gradient(145deg, #636366 0%, #3a3a3c 55%, #2c2c2e 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.package-icon-letter {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #f5f5f7;
  line-height: 1;
  text-transform: uppercase;
}

.package-option:has(:checked) .package-icon {
  background: linear-gradient(145deg, #64d2ff 0%, #0a84ff 55%, #0066cc 100%);
  border-color: rgba(100, 210, 255, 0.45);
}

.package-copy {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
  flex: 1;
}

.package-title {
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.25;
}

.package-option:has(:checked) .package-title {
  color: var(--now-ink);
}

.package-meta {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}

.package-option:has(:checked) .package-meta {
  color: rgba(100, 210, 255, 0.85);
}

.package-check {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.32);
  box-sizing: border-box;
  position: relative;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.package-option:has(:checked) .package-check {
  border-color: var(--accent);
  background: var(--accent);
}

.package-option:has(:checked) .package-check::after {
  content: "";
  position: absolute;
  left: 0.34rem;
  top: 0.14rem;
  width: 0.32rem;
  height: 0.58rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.package-guides {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 0.5px solid var(--line);
}

.package-guide-chip {
  display: inline-block;
  max-width: 100%;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--ink-secondary);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.package-guide-chip--warn {
  color: #ffb4a8;
  border-color: rgba(255, 105, 97, 0.35);
  background: rgba(255, 105, 97, 0.1);
}

.package-option:has(:checked) .package-guide-chip:not(.package-guide-chip--warn) {
  color: var(--now-ink);
  border-color: rgba(10, 132, 255, 0.35);
  background: rgba(10, 132, 255, 0.15);
}

.sheet-form input[type="password"],
.sheet-form input[type="text"] {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  padding: 0.82rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.sheet-form input::placeholder {
  color: var(--muted);
}

.sheet-form input:focus {
  outline: none;
  border-color: rgba(10, 132, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18);
}

.btn-primary,
.btn-glow {
  font: inherit;
  cursor: pointer;
  border: 0;
  min-height: 3rem;
  border-radius: 999px;
  padding: 0.78rem 1.15rem;
  color: #000;
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.01em;
  background: #f5f5f7;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-primary:active,
.btn-glow:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.btn-quiet {
  font: inherit;
  cursor: pointer;
  border: 0;
  min-height: 2.75rem;
  width: 100%;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
}

.logout-form {
  margin-top: 0.85rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

/* ——— Grouped lists (iOS style) ——— */

.grouped-list {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pick-list,
.guide-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.pick-row,
.guide-card {
  position: relative;
  display: flex;
  gap: 0.85rem;
  align-items: center;
  width: 100%;
  text-align: left;
  text-decoration: none;
  color: var(--ink-secondary);
  border: 0;
  border-radius: 0;
  padding: 0.78rem 0.85rem;
  min-height: 3.55rem;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.guide-list li + li .pick-row,
.pick-list .pick-row + .pick-row {
  border-top: 0.5px solid var(--line);
}

.pick-row:hover,
.guide-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.pick-row:has(:checked),
.playlist-item.is-current {
  background: var(--now);
  color: var(--now-ink);
}

.pick-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pick-cover {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #2c2c2e;
}

.pick-cover--glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pick-cover--glyph svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: var(--ink-secondary);
}

.pick-row:has(:checked) .pick-cover--glyph svg {
  fill: var(--now-ink);
}

.pick-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.pick-title,
.guide-title {
  font-weight: 650;
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.pick-row:has(:checked) .pick-title,
.playlist-item.is-current {
  color: var(--now-ink);
}

.pick-meta,
.guide-desc {
  color: inherit;
  font-size: 0.82rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pick-chevron svg {
  width: 1rem;
  height: 1rem;
  fill: var(--muted);
  flex-shrink: 0;
}

.pick-radio {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  position: relative;
}

.pick-row:has(:checked) .pick-radio {
  border-color: var(--accent);
}

.pick-row:has(:checked) .pick-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
}

body.player-has-bg {
  background: #000;
}

@keyframes player-page-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes player-card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes player-meta-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes player-bg-drift {
  from {
    transform: scale(1.04) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.12) translate3d(0, -1.2%, 0);
  }
}

@keyframes player-bg-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.player-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.player-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(10, 132, 255, 0.16), transparent 52%),
    radial-gradient(90% 60% at 100% 100%, rgba(255, 255, 255, 0.06), transparent 55%);
  animation: player-bg-fade-in 1.2s ease both;
}

.player-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.28) 0%,
    rgba(0, 0, 0, 0.52) 42%,
    rgba(0, 0, 0, 0.82) 100%
  );
}

.player-bg-layer {
  position: absolute;
  inset: -4%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(1.06);
  transition:
    opacity 1.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 1.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
}

.player-bg-layer.is-active {
  opacity: 1;
  transform: scale(1.04);
  animation: player-bg-drift 32s ease-in-out infinite alternate;
}

.player-page {
  position: relative;
  z-index: 1;
  max-width: 26rem;
  margin: 0 auto;
  font-family: inherit;
  animation: player-page-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ——— Player (iOS Now Playing) ——— */

body:has(.player-page) {
  display: block;
  padding-left: max(0.85rem, env(safe-area-inset-left));
  padding-right: max(0.85rem, env(safe-area-inset-right));
  background: #000;
}

.player-nav {
  display: flex;
  align-items: center;
  min-height: 2.85rem;
  margin: 0 0 0.9rem;
}

.player-back {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 2.15rem;
  padding: 0.45rem 0.95rem 0.45rem 0.65rem;
  margin-left: -0.15rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.05) 100%),
    rgba(28, 28, 30, 0.52);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 8px 24px rgba(0, 0, 0, 0.28);
  color: #64d2ff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: -0.015em;
  line-height: 1;
  transition:
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.16s ease;
}

.player-back:hover {
  border-color: rgba(100, 210, 255, 0.35);
  background:
    linear-gradient(180deg, rgba(100, 210, 255, 0.18) 0%, rgba(10, 132, 255, 0.08) 100%),
    rgba(28, 28, 30, 0.62);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 10px 28px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(10, 132, 255, 0.12);
}

.player-back:active {
  transform: scale(0.96);
  opacity: 0.92;
}

.player-back-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  margin-left: -0.1rem;
}

.player-back-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.player-back-label {
  position: relative;
  top: 0.5px;
}

.player-card {
  padding: 1.15rem 1.05rem 1.2rem;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 38%, rgba(255, 255, 255, 0) 100%),
    rgba(22, 22, 24, 0.58);
  backdrop-filter: blur(40px) saturate(185%);
  -webkit-backdrop-filter: blur(40px) saturate(185%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: calc(var(--radius-xl) + 2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 28px 90px rgba(0, 0, 0, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.28);
  animation: player-card-in 0.65s 0.06s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.player-wave {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(0, 0, 0, 0.22) 100%),
    rgba(0, 0, 0, 0.35);
  height: 7.5rem;
  border-radius: calc(var(--radius-lg) + 2px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 12px 32px rgba(0, 0, 0, 0.28);
}

.player-wave canvas {
  display: block;
  width: 100%;
  height: 7.5rem;
  cursor: pointer;
}

.player-wave-rule {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.player-meta {
  display: flex;
  gap: 0.95rem;
  align-items: center;
  min-height: 4.75rem;
  margin-top: 1.15rem;
}

.player-meta.is-changing {
  animation: player-meta-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.player-cover-wrap {
  position: relative;
  width: 4.85rem;
  height: 4.85rem;
  flex-shrink: 0;
  border-radius: 16px;
  background: #2c2c2e;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 16px 36px rgba(0, 0, 0, 0.42);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.player-cover-ph {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #3a3a3c, #1c1c1e);
}

.player-cover {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-titles {
  min-width: 0;
  flex: 1;
}

.player-title {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.player-subtitle {
  margin: 0.3rem 0 0;
  min-height: 1.15em;
  color: var(--muted);
  font-size: 0.86rem;
}

.player-description-wrap {
  margin-top: 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(28, 28, 30, 0.55);
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.player-description-wrap[hidden] {
  display: none;
}

.player-description-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.72rem 0.95rem;
  cursor: pointer;
  list-style: none;
  color: var(--ink-secondary);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  user-select: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.player-description-summary::-webkit-details-marker {
  display: none;
}

.player-description-summary::marker {
  content: '';
}

.player-description-summary:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.player-description-chevron {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  opacity: 0.72;
  transition: transform 0.22s ease, opacity 0.15s ease;
}

.player-description-wrap[open] .player-description-chevron {
  transform: rotate(180deg);
  opacity: 0.95;
}

.player-description {
  margin: 0 0.95rem 0.9rem;
  padding: 0.75rem 0 0;
  color: var(--ink-secondary);
  font-size: 0.88rem;
  line-height: 1.55;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.player-description p {
  margin: 0 0 0.75rem;
}

.player-description p:last-child {
  margin-bottom: 0;
}

.player-description strong {
  color: var(--ink);
  font-weight: 650;
}

.player-description em {
  font-style: italic;
  color: rgba(235, 235, 245, 0.78);
}

.player-progress {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1rem 0 1.05rem;
}

.player-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 2.2rem;
}

.player-time:last-child {
  text-align: right;
}

.player-slider {
  --fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    #f5f5f7 0,
    #f5f5f7 var(--fill),
    rgba(255, 255, 255, 0.18) var(--fill),
    rgba(255, 255, 255, 0.18) 100%
  );
  outline: none;
}

.player-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f5f5f7;
  border: 0;
  box-shadow: 0 0 0 4px rgba(245, 245, 247, 0.12);
  cursor: pointer;
}

.player-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f5f5f7;
  border: 0;
  cursor: pointer;
}

.player-slider::-moz-range-track {
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
}

.player-slider::-moz-range-progress {
  height: 3px;
  border-radius: 99px;
  background: #f5f5f7;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.player-transport {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.ctrl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.ctrl:active {
  transform: scale(0.94);
}

.ctrl svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
}

.ctrl-side {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.04) 100%),
    rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 8px 20px rgba(0, 0, 0, 0.22);
  color: var(--ink);
}

.ctrl-play {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #ececef 100%);
  color: #000;
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 12px 36px rgba(0, 0, 0, 0.38),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  transition:
    transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease,
    opacity 0.16s ease;
}

.ctrl-play.is-playing {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 14px 40px rgba(0, 0, 0, 0.42),
    0 0 24px rgba(100, 210, 255, 0.18);
}

.ctrl-play svg {
  width: 1.5rem;
  height: 1.5rem;
}

.ctrl-play .icon-play {
  margin-left: 3px;
}

.ctrl-play.is-loading {
  opacity: 0.65;
}

.player-vol {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
  max-width: 7rem;
  justify-content: flex-end;
}

.vol-icon {
  width: 1rem;
  height: 1rem;
  fill: var(--muted);
  flex-shrink: 0;
}

.player-vol-slider {
  width: 100%;
  height: 3px;
}

.player-vol-slider::-webkit-slider-thumb {
  width: 10px;
  height: 10px;
  box-shadow: none;
}

.player-vol-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
}

.player-playlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: min(15rem, 42dvh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.03) 100%),
    rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: calc(var(--radius-lg) + 2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 10px 28px rgba(0, 0, 0, 0.22);
}

.player-playlist::-webkit-scrollbar {
  width: 4px;
}

.player-playlist::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 99px;
}

.player-playlist .playlist-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 2.9375rem;
  min-height: 2.9375rem;
  max-height: 2.9375rem;
  padding: 0 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.playlist-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  padding: 0.85rem 1rem;
  min-height: 2.9rem;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.94rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background 0.22s ease,
    color 0.22s ease,
    transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.player-playlist li + li {
  border-top: 0.5px solid rgba(255, 255, 255, 0.08);
}

.playlist-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.playlist-item:active {
  transform: scale(0.995);
}

.playlist-item.is-current {
  font-weight: 650;
  color: var(--now-ink);
  background:
    linear-gradient(90deg, rgba(10, 132, 255, 0.24) 0%, rgba(10, 132, 255, 0.12) 100%);
  box-shadow: inset 3px 0 0 #0a84ff;
}

.player-empty,
.player-error {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.92rem;
}

.player-empty {
  color: var(--muted);
}

.player-error {
  color: var(--danger);
}

#player-audio {
  display: none;
}

@media (max-width: 480px) {
  body {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  h1 {
    font-size: 1.45rem;
  }

  .sheet-card {
    padding: 1.15rem 1rem 1.1rem;
    border-radius: calc(var(--radius-xl) - 4px);
  }

  .player-card {
    padding: 1rem 0.9rem 1.05rem;
  }

  .player-wave,
  .player-wave canvas {
    height: 6.25rem;
  }

  .player-title {
    font-size: 1.12rem;
  }

  .player-meta {
    gap: 0.75rem;
    min-height: 4.25rem;
  }

  .player-cover-wrap {
    width: 4.25rem;
    height: 4.25rem;
  }

  .player-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55rem;
  }

  .player-vol {
    flex: 1 1 100%;
    max-width: none;
    justify-content: center;
  }

  .player-playlist {
    max-height: min(12rem, 36dvh);
  }
}

@media (max-width: 380px) {
  .ctrl-side {
    width: 48px;
    height: 48px;
  }

  .ctrl-play {
    width: 64px;
    height: 64px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .player-slider,
  .player-vol-slider {
    height: 6px;
  }

  .player-slider::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }

  .player-slider::-moz-range-thumb,
  .player-vol-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .pick-row,
  .guide-card,
  .playlist-item,
  .btn-primary,
  .btn-glow,
  .player-back {
    min-height: var(--touch-min, 2.75rem);
  }
}

@media (max-height: 640px) and (orientation: landscape) {
  body:has(.player-page) {
    padding-top: max(0.35rem, env(safe-area-inset-top));
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
  }

  .player-nav {
    margin-bottom: 0.45rem;
    min-height: 2.25rem;
  }

  .player-wave,
  .player-wave canvas {
    height: 4.75rem;
  }

  .player-meta {
    margin-top: 0.65rem;
    min-height: 3.5rem;
  }

  .player-cover-wrap {
    width: 3.75rem;
    height: 3.75rem;
  }

  .player-progress {
    margin: 0.65rem 0 0.75rem;
  }

  .player-controls {
    margin-bottom: 0.65rem;
  }

  .player-playlist {
    max-height: min(7.5rem, 34dvh);
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-page,
  .player-card,
  .player-meta.is-changing,
  .player-bg::before {
    animation: none;
  }

  .player-bg-layer,
  .player-bg-layer.is-active {
    animation: none;
    transition: opacity 0.01ms;
  }

  .player-back,
  .ctrl,
  .playlist-item {
    transition: none;
  }
}
