:root {
  /* Three base colors on a black ground; every other shade is one of these at an opacity */
  --blue-rgb: 1 117 192;       /* #0175c0 */
  --orange-rgb: 230 99 72;     /* #e66348 */
  --white-rgb: 255 255 255;    /* #fff */

  --blue: rgb(var(--blue-rgb));
  --orange: rgb(var(--orange-rgb));
  --white: rgb(var(--white-rgb));
  --black: #000;

  /* New CD import status icons only (no matching token; from the design) */
  --green: #0a8a0a;
  --red: #e5141a;

  --blue-deep: color-mix(in srgb, var(--blue) 60%, var(--black)); /* CD background, hub */

  --orange-40: rgb(var(--orange-rgb) / 0.4);   /* list dividers */
  --orange-60: rgb(var(--orange-rgb) / 0.6);   /* empty-list hint */

  --white-07: rgb(var(--white-rgb) / 0.07);    /* control bar */
  --white-10: rgb(var(--white-rgb) / 0.1);     /* link inputs */
  --page: #111;                               /* page background under the crosshatch */
  --hatch: #262626;                           /* page crosshatch lines (solid gray) */
  --white-20: rgb(var(--white-rgb) / 0.2);     /* outlines */
  --white-22: rgb(var(--white-rgb) / 0.22);    /* small square buttons */
  --white-50: rgb(var(--white-rgb) / 0.5);     /* hover dots */
  --white-60: rgb(var(--white-rgb) / 0.6);     /* empty-state hint */

  --fs: 14px;
  --fs-small: 11px;
  --tracking-small: 1px; /* small type: all caps, 4% letter spacing */
  --fs-message: 13px;  /* panel message bubbles */

}

* { box-sizing: border-box; }

html { color-scheme: dark; }

html, body { margin: 0; }

/* Fixed, non-scrolling page on desktop; stacked layouts below still scroll */
@media (min-width: 1101px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Work Sans', system-ui, sans-serif;
  font-size: var(--fs);
  line-height: 1.3;
  color: var(--white);
  /* Near-black with a fine diagonal crosshatch */
  background:
    repeating-linear-gradient(-45deg, var(--hatch) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(45deg, var(--hatch) 0 1px, transparent 1px 5px),
    var(--page);
}

p, h2, ol { margin: 0; padding: 0; }
h2 { font-size: var(--fs); font-weight: 400; }
/* Browsers reset caps and tracking on buttons; take them from the surrounding text instead */
button { font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }

.small { font-size: var(--fs-small); }

/* Everything set in the small size is all caps with 4% letter spacing */
.small,
.cd-link,
.cd-hint,
.cd-clock,
.track-list li,
.list-input,
.embed {
  text-transform: uppercase;
  letter-spacing: var(--tracking-small);
}
.title { color: var(--blue); }
.accent { color: var(--orange); }
.body { color: var(--white); }

/* ---------- Top nav ---------- */

.topnav {
  /* logo on the left, buttons on the far right */
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 27px 24px 0 27px;
}

.topnav-actions {
  justify-self: end;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.logo {
  display: block;
  width: 80px;
  height: 80px;
}

.logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* One full turn on hover, easing in and out */
.logo:hover svg { animation: logo-spin 1s ease-in-out; }

@keyframes logo-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .logo:hover svg { animation: none; }
}

.btn {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  background: var(--black);
  border: 0;
  border-radius: 0;
  text-decoration: none;
  color: var(--white);
}

/* Nav buttons: light dots on hover */
.topnav-actions .btn:hover,
.topnav-actions .btn:focus-visible {
  background: radial-gradient(circle, var(--white-50) 0.6px, transparent 1px) 0 0 / 3px 3px, var(--black);
}

.btn-icon {
  width: 44px;
  justify-content: center;
  padding: 0;
}

/* ---------- Stage ---------- */

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 533px);
  gap: 6px;
  justify-content: center;
  align-content: center;
  /* Extra bottom padding lifts the centered stage ~100px */
  padding: 20px 16px 120px;
}

.stack {
  display: grid;
  grid-template-rows: 324px 258px;
  gap: 6px;
}

.panel {
  position: relative;
  border-radius: 8px;
  background: var(--black);
}

/* Sparse dotted outline: an orange dot at each corner and each side's midpoint */
.panel::before {
  --dot: linear-gradient(var(--orange), var(--orange));
  content: '';
  position: absolute;
  inset: -1.5px;
  pointer-events: none;
  background-image:
    var(--dot),
    var(--dot),
    var(--dot),
    var(--dot),
    var(--dot),
    var(--dot),
    var(--dot),
    var(--dot);
  background-size: 3px 3px;
  background-repeat: no-repeat;
  background-position:
    0 0,
    50% 0,
    100% 0,
    0 100%,
    50% 100%,
    100% 100%,
    0 50%,
    100% 50%;
}

/* ---------- Panel messages ---------- */

/* White bubble with a small pointer, just outside a panel. Hidden until
   js/ui/messages.js adds .is-visible for 5 seconds. */
.panel-msg {
  --pointer-w: 11px;
  --pointer-h: 13px;
  position: absolute;
  left: 50%;
  z-index: 3;
  /* Sized to the text, centered on the panel, never wider than it */
  width: max-content;
  max-width: 100%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--white);
  color: rgb(0 0 0 / 0.6);
  font-size: var(--fs-message);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s;
}

.panel-msg.is-visible {
  opacity: 1;
  visibility: visible;
}

.panel-msg::after {
  content: '';
  position: absolute;
  left: 50%;
  margin-left: calc(var(--pointer-w) / -2);
  border-left: calc(var(--pointer-w) / 2) solid transparent;
  border-right: calc(var(--pointer-w) / 2) solid transparent;
}

/* Above the panel, pointing down */
.panel-msg-top { bottom: calc(100% + 24px); }
.panel-msg-top::after {
  top: 100%;
  border-top: var(--pointer-h) solid var(--white);
}

/* Below the panel, pointing up */
.panel-msg-bottom { top: calc(100% + 25px); }
.panel-msg-bottom::after {
  bottom: 100%;
  border-bottom: var(--pointer-h) solid var(--white);
}

/* Left-aligned with the CD panel content, pointer near the bird */
.panel-msg-start {
  left: 31px;
  transform: none;
}
.panel-msg-start::after { left: 27px; }

@media (prefers-reduced-motion: reduce) {
  .panel-msg { transition: none; }
}

.btn-square {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--white-22);
  color: var(--white);
  display: grid;
  place-items: center;
}

/* Square buttons: white dots on hover */
.btn-square:hover,
.btn-square:focus-visible {
  background: radial-gradient(circle, var(--white-50) 0.6px, transparent 1px) 0 0 / 3px 3px, var(--white-22);
}

.btn-square svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
}

/* ---------- CD panel ---------- */

.panel-cd { padding: 14px; }

.cd-frame {
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--white-20);
  border-radius: 4px;
}

.cd-art {
  --cd-size: 434px;
  position: relative;
  height: 280px;
  margin: 16px 16px 0;
  overflow: hidden;
  background: var(--blue-deep);
}

/* Import / export links in the top corners */
.cd-link {
  position: absolute;
  top: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: var(--fs-small);
  line-height: 1;
}
.cd-link-import { left: 6px; }
.cd-link-export { right: 6px; }
.cd-link-new {
  left: 50%;
  transform: translateX(-50%);
}

.cd-link:hover,
.cd-link:focus-visible {
  background: radial-gradient(circle, var(--white-50) 0.6px, transparent 1px) 0 0 / 3px 3px;
}

.cd-link svg {
  width: 9px;
  height: 9px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
}

.cd-clock {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--white);
  font-size: var(--fs-small);
  font-variant-numeric: tabular-nums;
  z-index: 1;
}

/* Full disc centered on the bottom edge, so only the top half shows */
.cd {
  position: absolute;
  left: 50%;
  top: 100%;
  width: var(--cd-size);
  height: var(--cd-size);
  margin: calc(var(--cd-size) / -2) 0 0 calc(var(--cd-size) / -2);
  border-radius: 50%;
}

/* The face that turns while playing: sheen, drawing, label. Its own GPU layer from the start,
   so the spin never waits for a repaint.
   Starts half a turn round, so the CD's name (on the back half) faces up when loaded;
   the spin in disk.js turns on from this angle. */
.cd-spin {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: rotate(180deg);
  will-change: transform;
  /* Metallic sheen: mirrored light/dark bands */
  background:
    conic-gradient(from 20deg,
      rgb(0 0 0 / 0.01) 0deg, rgb(0 0 0 / 0.21) 35deg,
      rgb(0 0 0 / 0.04) 70deg, rgb(0 0 0 / 0.34) 110deg,
      rgb(0 0 0 / 0.07) 150deg, rgb(0 0 0 / 0.14) 180deg,
      rgb(0 0 0 / 0.01) 200deg, rgb(0 0 0 / 0.21) 235deg,
      rgb(0 0 0 / 0.04) 270deg, rgb(0 0 0 / 0.34) 310deg,
      rgb(0 0 0 / 0.07) 340deg, rgb(0 0 0 / 0.01) 360deg),
    var(--white);
}

/* Fine grooves over the face. Rings look the same at every angle, so they stay still:
   1px rings turned as an image shimmer, which made the spin look choppy. */
.cd::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, rgb(var(--white-rgb) / 0.12) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

/* Lines drawn in the CD editor: on the face, under the label, never over the hole
   (the hub covers 17% of the radius) */
.cd-drawing {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  mask-image: radial-gradient(circle closest-side, transparent 17%, var(--black) 17.3%);
}

/* Front of the label, upright at the top: the bird logo and the site name */
.cd-front {
  position: absolute;
  top: 16%;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.cd-logo {
  width: calc(var(--cd-size) * 0.075);
  height: calc(var(--cd-size) * 0.075);
  fill: none;
  stroke: var(--black);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cd-logo-frame { stroke: rgb(0 0 0 / 0.5); }
.cd-logo-dot { fill: var(--black); stroke: none; }

.cd-front p,
.cd-back p {
  color: rgb(0 0 0 / 0.8);
  font-size: var(--fs-small);
  line-height: 1.3;
}

/* Back of the label: the same layout turned 180° about the disc's center, so it reads
   upside down on the lower half: “cd name” nearest the edge, then credit and date */
.cd-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 14%;
  text-align: center;
  transform: rotate(180deg);
}

.cd-title {
  max-width: 60%;
  margin-bottom: 1.6em;
  overflow-wrap: anywhere;
}

.cd-label {
  position: absolute;
  top: 16%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: var(--fs-small);
  color: var(--black);
}

/* Dotted outer ring: a sibling of the disc, so it stays still while the disc spins */
.cd-ring {
  --ring-size: calc(var(--cd-size) + 18px);
  position: absolute;
  left: 50%;
  top: 100%;
  width: var(--ring-size);
  height: var(--ring-size);
  margin: calc(var(--ring-size) / -2) 0 0 calc(var(--ring-size) / -2);
  border: 1.5px dotted rgb(var(--white-rgb) / 0.85);
  border-radius: 50%;
}

/* Only in the empty state; a loaded CD has no ring */
.panel-cd:not(.is-empty) .cd-ring { display: none; }

/* Center hub: white ring, blue middle. Sized from the disc (74px ring, 12px band at 434px)
   so it lines up with the drawing's hole at any disc size. */
.cd-hub {
  --hub: calc(var(--cd-size) * 0.17);
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: var(--hub);
  height: var(--hub);
  margin: calc(var(--hub) / -2) 0 0 calc(var(--hub) / -2);
  border-radius: 50%;
  background: var(--blue-deep);
  border: calc(var(--cd-size) * 0.0276) solid var(--white);
}

/* Empty state (no disk): hub outline and a hint instead of the disc */
.cd-hub-outline {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 55px;
  height: 55px;
  margin: -27.5px 0 0 -27.5px;
  border: 1px solid var(--white);
  border-radius: 50%;
}

.cd-hint {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  /* Centered, then 40px lower */
  transform: translateY(calc(-50% + 40px));
  text-align: center;
  color: var(--white);
  font-size: var(--fs-small);
}

/* "loading a CD" / "create a CD." do the same as import / make a new CD */
.cd-hint-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cd-hint-link:hover,
.cd-hint-link:focus-visible {
  background: radial-gradient(circle, var(--white-50) 0.6px, transparent 1px) 0 0 / 3px 3px;
}

/* Static spin for the design record (states/playing.html). The app spins the disc from
   disk.js instead, so it can ease to a stop and resume from the same angle. */
.is-playing .cd-spin { animation: spin 6s linear infinite; }

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

@media (prefers-reduced-motion: reduce) {
  .is-playing .cd-spin { animation: none; }
}

.cd-info {
  display: grid;
  grid-template-columns: 206px 1fr auto;
  gap: 0 12px;
  margin-top: 16px;
  padding: 16px;
  border-top: 1px solid var(--white-20);
}

.cd-actions {
  display: flex;
  gap: 5px;
  align-self: start;
}

.cd-desc .body { margin-top: 6px; }

/* Source badge, bottom left of the CD panel */
.cd-badge {
  align-self: flex-start;
  margin: auto 0 16px 16px;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 0;
}

.cd-badge svg { display: block; }

/* Hover: every part turns blue, each at its own opacity */
.cd-badge:hover,
.cd-badge:focus-visible {
  background: radial-gradient(circle, rgb(var(--blue-rgb) / 0.5) 0.6px, transparent 1px) 0 0 / 3px 3px;
}
.cd-badge:hover .bird-frame,
.cd-badge:focus-visible .bird-frame { stroke: var(--blue); stroke-opacity: 0.5; }
.cd-badge:hover .bird-arrow,
.cd-badge:focus-visible .bird-arrow { stroke: var(--blue); stroke-opacity: 0.7; }
.cd-badge:hover .bird-eye,
.cd-badge:focus-visible .bird-eye { fill: var(--blue); stroke: var(--blue); }
.cd-badge:hover .bird-fill,
.cd-badge:focus-visible .bird-fill { fill-opacity: 0.15; }

/* ---------- Playlist panel ---------- */

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 45px;
  padding: 0 16px;
  border-bottom: 1px solid var(--white-20);
}

/* The lists fill the panel's height below the header */
.panel-list {
  display: flex;
  flex-direction: column;
}

.lists {
  flex: 1;
  min-height: 0;
  display: grid;
  /* minmax(0, …): long names must not widen the columns */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.list-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.track-list {
  list-style: none;
  /* Fills the column's height (at least six 28px rows plus the border). disk.js adds empty rows
     down to the bottom, the last one cut off, and adds .is-scrollable when the songs don't fit. */
  flex: 1;
  min-height: 170px;
  overflow: hidden;
  border: 1px solid var(--orange);
}

.track-list li {
  display: flex;
  align-items: center;
  height: 28px;
  border-bottom: 1px dotted var(--orange-40);
  color: var(--orange);
  font-size: var(--fs-small);
  cursor: pointer;
}

.track-list.is-scrollable { overflow-y: auto; }

/* Square scrollbars (song lists: orange; New CD import list: black on light gray).
   ::-webkit-scrollbar gives square ends in Chrome / Safari; Chrome ignores it if
   scrollbar-width / scrollbar-color are set, so those are only for browsers without it (Firefox). */
.track-list,
.newcd-import-list {
  --scroll-thumb: var(--orange);
  --scroll-track: transparent;
}

.newcd-import-list {
  --scroll-thumb: var(--black);
  --scroll-track: rgb(0 0 0 / 0.1);
}

.track-list::-webkit-scrollbar,
.newcd-import-list::-webkit-scrollbar { width: 4px; }

.track-list::-webkit-scrollbar-track,
.newcd-import-list::-webkit-scrollbar-track { background: var(--scroll-track); }

.track-list::-webkit-scrollbar-thumb,
.newcd-import-list::-webkit-scrollbar-thumb {
  border-radius: 0;
  background: var(--scroll-thumb);
}

@supports not selector(::-webkit-scrollbar) {
  .track-list,
  .newcd-import-list {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  }
}

/* The frame closes the last row */
.track-list li:last-child { border-bottom: 0; }


.track-list .num {
  align-self: stretch;
  display: grid;
  place-items: center;
  width: 28px; /* same as the row height: a square cell */
  border-right: 1px dotted var(--orange-40);
  font-variant-numeric: tabular-nums;
}

.track-list .name {
  flex: 1;
  min-width: 0;
  margin-left: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.name-text { display: inline-block; }

/* Names too long for the row (marked by disk.js) fade out on the right */
.track-list .name.is-long {
  --fade: 24px;
  mask-image: linear-gradient(to right, var(--black) calc(100% - var(--fade)), transparent);
}

/* The chosen row rolls its long name left in an endless loop: a copy follows 40px behind
   (LOOP_GAP in disk.js), and each loop moves exactly --loop (name width + gap), so the copy
   lands where the name started and the restart is invisible. */
.name-copy {
  display: none;
  margin-left: 40px;
}

.track-list li.current .name.is-long .name-copy { display: inline-block; }

.track-list li.current .name.is-long .name-text {
  animation: name-roll var(--loop-time, 8s) linear infinite;
}

@keyframes name-roll {
  to { transform: translateX(calc(var(--loop) * -1)); }
}

@media (prefers-reduced-motion: reduce) {
  .track-list li.current .name.is-long .name-text { animation: none; }
  .track-list li.current .name.is-long .name-copy { display: none; }
}

.track-list li.current {
  background: var(--orange);
  color: var(--white);
}

/* Rows: orange dots over the row's own color, white type on hover */
.track-list li:hover,
.track-list li:focus-visible {
  outline: 0;
  color: var(--white);
  background-image: radial-gradient(circle, rgb(var(--orange-rgb) / 0.5) 0.6px, transparent 1px);
  background-size: 3px 3px;
}

/* Orange dots would disappear on the solid orange row */
.track-list li.current:hover {
  background-image: radial-gradient(circle, rgb(var(--white-rgb) / 0.6) 0.6px, transparent 1px);
}

/* Empty rows before anything is added: muted, not interactive */
.track-list li.placeholder {
  color: var(--orange-60);
  cursor: default;
}

.track-list li.placeholder:hover {
  color: var(--orange-60);
  background-image: none;
}

/* Link input with remove / add buttons under each list */
.list-tools {
  display: flex;
  gap: 7px;
  margin-top: 12px;
}

.list-input {
  flex: 1;
  min-width: 0;
  height: 20px;
  padding: 0 6px;
  border: 0;
  border-radius: 0;
  background: var(--white-10);
  color: var(--white);
  font: inherit;
  font-size: var(--fs-small);
}

.list-input:focus-visible {
  outline: 1px solid var(--white-50);
  outline-offset: 0;
}

.list-input::placeholder { color: var(--white-50); }

/* Search (disk.js): nothing matches the typed text */
.list-input.no-match { color: var(--orange); }

/* Search: every matching row turns white; the located one (Enter moves it) is also outlined */
.track-list li.is-match { color: var(--white); }
.track-list li.is-located { box-shadow: inset 0 0 0 1px var(--white); }

/* ---------- Player panel ---------- */

.panel-player {
  display: flex;
  flex-direction: column;
}

.now-playing {
  display: flex;
  gap: 12px;
  height: 153px;
  padding: 18px 16px 0 18px;
  border-bottom: 1px solid var(--white-20);
}

.embed {
  flex: none;
  display: grid;
  place-items: center;
  width: 197px;
  height: 115px;
  background: var(--white-07);
  /* Dotted frame, like the CD's outer ring */
  outline: 1.5px dotted var(--white-50);
  font-size: var(--fs-small);
}

.embed:hover {
  background: radial-gradient(circle, var(--white-50) 0.6px, transparent 1px) 0 0 / 3px 3px, var(--white-07);
}

.embed.is-empty,
.embed.is-empty:hover { background: var(--white-20); }

/* Each player (YouTube / Vimeo / SoundCloud iframe, or the audio label) fills the box */
.embed { position: relative; overflow: hidden; }

.embed-frame {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.embed-frame[hidden] { display: none; }

.embed-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* "sound..." while a player loads, "cannot play" after it fails; covers the player underneath */
.embed-status {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  place-items: center;
  background: linear-gradient(var(--white-07), var(--white-07)), var(--black);
}

.embed.is-covered .embed-status { display: grid; }

/* "sound..." loading text: the 2nd and 3rd dots appear in turn */
.loading-dots span { animation: 1.2s steps(1, end) infinite; }
.loading-dots span:nth-child(2) { animation-name: dot-2; }
.loading-dots span:nth-child(3) { animation-name: dot-3; }

@keyframes dot-2 {
  0% { visibility: hidden; }
  33.33% { visibility: visible; }
}

@keyframes dot-3 {
  0% { visibility: hidden; }
  66.67% { visibility: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-dots span { animation: none; }
}

.song-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls {
  margin: 20px 16px 18px 18px;
  padding: 11px 12px 10px;
  background: var(--white-07);
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.controls-buttons {
  display: flex;
  gap: 5px;
}

.controls .btn-square svg path { stroke-width: 1.1; }

.time { font-variant-numeric: tabular-nums; }

.progress {
  position: relative;
  height: 8px;
  cursor: pointer;
  touch-action: none; /* dragging the handle shouldn't scroll the page */
  margin-top: 6px;
  background: radial-gradient(circle, var(--white) 0.6px, transparent 0.9px) 0 50% / 4px 4px repeat-x;
}

/* --p is progress from 0 to 1; the handle stays inside the bar at both ends */
.progress:focus-visible {
  outline: 1px solid var(--white-50);
  outline-offset: 3px;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 3px;
  width: calc((100% - 8px) * var(--p) + 4px);
  height: 2px;
  background: var(--orange);
}

.progress-handle {
  position: absolute;
  left: calc((100% - 8px) * var(--p));
  top: 0;
  width: 8px;
  height: 8px;
  background: var(--white);
}

.ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
}

.ticks i {
  width: 4px;
  height: 4px;
  background: var(--blue);
}

/* ---------- Popup entrance ---------- */

/* Popups rise slightly and fade in; their dimmed backdrops fade in */
.export-dialog[open],
.newcd-dialog[open],
.newcd-confirm:not([hidden]) .newcd-confirm-box {
  animation: popup-in 0.25s ease-out;
}

.export-dialog[open]::backdrop,
.newcd-dialog[open]::backdrop,
.newcd-confirm:not([hidden]) {
  animation: fade-in 0.25s ease-out;
}

@keyframes popup-in {
  from { opacity: 0; transform: translateY(10px); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .export-dialog[open],
  .newcd-dialog[open],
  .newcd-confirm:not([hidden]) .newcd-confirm-box,
  .export-dialog[open]::backdrop,
  .newcd-dialog[open]::backdrop,
  .newcd-confirm:not([hidden]) { animation: none; }
}

/* ---------- Export popup ---------- */

.export-dialog {
  width: 547px;
  max-width: calc(100vw - 32px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--white);
  color: var(--black);
}

.export-dialog::backdrop { background: rgb(0 0 0 / 0.5); }

.export-body {
  position: relative;
  display: grid;
  grid-template-columns: 272px 1fr;
  align-items: center;
  column-gap: 56px;
  padding: 15px 20px 15px 18px;
}

/* Sleeve + disc illustration on a dotted field */
.export-art {
  position: relative;
  height: 281px;
  background: radial-gradient(circle, rgb(0 0 0 / 0.6) 0.8px, transparent 1.2px) 0 0 / 3px 3px, var(--white);
}

/* Disc centered on the sleeve's right edge; it pokes out past the box.
   The group (disc, hub, label) rotates and slides as one piece. */
.export-disc-group {
  position: absolute;
  left: 74px;
  top: 33px;
  width: 214px;
  height: 214px;
  transition: transform 0.6s ease-in-out;
}

.export-disc,
.export-hub {
  position: absolute;
  border: 1px solid var(--black);
  border-radius: 50%;
}

.export-disc {
  inset: 0;
  background: var(--white);
}

/* The hole shows the dotted field through it */
.export-hub {
  left: 93px;
  top: 93px;
  width: 28px;
  height: 28px;
  background: radial-gradient(circle, rgb(0 0 0 / 0.6) 0.8px, transparent 1.2px) 0 0 / 3px 3px, var(--white);
}

.export-disc-label {
  position: absolute;
  left: 149px;
  top: 97px;
  transform: translate(-50%, -50%) rotate(-25deg);
  /* The CD's name (export.js); long names wrap and stay clear of the hole */
  width: max-content;
  max-width: 60px;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

/* On open: the disc turns clockwise, bringing its label out from behind the sleeve */
.export-dialog[open] .export-disc-group { animation: disc-in 0.9s ease-out; }

@keyframes disc-in {
  from { transform: rotate(-100deg); }
}

/* On "get cd file": the disc slides into the sleeve, then the popup fades out */
.export-dialog.is-saving .export-disc-group { transform: translateX(-40px); }
.export-dialog.is-saving .export-download { color: var(--blue); }

.export-dialog { transition: opacity 0.25s ease; }
.export-dialog.is-closing { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .export-dialog,
  .export-disc-group { transition: none; }
  .export-dialog[open] .export-disc-group { animation: none; }
}

.export-sleeve {
  position: absolute;
  left: 21px;
  top: 19px;
  width: 160px;
  height: 246px;
  display: grid;
  place-items: center;
  border: 1px solid var(--black);
  background: var(--white);
  color: var(--blue);
}

.export-copy {
  max-width: 175px;
  line-height: 1.2;
}

.export-download {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--black);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.export-close:hover,
.export-close:focus-visible {
  background: radial-gradient(circle, rgb(0 0 0 / 0.5) 0.6px, transparent 1px) 0 0 / 3px 3px;
}

.export-close {
  position: absolute;
  top: 13px;
  right: 13px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--black);
}

.export-close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
}

/* ---------- New CD popup ---------- */

.newcd-dialog {
  position: fixed;
  /* Same size on every step; content stretches to fill it */
  width: 546px;
  height: 379px;
  max-width: calc(100vw - 32px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--white);
  color: var(--black);
}

.newcd-dialog::backdrop { background: rgb(0 0 0 / 0.5); }

.newcd-dialog[open] {
  display: flex;
  flex-direction: column;
}

.newcd-head {
  position: relative;
  display: flex;
  align-items: center;
  height: 49px;
  padding: 0 28px;
  border-bottom: 1px solid rgb(0 0 0 / 0.4);
}

.newcd-step { color: rgb(0 0 0 / 0.5); }

.newcd-head .export-close { top: 50%; transform: translateY(-50%); right: 13px; }

.newcd-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 19px 19px 18px;
}

.newcd-form[hidden] { display: none; }

/* Step 0 and the success screen: centered text above the buttons */
.newcd-prompt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.newcd-fields {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.newcd-col {
  display: flex;
  flex-direction: column;
}

.newcd-col label { margin-bottom: 5px; }

.newcd-input {
  height: 30px;
  margin-bottom: 20px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: rgb(0 0 0 / 0.09);
  color: var(--black);
  font: inherit;
}

.newcd-input::placeholder { color: rgb(0 0 0 / 0.4); }

/* Active field gets a dotted outline */
.newcd-input:focus {
  outline: 1px dotted rgb(0 0 0 / 0.7);
  outline-offset: 0;
}

.newcd-textarea {
  flex: 1;
  height: auto;
  margin-bottom: 0;
  padding: 8px 12px;
  resize: none;
}

.newcd-error {
  min-height: 1.3em;
  margin: 0 0 6px;
  color: var(--orange);
}

.newcd-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.newcd-btn {
  height: 39px;
  border: 0;
  border-radius: 0;
  background: var(--black);
  color: var(--white);
}

/* Gray until every field is filled; still clickable so it can explain what's missing */
.newcd-btn-soft,
.newcd-next:not(.is-ready) { background: rgb(0 0 0 / 0.4); }

.newcd-btn:hover,
.newcd-btn:focus-visible {
  background-image: radial-gradient(circle, var(--white-50) 0.6px, transparent 1px);
  background-size: 3px 3px;
}

/* Steps 2 and 3: method list (or playlist name) on the left, fields on the right */
.newcd-split {
  display: grid;
  grid-template-columns: 235px 1fr;
  column-gap: 18px;
  flex: 1;
  min-height: 0;
  margin-bottom: 25px;
}

.newcd-options {
  display: flex;
  flex-direction: column;
  padding-left: 9px;
}

.newcd-option {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--black);
  text-align: left;
}

.newcd-option[aria-pressed="true"] {
  background: var(--black);
  color: var(--white);
}

.newcd-option[aria-pressed="false"]:hover,
.newcd-option[aria-pressed="false"]:focus-visible {
  background: radial-gradient(circle, rgb(0 0 0 / 0.5) 0.6px, transparent 1px) 0 0 / 3px 3px;
}

.newcd-pane {
  display: flex;
  flex-direction: column;
  padding-left: 14px;
  border-left: 1px solid rgb(0 0 0 / 0.3);
}

.newcd-pane label { margin-bottom: 5px; }

.newcd-link-field {
  display: flex;
  flex-direction: column;
}

.newcd-link-field[hidden] { display: none; }

/* Bottom of the pane: gray description, orange error, or black "loading..." */
.newcd-status {
  margin-top: auto;
  color: rgb(0 0 0 / 0.4);
  line-height: 1.2;
}

.newcd-status.is-error { color: var(--orange); }
.newcd-status.is-loading { color: var(--black); }

/* Step 3 (from scratch): the playlist the songs go into */
.newcd-side {
  min-width: 0;
  padding-left: 9px;
}

.newcd-playlist-tag {
  height: 30px;
  padding: 0 12px;
  overflow: hidden;
  background: var(--black);
  color: var(--white);
  line-height: 30px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Link type dropdown: native select with a small left-pointing triangle */
.newcd-select {
  position: relative;
  display: flex;
  flex-direction: column;
}

.newcd-select select {
  appearance: none;
  cursor: pointer;
}

.newcd-select::after {
  content: '';
  position: absolute;
  top: 11px;
  right: 14px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-right: 6px solid var(--black);
  pointer-events: none;
}

/* Step 3 (imported): scrolling list of found songs, each with a status icon */
.newcd-import-list {
  flex: 1;
  min-height: 0;
  margin-left: 7px;
  overflow-y: auto;
  list-style: none;
}

/* The last visible row fades out while there is more below */
.newcd-import-list.has-more {
  mask-image: linear-gradient(to bottom, var(--black) calc(100% - 40px), transparent);
}

.newcd-import-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 39px;
  margin-right: 6px;
  padding: 0 12px;
  border-bottom: 1px dotted rgb(0 0 0 / 0.5);
}

.newcd-item-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.newcd-item-icon {
  flex: none;
  position: relative;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
}

.newcd-item-icon:hover,
.newcd-item-icon:focus-visible {
  outline: 1px dotted rgb(0 0 0 / 0.7);
  outline-offset: 2px;
}

/* Loading: a turning dotted circle */
.newcd-item-icon[data-state="pending"] {
  border: 1.5px dotted rgb(0 0 0 / 0.5);
  animation: spin 3s linear infinite;
}

.newcd-item-icon[data-state="done"] { background: var(--green); }
.newcd-item-icon[data-state="error"] { background: var(--red); }

/* Check mark: a rotated corner */
.newcd-item-icon[data-state="done"]::after {
  content: '';
  position: absolute;
  left: 6.5px;
  top: 4px;
  width: 4px;
  height: 7px;
  border: solid var(--white);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* Cross: two bars */
.newcd-item-icon[data-state="error"]::before,
.newcd-item-icon[data-state="error"]::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 8.25px;
  width: 8px;
  height: 1.5px;
  background: var(--white);
  transform: rotate(45deg);
}

.newcd-item-icon[data-state="error"]::after { transform: rotate(-45deg); }

@media (prefers-reduced-motion: reduce) {
  .newcd-item-icon[data-state="pending"] { animation: none; }
}

/* Edit popups: the playlist name sits centered; the song form is name and artist on top,
   then link type and link, each pair side by side */
.newcd-edit-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 282px;
  max-width: 100%;
}

.newcd-edit-name label { margin-bottom: 8px; }

.newcd-edit-name .newcd-input {
  width: 100%;
  margin-bottom: 0;
  text-align: center;
}

.newcd-edit-song {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.newcd-edit-song .newcd-fields { flex: none; }

/* Errors / "loading..." just above the buttons */
.newcd-edit-status {
  min-height: 1.3em;
  margin: 0 0 12px;
}

/* Hover message for a status icon: the panel message bubble, inverted to black for the white popup.
   --pointer-x is where the icon is, from the bubble's left edge. */
.newcd-tip {
  --pointer-w: 11px;
  --pointer-h: 13px;
  position: absolute;
  z-index: 2;
  width: max-content;
  max-width: 300px;
  padding: 6px 12px;
  background: var(--black);
  color: var(--white);
  font-size: var(--fs-message);
  line-height: 1.3;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.newcd-tip[hidden] { display: none; }

/* Pointer above the bubble, pointing up at the icon */
.newcd-tip::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: var(--pointer-x, 50%);
  margin-left: calc(var(--pointer-w) / -2);
  border-left: calc(var(--pointer-w) / 2) solid transparent;
  border-right: calc(var(--pointer-w) / 2) solid transparent;
  border-bottom: var(--pointer-h) solid var(--black);
}

/* Near the bottom of the popup the bubble sits above the icon, pointing down */
.newcd-tip.is-above::after {
  top: 100%;
  bottom: auto;
  border-bottom: 0;
  border-top: var(--pointer-h) solid var(--black);
}

/* Live log under the list: progress, then the summary or an item's details */
.newcd-log {
  min-height: 1.3em;
  margin: 14px 0 14px 7px;
  overflow: hidden;
  color: rgb(0 0 0 / 0.5);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.newcd-log.is-error { color: var(--orange); }
.newcd-log.is-loading { color: var(--black); }

/* Success screen: names in black, the rest in gray */
.newcd-done-text {
  max-width: 290px;
  color: rgb(0 0 0 / 0.5);
  line-height: 1.2;
}

.newcd-done-text .newcd-name { color: var(--black); }

/* Confirmation over the popup */
.newcd-confirm {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.3);
}

.newcd-confirm[hidden] { display: none; }

.newcd-confirm-box {
  width: 302px;
  padding: 30px 15px 12px;
  background: var(--white);
  text-align: center;
}

.newcd-confirm-box .newcd-actions {
  gap: 10px;
  margin-top: 36px;
}

/* Hidden YouTube player used only to list a playlist's videos (youtubePlaylist.js).
   Inside the window but invisible and behind everything: browsers may hold back frames
   that are off-screen, which stopped the playlist from loading. */
.hidden-player {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: -1;
  width: 200px;
  height: 120px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- CD editor ("draw on your cd") ---------- */

.cd-editor {
  width: 580px;
  height: fit-content; /* not auto: a fixed dialog with auto height stretches to the full screen */
}

.cd-editor-body { padding: 19px 19px 0; }

/* Black stage with the disc in its natural orientation (logo up) */
.cd-editor-stage {
  --cd-size: 392px;
  display: grid;
  place-items: center;
  height: 441px;
  background: var(--black);
}

.cd-editor-stage .cd {
  position: relative;
  left: auto;
  top: auto;
  margin: 0;
  touch-action: none; /* drawing with a finger shouldn't scroll */
  user-select: none;  /* or a drag selects the label text */
}

.cd-editor-stage .cd-spin { transform: none; }
.cd-editor-stage .cd-hub { background: var(--black); }

.cd-editor-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-bottom: 26px; /* room for the arrow under the chosen color */
}

/* Undo / redo / eraser: black 20px squares with white line icons */
.cd-tool {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--black);
  color: var(--white);
}

.cd-tool svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cd-tool:disabled { opacity: 0.3; cursor: default; }

.cd-tool:not(:disabled):hover,
.cd-tool:focus-visible {
  outline: 1px dotted rgb(0 0 0 / 0.7);
  outline-offset: 2px;
}

/* Size buttons: a white dot on the black square, small for smaller, big for bigger */
.cd-size-button:first-of-type { margin-left: 10px; }

.cd-size-dot {
  border-radius: 50%;
  background: currentColor;
}

.cd-size-dot.is-small { width: 4px; height: 4px; }
.cd-size-dot.is-big { width: 10px; height: 10px; }

/* Follows the pointer over the disc at the pencil's size and color (dashed for the eraser) */
.cd-editor-stage { position: relative; }

.cd-editor-cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  border-radius: 50%;
  background: var(--color);
  box-shadow: 0 0 0 1px rgb(var(--white-rgb) / 0.6);
  pointer-events: none;
  translate: -50% -50%;
}

.cd-editor-cursor[hidden] { display: none; }

.cd-editor.is-erasing .cd-editor-cursor {
  background: none;
  border: 1px dashed var(--black);
  box-shadow: 0 0 0 1px rgb(var(--white-rgb) / 0.6);
}

.cd-editor-stage .cd:hover { cursor: none; }

.cd-editor-palette {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.cd-swatch {
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2);
}

/* An up arrow under the tool in use: straight shaft, wide chevron head */
.cd-editor-palette [aria-pressed="true"]::after {
  content: '';
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  width: 11px;
  height: 13px;
  margin-left: -5.5px;
  background: var(--black);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 13'%3E%3Cpath d='M5.5 12.5V1M1 5.5L5.5 1L10 5.5' fill='none' stroke='black' stroke-width='1.1'/%3E%3C/svg%3E") center / contain no-repeat;
}

.cd-editor-actions { padding: 0 19px 18px; }

@media (max-width: 600px) {
  .cd-editor-stage { --cd-size: min(300px, 70vw); height: auto; aspect-ratio: 1; }
  .cd-editor-tools { flex-wrap: wrap; }
  .cd-editor-palette { margin-left: 0; flex-wrap: wrap; }
}

/* ---------- Delete confirmation ('-' buttons) ---------- */

/* The same white box as the New CD popup's "exit without saving changes?" question */
.delete-dialog {
  padding: 0;
  border: 0;
  background: none;
  color: var(--black);
  overflow: visible;
}

.delete-dialog::backdrop { background: rgb(0 0 0 / 0.5); }

.delete-dialog[open] .newcd-confirm-box { animation: popup-in 0.25s ease-out; }
.delete-dialog[open]::backdrop { animation: fade-in 0.25s ease-out; }

.delete-title { overflow-wrap: anywhere; }

/* One button, full width */
.notice-actions { grid-template-columns: 1fr; }

.delete-detail {
  margin-top: 8px;
  color: rgb(0 0 0 / 0.5);
  line-height: 1.2;
}

@media (prefers-reduced-motion: reduce) {
  .delete-dialog[open] .newcd-confirm-box,
  .delete-dialog[open]::backdrop { animation: none; }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 1100px) {
  .stage {
    grid-template-columns: minmax(0, 533px);
  }
}

@media (max-width: 600px) {
  .topnav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 16px 16px 0;
  }
  .topnav-actions { justify-content: flex-start; }
  .logo { align-self: flex-start; }
  .stage { padding: 24px 16px; }
  .stack { grid-template-rows: auto auto; }
  .cd-art { --cd-size: 360px; height: 220px; }
  .cd-info { grid-template-columns: 1fr auto; gap: 12px; }
  .cd-meta { grid-column: 1; }
  .cd-desc { grid-column: 1; grid-row: 2; }
  .lists { grid-template-columns: minmax(0, 1fr); }
  .now-playing { flex-wrap: wrap; height: auto; padding-bottom: 18px; }
  .export-body { grid-template-columns: 1fr; row-gap: 20px; padding: 44px 16px 20px; }
  .export-art { width: 272px; }
  .export-copy { max-width: none; }
  .newcd-fields { grid-template-columns: 1fr; gap: 0; }
  /* fit-content, not auto: a fixed dialog with auto height stretches to the full screen */
  .newcd-dialog { height: fit-content; }
  .newcd-head { height: auto; min-height: 49px; padding: 8px 44px 8px 16px; }
  .newcd-log { white-space: normal; }
  .newcd-textarea { flex: none; height: 120px; margin-bottom: 20px; }
  .newcd-split { grid-template-columns: 1fr; row-gap: 16px; height: auto; }
  .newcd-side { padding-left: 0; }
  .newcd-import-list { flex: none; height: 240px; }
  .newcd-prompt { min-height: 200px; }
  .newcd-options { padding-left: 0; }
  .newcd-pane { min-height: 180px; padding-left: 0; border-left: 0; }
}
