* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

/* Solid, semi-opaque fill placed behind reading text so it stays legible over the gradient. */
:root { --panel: rgba(9, 9, 14, 0.72); }

/* Refractive-glass background: two stacked layers cross-faded on theme change.
   pointer-events:none guarantees the background can never intercept clicks. */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-layer {
  position: absolute; inset: -20%;
  opacity: 1; transition: opacity 600ms ease;
  background:
    linear-gradient(120deg, var(--g-base-1) 0%, var(--g-base-2) 50%, var(--g-base-3) 100%);
}
.bg-layer::after {
  content: ""; position: absolute; inset: 0; mix-blend-mode: screen; filter: blur(2px);
  background:
    linear-gradient(120deg, transparent 34%, var(--g-streak-a) 42%, var(--g-streak-b) 48%, var(--g-streak-c) 55%, transparent 63%),
    radial-gradient(30% 60% at 78% 20%, var(--g-streak-d) 0%, transparent 70%);
  animation: drift 24s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) rotate(0deg); }
  to   { transform: translate3d(3%, 2%, 0) rotate(4deg); }
}

.app { display: grid; grid-template-columns: 264px 1fr; height: 100vh; gap: 12px; padding: 12px; }
/* min-width/height:0 stops a wide child from overflowing the grid track and leaving
   stale, unclickable hit regions until a resize forces a reflow. */
.app > * { min-width: 0; min-height: 0; }

/* Rounded, gradient-bordered panel with a solid fill for contrast + elevation. */
.panel {
  position: relative;
  border-radius: 16px;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(125deg, var(--g-streak-a), var(--g-streak-c) 55%, var(--g-streak-d)) border-box;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.38);
}

/* Sidebar */
.sidebar {
  padding: 16px 12px; overflow-y: auto; position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 16px;
}
.brand { font-weight: 800; letter-spacing: .04em; color: var(--ink); }
.brand small { color: var(--muted); font-weight: 400; }
.tree { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.umbrella { cursor: pointer; padding: 7px 8px; border-radius: 8px; font-weight: 700; color: var(--ink); }
.umbrella:hover { background: rgba(255, 255, 255, 0.06); }
.umbrella .chev { display: inline-block; width: 1em; color: var(--muted); }
.sublist { display: none; flex-direction: column; margin: 2px 0 6px 12px; gap: 1px; }
.umbrella.open + .sublist { display: flex; }
.subgenre { cursor: pointer; padding: 5px 8px; border-radius: 7px; color: var(--muted); }
.subgenre:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
.subgenre.active { color: #0a0a0a; background: var(--accent); font-weight: 600; }
.umbrella.active { color: var(--accent); }

/* Registered-artists toggle */
.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 12.5px; color: var(--ink); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: relative; flex: 0 0 auto; width: 34px; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-switch { margin-top: auto; display: flex; gap: 8px; align-items: center; }
.theme-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; }
.theme-dot[data-theme='prism'] { background: linear-gradient(120deg,#67e8ff,#ff8adf); }
.theme-dot[data-theme='ember'] { background: linear-gradient(120deg,#ffd15c,#c85cff); }
.theme-dot[data-theme='aurora'] { background: linear-gradient(120deg,#6be3ff,#7affc3); }
.theme-dot.active { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Main column */
.main { padding: 4px 8px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.hero { display: flex; flex-direction: column; gap: 12px; align-items: center; }
/* Capped + centered so the player no longer dominates the page. */
.video-frame {
  position: relative; width: 100%; max-width: 42rem; margin: 0 auto;
  aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden;
  border: 2px solid transparent;
  background:
    linear-gradient(#000, #000) padding-box,
    linear-gradient(125deg, var(--g-streak-a), var(--g-streak-c) 55%, var(--g-streak-d)) border-box;
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.randomize {
  align-self: center; padding: 12px 28px; border: 0; border-radius: 999px;
  background: var(--accent); color: #0a0a0a; font-weight: 800; letter-spacing: .12em; cursor: pointer;
}

/* Book spread: two elevated, scrollable, gradient-bordered pages */
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.spine { display: none; }
.page {
  position: relative; min-height: 200px;
  padding: 16px 18px; max-height: 42vh; overflow-y: auto;
  border-radius: 16px; border: 2px solid transparent;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(125deg, var(--g-streak-a), var(--g-streak-c) 55%, var(--g-streak-d)) border-box;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.38);
}
.page .cap { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.page .body { font-size: 14px; line-height: 1.55; color: var(--ink); }
.page .body h3 { margin: 0 0 6px; }
.page .body p { margin: 0 0 10px; }

/* Flip panels: two-sided cards that rotate to reveal a second label + content.
   The whole panel is the click target; a hover raise signals it's interactive. */
.page.flip {
  padding: 0; overflow: visible; max-height: none;
  height: clamp(220px, 38vh, 440px); perspective: 1200px;
  cursor: pointer; transition: transform 180ms ease, box-shadow 180ms ease;
}
.page.flip:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(0, 0, 0, 0.46); }
.page.flip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 520ms cubic-bezier(.2, .7, .2, 1);
  transform-style: preserve-3d;
}
.page.flipped .flip-inner { transform: rotateY(180deg); }
/* Selective backface: the label intentionally shows through mirrored (a cue that a
   back side exists); the content must never mirror. The face is preserve-3d so its
   children decide their own backface visibility. */
.face {
  position: absolute; inset: 0; border-radius: 14px;
  padding: 16px 18px; overflow: visible;
  display: flex; flex-direction: column;
  transform-style: preserve-3d;
  backface-visibility: visible; -webkit-backface-visibility: visible;
}
.face .cap { backface-visibility: visible; -webkit-backface-visibility: visible; }
/* .content is culled when turned away. The translateZ makes it a genuine 3D layer so
   Chromium reliably honors backface-visibility here; overflow lives on the inner .body
   (Chromium ignores backface-visibility on a scrolling element). */
.face .content {
  flex: 1; min-height: 0;
  transform: translateZ(0.01px);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.face .content .body { height: 100%; overflow-y: auto; }
.face.back { transform: rotateY(180deg); }

/* In-content field label — distinct from the panel's main .cap label so it never
   looks like a duplicate of it. */
.face .body .field {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); opacity: .8; margin: 12px 0 2px;
}
.face .body .field:first-child { margin-top: 0; }
.face .body .lyrics {
  margin: 0; font: inherit; white-space: pre-wrap; line-height: 1.5; color: var(--ink);
}

/* Copy the visible side's text; does not trigger a flip (handled in JS). */
.copy-btn {
  position: absolute; bottom: 10px; right: 12px; z-index: 4;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .42); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer;
}
.copy-btn:hover { background: var(--accent); color: #0a0a0a; }

/* Tiled diagonal logo fallback */
.logo-fallback { position: absolute; inset: 0; overflow: hidden; }
.logo-fallback .tile {
  position: absolute; inset: -40%; transform: rotate(-24deg); opacity: .07;
  font-weight: 700; font-size: 1.1rem; line-height: 2.2; white-space: nowrap; word-spacing: 1.2em;
  color: var(--ink);
}
.logo-fallback .hero-mark {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.logo-fallback .hero-mark span {
  transform: rotate(-24deg); font-weight: 800; font-size: 1.8rem;
  background: linear-gradient(120deg, var(--g-streak-a), var(--g-streak-b) 40%, var(--g-streak-c) 60%, var(--g-streak-d));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
