:root {
  --bg: #0d0e12;
  --surface: #16181f;
  --surface-2: #1e212b;
  --line: #2b2f3c;
  --text: #eef0f5;
  --muted: #969cae;
  --accent: #7c5cff;
  --spotify: #1db954;
  --warn-bg: #2c2411;
  --warn-line: #6b5518;
  --warn-text: #f0d693;
  --error: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 620px;
  margin: 0 auto;
  padding: 28px 18px 64px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.masthead { margin-bottom: 24px; }

.masthead h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.card h3 {
  margin: 22px 0 4px;
  font-size: 15px;
}

.muted { color: var(--muted); font-size: 14px; }

.fineprint {
  color: var(--muted);
  font-size: 12.5px;
  margin: 14px 0 0;
  line-height: 1.5;
}

/* ---------- file input ---------- */

.filedrop {
  display: block;
  margin: 18px 0 0;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.filedrop:hover, .filedrop:focus-within {
  border-color: var(--accent);
  background: #22243040;
}

.filedrop input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.filedrop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 30px 16px;
  text-align: center;
}

.filedrop-icon { font-size: 26px; }
.filedrop-label { font-weight: 600; }
.filedrop-hint { color: var(--muted); font-size: 13px; }

figure#preview { margin: 16px 0 0; }

figure#preview img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: var(--radius);
  background: #000;
  border: 1px solid var(--line);
}

figure#preview figcaption { margin-top: 8px; word-break: break-all; }

/* ---------- buttons ---------- */

button, .linkbutton {
  font: inherit;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 13px 18px;
  transition: filter 120ms ease, background 120ms ease;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

.primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.primary:hover:not(:disabled) { filter: brightness(1.1); }

.primary.spotify { background: var(--spotify); color: #04220f; }

.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
  font-size: 14px;
  padding: 10px 14px;
}

.secondary:hover { background: #262a36; }

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.row button { flex: 1 1 auto; }

/* ---------- artist list ---------- */

.artist-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.artist-list li { display: flex; gap: 8px; align-items: center; }

.artist-list input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 11px 12px;
  font: inherit;
}

.artist-list input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.remove {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 9px 12px;
  font-size: 15px;
  line-height: 1;
}

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

/* ---------- fields ---------- */

.field { margin-top: 22px; }

fieldset.field {
  border: none;
  padding: 0;
  margin-top: 22px;
}

fieldset.field legend {
  padding: 0;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 15px;
}

.choice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  margin-bottom: 8px;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: #232338;
}

.choice input { margin-top: 3px; accent-color: var(--accent); flex: 0 0 auto; }
.choice strong { display: block; font-size: 15px; }
.choice em { display: block; font-style: normal; color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Excludes .choice: those are labels inside fieldset.field, and this rule's
   higher specificity would otherwise override their display: flex. */
.field > label:not(.choice) { display: block; font-weight: 600; font-size: 15px; margin-bottom: 8px; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

input[type="text"]#playlist-name {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 11px 12px;
  font: inherit;
}

input[type="text"]#playlist-name:focus { outline: none; border-color: var(--accent); }

output { color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---------- notices ---------- */

.notice {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14px;
  margin: 14px 0 0;
}

.notice.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-text);
}

.error { color: var(--error); font-size: 14px; margin: 14px 0 0; }

.notfound {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- busy overlay ---------- */

.busy {
  position: fixed;
  inset: 0;
  background: #0d0e12e8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

#busy p { margin: 0; color: var(--muted); }

[hidden] { display: none !important; }
