/* SoundAris styles. One file, in cascade order; later sections build on earlier ones.
   Sections: 1. Base: tokens, layout, components | 2. Decks, Now Playing details, VU meters | 3. Light themes and dark mode | 4. Layouts (Full / Compact), View menu, radio, footer, tablets and touch */

/* ========================================================================
   1. Base: tokens, layout, components
   ======================================================================== */

:root {

  --saffron: #ff9933;
  --saffron-deep: #e06d00;
  --tricolor-white: #ffffff;
  --india-green: #138808;
  --chakra-navy: #1d3c8a;

  /* Warm studio surfaces with restrained tricolor accents. */
  --bg-app: #e8e2d7;
  --bg-panel: #f3eee4;
  --bg-elevated: #e9e1d4;
  --bg-hover: #ddd5c7;
  --border: rgba(67, 53, 35, 0.12);
  --border-strong: rgba(67, 53, 35, 0.24);

  --text-primary: #252822;
  --text-secondary: #53594e;
  --text-muted: #5b6258;

  --accent: #a65323;
  --accent-strong: #813f1b;
  --accent-glow: rgba(229, 144, 74, 0.24);
  --warning: #a65a25;
  --danger: #b33a32;

  --neu-out: 0 8px 18px rgba(58, 45, 28, 0.08), 0 1px 3px rgba(58, 45, 28, 0.05);
  --neu-out-sm: 0 3px 8px rgba(58, 45, 28, 0.08);
  --neu-in: inset 0 1px 3px rgba(58, 45, 28, 0.08);
  --neu-in-sm: inset 0 1px 2px rgba(58, 45, 28, 0.07);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-lg: 0 22px 50px rgba(48, 39, 26, 0.18);
}

[data-theme="dark"] {
  --bg-app: #141916;
  --bg-panel: #1d231f;
  --bg-elevated: #272e29;
  --bg-hover: #303a33;
  --bg-active: linear-gradient(135deg, rgba(229, 160, 96, 0.2), rgba(50, 61, 52, 0.88), rgba(86, 128, 88, 0.16));
  --border: rgba(245, 239, 222, 0.1);
  --border-strong: rgba(245, 239, 222, 0.2);

  --text-primary: #f2efe5;
  --text-secondary: #c5c6b8;
  --text-muted: #9da496;

  --accent: #e1a16a;
  --accent-strong: #f0bc88;
  --accent-glow: rgba(229, 160, 96, 0.26);
  --warning: #e8ad64;
  --danger: #f28a7f;

  --neu-out: 0 10px 24px rgba(0, 0, 0, 0.28);
  --neu-out-sm: 0 3px 9px rgba(0, 0, 0, 0.24);
  --neu-in: inset 0 1px 3px rgba(0, 0, 0, 0.22);
  --neu-in-sm: inset 0 1px 2px rgba(0, 0, 0, 0.18);

  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
  overflow-wrap: break-word;
}

p, li {
  text-wrap: pretty;
}

h1, h2, h3 {
  text-wrap: balance;
}

button, input, select {
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* App Shell */
.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  flex-shrink: 0;
  z-index: 5;
}

.topbar::after {
  position: absolute;
  inset-inline: 20px;
  bottom: -1px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
  opacity: 0.7;
}

[data-theme="dark"] .topbar {
  background: rgba(29, 35, 31, 0.96);
  border-bottom-color: var(--border);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.24);
}

.topbar .btn-secondary,
.topbar .btn-ghost,
.topbar .btn-icon {
  background: var(--bg-panel);
}

.topbar .search-wrap input {
  background: var(--bg-panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

/* App logo (icons/logo-96.png): a rounded tile with its own transparent surround. */
.brand-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(15, 18, 35, 0.22));
}

.brand-title {
  margin: 0;
  font-size: clamp(1rem, 0.9rem + 0.25vw, 1.12rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  text-wrap: balance;
}

[data-theme="dark"] .brand-title {
  background: linear-gradient(90deg, #ff9933 0%, #f8fafc 52%, #34d399 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  font-size: clamp(0.68rem, 0.64rem + 0.12vw, 0.76rem);
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
  min-width: 180px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border-radius: 999px;
  background: var(--bg-panel);
  font-size: 0.875rem;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-more {
  position: relative;
  flex-shrink: 0;
}

.topbar-more-trigger {
  list-style: none;
}

.topbar-more-trigger::-webkit-details-marker {
  display: none;
}

.topbar-more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: grid;
  gap: 4px;
  min-width: 180px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
}

.topbar-more-menu .btn {
  justify-content: flex-start;
  width: 100%;
}

.modal-input:focus-visible,
.lyrics-search-input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Neumorphic Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
  background: var(--bg-panel);
  box-shadow: var(--neu-out-sm);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn:active {
  transform: scale(0.97);
  box-shadow: var(--neu-in-sm);
}

.btn-primary:hover {
  filter: none;
}

[data-theme="dark"] .btn-ghost.active {
  color: var(--saffron);
  border-color: rgba(255, 153, 51, 0.3);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.18);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.74rem;
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
  position: relative;
}

[data-theme="dark"] .btn-icon.active {
  color: var(--saffron);
}

.btn-play {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  padding: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (forced-colors: active) {
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  summary:focus-visible {
    outline-color: Highlight;
  }
}

.btn-play:hover {
  transform: scale(1.06);
}

.btn-play svg {
  width: 21px;
  height: 21px;
}

.link-btn {
  background: none;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

/* Workspace Grid */
.workspace {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr) minmax(300px, 340px);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.workspace.lyrics-collapsed {
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
}

.workspace.lyrics-collapsed .lyrics-panel {
  display: none;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

[data-theme="dark"] .panel {
  background: var(--bg-panel);
  border-color: var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h2 {
  margin: 0;
  font-size: clamp(0.72rem, 0.68rem + 0.1vw, 0.78rem);
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Left Sidebar */
.playlist-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}

.playlist-item:hover {
  background: var(--bg-panel);
  box-shadow: var(--neu-out-sm);
  color: var(--text-primary);
}

.playlist-item.active {
  font-weight: 700;
}

.playlist-item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-count {
  font-size: 0.74rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Center Column */
.center-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  /* Clip (not hidden) + clip margin so card shadows aren't cut into hard corners. */
  overflow: clip;
  overflow-clip-margin: 24px;
}

/* Now Playing Card */
.now-playing {
  position: relative;
  isolation: isolate;
  container: now-playing / inline-size;
  flex-shrink: 0;
}

.now-playing::before {
  position: absolute;
  content: "";
}

.now-playing > * {
  position: relative;
  z-index: 1;
}

.now-playing .panel-header {
  color: var(--deck-text);
  border-color: var(--deck-border);
}

.np-deck-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-inline-size: 0;
}

.deck-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--deck-muted);
  font-weight: 600;
  letter-spacing: 0.12em;
}

.deck-select {
  min-inline-size: 0;
}

#btnFavoriteCurrent.favorited svg {
  fill: var(--danger);
  stroke: var(--danger);
}

.np-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
}

@container now-playing (inline-size > 680px) {
  }

/* Animated Deck Stage */
.deck-stage {
  inline-size: 100%;
  min-inline-size: 0;
  display: grid;
  place-items: center;
  --tape-left: 0.94;
  --tape-right: 0.38;
}

.deck-view {
  display: none;
}

.deck-cassette-view {
  width: 100%;
}

.deck-stage.style-vinyl-classic .deck-vinyl-view {
  display: block;
}

.deck-stage.style-cassette-retro .deck-cassette-view,
.deck-stage.style-cassette-chrome .deck-cassette-view,
.deck-stage.style-cassette-deck .deck-cassette-view {
  display: block;
}

.deck-stage.style-cover .deck-cover-view {
  display: block;
}

/* --- Vinyl Turntable Animations (Extra-Large Light & Translucent Stage) --- */
.turntable-plinth {
  width: 276px;
  height: 224px;
  border-radius: 22px;
  background: linear-gradient(145deg, #f8f4eb, #e1d8c8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(105, 82, 54, 0.2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 17px;
  box-shadow: var(--neu-out);
}

[data-theme="dark"] .turntable-plinth {
  background: linear-gradient(145deg, #34312b, #211f1b);
  border-color: rgba(238, 220, 187, 0.18);
}

.strobe-ring {
  position: absolute;
  left: 12px;
  width: 202px;
  height: 202px;
  border-radius: 50%;
  border: 3px dotted rgba(112, 84, 51, 0.28);
  pointer-events: none;
}

[data-theme="dark"] .strobe-ring {
  border-color: rgba(238, 220, 187, 0.2);
}

.vinyl-disc-lg {
  width: 192px;
  height: 192px;
  border-radius: 50%;
  background: radial-gradient(circle, #252321 0 14%, #11100f 14.5% 67%, #252321 67.5% 69%, #080808 70% 100%);
  border: 1px solid rgba(245, 236, 218, 0.2);
  position: relative;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34), inset 0 0 16px rgba(255, 255, 255, 0.08);
  animation: spin 4.2s linear infinite;
  animation-play-state: paused;
}

.playing .vinyl-disc-lg {
  animation-play-state: running;
}

.vinyl-grooves {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: repeating-radial-gradient(
    circle,
    rgba(235, 225, 207, 0.12) 0px,
    rgba(235, 225, 207, 0.12) 1px,
    transparent 1px,
    transparent 5px
  );
  pointer-events: none;
}

.vinyl-sheen {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 25deg,
    transparent 0deg 50deg,
    rgba(255, 255, 255, 0.18) 75deg,
    transparent 105deg 230deg,
    rgba(255, 255, 255, 0.12) 255deg,
    transparent 285deg 360deg
  );
  pointer-events: none;
}

.vinyl-center-label {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle, #d26037 0 68%, #b74a2e 69% 100%);
  border: 3px solid #f1dfbd;
  box-shadow: 0 3px 10px rgba(20, 16, 12, 0.32);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.vinyl-brand-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff1d2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.vinyl-center-img:not(.hidden) + .vinyl-brand-mark {
  display: none;
}

.vinyl-center-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vinyl-spindle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f4e3c3;
  border: 2px solid #8e4b31;
  box-shadow: 0 2px 5px rgba(20, 33, 61, 0.25);
  z-index: 2;
}

.tonearm {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 28px;
  height: 154px;
  transform-origin: 14px 14px;
  transform: rotate(-16deg);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: 4;
}

.tonearm-base {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #cbd5e1);
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: var(--neu-out-sm);
}

.tonearm-rod {
  width: 5px;
  height: 108px;
  margin: -2px auto 0;
  background: linear-gradient(90deg, #94a3b8, #f8fafc, #94a3b8);
  border-radius: 3px;
}

.tonearm-head {
  width: 13px;
  height: 22px;
  margin: -1px auto 0;
  background: #ffffff;
  border: 2px solid #8e4b31;
  border-radius: 3px;
  transform: rotate(12deg);
}

/* Neon / Translucent Tricolor Vinyl Variant */

/* Analog cassette stage */
.cassette-shell {
  width: min(380px, 100%);
  height: 242px;
  border-radius: 18px;
  padding: 16px 20px 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(
    160deg,
    #fffdf7,
    #f0eadc 55%,
    #ded4c2
  );
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(126, 100, 66, 0.3);
  box-shadow:
    var(--neu-out),
    inset 0 2px 3px rgba(255, 255, 255, 0.95),
    inset 0 -3px 6px rgba(112, 88, 59, 0.2);
}

/* Molded edge and top ridge */
.cassette-shell::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 14px;
  border: 1px solid rgba(112, 88, 59, 0.25);
  pointer-events: none;
}

.cassette-shell::after {
  content: "";
  position: absolute;
  top: 0;
  left: 56px;
  right: 56px;
  height: 5px;
  border-radius: 0 0 5px 5px;
  background: rgba(112, 88, 59, 0.16);
  box-shadow: inset 0 1px 2px rgba(100, 76, 48, 0.18);
  pointer-events: none;
}

[data-theme="dark"] .cassette-shell {
  background: linear-gradient(145deg, #fffdf7, #e6dece);
  border-color: rgba(126, 100, 66, 0.42);
}

[data-theme="dark"] .cassette-shell::before {
  border-color: rgba(112, 88, 59, 0.25);
}

/* Recessed metal shell screws */
.screw {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f8fafc, #94a3b8);
  border: 1px solid rgba(100, 116, 139, 0.42);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.9), 0 1px 2px rgba(15, 23, 42, 0.18);
  z-index: 3;
}
.screw::before,
.screw::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(51, 65, 85, 0.7);
  transform: translate(-50%, -50%);
}
.screw::before { width: 6px; height: 1.2px; }
.screw::after { width: 1.2px; height: 6px; }
.screw.tl { top: 8px; left: 8px; }
.screw.tr { top: 8px; right: 8px; }
.screw.bl { bottom: 8px; left: 8px; }
.screw.br { bottom: 8px; right: 8px; }
.screw.bc { bottom: 25px; left: 50%; transform: translateX(-50%); }

/* Authentic Ruled Cream/Ivory Sticker Label */
.cassette-label {
  height: 76px;
  border-radius: 9px;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0px,
      transparent 13px,
      rgba(88, 72, 53, 0.11) 13px,
      rgba(88, 72, 53, 0.11) 14px
    ),
    linear-gradient(180deg, #fffdf8, #f3eddf);
  color: #342f28;
  padding: 5px 12px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(126, 100, 66, 0.3);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 3px rgba(112, 88, 59, 0.2);
}

.cassette-label-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(88, 72, 53, 0.22);
  padding-bottom: 3px;
}

.cassette-brand-tag {
  font-weight: 900;
  color: #514638;
  letter-spacing: 0.1em;
}

.cassette-brand-tag::before {
  content: "STUDIO · C-90";
}

.cassette-spec-tag {
  color: #62594c;
  font-weight: 700;
  font-size: 0.56rem;
}

.cassette-label-body {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 2px 0;
}

.cassette-side-badge {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 900;
  background: #44392e;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

.cassette-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cassette-title {
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #342f28;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cassette-artist {
  font-size: 0.72rem;
  font-weight: 600;
  color: #62594c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cassette-nr-box {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 800;
  color: #62594c;
  border: 1px solid rgba(98, 89, 76, 0.45);
  border-radius: 3px;
  padding: 2px 5px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.65);
}

.cassette-stripe {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
  background: linear-gradient(
      180deg,
      #f0786d 0 34%,
      #c9413d 35% 100%
  );
    border-top: 1px solid rgba(120, 45, 39, 0.24);
}

/* Crystal Clear Viewing Window with Real Winding Tape Pancakes */
.cassette-window {
  height: 92px;
  border-radius: 12px;
  background: linear-gradient(180deg, #c5bdae, #a89d8c);
  border: 1.5px solid rgba(255, 255, 255, 0.88);
  box-shadow:
    inset 0 3px 8px rgba(148, 163, 184, 0.42),
    inset 0 -2px 4px rgba(255, 255, 255, 0.9);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

/* Diagonal glass reflection across the window */
.cassette-window::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    118deg,
    transparent 20%,
    rgba(255, 255, 255, 0.5) 36%,
    rgba(255, 255, 255, 0.15) 48%,
    transparent 62%
  );
  pointer-events: none;
  z-index: 4;
}

[data-theme="dark"] .cassette-window {
  background: linear-gradient(180deg, #bdb4a5, #9b9181);
  border-color: rgba(255, 255, 255, 0.88);
}

.tape-spool {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

/* Real dark ferric/chrome wound tape pancake whose radius shrinks/grows with track progress */
.tape-pancake {
  position: absolute;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #2d1a12 0 42%,
    #46291c 43% 62%,
    #2b1810 63% 84%,
    #1c0f0a 85% 100%
  );
  box-shadow:
    inset 0 0 6px rgba(0, 0, 0, 0.65),
    0 1px 4px rgba(15, 23, 42, 0.35);
  transition: transform 0.35s linear;
  pointer-events: none;
}

.tape-spool.left .tape-pancake {
  transform: scale(var(--tape-left, 0.94));
}

.tape-spool.right .tape-pancake {
  transform: scale(var(--tape-right, 0.38));
}

/* Subtle glossy concentric reel sheen so rotation of tape pancake is visible */
.tape-pancake-rings {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background:
    conic-gradient(
      from 15deg,
      transparent 0deg 65deg,
      rgba(255, 255, 255, 0.16) 85deg,
      transparent 115deg 245deg,
      rgba(255, 255, 255, 0.14) 265deg,
      transparent 295deg 360deg
    ),
    repeating-radial-gradient(
      circle,
      rgba(255, 255, 255, 0.06) 0px,
      rgba(255, 255, 255, 0.06) 1px,
      transparent 1px,
      transparent 4px
    );
  animation: spin 1.95s linear infinite;
  animation-play-state: paused;
}

.playing .tape-pancake-rings {
  animation-play-state: running;
}

/* Authentic White 6-Tooth Nylon Cassette Hub */
.reel {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 11px, #f1f5f9 12px 17px, #cbd5e1 18px 20px);
  border: 2px solid #f8fafc;
  box-shadow:
    0 2px 5px rgba(15, 23, 42, 0.25),
    inset 0 0 0 5px #ffffff,
    inset 0 0 6px rgba(100, 116, 139, 0.4);
  position: relative;
  display: grid;
  place-items: center;
  z-index: 3;
  animation: spin 1.65s linear infinite;
  animation-play-state: paused;
}

.tape-spool.right .reel {
  animation-duration: 1.9s;
}

.playing .reel {
  animation-play-state: running;
}

.reel .tooth {
  position: absolute;
  width: 4px;
  height: 7px;
  background: #475569;
  border-radius: 1.5px;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.5);
}
.reel .tooth:nth-child(1) { transform: rotate(0deg) translateY(-10px); }
.reel .tooth:nth-child(2) { transform: rotate(60deg) translateY(-10px); }
.reel .tooth:nth-child(3) { transform: rotate(120deg) translateY(-10px); }
.reel .tooth:nth-child(4) { transform: rotate(180deg) translateY(-10px); }
.reel .tooth:nth-child(5) { transform: rotate(240deg) translateY(-10px); }
.reel .tooth:nth-child(6) { transform: rotate(300deg) translateY(-10px); }

/* Tiny red/orange tape-leader anchor dot on the hub */
.reel-hub-pin {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e0531f;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}

.tape-bridge {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  z-index: 3;
  pointer-events: none;
}

/* Etched Window Scale: 100 | 50 | 0 */
.tape-scale {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 3px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px dashed rgba(71, 85, 105, 0.45);
}

[data-theme="dark"] .tape-scale {
  color: rgba(226, 232, 240, 0.72);
  border-bottom-color: rgba(226, 232, 240, 0.25);
}

/* Dark ferric magnetic tape ribbon running cleanly along lower window path */
.tape-path-line {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 7px;
  height: 4px;
  border-radius: 2px;
  background: repeating-linear-gradient(
    90deg,
    #3d2419 0px,
    #3d2419 10px,
    #5a3626 10px,
    #5a3626 16px,
    #2c1810 16px,
    #2c1810 26px
  );
  background-size: 26px 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  opacity: 0.92;
  z-index: 1;
  animation: tapeMove 0.45s linear infinite;
  animation-play-state: paused;
}

.playing .tape-path-line {
  animation-play-state: running;
}

@keyframes tapeMove {
  from { background-position: 0 0; }
  to { background-position: 26px 0; }
}

.tape-counter {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 800;
  color: #14213d;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: inset 0 1px 3px rgba(148, 163, 184, 0.3);
  padding: 2px 9px;
  border-radius: 5px;
  display: none;
}

/* Protruding Bottom Trapezoid Head-Bridge with Rollers, Guide Holes & Pressure Pad */
.cassette-bottom-trapezoid {
  height: 30px;
  margin: 0 32px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, rgba(235, 240, 246, 0.92), rgba(220, 227, 236, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-bottom: none;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.9), 0 -1px 3px rgba(148, 163, 184, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
}

[data-theme="dark"] .cassette-bottom-trapezoid {
  background: linear-gradient(180deg, rgba(38, 46, 66, 0.9), rgba(26, 32, 48, 0.9));
  border-color: rgba(255, 255, 255, 0.14);
}

.guide-hole {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg-app);
  box-shadow: inset 1px 1px 2px rgba(100, 116, 139, 0.65);
}

.roller {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #f8fafc, #94a3b8, #f8fafc, #64748b);
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.28);
  animation: spin 0.9s linear infinite;
  animation-play-state: paused;
}

.playing .roller {
  animation-play-state: running;
}

.pressure-pad-assembly {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.shield-spring {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #b45309, #f59e0b, #b45309);
}

.felt-pad {
  width: 12px;
  height: 5px;
  border-radius: 1.5px;
  background: #e2e8f0;
  border: 1px solid #94a3b8;
}

.vu-meters {
  align-items: flex-end;
  gap: 5px;
  height: 18px;
}

.vu-bar {
  width: 7px;
  height: 4px;
  border-radius: 2px;
  background: #138808;
}

.playing .vu-bar {
  animation: vuPulse 0.45s ease-in-out infinite alternate;
}
.playing .vu-bar:nth-child(2) { animation-delay: 0.1s; background: #1d3c8a; }
.playing .vu-bar:nth-child(3) { animation-delay: 0.2s; background: #ff9933; }
.playing .vu-bar:nth-child(4) { animation-delay: 0.05s; background: #ff9933; }
.playing .vu-bar:nth-child(5) { animation-delay: 0.25s; background: #1d3c8a; }
.playing .vu-bar:nth-child(6) { animation-delay: 0.15s; background: #138808; }

@keyframes vuPulse {
  from { height: 3px; opacity: 0.55; }
  to { height: 18px; opacity: 1; }
}

/* Studio C-90 cassette variant */
.style-cassette-chrome .cassette-shell {
  background: linear-gradient(
    155deg,
    #fffdf7,
    #eee7d8 55%,
    #dcd1bf
  );
  border-color: rgba(126, 100, 66, 0.3);
}

.style-cassette-chrome .cassette-label {
  background: linear-gradient(180deg, #fffdf8, #f3eddf);
  color: #342f28;
}

.style-cassette-chrome .cassette-brand-tag {
  color: #514638;
}

.style-cassette-chrome .cassette-brand-tag::before {
  content: "C-90 · TYPE I";
}

.style-cassette-chrome .cassette-artist {
  color: #62594c;
}

.style-cassette-chrome .cassette-stripe {
  background: linear-gradient(180deg, #f0786d 0 34%, #c9413d 35% 100%);
}

.style-cassette-chrome .tape-pancake {
  background: radial-gradient(
    circle,
    #2d2119 0 42%,
    #493528 43% 64%,
    #2b1f18 65% 84%,
    #170f0b 85% 100%
  );
}

.style-cassette-chrome .tape-path-line {
  background: repeating-linear-gradient(
    90deg,
    #302219 0px,
    #302219 10px,
    #59402e 10px,
    #59402e 16px,
    #1b120c 16px,
    #1b120c 26px
  );
  background-size: 26px 100%;
}

/* Hi-Fi tape deck variant */
.style-cassette-deck .cassette-shell {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(226, 232, 240, 0.88));
  border: 2px solid rgba(255, 255, 255, 0.98);
}

.style-cassette-deck .cassette-label {
  background: rgba(241, 245, 249, 0.92);
  color: #14213d;
  border: 1px solid rgba(29, 60, 138, 0.2);
}

.style-cassette-deck .cassette-brand-tag {
  color: #138808;
}

.style-cassette-deck .cassette-brand-tag::before {
  content: "HI-FI STEREO";
}

.style-cassette-deck .cassette-artist {
  color: #62594c;
}

.style-cassette-deck .cassette-stripe {
  height: 5px;
  background: linear-gradient(180deg, #f0786d 0 34%, #c9413d 35% 100%);
}

.style-cassette-deck .tape-counter {
  display: inline-block;
}

.style-cassette-deck .pressure-pad-assembly {
  display: none;
}

.style-cassette-deck .vu-meters {
  display: flex;
}

.cover-art-wrap {
  width: 212px;
  height: 212px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--neu-out);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  position: relative;
}

.cover-art-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-art-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    rgba(255, 153, 51, 0.22),
    rgba(255, 255, 255, 0.72),
    rgba(19, 136, 8, 0.2)
  );
}

.vinyl-disc {
  width: 146px;
  height: 146px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, rgba(235, 225, 207, 0.12) 0 1px, transparent 1px 5px),
    radial-gradient(circle, #252321 0 14%, #11100f 14.5% 67%, #252321 67.5% 69%, #080808 70% 100%);
  border: 2px solid rgba(245, 236, 218, 0.2);
  display: grid;
  place-items: center;
  box-shadow: var(--neu-out-sm);
}

.playing .vinyl-disc {
  animation: spin 7s linear infinite;
}

.vinyl-label {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle, #d26037 0 68%, #b74a2e 69% 100%);
  border: 2px solid #f1dfbd;
  box-shadow: 0 2px 8px rgba(20, 16, 12, 0.32);
  display: grid;
  place-items: center;
}

.vinyl-label span {
  color: #fff1d2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.46rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.np-info {
  width: 100%;
}

.np-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-accent {
  box-shadow: none;
}

.meta-extra {
  font-size: 0.74rem;
  color: var(--deck-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-title {
  margin: 0;
  color: var(--deck-text);
  font-size: clamp(1.55rem, 1.25rem + 1.2cqi, 2.15rem);
  font-weight: 780;
  letter-spacing: -0.045em;
  line-height: 1.08;
  text-wrap: balance;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.np-artist {
  margin: 6px 0 0;
  font-size: clamp(0.92rem, 0.86rem + 0.18vw, 1.02rem);
  line-height: 1.35;
  color: var(--deck-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-album {
  margin: 4px 0 0;
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visualizer-row {
  display: flex;
  margin-top: 18px;
}

#visualizerCanvas {
  flex: 1;
  height: 48px;
  max-width: 440px;
  border: 1px solid var(--deck-border);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}

.now-playing .btn-icon:hover,
.now-playing .btn-icon.active {
  box-shadow: none;
}

.now-playing .btn-play {
  width: 56px;
  height: 56px;
}

.now-playing .btn-play:hover {
  transform: translateY(-2px);
}

.now-playing .speed-select,
.now-playing .deck-select {
  border-color: var(--deck-border);
}

.now-playing input[type="range"] {
  accent-color: var(--deck-accent);
}

/* Progress Row */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.now-playing .progress-row {
  border-top: 1px solid var(--deck-border);
}

.now-playing .controls-row {
  gap: 16px;
}

.now-playing .transport-buttons {
  gap: 10px;
}

.time-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 40px;
}

.now-playing .time-label {
  color: var(--deck-muted);
}

.time-label:last-child {
  text-align: right;
}

input[type="range"] {
  cursor: pointer;
}

.seek-bar {
  flex: 1;
  height: 5px;
}

/* Transport Controls */
.controls-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume-slider {
  width: 90px;
}

.transport-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.repeat-one-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.62rem;
  font-weight: 700;
  background: var(--accent);
  color: #082f49;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.controls-right {
  display: flex;
  justify-content: flex-end;
}

.speed-select,
.deck-select {
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 0.78rem;
  cursor: pointer;
}

/* Playlist Section */
.playlist-section {
  flex: 1;
  min-height: 0;
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.playlist-heading-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.count-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.playlist-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.track-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.track-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.14s, box-shadow 0.14s, border-color 0.14s;
}

.track-row:hover {
  background: var(--bg-panel);
  box-shadow: var(--neu-out-sm);
}

.track-index {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
}

.track-row.active .track-index {
  font-weight: 700;
}

.track-row-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-row.active .track-row-title {
  font-weight: 600;
}

.track-row-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.track-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-tag {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.mini-tag.has-lyrics {
  border-color: rgba(52, 211, 153, 0.3);
}

.track-duration {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  min-width: 38px;
  text-align: right;
}

.track-row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.75;
}

.track-row:hover .track-row-actions {
  opacity: 1;
}

.track-action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  min-width: 32px;
  min-height: 32px;
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.track-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.track-action-btn svg {
  width: 14px;
  height: 14px;
}

.track-action-btn.fav svg {
  fill: var(--danger);
  stroke: var(--danger);
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  color: var(--text-secondary);
}

.empty-title {
  margin: 0 0 6px;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-sub {
  margin: 0 0 14px;
  font-size: 0.82rem;
  max-width: 340px;
}

.empty-actions {
  display: flex;
  gap: 8px;
}

/* Lyrics Panel */
.lyrics-mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.tab-btn.active {
  font-weight: 600;
}

[data-theme="light"] .tab-btn.active {
  color: #fff;
}

.lyrics-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lyrics-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.lyrics-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.lyrics-search-input {
  flex: 1;
  min-width: 0;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}

.lyrics-search-input:focus {
  border-color: var(--accent);
}

.lyrics-search-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 34px;
  text-align: center;
}

.lyrics-line.search-match {
  background: rgba(251, 191, 36, 0.12);
}

.lyrics-line.search-current {
  outline: 1px solid var(--warning);
  background: rgba(251, 191, 36, 0.22);
}

.lyric-match-hl {
  background: rgba(251, 191, 36, 0.35);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.lyrics-online-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lyrics-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.lyrics-result-card {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lyrics-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lyrics-result-title {
  font-size: 0.88rem;
  font-weight: 600;
}

.lyrics-result-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.lyrics-result-preview {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: pre-line;
  max-height: 54px;
  overflow: hidden;
  margin: 0;
}

.lyrics-options {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 3px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}

.seg-btn.active {
  font-weight: 600;
}

[data-theme="light"] .seg-btn.active {
  color: #fff;
}

.offset-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.offset-value {
  font-family: var(--font-mono);
  min-width: 44px;
  text-align: center;
  color: var(--text-primary);
}

.lyrics-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  scroll-behavior: smooth;
}

.lyrics-body.font-sm { font-size: 0.86rem; }
.lyrics-body.font-md { font-size: 1rem; }
.lyrics-body.font-lg { font-size: 1.18rem; }

.lyrics-line {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  cursor: pointer;
  transition: color 0.16s, background 0.16s, transform 0.16s;
}

.lyrics-line:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.lyrics-line.active {
  font-weight: 600;
}

.lyrics-line.past {
  opacity: 0.72;
}

.lyric-ts {
  font-family: var(--font-mono);
  font-size: 0.72em;
  color: var(--text-muted);
  margin-right: 8px;
}

.lyrics-plain {
  white-space: pre-wrap;
  line-height: 1.75;
  color: var(--text-primary);
  margin: 0;
}

.lyrics-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
  gap: 10px;
  padding: 16px;
}

.lyrics-empty p {
  margin: 0;
  font-size: 0.85rem;
}

/* Now Playing Story Teaser Strip */
.np-story-strip {
  display: flex;
  justify-content: space-between;
}

.np-story-teaser {
  text-overflow: ellipsis;
}

/* Song & Singer Story Panel */
.story-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.story-card {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.story-card-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.story-artist-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-artist-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.story-card-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-primary);
}

.story-card-text {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.58;
  color: var(--text-secondary);
}

.story-source-link {
  align-self: flex-start;
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}

.story-source-link:hover {
  text-decoration: underline;
}

.story-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.story-stat {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
}

.story-stat-k {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.story-stat-v {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-note-textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.45;
}

/* EQ & Spatial Audio Studio */
.eq-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dsp-switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.dsp-section {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dsp-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dsp-knobs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.dsp-knob-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dsp-knob-row input[type="range"] {
  width: 100%;
}

.dsp-knob-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.dsp-knob-label strong {
  font-family: var(--font-mono);
  color: var(--accent);
}

.dsp-leveler-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding-top: 4px;
  border-top: 1px solid var(--border);
  cursor: pointer;
}

.eq-bands-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
}

.eq-band {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.eq-band-val {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.eq-slider-wrap {
  height: 112px;
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eq-slider {
  width: 104px;
  transform: rotate(-90deg);
  margin: 0;
}

.eq-band-freq {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .dsp-knobs-grid {
    grid-template-columns: 1fr;
  }
  .eq-bands-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    row-gap: 12px;
  }
}

/* Drop Overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 16, 23, 0.82);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: grid;
  place-items: center;
}

.drop-overlay-box {
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  text-align: center;
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
}

.drop-overlay-box svg {
  width: 44px;
  height: 44px;
  color: var(--accent);
  margin-bottom: 10px;
}

.drop-overlay-box h3 {
  margin: 0 0 6px;
}

.drop-overlay-box p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  grid-template-columns: minmax(0, 1fr);
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}

.story-card,
.dsp-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--neu-out-sm);
}

.modal-card {
  width: 100%;
  max-width: 420px;
  min-width: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card.modal-lg {
  max-width: 640px;
}

.modal-card h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.modal-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.editor-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.modal-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
}

.lyrics-textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
}

.modal-hint {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-playlist-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.choice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
}

.choice-row:hover {
  border-color: var(--accent);
}

/* Formats Table */
.formats-table-wrap {
  max-height: 360px;
  min-width: 0;
  overflow: auto;
}

.formats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.formats-table th,
.formats-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.formats-table th {
  color: var(--text-secondary);
  font-weight: 600;
}

.status-ok {
  color: var(--success);
  font-weight: 600;
}

.status-maybe {
  color: var(--warning);
  font-weight: 600;
}

.status-no {
  color: var(--text-muted);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.18s ease-out;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast-action {
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: var(--bg-active);
  color: var(--accent);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.toast.error {
  border-left-color: var(--danger);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile Mini Bar & Bottom Navigation (hidden on desktop) */
.mobile-mini-bar,
.mobile-nav-bar {
  display: none;
}

/* Responsive */
@media (max-width: 1379px) {
  .workspace {
    grid-template-columns: minmax(190px, 220px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(160px, 220px);
    gap: 12px;
    padding: 12px;
  }
  .lyrics-panel {
    grid-column: 1 / -1;
    max-height: none;
  }
  .center-column {
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .now-playing {
    flex: 0 0 auto;
    overflow: visible;
  }
  .playlist-section {
    flex: 0 0 220px;
    min-height: 180px;
  }
  
}

@media (max-width: 760px) {
  .app-shell {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }
  .topbar-actions {
    flex: 1 0 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
  }
  .topbar-actions > .btn,
  .topbar-more-trigger {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
  }
  .topbar-more-trigger span {
    display: none;
  }
  .topbar-more-menu {
    top: auto;
    bottom: calc(100% + 8px);
  }
  .brand-subtitle {
    display: none;
  }
  .search-wrap {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }
  .workspace,
  .workspace.lyrics-collapsed {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 10px;
    gap: 10px;
    overflow: hidden;
  }

  /* Android Mobile Tab Switching: Player | Playlists | Lyrics */
  body[data-mobile-view="player"] .sidebar,
  body[data-mobile-view="player"] .playlist-section,
  body[data-mobile-view="player"] .lyrics-panel {
    display: none !important;
  }
  body[data-mobile-view="player"] .center-column,
  body[data-mobile-view="player"] .now-playing {
    flex: 1;
    overflow-y: auto;
  }

  body[data-mobile-view="library"] .now-playing,
  body[data-mobile-view="library"] .lyrics-panel {
    display: none !important;
  }
  body[data-mobile-view="library"] .sidebar {
    max-height: 190px;
    flex-shrink: 0;
  }
  body[data-mobile-view="library"] .center-column,
  body[data-mobile-view="library"] .playlist-section {
    flex: 1;
    min-height: 0;
  }

  body[data-mobile-view="lyrics"] .sidebar,
  body[data-mobile-view="lyrics"] .center-column {
    display: none !important;
  }
  body[data-mobile-view="lyrics"] .lyrics-panel {
    display: flex !important;
    flex: 1;
    max-height: none;
    min-height: 0;
  }

  .np-top {
    grid-template-columns: minmax(0, 1fr);
    text-align: center;
  }
  .cassette-shell {
    width: min(380px, calc(100vw - 44px), 100%);
    height: 224px;
    padding: 14px 16px 10px;
  }
  .np-info {
    width: 100%;
  }
  .np-badges {
    justify-content: center;
  }
  .controls-row {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 10px;
  }
  .controls-left, .controls-right {
    justify-content: center;
  }
  .btn-play {
    width: 52px;
    height: 52px;
  }
  .btn-icon {
    min-width: 42px;
    min-height: 42px;
  }
    .track-action-btn {
    padding: 8px;
  }

  .mobile-mini-bar {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }
  body[data-mobile-view="player"] .mobile-mini-bar {
    display: none !important;
  }
  .mini-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
  }
  .mini-title {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mini-artist {
    display: block;
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .btn-mini-play {
    width: 38px;
    height: 38px;
  }

  .mobile-nav-bar {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: 4px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
  }
  .mobile-nav-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
  }
  .mobile-nav-btn svg {
    width: 19px;
    height: 19px;
  }
  .mobile-nav-btn.active {
    color: var(--text-primary);
    background: var(--bg-active);
    border-bottom: 2px solid var(--accent);
    font-weight: 600;
  }

  .toast-container {
    bottom: 118px;
    right: 12px;
    left: 12px;
  }

  .hide-sm { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #deckStage * {
    animation: none !important;
    transition: none !important;
  }

  .now-playing .btn-play:hover {
    transform: none;
  }
}

/* ========================================================================
   2. Decks, Now Playing details, VU meters
   ======================================================================== */

/* Light deck overrides + vintage VU meters.
   Comes after the base section, so equal-specificity rules here win.
   Dark theme keeps the original dark card. */

/* ---- Now-playing card: light (default) ---- */
.now-playing {
  border-color: rgba(67, 53, 35, 0.16);
}

/* ---- Now-playing card: dark (original look, unchanged) ---- */
[data-theme="dark"] .now-playing {
  color: #f2efe5;
  background:
    radial-gradient(ellipse at 88% 8%, rgba(204, 139, 82, 0.17), transparent 34%),
    linear-gradient(142deg, #17211d 0%, #26312a 58%, #19211c 100%);
  border-color: rgba(245, 239, 222, 0.16);
  box-shadow: 0 20px 44px rgba(25, 30, 24, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --deck-text: #f2efe5;
  --deck-muted: #bdc5b8;
  --deck-border: rgba(245, 239, 222, 0.16);
  --deck-accent: #e8a05f;
  --deck-surface: rgba(8, 14, 11, 0.34);
  --deck-fill: rgba(245, 239, 222, 0.07);
  --deck-fill-hover: rgba(245, 239, 222, 0.13);
}

/* ---- Replace hard-coded dark fills from the base section with theme tokens ---- */

.now-playing .speed-select,
.now-playing .deck-select {
  background: var(--deck-surface);
}

/* Story strip: full-width band under the deck, larger text, slow sheen */
.np-story-strip {
  width: 100%;
  margin-top: 0;
  align-items: center;
  border-width: 1px;
  background:
    linear-gradient(100deg,
      rgba(255, 255, 255, 0.5) 0%,
      rgba(255, 255, 255, 0.5) 38%,
      rgba(255, 226, 186, 0.95) 50%,
      rgba(255, 255, 255, 0.5) 62%,
      rgba(255, 255, 255, 0.5) 100%);
  animation: storySheen 9s ease-in-out infinite alternate;
}

.np-story-teaser {
  flex: 1;
  min-width: 0;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--deck-text);
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.np-story-strip .link-btn {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: 8px;
}

[data-theme="dark"] .np-story-strip {
  background:
    linear-gradient(100deg,
      rgba(8, 14, 11, 0.25) 0%,
      rgba(8, 14, 11, 0.25) 38%,
      rgba(229, 160, 96, 0.22) 50%,
      rgba(8, 14, 11, 0.25) 62%,
      rgba(8, 14, 11, 0.25) 100%);
  background-size: 260% 100%;
}

[data-theme="dark"] .np-story-strip .link-btn {
  background: rgba(8, 14, 11, 0.3);
  box-shadow: none;
}

@keyframes storySheen {
  from { background-position: 100% 0; }
  to { background-position: 0% 0; }
}

.np-album {
  color: var(--deck-muted);
}

[data-theme="dark"] .badge-accent {
  color: #f0b77f;
  background: rgba(232, 160, 95, 0.16);
  border-color: rgba(232, 160, 95, 0.34);
}

/* Retire the old timer-driven bars; the VU meters below replace them */
.vu-meters {
  display: none !important;
}

/* ---- Vintage VU meter pair ---- */
/* Right of the cassette deck: two meters stacked, matching the deck's height */
.vu-panel {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
  align-self: center;
  gap: 10px;
  margin-top: 0;
}

/* Narrow cards: keep the meters in one row under the track info */
@container now-playing (inline-size <= 680px) {
  .vu-panel {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 14px;
  }
}

/* Wide cards: the deck, track info and meters share one row */
@container now-playing (inline-size > 680px) {
  .np-top {
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  }
}

.vu-meter {
  width: 176px;
  max-width: 100%;
  padding: 8px 10px 6px;
  border-radius: 12px;
  background: linear-gradient(180deg, #3d3329, #241d17);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 3px 8px rgba(40, 30, 20, 0.28);
}

.vu-face {
  position: relative;
  height: 76px;
  border-radius: 8px 8px 4px 4px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 115%, #fff7e2 0%, #f4e7c8 55%, #e4d1a6 100%);
  box-shadow: inset 0 0 0 1px rgba(90, 64, 35, 0.35), inset 0 2px 6px rgba(120, 80, 30, 0.2);
}

/* Warm backlight glow while the track plays */
.vu-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 178, 86, 0.42), transparent 72%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.now-playing.playing .vu-face::after {
  opacity: 1;
}

.vu-scale {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.vu-needle {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 1.5px;
  height: 60px;
  margin-left: -0.75px;
  transform-origin: 50% 100%;
  transform: rotate(-42deg);
  background: linear-gradient(180deg, #c0392b 0 14%, #1d1a16 14%);
  border-radius: 1px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.vu-channel {
  display: block;
  margin-top: 4px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #e9dcc0;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .vu-face::after,
  .np-story-strip {
    transition: none;
    animation: none;
  }
}

/* Song title: blue-to-red metallic gradient fixed to the title width; a white sheen band moves across it */
.now-playing .np-title {
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: titleMetalSheen 6s ease-in-out infinite alternate;
}

@keyframes titleMetalSheen {
  from { background-position: 100% 0, 0 0; }
  to { background-position: 0% 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .now-playing .np-title { animation: none; }
}

/* ---- Modern Digital Deck ---- */
.deck-stage.style-modern-digital .deck-digital-view {
  display: block;
  width: 100%;
}

.digital-deck {
  width: min(100%, 340px);
  margin: 0 auto;
  padding: 16px;
  border-radius: 20px;
  display: grid;
  gap: 14px;
}

.digital-lcd {
  border-radius: 12px;
  padding: 12px 14px;
  background: radial-gradient(120% 120% at 50% 0%, #163a31 0%, #0a1613 70%);
  box-shadow: inset 0 0 0 1px rgba(94, 242, 208, 0.18), inset 0 0 22px rgba(0, 0, 0, 0.6);
}

.digital-lcd-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 700 0.7rem/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.12em;
  color: #5ef2d0;
  text-shadow: 0 0 8px rgba(94, 242, 208, 0.6);
}

.digital-lcd-status::before {
  content: "READY";
}

.now-playing.playing .digital-lcd-status::before {
  content: "PLAYING";
}

.digital-eq {
  height: 64px;
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.digital-eq span {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(to top, #1c7a66, #5ef2d0);
  transform-origin: bottom;
}

.now-playing.playing .digital-eq span {
  animation: digitalEq 0.9s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.13s);
}

@keyframes digitalEq {
  from { transform: scaleY(0.15); }
  to { transform: scaleY(var(--p, 0.8)); }
}

.digital-disc-well {
  display: grid;
  place-items: center;
  padding: 8px 0;
}

.digital-disc {
  width: 128px;
  height: 128px;
  border-radius: 50%;
}

.now-playing.playing .digital-disc {
  animation: digitalSpin 3.2s linear infinite;
}

@keyframes digitalSpin {
  to { transform: rotate(360deg); }
}

/* Progress follows the existing --tape-right value (0.38 at start, 0.94 at end) */
.digital-progress {
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
}

.digital-progress-fill {
  display: block;
  height: 100%;
  width: clamp(0%, calc((var(--tape-right, 0.38) - 0.38) / 0.56 * 100%), 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, #1c7a66, #5ef2d0);
  box-shadow: 0 0 10px rgba(94, 242, 208, 0.6);
}

.digital-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.digital-keys span {
  height: 26px;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .now-playing.playing .digital-eq span,
  .now-playing.playing .digital-disc { animation: none; }
}

/* ---- Modern Digital Deck: light body so it reads on the cream card ---- */
.digital-deck {
  color: #1d2a26;
  background: linear-gradient(160deg, #f7f8f9 0%, #d8dde1 55%, #c3cad0 100%);
  border: 1px solid rgba(60, 70, 78, 0.22);
  box-shadow: 0 14px 28px rgba(80, 60, 40, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.digital-eq span {
  opacity: 0.95;
  transform: scaleY(0.32);
}

.digital-disc {
  background:
    radial-gradient(circle, #3a4247 0 9px, transparent 10px),
    conic-gradient(from 30deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.55) 60%, rgba(255, 255, 255, 0)),
    repeating-radial-gradient(circle at 50% 50%, #e4e9ec 0 2px, #aab4bc 2px 4px);
  box-shadow: 0 0 0 6px #b7c0c7, inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.digital-progress {
  background: #b6bfc6;
  box-shadow: inset 0 1px 2px rgba(40, 50, 56, 0.35);
}

.digital-keys span {
  background: linear-gradient(#ffffff, #d5dbe0);
  box-shadow: 0 3px 0 #9aa4ac, inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* ---- Lyrics scroller: a shade darker than the panel ---- */
.lyrics-body {
  background: var(--bg-elevated);
  box-shadow: inset 0 2px 10px rgba(60, 40, 20, 0.08);
}

[data-theme="dark"] .lyrics-body {
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* ---- Lyrics scrollbar: darker track and thumb ---- */
.lyrics-body {
  scrollbar-width: thin;
  scrollbar-color: #6b604f #d9d0bd;
}

.lyrics-body::-webkit-scrollbar {
  width: 10px;
}

.lyrics-body::-webkit-scrollbar-track {
  background: #d9d0bd;
  border-radius: 8px;
}

.lyrics-body::-webkit-scrollbar-thumb {
  background: #6b604f;
  border-radius: 8px;
  border: 2px solid #d9d0bd;
}

.lyrics-body::-webkit-scrollbar-thumb:hover {
  background: #4f4538;
}

[data-theme="dark"] .lyrics-body {
  scrollbar-color: #5a6b60 #0d110f;
}

[data-theme="dark"] .lyrics-body::-webkit-scrollbar-track {
  background: #0d110f;
}

[data-theme="dark"] .lyrics-body::-webkit-scrollbar-thumb {
  background: #5a6b60;
  border: 2px solid #0d110f;
}

/* ---- Cassette realism (light theme only; dark theme keeps its own look) ---- */
/* Glossy moulded shell: a diagonal light sweep over the warm plastic */
:root:not([data-theme="dark"]) .deck-stage[class*="style-cassette"] .cassette-shell {
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 30%),
    linear-gradient(165deg, #fffefa 0%, #f5f0e4 35%, #e4dac8 75%, #d5c9b2 100%);
  box-shadow:
    var(--neu-out),
    inset 0 2px 3px rgba(255, 255, 255, 0.95),
    inset 0 -4px 8px rgba(112, 88, 59, 0.22),
    0 22px 30px -14px rgba(70, 50, 30, 0.4);
}

/* Smoked clear window: the dark tape and turning reels show through */
:root:not([data-theme="dark"]) .deck-stage[class*="style-cassette"] .cassette-window {
  background: linear-gradient(180deg, #5a5046 0%, #3d352c 55%, #2a241e 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.55),
    inset 0 -2px 4px rgba(255, 255, 255, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Wound tape: fine winding lines over the pancake's brown bands */

/* Reel hub casts a small shadow onto the tape */
:root:not([data-theme="dark"]) .deck-stage[class*="style-cassette"] .reel {
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.45),
    inset 0 0 0 5px #ffffff,
    inset 0 0 6px rgba(100, 116, 139, 0.4);
}

/* ---- Cassette fixes: quieter scale, steel spring, darker wound tape (light theme) ---- */
:root:not([data-theme="dark"]) .deck-stage[class*="style-cassette"] .tape-scale {
  opacity: 0.4;
}

:root:not([data-theme="dark"]) .deck-stage[class*="style-cassette"] .shield-spring {
  background: linear-gradient(90deg, #8b939b, #d7dde2, #8b939b);
}

:root:not([data-theme="dark"]) .deck-stage[class*="style-cassette"] .tape-pancake {
  background:
    repeating-radial-gradient(circle, rgba(255, 205, 150, 0.06) 0px, rgba(255, 205, 150, 0.06) 1px, transparent 1px, transparent 3px),
    radial-gradient(circle, #1f120c 0 40%, #2e1b13 41% 62%, #1d110b 63% 84%, #120a06 85% 100%);
  box-shadow:
    inset 0 0 8px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(255, 220, 180, 0.1),
    0 3px 6px rgba(0, 0, 0, 0.4);
}

/* ---- Studio C-90 cassette: black ribbed shell, silver label and strip (no brand names) ---- */
.deck-stage.style-cassette-chrome .cassette-shell,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-chrome .cassette-shell {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0px, rgba(255, 255, 255, 0.05) 1px, rgba(0, 0, 0, 0.35) 1px, rgba(0, 0, 0, 0.35) 3px),
    linear-gradient(180deg, #2b2b2e 0%, #1a1a1d 60%, #111113 100%);
  border: 1px solid #0b0b0d;
  box-shadow:
    0 18px 28px -12px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* ---- Compact layout: shorter player card and tighter track rows (more songs visible) ---- */
.now-playing {
  padding: 14px 18px;
  gap: 10px;
}

.np-top {
  gap: 12px;
}

@container now-playing (inline-size > 680px) {
  .np-top {
    gap: 18px;
  }
}

.np-badges {
  margin-bottom: 6px;
}

.now-playing .progress-row {
  padding-top: 8px;
}

.np-story-strip {
  padding: 10px 14px;
  gap: 12px;
}

.np-story-teaser {
  -webkit-line-clamp: 2;
}

.track-row {
  padding: 6px 11px;
  margin-bottom: 2px;
}

/* ---- VU Meters as a Deck menu option: shown only when selected ---- */
.deck-stage .deck-vu-view {
  display: none;
}

.deck-stage.style-vu-meters .deck-vu-view {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0;
  width: 100%;
}

.deck-stage.style-vu-meters .deck-vu-view .vu-meter {
  width: 170px;
}

/* ---- Song name and visualizer on one row; artist and album on one line ---- */
.np-head {
  display: flex;
  min-width: 0;
}

.np-head .np-title {
  flex: 1 1 auto;
  min-width: 0;
}

.np-head .visualizer-row {
  min-width: 0;
  margin: 0;
}

.np-head #visualizerCanvas {
  max-width: none;
}

.np-meta {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-meta .np-artist,
.np-meta .np-album {
  display: inline;
  margin: 0;
  white-space: nowrap;
}

.np-meta .np-album:not(:empty)::before {
  content: " \00B7  ";
}

@container now-playing (inline-size <= 680px) {
  .np-head {
    flex-direction: column;
  }

  .np-head .visualizer-row {
    width: 100%;
  }
}

/* ---- Song list: title and artist on one line per track ---- */
.track-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.track-main .track-row-title {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 55%;
}

.track-main .track-row-sub {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

/* ---- Song list: bold title, italic artist, one line ---- */
.track-main .track-row-title {
  font-weight: 700;
}

.track-main .track-row-sub::before {
  content: "\2013";
  margin-right: 6px;
  color: var(--text-secondary);
}

.track-main .track-row-artist {
  font-style: italic;
}

/* Song title on white: darker stops so the letters stay visible; same two-layer sheen structure */
.now-playing .np-title {
  background-size: 250% 100%, 100% 100%;
  background-repeat: no-repeat;
}

.theme-select {
  padding: 6px 10px;
  margin-right: 8px;
  background: var(--bg-panel);
  font-size: 0.82rem;
  cursor: pointer;
}

/* ---- Story box: film or album name search when no story is found ---- */
.story-film-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.story-film-row input {
  flex: 1 1 200px;
  min-width: 0;
}

/* ---- Classic Vinyl: tonearm travels from the outer groove (21deg) to the label (43deg) as the track plays ---- */
.tonearm {
  --arm-p: clamp(0, calc((var(--tape-right, 0.38) - 0.38) / 0.56), 1);
}

.playing .tonearm {
  transform: rotate(calc(21deg + var(--arm-p) * 22deg));
  transition: transform 1.2s linear;
}

/* ---- Vintage Cassette: amber tinted shell, cream label, warm stripe, smoked window ---- */
.deck-stage.style-cassette-retro .cassette-shell,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-retro .cassette-shell {
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 35%),
    linear-gradient(170deg, rgba(196, 128, 70, 0.94), rgba(140, 82, 38, 0.97) 60%, rgba(96, 54, 24, 0.98));
  border: 1px solid rgba(70, 40, 18, 0.5);
  box-shadow:
    0 16px 26px -12px rgba(60, 30, 10, 0.55),
    inset 0 1px 0 rgba(255, 235, 200, 0.35),
    inset 0 -3px 6px rgba(40, 20, 8, 0.35);
}

.deck-stage.style-cassette-retro .cassette-label,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-retro .cassette-label {
  background:
    repeating-linear-gradient(180deg, transparent 0px, transparent 22px, rgba(120, 90, 60, 0.22) 22px, rgba(120, 90, 60, 0.22) 23px),
    linear-gradient(180deg, #fbf3df, #efe2c4);
  border: 1px solid rgba(90, 60, 30, 0.25);
  border-radius: 4px;
  color: #3b2a1a;
}

.deck-stage.style-cassette-retro .cassette-stripe,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-retro .cassette-stripe {
  background: linear-gradient(180deg, #d9572b 0%, #d9572b 40%, #f2b233 40%, #f2b233 70%, #3f7a4a 70%, #3f7a4a 100%);
}

.deck-stage.style-cassette-retro .cassette-window,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-retro .cassette-window {
  background: linear-gradient(180deg, #6b4a2c, #3b2615);
  border: 1.5px solid rgba(255, 235, 200, 0.45);
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.5);
}

.deck-stage.style-cassette-retro .cassette-bottom-trapezoid,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-retro .cassette-bottom-trapezoid {
  background: linear-gradient(180deg, #3a2a1e, #1d140d);
  border: 1px solid #140c07;
  border-bottom: none;
}

/* ---- Studio C-90: brushed-metal label, red stripe, metal bottom plate ---- */
.deck-stage.style-cassette-chrome .cassette-label,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-chrome .cassette-label {
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 255, 255, 0.9), transparent 55%),
    linear-gradient(180deg, #e9ebee, #b9bfc6);
  color: #15181c;
}

.deck-stage.style-cassette-chrome .cassette-stripe,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-chrome .cassette-stripe {
  background: linear-gradient(90deg, #c62828, #e53935 60%, #7f1d1d);
}

.deck-stage.style-cassette-chrome .cassette-bottom-trapezoid,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-chrome .cassette-bottom-trapezoid {
  background: linear-gradient(180deg, #c9ced4, #7b828b);
  border: 1px solid #4b5159;
  border-bottom: none;
}

.deck-stage.style-cassette-chrome .guide-hole,
:root:not([data-theme="dark"]) .deck-stage.style-cassette-chrome .guide-hole {
  background: #2b3036;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* ---- Modern Digital: time and track readout on the LCD ---- */
.digital-readout {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  min-width: 0;
}

.digital-clock {
  font: 700 1.5rem/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.06em;
  color: #7dffe3;
  text-shadow: 0 0 10px rgba(94, 242, 208, 0.7);
}

.digital-track {
  font: 600 0.72rem/1.2 ui-monospace, Consolas, monospace;
  color: #9be9d4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Story panel: blank note when no verified info was found */
.story-empty-note {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-style: italic;
}

/* ========================================================================
   3. Light themes and dark mode
   ======================================================================== */

/* =====================================================================
   Themes
   This section comes after the base and deck sections, so its rules take precedence.
   1. Shared token defaults        (html[data-light-theme])
   2. One token block per theme    (light themes skip dark mode)
   3. Dark-mode tokens
   4. Component rules that read the tokens
   5. Theme-specific touches (neumorphism, clay, brutalism, glass)
   6. Now-playing layout fixes for mid-width screens
   ===================================================================== */

/* ---------- 1. Shared defaults ---------- */
html[data-light-theme] {
  --font-sans: "Manrope", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --accent-ink: #ffffff;
  --accent-text: var(--accent);
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 30%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 24%, transparent);
  --bg-active: var(--accent-soft);

  --panel-border-w: 1px;
  --panel-border: var(--border);
  --panel-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px rgba(16, 24, 40, 0.06);
  --card-bg: var(--bg-panel);
  --card-stripe: transparent;
  --topbar-bg: color-mix(in srgb, var(--bg-panel) 82%, transparent);

  --btn-bg: var(--bg-panel);
  --btn-border: var(--border);
  --btn-shadow: none;
  --input-bg: var(--bg-elevated);
  --input-shadow: none;

  --brand-fill: linear-gradient(90deg, var(--text-primary), var(--text-primary));
  --title-a: var(--text-primary);
  --title-b: var(--accent-text);
  --play-bg: var(--accent);
  --play-border: transparent;
  --play-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 32%, transparent);

  --viz-1: var(--accent);
  --viz-2: var(--accent);
  --viz-3: var(--accent);

  --success: #2f7d55;
}

/* ---------- 2. Light themes ---------- */

/* Clean Studio: cool neutral canvas, white cards, cobalt accent */
html[data-light-theme="clean"]:not([data-theme="dark"]) {
  --bg-app: #f3f5f8;
  --bg-panel: #ffffff;
  --bg-elevated: #f7f8fa;
  --bg-hover: #eef1f5;
  --border: rgba(16, 24, 40, 0.08);
  --border-strong: rgba(16, 24, 40, 0.16);
  --text-primary: #101828;
  --text-secondary: #475467;
  --text-muted: #667085;
  --accent: #3656d6;
  --accent-strong: #2742b3;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --neu-out: var(--panel-shadow);
  --neu-out-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --neu-in: inset 0 1px 2px rgba(16, 24, 40, 0.06);
  --neu-in-sm: inset 0 1px 2px rgba(16, 24, 40, 0.05);
  --viz-1: #3656d6;
  --viz-2: #7a5cf0;
  --viz-3: #14a89b;
}

/* Warm Paper: oat paper, ink text, terracotta + olive, serif display */
html[data-light-theme="warm"]:not([data-theme="dark"]) {
  --font-sans: "Figtree", "Segoe UI", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --bg-app: #ece4d6;
  --bg-panel: #faf6ee;
  --bg-elevated: #f3ecdf;
  --bg-hover: #ebe1cf;
  --border: rgba(70, 48, 22, 0.12);
  --border-strong: rgba(70, 48, 22, 0.22);
  --text-primary: #2a2118;
  --text-secondary: #62513e;
  --text-muted: #7f6d58;
  --accent: #b04a2b;
  --accent-strong: #8c3820;
  --accent-ink: #fff8ef;
  --success: #5b6f2c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --panel-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 26px rgba(70, 45, 15, 0.08);
  --neu-out: var(--panel-shadow);
  --neu-out-sm: 0 1px 2px rgba(70, 45, 15, 0.08);
  --neu-in: inset 0 1px 3px rgba(70, 45, 15, 0.08);
  --neu-in-sm: inset 0 1px 2px rgba(70, 45, 15, 0.07);
  --card-stripe: linear-gradient(90deg, #b04a2b, #d9993f 55%, #6b7d3a);
  --viz-1: #b04a2b;
  --viz-2: #d9993f;
  --viz-3: #6b7d3a;
}

/* Tricolour Light: white, navy ink, saffron accent, India-green support */
html[data-light-theme="tricolour"]:not([data-theme="dark"]) {
  --font-sans: "Mukta", "Segoe UI", system-ui, sans-serif;
  --font-display: "Baloo 2", "Mukta", system-ui, sans-serif;
  --bg-app: #f8f6f1;
  /* The tricolour (no chakra) waving diagonally from top-left to bottom-right. */
  --app-backdrop: url("tricolour-wave.svg") center / 100% 100% no-repeat, #f8f6f1;
  --bg-panel: #ffffff;
  --bg-elevated: #fbf8f3;
  --bg-hover: #f6efe4;
  --border: rgba(27, 42, 74, 0.1);
  --border-strong: rgba(27, 42, 74, 0.2);
  --text-primary: #17223d;
  --text-secondary: #46526f;
  --text-muted: #58627c;
  --accent: #e8741c;
  --accent-strong: #c95f0e;
  --accent-text: #9e4807;
  --accent-ink: #17223d;
  --success: #1e7b3c;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --neu-out: var(--panel-shadow);
  --neu-out-sm: 0 1px 2px rgba(27, 42, 74, 0.06);
  --neu-in: inset 0 1px 2px rgba(27, 42, 74, 0.06);
  --neu-in-sm: inset 0 1px 2px rgba(27, 42, 74, 0.05);
  --brand-fill: linear-gradient(90deg, #d9650c 0%, #22378a 52%, #1e7b3c 100%);
  --card-stripe: linear-gradient(90deg, #ff9933 0 33.3%, #22378a 33.3% 66.6%, #138808 66.6%);
  --title-b: #22378a;
  --viz-1: #ff9933;
  --viz-2: #22378a;
  --viz-3: #1e8a3e;
}

/* Neo Morphism: true soft UI. One neutral grey surface; everything is molded from it,
   raised (dual light/dark shadow) or pressed (inset). No coloured fills; graphite ink only. */
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) {
  --font-sans: "Nunito", "Segoe UI", system-ui, sans-serif;
  --nm-surface: #e4e5e7;
  --nm-dark: #c3c5c9;
  --nm-light: #ffffff;
  --bg-app: var(--nm-surface);
  --bg-panel: var(--nm-surface);
  --bg-elevated: var(--nm-surface);
  --bg-hover: var(--nm-surface);
  --border: transparent;
  --border-strong: transparent;
  --text-primary: #2d2f33;
  --text-secondary: #53565c;
  --text-muted: #5f6268;
  --accent: #3a3c41;
  --accent-strong: #2d2f33;
  --accent-text: #2d2f33;
  --accent-ink: #2d2f33;
  --accent-soft: var(--nm-surface);
  --accent-line: transparent;
  --accent-glow: rgba(45, 47, 51, 0.12);
  --success: #53565c;
  --radius-sm: 14px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --neu-out: 9px 9px 18px var(--nm-dark), -9px -9px 18px var(--nm-light);
  --neu-out-sm: 4px 4px 8px var(--nm-dark), -4px -4px 8px var(--nm-light);
  --neu-in: inset 5px 5px 10px var(--nm-dark), inset -5px -5px 10px var(--nm-light);
  --neu-in-sm: inset 3px 3px 6px var(--nm-dark), inset -3px -3px 6px var(--nm-light);
  --nm-convex: linear-gradient(145deg, #f4f5f7, #cdcfd2);
  --panel-border: transparent;
  --panel-shadow: var(--neu-out);
  --topbar-bg: var(--nm-surface);
  --btn-bg: var(--nm-surface);
  --btn-border: transparent;
  --btn-shadow: var(--neu-out-sm);
  --input-bg: var(--nm-surface);
  --input-shadow: var(--neu-in-sm);
  --play-bg: var(--nm-convex);
  --play-border: transparent;
  --play-shadow: 6px 6px 14px var(--nm-dark), -6px -6px 14px var(--nm-light);
  --title-b: #2d2f33;
  --viz-1: #3a3c41;
  --viz-2: #6c6f75;
  --viz-3: #a3a6ab;
}

/* Clay Morphism (Malewicz, 2021): soft, inflated, clay-like surfaces.
   - Large radii (20-40px)
   - Three-shadow stack on every clay object:
       outer drop shadow (floats) + inset dark (underside curve) + inset light (highlight)
   - Pastel soft blue, pink and white. Pink = actions, blue = selection.
   - Text keeps 4.5:1+ contrast (claymorphism's fix for neumorphism's weak contrast). */
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) {
  --font-sans: "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;

  --clay-blue: #cfe6fb;
  --clay-blue-deep: #1f5f9e;
  --clay-pink: #ffb6d0;
  --clay-pink-deep: #b8325f;
  --clay-white: #fdfeff;

  /* Three-shadow stacks (outer, inset dark, inset light) */
  --clay-lg: 14px 18px 36px rgba(72, 112, 160, 0.2), inset -10px -12px 20px rgba(72, 112, 160, 0.12), inset 10px 12px 20px rgba(255, 255, 255, 0.95);
  --clay-sm: 6px 8px 16px rgba(72, 112, 160, 0.2), inset -4px -5px 9px rgba(72, 112, 160, 0.14), inset 4px 5px 9px rgba(255, 255, 255, 0.95);
  --clay-pressed: 2px 3px 6px rgba(72, 112, 160, 0.14), inset -2px -3px 5px rgba(255, 255, 255, 0.7), inset 4px 5px 10px rgba(72, 112, 160, 0.22);
  --clay-pink-sm: 6px 8px 16px rgba(214, 92, 140, 0.3), inset -4px -5px 9px rgba(184, 50, 95, 0.22), inset 4px 5px 9px rgba(255, 255, 255, 0.65);
  --clay-blue-sm: 6px 8px 16px rgba(72, 130, 190, 0.26), inset -4px -5px 9px rgba(31, 95, 158, 0.16), inset 4px 5px 9px rgba(255, 255, 255, 0.75);

  --bg-app: #dcecfa;
  --app-backdrop:
    radial-gradient(55% 60% at 0% 0%, rgba(255, 214, 230, 0.9), transparent 70%),
    radial-gradient(50% 55% at 100% 100%, rgba(255, 222, 236, 0.75), transparent 70%),
    linear-gradient(160deg, #e3f0fc 0%, #dcecfa 55%, #e6f1fb 100%);
  --bg-panel: var(--clay-white);
  --bg-elevated: #f2f8fe;
  --bg-hover: #eaf4fd;
  --border: transparent;
  --border-strong: rgba(72, 112, 160, 0.18);
  --text-primary: #26324d;
  --text-secondary: #4e5b78;
  --text-muted: #5f6b87;
  --accent: #f48fb5;
  --accent-strong: #ec7aa5;
  --accent-text: var(--clay-pink-deep);
  --accent-ink: #5a1535;
  --accent-soft: var(--clay-blue);
  --accent-line: transparent;
  --accent-glow: rgba(244, 143, 181, 0.3);
  --success: #1f5f9e;
  --radius-sm: 20px;
  --radius-md: 28px;
  --radius-lg: 36px;

  --panel-border-w: 0px;
  --panel-border: transparent;
  --panel-shadow: var(--clay-lg);
  --neu-out: var(--clay-lg);
  --neu-out-sm: var(--clay-sm);
  --neu-in: var(--clay-pressed);
  --neu-in-sm: var(--clay-pressed);
  --topbar-bg: rgba(253, 254, 255, 0.78);
  --btn-bg: var(--clay-white);
  --btn-border: transparent;
  --btn-shadow: var(--clay-sm);
  --input-bg: #f2f8fe;
  --input-shadow: var(--clay-pressed);

  --play-bg: var(--clay-pink);
  --play-border: transparent;
  --play-shadow: 8px 10px 20px rgba(214, 92, 140, 0.34), inset -6px -7px 12px rgba(184, 50, 95, 0.24), inset 6px 7px 12px rgba(255, 255, 255, 0.7);
  --title-b: var(--clay-pink-deep);
  /* pink -> peach -> blue: the peach stop keeps the gradient out of lavender */
  --viz-1: #f27aa6;
  --viz-2: #ffc59e;
  --viz-3: #6fb3ee;
}

/* Minimalism: white, hairlines, monochrome, no shadows */
html[data-light-theme="minimalism"]:not([data-theme="dark"]) {
  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --bg-app: #ffffff;
  --bg-panel: #ffffff;
  --bg-elevated: #fafafa;
  --bg-hover: #f3f3f3;
  --border: #e6e6e6;
  --border-strong: #cfcfcf;
  --text-primary: #0a0a0a;
  --text-secondary: #545454;
  --text-muted: #7a7a7a;
  --accent: #0a0a0a;
  --accent-strong: #2e2e2e;
  --accent-soft: #f2f2f2;
  --success: #3d3d3d;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --neu-out: none;
  --neu-out-sm: none;
  --neu-in: none;
  --neu-in-sm: none;
  --shadow-lg: none;
  --panel-shadow: none;
  --topbar-bg: #ffffff;
  --btn-bg: #ffffff;
  --input-bg: #ffffff;
  --play-shadow: none;
  --title-b: #0a0a0a;
  --viz-1: #0a0a0a;
  --viz-2: #5c5c5c;
  --viz-3: #a8a8a8;
}

/* NeoBrutalism: cream, thick ink borders, hard shadows, loud pink + yellow */
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) {
  --font-sans: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, Consolas, monospace;
  --bg-app: #fff3d1;
  --bg-panel: #ffffff;
  --bg-elevated: #fffaea;
  --bg-hover: #ffeb99;
  --border: #111111;
  --border-strong: #111111;
  --text-primary: #111111;
  --text-secondary: #2b2b2b;
  --text-muted: #474747;
  --accent: #ff4f87;
  --accent-strong: #e8336d;
  --accent-text: #111111;
  --accent-ink: #111111;
  --accent-soft: #ffd84d;
  --success: #111111;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --panel-border-w: 3px;
  --panel-border: #111111;
  --panel-shadow: 6px 6px 0 #111111;
  --neu-out: var(--panel-shadow);
  --neu-out-sm: 3px 3px 0 #111111;
  --neu-in: inset 2px 2px 0 #111111;
  --neu-in-sm: inset 2px 2px 0 #111111;
  --shadow-lg: 8px 8px 0 #111111;
  --topbar-bg: #ffffff;
  --btn-bg: #ffffff;
  --btn-border: #111111;
  --btn-shadow: 3px 3px 0 #111111;
  --input-bg: #ffffff;
  --play-bg: #ffd84d;
  --play-border: #111111;
  --play-shadow: 4px 4px 0 #111111;
  --title-a: #111111;
  --title-b: #111111;
  --viz-1: #ff4f87;
  --viz-2: #ffc400;
  --viz-3: #3b6cff;
}

/* Glass Morphism: frosted panels over a colour mesh */
html[data-light-theme="glassmorphism"]:not([data-theme="dark"]) {
  --font-sans: "Sora", "Segoe UI", system-ui, sans-serif;
  --bg-app: #dfe4fb;
  --app-backdrop:
    radial-gradient(40% 50% at 8% 10%, rgba(120, 150, 255, 0.55), transparent 70%),
    radial-gradient(35% 45% at 92% 12%, rgba(255, 140, 200, 0.5), transparent 70%),
    radial-gradient(45% 50% at 85% 95%, rgba(90, 210, 220, 0.45), transparent 70%),
    radial-gradient(40% 45% at 15% 92%, rgba(175, 130, 255, 0.45), transparent 70%),
    #e4e6fa;
  --bg-panel: rgba(255, 255, 255, 0.42);
  --bg-elevated: rgba(255, 255, 255, 0.5);
  --bg-hover: rgba(255, 255, 255, 0.62);
  --border: rgba(255, 255, 255, 0.65);
  --border-strong: rgba(255, 255, 255, 0.85);
  --text-primary: #161d36;
  --text-secondary: #3a4466;
  --text-muted: #56607f;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: rgba(255, 255, 255, 0.6);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --panel-shadow: 0 10px 34px rgba(40, 46, 140, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --neu-out: var(--panel-shadow);
  --neu-out-sm: 0 4px 12px rgba(40, 46, 140, 0.1);
  --neu-in: inset 0 1px 2px rgba(40, 46, 140, 0.08);
  --neu-in-sm: inset 0 1px 2px rgba(40, 46, 140, 0.06);
  --topbar-bg: rgba(255, 255, 255, 0.4);
  --btn-bg: rgba(255, 255, 255, 0.45);
  --input-bg: rgba(255, 255, 255, 0.5);
  --play-bg: linear-gradient(135deg, #5b52f0, #c03fa4);
  --play-border: rgba(255, 255, 255, 0.7);
  --title-b: #b83291;
  --viz-1: #4f46e5;
  --viz-2: #d63b98;
  --viz-3: #0ea5c4;
}

/* ---------- 3. Dark mode (any light theme selection) ---------- */
html[data-light-theme][data-theme="dark"] {
  --accent-ink: #24170d;
  --accent-soft: rgba(225, 161, 106, 0.14);
  --panel-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  --card-bg:
    radial-gradient(ellipse at 88% 8%, rgba(204, 139, 82, 0.15), transparent 34%),
    linear-gradient(142deg, #17211d 0%, #232d27 58%, #19211c 100%);
  --topbar-bg: rgba(29, 35, 31, 0.82);
  --btn-bg: rgba(245, 239, 222, 0.05);
  --input-bg: rgba(8, 14, 11, 0.35);
  --play-bg: linear-gradient(145deg, #f1bb82, #d28243);
  --play-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  --title-a: #f2efe5;
  --title-b: #f0bc88;
  --success: #8ac29a;
  --viz-1: #f0b07a;
  --viz-2: #d9c79a;
  --viz-3: #7fb889;
}

/* ---------- 4. Components ---------- */
html[data-light-theme] body {
  font-family: var(--font-sans);
  background: var(--bg-app);
}

html[data-light-theme] .app-shell {
  background: var(--app-backdrop, var(--bg-app));
}

html[data-light-theme] .brand-title {
  /* Fit the box to the word so the brand gradient spans the whole name. */
  width: fit-content;
  font-family: var(--font-display);
  background: var(--brand-fill);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

html[data-light-theme] .topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
}

/* Panels and the now-playing card share one surface treatment */
html[data-light-theme] .panel,
html[data-light-theme] .now-playing {
  border: var(--panel-border-w) solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--panel-shadow);
}

html[data-light-theme] .panel {
  background: var(--bg-panel);
}

html[data-light-theme] .now-playing {
  color: var(--text-primary);
  background: var(--card-bg);
  --deck-text: var(--text-primary);
  --deck-muted: var(--text-secondary);
  --deck-border: var(--border);
  --deck-accent: var(--accent);
  --deck-surface: var(--bg-elevated);
  --deck-fill: var(--btn-bg);
  --deck-fill-hover: var(--bg-hover);
}

html[data-light-theme] .now-playing::before {
  inset: 0 var(--radius-lg) auto;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--card-stripe);
  opacity: 1;
}

html[data-light-theme] .panel-header h2 {
  font-family: var(--font-display);
  color: var(--text-secondary);
}

/* Buttons */
html[data-light-theme] .btn {
  font-family: inherit;
}

html[data-light-theme] .btn-secondary,
html[data-light-theme] .btn-ghost,
html[data-light-theme] .now-playing .btn-secondary,
html[data-light-theme] .now-playing .btn-ghost,
html[data-light-theme] .now-playing .btn-icon {
  background: var(--btn-bg);
  border-color: var(--btn-border);
  box-shadow: var(--btn-shadow);
  color: var(--text-primary);
}

html[data-light-theme] .now-playing .btn-icon {
  color: var(--text-secondary);
}

html[data-light-theme] .btn-secondary:hover,
html[data-light-theme] .btn-ghost:hover,
html[data-light-theme] .btn-icon:hover,
html[data-light-theme] .now-playing .btn-secondary:hover,
html[data-light-theme] .now-playing .btn-ghost:hover,
html[data-light-theme] .now-playing .btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

html[data-light-theme] .btn-ghost.active,
html[data-light-theme] .btn-icon.active,
html[data-light-theme] .now-playing .btn-ghost.active,
html[data-light-theme] .now-playing .btn-icon.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-text);
  box-shadow: var(--neu-in-sm);
}

html[data-light-theme] .btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: var(--btn-shadow);
  font-weight: 700;
}

html[data-light-theme] .btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

html[data-light-theme] .btn-play,
html[data-light-theme] .now-playing .btn-play {
  background: var(--play-bg);
  color: var(--accent-ink);
  border: 2px solid var(--play-border);
  box-shadow: var(--play-shadow);
}

html[data-light-theme] .btn-play:hover,
html[data-light-theme] .now-playing .btn-play:hover {
  background: var(--play-bg);
  filter: brightness(1.06);
}

html[data-light-theme] .link-btn {
  color: var(--accent-text);
}

/* Inputs and selects */
html[data-light-theme] .search-wrap input,
html[data-light-theme] .theme-select,
html[data-light-theme] .speed-select,
html[data-light-theme] .deck-select,
html[data-light-theme] .now-playing .speed-select,
html[data-light-theme] .now-playing .deck-select {
  background-color: var(--input-bg);
  border: 1px solid var(--btn-border);
  box-shadow: var(--input-shadow);
  color: var(--text-primary);
  font-family: inherit;
}

html[data-light-theme] .search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: var(--input-shadow), 0 0 0 3px var(--accent-glow);
}

html[data-light-theme] .theme-select {
  border-radius: var(--radius-sm);
}

html[data-light-theme] input[type="range"] {
  accent-color: var(--accent-strong);
}

/* Player sliders in every theme: volume is blue, song position is dark green.
   Dark mode uses lighter shades of the same colours so they stay visible. */
:root {
  --volume-color: #1f5fd6;
  --seek-color: #146b2e;
}
html[data-theme="dark"] {
  --volume-color: #5b9cff;
  --seek-color: #2fa35a;
}
#volumeSlider {
  accent-color: var(--volume-color);
}
#seekBar {
  accent-color: var(--seek-color);
}

/* Tricolour Light: panels are frosted so the waving flag shows through softly. */
html[data-light-theme="tricolour"]:not([data-theme="dark"]) .workspace .panel,
html[data-light-theme="tricolour"]:not([data-theme="dark"]) .workspace .now-playing {
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
}

/* Lists: playlists, tracks, lyrics */
html[data-light-theme] .playlist-item.active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  box-shadow: var(--neu-in-sm);
  color: var(--accent-text);
}

html[data-light-theme] .track-row.active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  box-shadow: var(--neu-in-sm);
}

html[data-light-theme] .track-row.active .track-index,
html[data-light-theme] .track-row.active .track-row-title {
  color: var(--accent-text);
}

html[data-light-theme] .lyrics-line.active {
  color: var(--accent-text);
  background: var(--accent-soft);
}

html[data-light-theme] .tab-btn.active,
html[data-light-theme] .seg-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Chips and badges */
html[data-light-theme] .badge-accent {
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}

html[data-light-theme] .mini-tag.has-lyrics {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  background: color-mix(in srgb, var(--success) 8%, transparent);
}

html[data-light-theme] .count-pill,
html[data-light-theme] .mini-tag {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

/* Song title: display font, ink-to-accent gradient with the existing moving sheen */
html[data-light-theme] .now-playing .np-title {
  font-family: var(--font-display);
  background-image:
    linear-gradient(100deg, transparent 42%, rgba(255, 255, 255, 0.5) 50%, transparent 58%),
    linear-gradient(100deg, var(--title-a) 0%, var(--title-a) 40%, var(--title-b) 100%);
  filter: none;
}

/* Story strip under the deck */
html[data-light-theme] .np-story-strip {
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-md);
  background:
    linear-gradient(100deg,
      var(--bg-elevated) 0%,
      var(--bg-elevated) 38%,
      color-mix(in srgb, var(--accent) 14%, var(--bg-elevated)) 50%,
      var(--bg-elevated) 62%,
      var(--bg-elevated) 100%);
  background-size: 260% 100%;
}

html[data-light-theme] .np-story-strip .link-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  box-shadow: var(--btn-shadow);
}

html[data-light-theme] #visualizerCanvas {
  background: var(--deck-surface);
  border-color: var(--border);
}

/* ---------- 5. Theme-specific touches ---------- */

/* Neumorphism: every control is the surface itself, raised; active/pressed = inset */
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn {
  transition: box-shadow 150ms ease, color 150ms ease;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-primary,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-secondary,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-ghost,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-icon,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-icon,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-secondary,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-ghost {
  background: var(--nm-surface);
  color: var(--text-primary);
  border-color: transparent;
  box-shadow: var(--neu-out-sm);
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-primary {
  font-weight: 800;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn:hover,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-primary:hover,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-icon:hover {
  background: var(--nm-convex);
  color: var(--text-primary);
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn:active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-primary:active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-ghost.active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-icon.active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-ghost.active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-icon.active {
  background: var(--nm-surface);
  box-shadow: var(--neu-in-sm);
  transform: none;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-play,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-play {
  color: #2d2f33;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-play:hover,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-play:hover {
  background: var(--nm-convex);
  filter: none;
  transform: none;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn-play:active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing .btn-play:active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .now-playing.playing .btn-play {
  background: linear-gradient(145deg, #cdcfd2, #f4f5f7);
  box-shadow: var(--neu-in-sm);
}

/* Tab groups sit in a pressed well; the selected tab rises out of it */
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .lyrics-mode-tabs,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .segmented {
  background: var(--nm-surface);
  border: none;
  box-shadow: var(--neu-in-sm);
  padding: 4px;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .tab-btn.active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .seg-btn.active {
  background: var(--nm-surface);
  color: var(--text-primary);
  font-weight: 800;
  box-shadow: var(--neu-out-sm);
}

/* Lists: hover rises, active is pressed in */
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .playlist-item:hover,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .track-row:hover {
  background: var(--nm-surface);
  box-shadow: var(--neu-out-sm);
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .track-row.active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .playlist-item.active {
  background: var(--nm-surface);
  border-left-color: transparent;
  box-shadow: var(--neu-in-sm);
  color: var(--text-primary);
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .playlist-item.active,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .track-row.active .track-row-title {
  font-weight: 800;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .lyrics-line.active {
  background: transparent;
  color: var(--text-primary);
  font-weight: 800;
}

/* Small chips are shallow dimples */
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .badge,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .badge-accent,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .count-pill,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .mini-tag,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .mini-tag.has-lyrics {
  background: var(--nm-surface);
  color: var(--text-secondary);
  border-color: transparent;
  box-shadow: inset 1.5px 1.5px 3px var(--nm-dark), inset -1.5px -1.5px 3px var(--nm-light);
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .panel-header {
  border-bottom-color: transparent;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) #visualizerCanvas,
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .np-story-strip {
  border: none;
  box-shadow: var(--neu-in);
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .np-story-strip {
  background: var(--nm-surface);
  animation: none;
}

html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .np-story-strip .link-btn {
  border: none;
}

/* Clay: every control is a puffy three-shadow object; press squashes it (200ms soft bounce) */
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn {
  border: none;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 200ms ease-out, background-color 200ms ease-out;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn:not(.btn-icon):not(.btn-play) {
  border-radius: var(--radius-sm);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-secondary,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-ghost,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .btn-secondary,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .btn-ghost,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .btn-icon {
  background: var(--clay-white);
  color: var(--text-primary);
  box-shadow: var(--clay-sm);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn:hover {
  transform: translateY(-2px);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn:active {
  transform: scale(0.94);
  box-shadow: var(--clay-pressed);
}

/* Actions: pastel pink clay */
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-primary {
  background: var(--clay-pink);
  color: var(--accent-ink);
  box-shadow: var(--clay-pink-sm);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-primary:hover {
  background: #ffc4d9;
}

/* Play: the biggest, puffiest pink clay ball */
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-play,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .btn-play {
  background: var(--play-bg);
  color: var(--accent-ink);
  box-shadow: var(--play-shadow);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-play:active,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .btn-play:active {
  box-shadow: 2px 3px 8px rgba(214, 92, 140, 0.3), inset -2px -3px 6px rgba(255, 255, 255, 0.5), inset 5px 6px 12px rgba(184, 50, 95, 0.3);
}

/* Selection: pastel blue clay */
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-ghost.active,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn-icon.active,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .btn-ghost.active,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .btn-icon.active,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .tab-btn.active,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .seg-btn.active {
  background: var(--clay-blue);
  color: #163a63;
  box-shadow: var(--clay-blue-sm);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .lyrics-mode-tabs,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .segmented {
  border: none;
  background: #f2f8fe;
  box-shadow: var(--clay-pressed);
  border-radius: var(--radius-sm);
  padding: 4px;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .tab-btn {
  border-radius: 16px;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .track-row,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .playlist-item {
  border-radius: 20px;
  border: none;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .track-row:hover,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .playlist-item:hover {
  background: var(--clay-white);
  box-shadow: var(--clay-sm);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .track-row.active,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .playlist-item.active {
  background: var(--clay-blue);
  border-left: none;
  box-shadow: var(--clay-blue-sm);
  color: #163a63;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .track-row.active .track-index,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .track-row.active .track-row-title {
  color: #163a63;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .lyrics-line.active {
  background: #ffe4ee;
  color: var(--clay-pink-deep);
  border-radius: 16px;
}

/* Small chips: tiny clay pebbles */
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .badge,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .badge-accent,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .mini-tag,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .count-pill {
  border: none;
  border-radius: 999px;
  background: var(--clay-white);
  color: var(--text-secondary);
  box-shadow: 2px 3px 6px rgba(72, 112, 160, 0.16), inset -1px -2px 3px rgba(72, 112, 160, 0.12), inset 1px 2px 3px rgba(255, 255, 255, 0.9);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .mini-tag.has-lyrics {
  background: var(--clay-blue);
  color: #163a63;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .badge-accent {
  background: #ffe4ee;
  color: var(--clay-pink-deep);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .panel-header {
  border-bottom-color: rgba(72, 112, 160, 0.1);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) #visualizerCanvas {
  border: none;
  border-radius: var(--radius-sm);
  background: #f2f8fe;
  box-shadow: var(--clay-pressed);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .np-story-strip {
  border: none;
  border-radius: var(--radius-md);
  background: #fff1f6;
  box-shadow: var(--clay-sm);
  animation: none;
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .np-story-strip .link-btn {
  background: var(--clay-white);
  border: none;
  border-radius: 16px;
  color: var(--clay-pink-deep);
  box-shadow: var(--clay-sm);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .viz-eq-btn,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .viz-eq-btn {
  background: var(--clay-white);
  color: var(--clay-pink-deep);
}

html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .search-wrap input,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .theme-select,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .deck-select,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .speed-select,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .deck-select,
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .now-playing .speed-select {
  border: none;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn,
  html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .btn {
    transition: none;
  }

  html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn:hover,
  html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .btn:active {
    transform: none;
  }
}

/* Minimalism: flat, underline-style active states */
html[data-light-theme="minimalism"]:not([data-theme="dark"]) .track-row.active,
html[data-light-theme="minimalism"]:not([data-theme="dark"]) .playlist-item.active {
  box-shadow: none;
  border-left-color: #0a0a0a;
}

html[data-light-theme="minimalism"]:not([data-theme="dark"]) .np-story-strip {
  animation: none;
  background: #fafafa;
  border-inline-start-color: #0a0a0a;
}

/* NeoBrutalism: thick outlines, press-down buttons, loud active rows */
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .topbar {
  border-bottom: 3px solid #111111;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .panel-header {
  border-bottom: 3px solid #111111;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .btn,
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .search-wrap input,
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .theme-select,
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .deck-select,
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .speed-select {
  border: 2px solid #111111;
  border-radius: 6px;
  font-weight: 700;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .btn-primary {
  background: #ff4f87;
  color: #111111;
  border-color: #111111;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 #111111;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .btn:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .track-row {
  border: 2px solid transparent;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .track-row:hover {
  background: #fffaea;
  border-color: #111111;
  box-shadow: 3px 3px 0 #111111;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .track-row.active,
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .playlist-item.active {
  background: #ffd84d;
  border: 2px solid #111111;
  box-shadow: 3px 3px 0 #111111;
  color: #111111;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .tab-btn.active,
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .seg-btn.active {
  background: #111111;
  color: #ffffff;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .np-story-strip {
  border: 2px solid #111111;
  border-inline-start: 8px solid #ff4f87;
  background: #fffaea;
  animation: none;
  box-shadow: 4px 4px 0 #111111;
}

html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) #visualizerCanvas {
  border: 2px solid #111111;
  background: #fffaea;
}

/* Glass: frosted surfaces */
html[data-light-theme="glassmorphism"]:not([data-theme="dark"]) .panel,
html[data-light-theme="glassmorphism"]:not([data-theme="dark"]) .now-playing {
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}

html[data-light-theme="glassmorphism"]:not([data-theme="dark"]) .btn-primary {
  background: linear-gradient(135deg, #5b52f0, #b83291);
  border-color: rgba(255, 255, 255, 0.5);
}

html[data-light-theme="glassmorphism"]:not([data-theme="dark"]) .np-story-strip {
  background: rgba(255, 255, 255, 0.45);
  animation: none;
}

/* ---------- 6. Now-playing layout at mid widths ---------- */
.np-info {
  container: np-info / inline-size;
  min-width: 0;
}

#visualizerCanvas {
  min-width: 0;
  width: 100%;
}

@container np-info (inline-size < 560px) {
  .np-head {
    flex-direction: column;
  }

  .np-head .visualizer-row {
    width: 100%;
  }

  
  .controls-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "transport transport"
      "left right";
    row-gap: 10px;
  }

  .controls-row .transport-buttons {
    grid-area: transport;
    justify-self: center;
  }

  .controls-row .controls-left {
    grid-area: left;
  }

  .controls-row .controls-right {
    grid-area: right;
  }
}

/* ---------- 7. EQ & FX sits on top of the visualizer ---------- */
html[data-light-theme] .visualizer-row {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.viz-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

html[data-light-theme] .viz-eq-btn,
html[data-light-theme] .now-playing .viz-eq-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 12px;
  font-weight: 700;
  color: var(--accent-text);
  border-color: var(--accent-line);
}

.viz-eq-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Effects switched on: the button lights up so the change is visible */
html[data-light-theme] .viz-eq-btn.active,
html[data-light-theme] .now-playing .viz-eq-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Wide card: song details on the left; on the right, EQ & FX sits level with the
   format line at the top and the visualizer fills the full height below it. */
html[data-light-theme] .np-head {
  align-items: stretch;
  gap: 22px;
}

.np-head-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.np-head-main .np-badges {
  margin-bottom: 0;
}

/* Song title with the favourite heart right after it */
.np-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.np-title-row .np-title {
  flex: 0 1 auto;
  min-width: 0;
}

.np-title-row #btnFavoriteCurrent {
  flex-shrink: 0;
}

html[data-light-theme] .np-head .visualizer-row {
  flex: 0 0 54%;
  gap: 12px;
}

html[data-light-theme] .np-head #visualizerCanvas {
  flex: 1 1 auto;
  height: auto;
  min-height: 128px;
}

/* Narrow card: everything stacks; the visualizer keeps a generous fixed height */
@container np-info (inline-size < 560px) {
  html[data-light-theme] .np-head .visualizer-row {
    flex: 0 0 auto;
  }

  html[data-light-theme] .np-head #visualizerCanvas {
    flex: none;
    height: 84px;
    min-height: 0;
  }
}

/* Clay sliders: deep pink thumb/fill so Chrome keeps a light track */
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) input[type="range"] {
  accent-color: var(--clay-pink-deep);
}

/* ---------- 8. Playlists: open / save / drag & drop ---------- */
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.playlist-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-xs svg,
.sidebar-header-actions .btn svg {
  width: 13px;
  height: 13px;
}

.playlist-actions .btn,
.sidebar-header-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.sidebar-header-actions .btn {
  padding: 5px 9px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Rows: grip on hover where reordering is allowed; a line shows where the song will land */
.track-row {
  position: relative;
}

.track-list.can-reorder .track-row::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 6px;
  height: 14px;
  transform: translateY(-50%);
  background-image: radial-gradient(circle, var(--text-muted) 1.2px, transparent 1.4px);
  background-size: 3px 4.6px;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: grab;
}

.track-list.can-reorder .track-row:hover::before {
  opacity: 0.8;
}

.track-row.dragging {
  opacity: 0.4;
}

.track-row.drop-before::after,
.track-row.drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent-text);
  pointer-events: none;
}

.track-row.drop-before::after {
  top: -3px;
}

.track-row.drop-after::after {
  bottom: -3px;
}

/* Sidebar: while a song is dragged, playlists that accept it are outlined; the one under the pointer lights up */
body.is-dragging-song .playlist-item[data-drop-target] {
  outline: 1.5px dashed color-mix(in srgb, var(--text-muted) 70%, transparent);
  outline-offset: -3px;
}

body.is-dragging-song .playlist-item.drop-target {
  outline: 2px solid var(--accent-text);
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Visualizer style picker sits at the right of the EQ toolbar */
.viz-mode-select {
  min-width: 0;
  padding: 4px 8px;
  font-size: 0.78rem;
  cursor: pointer;
}

/* ========================================================================
   4. Layouts (Full / Compact), View menu, radio, footer, tablets and touch
   ======================================================================== */

/* =========================================================================
   Layout: hidden sections + Compact player (driven by js/layout.js)
   html.lay-compact      compact mini-player layout
   html.hide-<part>      sidebar | codecs | tracks | deck | viz hidden
   html.lay-measure      temporary: lay out at natural height so the
                         desktop window can be sized to fit
   ========================================================================= */

/* ---------- Hidden sections (both layouts) ---------- */
html.hide-sidebar .workspace > .sidebar,
html.hide-tracks #playlistSection,
html.hide-deck .np-deck-toolbar,
html.hide-deck #deckStage,
html.hide-viz #visualizerCanvas,
html.hide-viz #visualizerModeSelect {
  display: none !important;
}

/* Without the deck the song info takes the whole card width. */
html.hide-deck .np-top {
  grid-template-columns: minmax(0, 1fr) !important;
}

/* Without the visualizer, the EQ & FX button just sits beside the title. */
html.hide-viz .np-head .visualizer-row {
  flex: 0 0 auto !important;
  justify-content: center;
}

/* ---------- Full layout: let the grid close the gaps ---------- */
html:not(.lay-compact).hide-sidebar .workspace {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
}
html:not(.lay-compact).hide-sidebar .workspace.lyrics-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 1379px) and (min-width: 761px) {
  html:not(.lay-compact).hide-sidebar .workspace,
  html:not(.lay-compact).hide-sidebar .workspace.lyrics-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  /* No empty lyrics row when the lyrics panel is closed. */
  html:not(.lay-compact) .workspace.lyrics-collapsed {
    grid-template-rows: minmax(0, 1fr);
  }
}

/* Song list hidden: the Now Playing card gets the whole column. */
html:not(.lay-compact).hide-tracks .now-playing {
  flex: 1 1 auto;
  justify-content: center;
}

/* ---------- Compact layout ---------- */
html.lay-compact .mobile-nav-bar,
html.lay-compact .mobile-mini-bar,
html.lay-compact .brand-subtitle,
html.lay-compact #btnAddFiles,
html.lay-compact #btnAddFolder,
html.lay-compact #btnPcFolder,
html.lay-compact #topbarMore,
html.lay-compact #themeSelect,
html.lay-compact #btnToggleLyrics,
html.lay-compact .np-story-strip,
html.lay-compact.hide-tracks .search-wrap {
  display: none !important;
}

html.lay-compact .app-shell {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

html.lay-compact .topbar {
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 12px;
}
html.lay-compact .brand {
  flex: 1 1 auto;
  min-width: 0;
}
html.lay-compact .brand-title {
  font-size: 1.02rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.lay-compact .brand-logo {
  width: 30px;
  height: 30px;
}
html.lay-compact .topbar-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
}
html.lay-compact .search-wrap {
  order: 3;
  flex: 1 0 100%;
  max-width: none;
}

/* One centred column; each visible section stacks in order. */
html.lay-compact .workspace,
html.lay-compact .workspace.lyrics-collapsed {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 10px;
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
  padding: 10px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
html.lay-compact .workspace > *,
html.lay-compact .center-column > * {
  flex: 0 0 auto;
}
html.lay-compact .center-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: visible;
}

/* Scrolling sections get a sensible height and share any extra room. */
html.lay-compact .workspace > .sidebar {
  max-height: 420px;
}
html.lay-compact:not(.hide-tracks) .center-column {
  flex: 1 0 auto;
}
html.lay-compact #playlistSection {
  flex: 1 0 300px;
  min-height: 240px;
}
html.lay-compact .lyrics-panel {
  flex: 1 0 300px;
  min-height: 240px;
  max-height: none;
}

/* Song list, trimmed for a narrow player: manage playlists in the Full layout. */
html.lay-compact #playlistSection .playlist-actions,
html.lay-compact #playlistSection .track-tags {
  display: none !important;
}
html.lay-compact #playlistSection .count-pill {
  white-space: nowrap;
}
html.lay-compact #playlistSection .track-main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}
html.lay-compact #playlistSection .track-main .track-row-sub::before {
  content: none;
}
html.lay-compact #playlistSection .track-main > * {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The Now Playing card, tightened. */
html.lay-compact .now-playing {
  padding: 14px 16px 12px;
  gap: 10px;
}
html.lay-compact .np-top {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 12px;
}
html.lay-compact #deckStage {
  width: 100%;
  max-width: 320px;
  margin-inline: auto;
}
html.lay-compact .np-deck-toolbar {
  justify-content: center;
}
html.lay-compact .np-head {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
html.lay-compact .np-title-row {
  justify-content: center;
}
html.lay-compact .np-head .visualizer-row {
  flex: 0 0 auto !important;
  gap: 8px;
}
html.lay-compact .np-head #visualizerCanvas {
  flex: none;
  height: 84px;
  min-height: 0;
}

/* Natural-height pass used to size the desktop window (never painted). */
html.lay-measure .app-shell {
  height: auto !important;
  min-height: 0 !important;
}
html.lay-measure .workspace,
html.lay-measure .workspace.lyrics-collapsed {
  flex: none !important;
  height: auto !important;
  overflow: visible !important;
}

/* ---------- View menu ---------- */
.view-menu-panel {
  min-width: 248px;
  gap: 2px;
  padding: 10px;
}
.view-menu-label {
  margin: 6px 4px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.view-menu-label:first-child {
  margin-top: 0;
}
.view-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-active, rgba(0, 0, 0, 0.05));
}
.view-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.view-seg-btn svg {
  width: 16px;
  height: 16px;
}
.view-seg-btn:hover {
  color: var(--text-primary);
}
.view-seg-btn.active {
  background: var(--bg-panel);
  color: var(--accent-text, var(--accent));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.view-seg-btn:focus-visible,
.view-check input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.view-checks {
  display: grid;
}
.view-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 4px 6px;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
}
.view-check:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}
.view-check input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent-strong, var(--accent));
  cursor: pointer;
}

.view-check.is-disabled {
  opacity: 0.5;
  cursor: default;
}
.view-ontop {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding-top: 8px;
}
.view-menu-hint {
  margin: 6px 4px 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.view-menu-hint kbd {
  padding: 1px 5px;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
}

.view-pip-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.view-pip-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.view-pip-btn:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}
.view-pip-btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent-text, var(--accent));
}
.view-pip-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Pop-out player window (Document Picture-in-Picture) ---------- */
.pip-body {
  margin: 0;
  min-height: 100vh;
  padding: 8px;
  box-sizing: border-box;
  overflow-y: auto;
  background: var(--bg-app, #f3f5f8);
}
.pip-body .now-playing {
  margin: 0;
}
.pip-placeholder {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}
.pip-placeholder p {
  margin: 0;
  color: var(--text-secondary);
}

/* In compact the menu opens downward from the right edge and stays on screen. */
html.lay-compact .view-menu-panel {
  top: calc(100% + 8px);
  bottom: auto;
  right: 0;
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
}

@media (prefers-reduced-motion: reduce) {
  .view-seg-btn {
    transition: none;
  }
}

/* =========================================================================
   Credit line: "App created by NR for the love of Music."
   A pill with a gradient rim in the theme's title colours, a heart that
   beats while music plays, and a soft shine that sweeps across now and then.
   ========================================================================= */
html {
  --credit-fill: linear-gradient(100deg, var(--title-a, var(--text-primary)), var(--title-b, var(--accent)));
  --credit-bg: var(--bg-panel);
  --credit-shine: rgba(255, 255, 255, 0.6);
}
html[data-theme="dark"] {
  --credit-shine: rgba(255, 255, 255, 0.14);
}
/* Flag colours, with a deeper saffron so the small text stays readable. */
html[data-light-theme="tricolour"]:not([data-theme="dark"]) {
  --credit-fill: linear-gradient(100deg, #b4530b 0%, #22378a 55%, #1e7b3c 100%);
}

.app-credit {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 14px 6px;
}

/* © line under the credit: small, quiet, with links to the Privacy and Disclaimer pages. */
.app-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px 10px;
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--text-muted, var(--text-secondary));
  text-align: center;
}
.app-legal a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 2px;
}
.app-legal a:hover {
  color: var(--text-primary);
}
.app-legal a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.credit-pill {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.34em;
  margin: 0;
  padding: 6px 18px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(var(--credit-bg), var(--credit-bg)) padding-box,
    var(--credit-fill) border-box;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent, #3656d6) 16%, transparent);
  color: var(--text-secondary);
  font-family: var(--font-sans, inherit);
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: center;
}

.credit-name,
.credit-music {
  font-family: var(--font-display, inherit);
  font-weight: 800;
  background: var(--credit-fill);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.credit-name {
  font-size: 1.06em;
  letter-spacing: 0.08em;
}
.credit-music {
  font-size: 1.1em;
  font-style: italic;
  padding-right: 0.08em; /* italic overhang stays inside the gradient */
}

.credit-heart {
  width: 14px;
  height: 14px;
  flex: none;
  fill: var(--danger, #e0245e);
  transform-origin: 50% 55%;
  transition: transform 200ms ease;
}
html.is-playing .credit-heart {
  animation: credit-beat 1.2s ease-in-out infinite;
}
@keyframes credit-beat {
  0%, 60%, 100% { transform: scale(1); }
  14% { transform: scale(1.25); }
  28% { transform: scale(1); }
  42% { transform: scale(1.15); }
}

/* A soft shine that sweeps across the pill every few seconds. */
.credit-pill::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg, transparent 35%, var(--credit-shine) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: credit-shine 8s ease-in-out 2s infinite;
  pointer-events: none;
}
@keyframes credit-shine {
  0% { transform: translateX(-120%); }
  16%, 100% { transform: translateX(120%); }
}

/* Theme touches */
html[data-light-theme="neumorphism"]:not([data-theme="dark"]) .credit-pill {
  border: 0;
  background: var(--nm-surface);
  box-shadow: var(--neu-out-sm);
}
html[data-light-theme="claymorphism"]:not([data-theme="dark"]) .credit-pill {
  border: 0;
  background: var(--clay-white);
  box-shadow: var(--clay-sm);
}
html[data-light-theme="neobrutalism"]:not([data-theme="dark"]) .credit-pill {
  border: 2.5px solid #111111;
  border-radius: 10px;
  background: #ffd84d;
  box-shadow: 3px 3px 0 #111111;
  color: #111111;
}
html[data-light-theme="glassmorphism"]:not([data-theme="dark"]) .credit-pill {
  /* Frosted glass with a light edge (the theme's panel colour is see-through, so no gradient rim). */
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  color: var(--text-primary);
}

/* Compact and phone layouts: a little smaller, same look. */
html.lay-compact .app-credit {
  padding: 0 10px 6px;
}
html.lay-compact .credit-pill {
  font-size: 0.74rem;
  padding: 4px 14px;
}
@media (max-width: 760px) {
  .app-credit {
    padding: 0 10px 6px;
  }
  .credit-pill {
    font-size: 0.74rem;
    padding: 4px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.is-playing .credit-heart,
  .credit-pill::after {
    animation: none;
  }
}

/* =========================================================================
   Sidebar: compact, scrollable playlists + Online Radio
   ========================================================================= */
/* Playlists keep their natural height (scrolling after ~6 rows); the radio list takes what's left. */
.sidebar .playlist-list {
  flex: 0 0 auto;
  min-height: 84px;
  max-height: min(232px, 34%);
  padding: 6px 8px;
  gap: 2px;
}
html .sidebar .playlist-list .playlist-item {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.84rem;
}

.radio-section {
  flex: 1 1 0;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.radio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px 4px;
}
.radio-header h2 {
  margin: 0;
  font-family: var(--font-sans, inherit);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.radio-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, #e11d48 12%, transparent);
  color: #be123c;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
html[data-theme="dark"] .radio-live-badge {
  color: #fb7185;
}
.radio-live-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e11d48;
  animation: radio-live-pulse 1.8s ease-in-out infinite;
}
@keyframes radio-live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

.radio-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0 8px 10px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.radio-group-label {
  padding: 10px 8px 4px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--radius-sm, 10px);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease;
}
.radio-item:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}
.radio-item.active {
  background: var(--accent-soft, var(--bg-active, rgba(0, 0, 0, 0.06)));
}
.radio-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.radio-art {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.radio-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.radio-name,
.radio-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.radio-name {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.25;
}
.radio-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.radio-state {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text, var(--accent));
}
.radio-fav {
  width: 12px;
  height: 12px;
  fill: var(--danger, #e0245e);
}
.radio-play {
  width: 14px;
  height: 14px;
  fill: currentColor;
  opacity: 0;
  transition: opacity 140ms ease;
}
.radio-item:hover .radio-play,
.radio-item:focus-visible .radio-play,
.radio-item.active .radio-play {
  opacity: 0.85;
}
.radio-eq {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.radio-eq i {
  display: block;
  width: 3px;
  height: 40%;
  border-radius: 1px;
  background: currentColor;
  animation: radio-eq 0.9s ease-in-out infinite;
}
.radio-eq i:nth-child(2) { animation-delay: -0.3s; }
.radio-eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes radio-eq {
  0%, 100% { height: 30%; }
  50% { height: 100%; }
}
.radio-item.is-playing .radio-eq { display: inline-flex; }
.radio-item.is-playing .radio-play { display: none; }
.radio-item.is-buffering .radio-eq i {
  animation-duration: 1.8s;
  opacity: 0.55;
}

/* Now Playing while a station is live */
.now-playing.is-live #trackFormatBadge {
  border-color: transparent;
  background: #e11d48;
  color: #ffffff;
  letter-spacing: 0.08em;
}
.now-playing.is-live #totalTime {
  color: #be123c;
  font-weight: 800;
}
html[data-theme="dark"] .now-playing.is-live #totalTime {
  color: #fb7185;
}
.now-playing.is-live #seekBar {
  pointer-events: none;
}
.now-playing.is-live #speedSelect {
  opacity: 0.5;
}
.lyrics-toolbar.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Station card in the Story tab */
.radio-story {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
}
.radio-story-art {
  flex: none;
  width: 88px;
  height: 88px;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.radio-story-text h3 {
  margin: 0 0 4px;
  font-family: var(--font-display, inherit);
  font-size: 1.1rem;
}
.radio-story-meta {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.radio-story-desc {
  margin: 0 0 12px;
  line-height: 1.55;
}

/* Phones: the Playlists tab has room for both lists (the codec box is left out there) */
@media (max-width: 760px) {
  html body[data-mobile-view="library"] .sidebar {
    max-height: 56vh;
  }
  
}

@media (prefers-reduced-motion: reduce) {
  .radio-live-badge i,
  .radio-eq i {
    animation: none;
  }
  .radio-eq i { height: 70%; }
}

/* The song-count badge ("3 songs · 1 min") always stays on one line. */
.count-pill {
  white-space: nowrap;
}

/* =========================================================================
   Tablets (761–1180px): the top bar was too narrow for every label.
   Buttons go icon-only and search moves to its own row.
   ========================================================================= */
@media (min-width: 761px) and (max-width: 1180px) {
  html:not(.lay-compact) .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  html:not(.lay-compact) .topbar .brand-subtitle {
    display: none;
  }
  html:not(.lay-compact) .topbar .search-wrap {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
  }
  html:not(.lay-compact) .topbar-actions {
    margin-left: auto;
  }
  html:not(.lay-compact) .topbar-actions .hide-sm,
  html:not(.lay-compact) .topbar-more-trigger > span {
    display: none;
  }
  html:not(.lay-compact) .topbar-actions > .btn:not(.btn-primary),
  html:not(.lay-compact) .topbar-actions .topbar-more-trigger {
    min-width: 40px;
    padding-inline: 10px;
  }
}

/* Touch screens: comfortable tap targets for the small controls. */
@media (pointer: coarse) {
  #deckStyleSelect,
  #btnCycleDeckStyle,
  #btnEqModal,
  #visualizerModeSelect,
  #speedSelect,
  #btnOpenStoryTab,
  #btnOpenPlaylist,
  #btnNewPlaylist,
  .playlist-actions .btn {
    min-height: 40px;
  }
  .app-legal a {
    display: inline-block;
    padding: 6px 4px;
  }
}
