/* THE GOD TERMINAL — QuackAmp, the costume's Music app (js/costume-music.js).
 * An original Winamp-era skin: brushed gunmetal chassis, light aluminium buttons, phosphor LCDs.
 * Its own tokens live on .csm-app; like the rest of the costume it ignores the palettes. */

.cs-win.csm-app {
  --csm-ink: #e9eef7;
  --csm-dim: #9aa6b8;
  --csm-amber: #ffbe4d;
  --csm-lcd: #4dff86;
  --csm-lcd-mid: #2fcf62;
  --csm-lcd-off: #0f3019;
  --csm-lcd-bg: #040b06;
  --csm-chassis: #2b313d;
  --csm-chassis-lo: #1a1e26;
  --csm-alu-hi: #eef1f5;
  --csm-alu: #b9c1cd;
  --csm-alu-lo: #7b8494;
  --csm-select: #2a5bc7;
  --csm-grip: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0 1px, rgba(0, 0, 0, 0.45) 1px 2px, transparent 2px 4px);
  --csm-brush: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0 1px, rgba(0, 0, 0, 0.05) 1px 2px, transparent 2px 3px);
  border: 1px solid #0b0d12;
  border-radius: 4px 4px 3px 3px;
  background: var(--csm-brush), linear-gradient(180deg, var(--csm-chassis), var(--csm-chassis-lo));
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.14), inset -1px -1px 0 rgba(0, 0, 0, 0.6), 4px 6px 18px rgba(0, 0, 0, 0.55);
  color: var(--csm-ink);
}

/* ── the window's own title bar, reskinned: dark, ridged, amber lettering ── */
.cs-win.csm-app .cs-win-bar {
  position: relative;
  gap: 0.55rem;
  height: 2.1rem;
  margin: 0;
  padding: 0 0.35rem 0 0.6rem;
  border-radius: 3px 3px 0 0;
  border-bottom: 1px solid #07090c;
  background: linear-gradient(180deg, #4a5262 0%, #343a47 45%, #262b35 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.cs-win.csm-app:not(.is-active) .cs-win-bar { background: linear-gradient(180deg, #3a404c, #2b3039 60%, #23272f); }
.cs-win.csm-app .cs-win-title {
  flex: none;
  order: 2;
  color: var(--csm-amber);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  text-shadow: 0 0 6px rgba(255, 170, 40, 0.45), 0 1px 0 #000;
}
.cs-win.csm-app:not(.is-active) .cs-win-title { color: #b9925a; text-shadow: 0 1px 0 #000; }
.cs-win.csm-app .cs-win-icon { order: 0; }
/* Grip ridges either side of the name. */
.cs-win.csm-app .cs-win-bar::before,
.cs-win.csm-app .cs-win-bar::after {
  content: '';
  flex: 1;
  height: 0.6rem;
  border-radius: 1px;
  background: var(--csm-grip);
  opacity: 0.9;
}
.cs-win.csm-app .cs-win-bar::before { order: 1; }
.cs-win.csm-app .cs-win-bar::after { order: 3; }
.cs-win.csm-app .cs-win-x {
  order: 4;
  width: 1.55rem;
  height: 1.4rem;
  border: 1px solid #0b0d12;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--csm-alu-hi), var(--csm-alu) 55%, var(--csm-alu-lo));
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 rgba(0, 0, 0, 0.3);
}
.cs-win.csm-app .cs-win-x::before, .cs-win.csm-app .cs-win-x::after { background: #262b35; height: 2.4px; width: 56%; }

.csm {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: 100%;
  min-height: 0;
  padding: 0.45rem;
  font-size: 0.9375rem;
  color: var(--csm-ink);
  -webkit-user-select: none;
  user-select: none;
}
.csm :focus { outline: none; }
.csm :focus-visible { outline: 2px solid var(--csm-amber); outline-offset: 1px; }

/* ── panels: chassis plates with a bevel and their own small title strip ── */
.csm-panel {
  position: relative;
  flex: none;
  border: 1px solid #0a0c10;
  border-radius: 3px;
  background: var(--csm-brush), linear-gradient(180deg, #353c4a, #242933);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.12), inset -1px -1px 0 rgba(0, 0, 0, 0.5);
}
.csm-strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 1.6rem;
  padding: 0 0.5rem;
  color: var(--csm-dim);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.csm-strip::before, .csm-strip::after { content: ''; flex: 1; height: 0.45rem; background: var(--csm-grip); opacity: 0.55; }
.csm-strip > span { flex: none; }

/* ── LCD wells ── */
.csm-lcd {
  position: relative;
  overflow: hidden;
  border: 1px solid #000;
  border-radius: 2px;
  background:
    repeating-linear-gradient(180deg, rgba(77, 255, 134, 0.035) 0 1px, transparent 1px 3px),
    radial-gradient(120% 140% at 30% 0%, #0b1d10, var(--csm-lcd-bg) 70%);
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.12);
  font-family: 'VT323', 'Lucida Console', monospace;
  color: var(--csm-lcd);
  text-shadow: 0 0 6px rgba(77, 255, 134, 0.55);
}
/* Glass: a faint sheen across every LCD. */
.csm-lcd::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(168deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.015) 34%, rgba(255, 255, 255, 0) 35%);
}
.csm-flash {
  position: absolute;
  inset: 0;
  background: #eafff0;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* ── main panel ── */
.csm-main { padding: 0.5rem; display: flex; flex-direction: column; gap: 0.45rem; }
.csm-top { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr); gap: 0.5rem; }
.csm-screen { display: flex; flex-direction: column; padding: 0.35rem 0.5rem 0.4rem; min-height: 7.6rem; }
.csm-readout { display: flex; align-items: center; gap: 0.55rem; height: 3.3rem; }
.csm-state { flex: none; width: 1.35rem; height: 1.35rem; color: var(--csm-lcd); filter: drop-shadow(0 0 4px rgba(77, 255, 134, 0.6)); }
.csm-state svg { display: block; width: 100%; height: 100%; }
.csm-time {
  display: flex;
  align-items: center;
  gap: 0.18rem;
  height: 3rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.csm-time.is-pressed { transform: scale(1.06); }
.csm-dig { display: block; width: 1.55rem; height: 2.7rem; transform: skewX(-7deg); overflow: visible; }
.csm-dig path { fill: var(--csm-lcd-off); transition: fill 60ms; }
.csm-dig path.on { fill: var(--csm-lcd); filter: drop-shadow(0 0 3px rgba(77, 255, 134, 0.7)); }
.csm-minus { width: 0.7rem; }
.csm-colon { display: flex; flex-direction: column; gap: 0.55rem; padding: 0 0.05rem; }
.csm-colon i { display: block; width: 0.32rem; height: 0.32rem; border-radius: 1px; background: var(--csm-lcd); box-shadow: 0 0 5px rgba(77, 255, 134, 0.7); }
.csm.is-paused .csm-time { animation: csm-blink 1s steps(1) infinite; }
@keyframes csm-blink { 50% { opacity: 0.12; } }
/* An explicit height: a canvas's own pixel size would otherwise feed back into its layout height. */
.csm-vis { display: block; flex: none; width: 100%; height: 4.4rem; margin-top: auto; cursor: pointer; }

.csm-side { display: flex; flex-direction: column; justify-content: space-between; gap: 0.4rem; min-width: 0; }
.csm-marquee { height: 2.25rem; display: flex; align-items: center; font-size: 1.45rem; line-height: 1; white-space: nowrap; }
.csm-marquee-track { display: flex; padding-left: 0.5rem; will-change: transform; }
.csm-marquee-track > span { flex: none; padding-right: 3rem; }
.csm-marquee.is-scroll .csm-marquee-track { animation: csm-scroll var(--csm-scroll, 14s) linear infinite; }
.csm-marquee.is-note .csm-marquee-track { animation: none; justify-content: center; width: 100%; padding: 0; }
@keyframes csm-scroll { to { transform: translateX(-50%); } }

.csm-info { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.csm-chip {
  padding: 0.12rem 0.4rem 0.05rem;
  font-size: 1.15rem;
  line-height: 1;
}
.csm-lamp {
  padding: 0.1rem 0.4rem;
  border: 1px solid #0a0c10;
  border-radius: 2px;
  background: #1c2027;
  color: #4b5463;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.csm-lamp.is-on { color: var(--csm-lcd); background: #0b1a0f; text-shadow: 0 0 5px rgba(77, 255, 134, 0.8); }

.csm-row { display: flex; align-items: center; gap: 0.45rem; }
.csm-label { flex: none; color: var(--csm-dim); font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.14em; }

/* ── sliders: a sunken groove and an aluminium thumb ── */
.csm-slider { position: relative; flex: 1; height: 1.6rem; touch-action: none; cursor: pointer; }
.csm-groove {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0.5rem;
  margin-top: -0.25rem;
  border-radius: 0.25rem;
  background: #0b0d11;
  box-shadow: inset 1px 1px 2px #000, 0 1px 0 rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.csm-fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(var(--v, 0)); background: linear-gradient(90deg, #1f9e46, #57e06b 55%, #e8d442 80%, #ff6a3a); }
.csm-seek .csm-fill { background: linear-gradient(90deg, #1b6fd8, #4aa3ff); opacity: 0.85; }
.csm-thumb {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.6rem;
  height: 1.15rem;
  margin-top: -0.575rem;
  border: 1px solid #0b0d12;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, transparent 0 0.3rem, rgba(0, 0, 0, 0.22) 0.3rem calc(0.3rem + 1px)), linear-gradient(180deg, var(--csm-alu-hi), var(--csm-alu) 55%, var(--csm-alu-lo));
  box-shadow: inset 1px 1px 0 #fff, 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: scale 120ms cubic-bezier(.2, 1.6, .4, 1);
}
.csm-slider.is-dragging .csm-thumb { scale: 1.15; box-shadow: inset 1px 1px 0 #fff, 0 0 0 2px rgba(255, 190, 77, 0.7), 0 2px 4px rgba(0, 0, 0, 0.6); }
.csm-seek { flex: none; height: 1.9rem; }
.csm-seek .csm-groove { height: 0.6rem; margin-top: -0.3rem; }
.csm-seek .csm-thumb { width: 2.4rem; }

/* ── buttons: aluminium, bevelled, they grow when pressed ── */
.csm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 2.5rem;
  height: 2.25rem;
  padding: 0 0.55rem;
  border: 1px solid #0b0d12;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--csm-alu-hi), var(--csm-alu) 52%, var(--csm-alu-lo));
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 rgba(0, 0, 0, 0.25), 0 1px 1px rgba(0, 0, 0, 0.5);
  color: #232833;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 110ms cubic-bezier(.2, 1.6, .4, 1), filter 110ms;
}
.csm-btn svg { width: 1.15rem; height: 1.15rem; display: block; }
.csm-btn:hover { filter: brightness(1.06); }
.csm-btn.is-pressed {
  transform: scale(1.12);
  background: linear-gradient(180deg, var(--csm-alu-lo), var(--csm-alu) 48%, var(--csm-alu-hi));
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.4);
}
.csm-led { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #3b4250; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6); }
.csm-btn[aria-pressed="true"] .csm-led { background: #5dff90; box-shadow: 0 0 6px #5dff90, inset 0 -1px 1px rgba(0, 0, 0, 0.3); }
.csm-btn.is-play[aria-pressed="true"] { color: #0c6a2b; }
.csm-controls { display: flex; align-items: center; gap: 0.3rem; }
.csm-controls .csm-transport { display: flex; gap: 0.25rem; }
.csm-controls .csm-transport .csm-btn { min-width: 2.75rem; height: 2.4rem; padding: 0; }
.csm-spacer { flex: 1; }
.csm-logo {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.15rem;
  border: 0;
  background: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
  transition: transform 140ms cubic-bezier(.2, 1.6, .4, 1);
}
.csm-logo.is-pressed { transform: scale(1.18) rotate(-8deg); }
.csm-logo svg { display: block; width: 100%; height: 100%; }

/* ── equaliser ── */
.csm-eq-body { display: flex; align-items: center; gap: 0.5rem; padding: 0.1rem 0.55rem 0.45rem; }
.csm-eq-left { display: flex; gap: 0.3rem; flex: none; }
.csm-eq-graph { display: block; flex: 1; min-width: 0; height: 2.3rem; border: 1px solid #000; border-radius: 2px; box-shadow: inset 1px 1px 3px #000, 0 1px 0 rgba(255, 255, 255, 0.1); }
.csm-bands { display: grid; grid-template-columns: 1.1fr 0.6fr repeat(10, 1fr); gap: 0.1rem; align-items: stretch; }
.csm-band { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; min-width: 0; }
.csm-band b { font-size: 0.8125rem; font-weight: 700; color: var(--csm-dim); letter-spacing: 0.02em; white-space: nowrap; }
.csm-vslider { position: relative; width: 100%; height: 6.4rem; touch-action: none; cursor: pointer; }
.csm-vslider .csm-groove { left: 50%; right: auto; top: 0; bottom: 0; width: 0.42rem; height: auto; margin: 0 0 0 -0.21rem; }
.csm-vslider .csm-fill { left: 0; right: 0; opacity: 0.9; }
.csm-vslider .csm-fill.is-up { top: 0; bottom: 50%; transform-origin: 50% 100%; transform: scaleY(var(--up, 0)); background: linear-gradient(180deg, #ff6a3a, #e8d442 45%, #57e06b); }
.csm-vslider .csm-fill.is-down { top: 50%; bottom: 0; transform-origin: 50% 0; transform: scaleY(var(--down, 0)); background: linear-gradient(0deg, #ff6a3a, #e8d442 45%, #57e06b); }
.csm-vslider .csm-groove::after { content: ''; position: absolute; left: -0.35rem; right: -0.35rem; top: 50%; height: 1px; background: rgba(255, 255, 255, 0.18); }
.csm-vslider .csm-thumb { left: 50%; top: 0; width: 1.5rem; height: 0.9rem; margin: -0.45rem 0 0 -0.75rem; }
.csm-vslider.is-dragging .csm-thumb { scale: 1.18; }
.csm-scale { display: flex; flex-direction: column; justify-content: space-between; height: 6.4rem; color: var(--csm-dim); font-size: 0.8125rem; text-align: right; }
.csm-presets { position: relative; }
.csm-menu {
  position: absolute;
  z-index: 5;
  min-width: 12rem;
  padding: 0.25rem;
  border: 1px solid #0a0c10;
  border-radius: 3px;
  background: linear-gradient(180deg, #3c4352, #2a2f3a);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), inset 1px 1px 0 rgba(255, 255, 255, 0.12);
}
.csm-menu button {
  display: block;
  width: 100%;
  min-height: 2.1rem;
  padding: 0.25rem 0.7rem;
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--csm-ink);
  font-size: 0.9375rem;
  text-align: left;
  transition: transform 110ms cubic-bezier(.2, 1.6, .4, 1);
}
.csm-menu button:hover { background: var(--csm-select); }
.csm-menu button.is-pressed { transform: scale(1.04); background: #3d72e6; }

/* ── playlist ── */
.csm-pl { flex: 1; min-height: 7rem; display: flex; flex-direction: column; }
.csm-list {
  flex: 1;
  min-height: 0;
  margin: 0 0.45rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #000;
  border-radius: 2px;
  background: #06080b;
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.1);
  scrollbar-color: #4a5262 #10131a;
}
.csm-track {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.35rem;
  padding: 0 0.7rem;
  color: #5fd27e;
  font-size: 0.9375rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.csm-track .csm-n { flex: none; width: 2.2rem; color: #3f8f56; text-align: right; white-space: nowrap; }
.csm-track .csm-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csm-track .csm-len { flex: none; color: #3f8f56; font-variant-numeric: tabular-nums; }
.csm-track:hover { background: rgba(77, 255, 134, 0.07); }
.csm-track.is-selected { background: var(--csm-select); color: #fff; }
.csm-track.is-selected .csm-n, .csm-track.is-selected .csm-len { color: #cfe0ff; }
.csm-track.is-current { color: #fff; text-shadow: 0 0 6px rgba(140, 255, 170, 0.6); }
.csm-track.is-current .csm-n::before { content: '▶ '; font-size: 0.7em; color: var(--csm-lcd); }
.csm-foot { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.45rem 0.45rem; }
.csm-foot .csm-lcd { padding: 0.15rem 0.5rem 0.05rem; font-size: 1.25rem; line-height: 1; }

/* The about bubble. */
.csm-about {
  position: absolute;
  right: 1rem;
  bottom: 3.3rem;
  z-index: 6;
  max-width: 17rem;
  padding: 0.6rem 0.8rem;
  font-size: 1.3rem;
  line-height: 1.1;
}

/* EQ / playlist panels can be tucked away. */
.csm-panel[hidden] { display: none; }

/* ── phones: the window fills the desk; everything stacks ── */
@media (max-width: 599px) {
  .csm { gap: 0.3rem; padding: 0.35rem; }
  .csm-top { grid-template-columns: 1fr; }
  .csm-screen { min-height: 0; }
  .csm-vis { height: 4.6rem; }
  .csm-controls { flex-wrap: wrap; row-gap: 0.4rem; }
  .csm-controls .csm-transport { flex: 1 1 100%; justify-content: space-between; }
  .csm-controls .csm-transport .csm-btn { flex: 1; height: 2.75rem; }
  .csm-btn { height: 2.6rem; }
  .csm-vslider, .csm-scale { height: 5.6rem; }
  .csm-track { min-height: 2.75rem; }
}
@media (pointer: coarse) {
  .cs-win.csm-app .cs-win-bar { height: 2.75rem; }
  .cs-win.csm-app .cs-win-x { width: 2.4rem; height: 2.2rem; }
}

/* Reduced motion: no scrolling title, no blinking time, no bouncy presses. */
html[data-reduced-motion="on"] .csm-marquee.is-scroll .csm-marquee-track { animation: none; }
html[data-reduced-motion="on"] .csm-marquee-track > span + span { display: none; }
html[data-reduced-motion="on"] .csm-marquee-track > span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding-right: 0.5rem; }
html[data-reduced-motion="on"] .csm-marquee-track { max-width: 100%; }
html[data-reduced-motion="on"] .csm.is-paused .csm-time { animation: none; opacity: 0.55; }
