:root {
  --bg: #14121f;
  --bg2: #1b1930;
  --surface: #23203a;
  --surface2: #2c2846;
  --primary: #7c4dff;
  --primary-dim: #5a3fd0;
  --on-surface: #ece9f5;
  --muted: #a99fc7;
  --accent: #ffc24b;
  --tertiary: #26c6da;
  --error: #ff6b6b;
}

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

/* the hidden attribute must beat display rules like .overlay { display: flex } */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(120% 80% at 50% 0%, #2a2450 0%, var(--bg) 60%);
  color: var(--on-surface);
  user-select: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
}
.screen.active {
  display: flex;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
}
.topbar h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--on-surface);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chip {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chip.ghost {
  background: transparent;
  color: var(--primary);
}
.chip.full {
  width: 100%;
  margin-top: 18px;
  padding: 12px;
}

/* ---- library ---- */
.search-wrap {
  padding: 0 16px 8px;
}
#search {
  width: 100%;
  padding: 11px 16px;
  border-radius: 22px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--on-surface);
  font-size: 15px;
  outline: none;
}
.song-list {
  list-style: none;
  margin: 0;
  padding: 4px 12px 96px;
  overflow-y: auto;
  flex: 1;
}
.song-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
}
.song-item:hover {
  background: var(--surface2);
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 21px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.song-meta {
  flex: 1;
  overflow: hidden;
}
.song-meta .name {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.song-actions {
  display: flex;
  gap: 2px;
}
.empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 32px;
  white-space: pre-line;
}

/* ---- player ---- */
.deck {
  margin: 4px 16px 0;
  padding: 12px 16px;
  border-radius: 26px;
  background: rgba(44, 40, 70, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stats {
  font-size: 12px;
  color: var(--muted);
}
#seek {
  width: 100%;
  accent-color: var(--primary);
}
.times {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}
.transport {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 4px;
}
.round {
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: white;
}
.round.tonal {
  width: 50px;
  height: 50px;
  background: var(--surface2);
  font-size: 22px;
}
.round.primary {
  width: 74px;
  height: 74px;
  background: var(--primary);
  font-size: 30px;
}
.round.primary:active {
  background: var(--primary-dim);
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  min-height: 0;
}
.stage.left .fall {
  order: 2;
}
.stage.left .wheel-wrap {
  order: 1;
}
.fall {
  flex: 1.1;
  height: 100%;
  border-radius: 16px;
  background: rgba(44, 40, 70, 0.35);
  min-width: 0;
}
.wheel-wrap {
  flex: 1;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
}
.wheel-wrap::before {
  content: "";
  position: absolute;
  width: 90%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 77, 255, 0.22), transparent 65%);
}
.wheel {
  width: 100%;
  aspect-ratio: 1;
  max-height: 100%;
  touch-action: none;
  position: relative;
}
.hidden-hint {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}
.hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 20px 16px;
  margin: 0;
}

.error-line {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  padding: 6px 16px;
}

/* ---- overlays / sheets ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.sheet {
  background: var(--bg2);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 20px 24px 28px;
}
.grabber {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface2);
  margin: 0 auto 10px;
}
.sheet.small {
  border-radius: 24px;
  margin: auto;
  max-width: 420px;
}
.sheet h2 {
  margin: 4px 0 16px;
}
.sheet h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}
.sheet h3.sub {
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 4px;
}
.sheet hr {
  border: none;
  border-top: 1px solid var(--surface2);
  margin: 18px 0 0;
}
.sheet input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}
.sheet input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--on-surface);
  font-size: 15px;
  margin-bottom: 14px;
}
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 15px;
}
input[type="checkbox"] {
  width: 40px;
  height: 24px;
  accent-color: var(--primary);
}
.caption {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}
.mono {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}
.seg {
  display: flex;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--surface2);
}
.seg button {
  flex: 1;
  background: transparent;
  color: var(--on-surface);
  border: none;
  padding: 9px;
  font-size: 13px;
  cursor: pointer;
}
.seg button.on {
  background: var(--primary);
  color: white;
}
.caption a {
  color: var(--primary);
}
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.preset-chips button {
  background: transparent;
  color: var(--on-surface);
  border: 1px solid var(--surface2);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.preset-chips button.on {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.eq-bands {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.eq-band {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.eq-band input[type="range"] {
  writing-mode: vertical-lr;
  direction: rtl;
  height: 90px;
  width: 24px;
  accent-color: var(--primary);
}
.eq-band label {
  font-size: 10px;
  color: var(--muted);
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
