:root {
  --bg: #14161b;
  --surface: #1c1f26;
  --surface-2: #252932;
  --border: #30353f;
  --text: #e8eaf0;
  --muted: #9aa1b0;
  --accent: #7bc950;
  --accent-hover: #8fd866;
  --accent-ink: #11240a;
  --danger: #ff7b72;
  --radius: 12px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 16px 32px;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 1.6rem;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

p {
  margin: 0;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Header & loading */

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.logo {
  image-rendering: pixelated;
  flex: none;
}

.load-form {
  display: flex;
  gap: 8px;
}

.load-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.load-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link:hover {
  color: var(--accent-hover);
}

.status {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.status.error {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  color: var(--danger);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: var(--border);
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.round {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  flex: none;
}

.btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.btn:focus-visible,
.link:focus-visible,
input[type="range"]:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#play-btn .icon-pause,
#play-btn.playing .icon-play {
  display: none;
}

#play-btn.playing .icon-pause {
  display: block;
}

/* Player card */

.card {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.song-head h2 {
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

.song-head p {
  margin-top: 4px;
}

.roll {
  display: block;
  width: 100%;
  height: 240px;
  margin: 18px 0 16px;
  border-radius: 10px;
  background: #101216;
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time {
  min-width: 3.2em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

input[type="range"] {
  accent-color: var(--accent);
  cursor: pointer;
}

#seek {
  flex: 1;
  min-width: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-top: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.check input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.volume {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.volume svg {
  width: 20px;
  height: 20px;
  fill: var(--muted);
}

.volume svg .stroke {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.volume input {
  width: 110px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0 0 0 auto;
  font-size: 0.875rem;
}

.stats div {
  display: flex;
  gap: 6px;
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* Instruments legend */

.instruments {
  margin-top: 18px;
}

.instruments h3 .muted {
  font-weight: 400;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.chip .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.chip .count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] {
  opacity: 0.45;
  text-decoration: line-through;
}

.notice {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.875rem;
}

.description {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Instrument sounds */

.sounds {
  margin-top: 24px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.sounds-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}

.sounds-head p {
  margin-top: 2px;
  font-size: 0.9rem;
}

.sounds-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.sounds-actions .btn {
  padding: 8px 14px;
  font-size: 0.9rem;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.segmented button {
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.segmented button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sounds .status {
  margin-top: 12px;
  font-size: 0.9rem;
}

.help {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.875rem;
}

.help summary {
  width: fit-content;
  color: var(--text);
  cursor: pointer;
}

.help p,
.help ul {
  margin: 10px 0 0;
}

.help ul {
  padding-left: 20px;
}

.help li + li {
  margin-top: 4px;
}

.help strong {
  color: var(--text);
  font-weight: 600;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  overflow-wrap: anywhere;
}

footer {
  margin-top: 28px;
  font-size: 0.82rem;
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  font-size: 0.78rem;
}

.drop-overlay {
  position: fixed;
  inset: 12px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  font-size: 1.3rem;
  font-weight: 600;
  pointer-events: none;
}

@media (max-width: 560px) {
  .app {
    padding-top: 24px;
  }

  .card,
  .sounds {
    padding: 16px;
  }

  .roll {
    height: 180px;
  }

  .stats {
    margin-left: 0;
  }
}
