:root {
  --bg: #e6eaf5;
  --surface: #f7f8fd;
  --ink: #1b1f3b;
  --muted: #5a6186;
  --line: #cad0e6;
  --accent: #5848d8;
  --accent-ink: #ffffff;
  --danger: #b4233c;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14172a;
    --surface: #1d2138;
    --ink: #e7e9f7;
    --muted: #9ca2c8;
    --line: #2d3254;
    --accent: #a79cff;
    --accent-ink: #14172a;
    --danger: #ff8a9e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 6rem;
}

h1, h2, p { margin: 0; }

button, input { font: inherit; color: inherit; }

button {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}

button.quiet {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

button:disabled { opacity: 0.45; cursor: default; }

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

a { color: var(--accent); }

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.top h1 {
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.listeners { color: var(--muted); white-space: nowrap; }

.host {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.9rem 1rem;
  margin-bottom: 2rem;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.host p { flex: 1 1 14rem; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.toggle input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
}

#controls-note { margin-top: 0.75rem; }

.volume {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 8rem;
  height: 1.25rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--line) var(--fill, 50%));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--accent);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--accent);
}

.yt-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 1.25rem;
  align-items: end;
  margin: -1rem 0 2rem;
}

.yt-wrap iframe {
  display: block;
  width: 356px;
  max-width: 100%;
  height: 200px;
  border: 0;
  border-radius: 10px;
}

.yt-fix > label { display: block; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem; }

.yt-fix input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.listen-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

.now {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 2.5rem;
}

.art-wrap {
  position: relative;
  aspect-ratio: 1;
  margin: 0 0.6rem 0.6rem 0;
}

.art-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: var(--line);
  z-index: 1;
}

.art-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: translate(0.6rem, 0.6rem);
  border-radius: 10px;
  background: var(--accent);
  z-index: 0;
}

.art {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.now-text { min-width: 0; }

.now-title {
  font-size: clamp(1.6rem, 5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.now-artist { font-size: 1.125rem; margin-top: 0.25rem; }

.now-meta { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; min-height: 1.35em; }

.progress {
  height: 6px;
  margin-top: 1rem;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
}

.times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  margin-top: 0.3rem;
}

.controls { display: flex; gap: 0.6rem; margin-top: 0.75rem; }

.add { margin-bottom: 2.5rem; }

.add > label { display: block; font-weight: 600; margin-bottom: 0.5rem; }

.add-row { display: flex; gap: 0.6rem; }

.add-row input, .name-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.name-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.name-row input { max-width: 16rem; padding: 0.4rem 0.7rem; }

.queue h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 0.75rem; }

.queue-list { list-style: none; margin: 0; padding: 0; counter-reset: queue; }

.queue-list li {
  counter-increment: queue;
  display: grid;
  grid-template-columns: 1.75rem 3rem 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}

.queue-list li::before {
  content: counter(queue);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.queue-list img, .queue-list .no-art {
  width: 3rem;
  height: 3rem;
  border-radius: 6px;
  object-fit: cover;
  background: var(--line);
}

.song { min-width: 0; }

.song-title, .song-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-title { font-weight: 600; }

.song-sub { color: var(--muted); font-size: 0.875rem; }

.duration { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

.remove {
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
}

.remove:hover { color: var(--danger); }

.queue-empty { color: var(--muted); }

.locked {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.upcoming { margin-top: 2.25rem; }

.upcoming h2 { font-size: 1.05rem; font-weight: 600; color: var(--muted); margin-bottom: 0.5rem; }

.upcoming-list { list-style: none; margin: 0; padding: 0; }

.upcoming-list li {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.35rem 0;
  color: var(--muted);
}

.upcoming-list img, .upcoming-list .no-art {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 5px;
  object-fit: cover;
  background: var(--line);
  opacity: 0.85;
}

.upcoming-list .song-title { font-weight: 400; color: var(--ink); }

.gate { max-width: 28rem; }

.gate > label { display: block; font-weight: 600; margin-bottom: 0.5rem; }

.gate-error { color: var(--danger); margin-top: 0.5rem; min-height: 1.5em; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: grid;
  gap: 0.5rem;
  width: min(30rem, calc(100% - 2rem));
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
}

.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 44rem) {
  .yt-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 36rem) {
  .yt-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 1.25rem;
  align-items: end;
  margin: -1rem 0 2rem;
}

.yt-wrap iframe {
  display: block;
  width: 356px;
  max-width: 100%;
  height: 200px;
  border: 0;
  border-radius: 10px;
}

.yt-fix > label { display: block; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem; }

.yt-fix input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.listen-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

.now { grid-template-columns: 6.5rem 1fr; gap: 1.1rem; }
  .queue-list li { grid-template-columns: 1.5rem 2.75rem 1fr auto; }
  .queue-list li .duration { display: none; }
  .duration { display: none; }
  .queue-list img, .queue-list .no-art { width: 2.75rem; height: 2.75rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise 180ms ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}
