:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d2230;
  --muted: #646a78;
  --line: #d9d5cc;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --minor: #1e78af;
  --error: #b91c1c;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d11;
    --panel: #151820;
    --ink: #e4e8f0;
    --muted: #98a0b0;
    --line: #2a2f3a;
    --accent: #f0aa5a;
    --accent-ink: #14110c;
    --minor: #5ab4dc;
    --error: #f87171;
  }
}

* {
  box-sizing: border-box;
}

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

header,
main,
footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

header h1 {
  margin: 20px 0 4px;
  font-size: 28px;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0 0 16px;
  max-width: 78ch;
  color: var(--muted);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
  align-items: start;
}

.canvas-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
}

#view:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

#view.dragging {
  cursor: grabbing;
}

.zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zoom button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
}

.piano {
  position: relative;
  height: 74px;
  margin-top: 10px;
  user-select: none;
}

.piano button {
  position: absolute;
  top: 0;
  padding: 0;
  border-radius: 0 0 4px 4px;
  border: 1px solid var(--line);
}

.piano .white {
  height: 100%;
  background: #fdfdfb;
  z-index: 0;
}

.piano .black {
  height: 60%;
  background: #22252c;
  border-color: #22252c;
  z-index: 1;
}

.piano .sounding {
  background: #ffd166;
  border-color: #c27c00;
}

.piano .black.sounding {
  background: #c27c00;
}

.piano [aria-pressed='true'] {
  box-shadow: inset 0 -6px 0 #7c3aed;
}

.piano button:focus-visible {
  z-index: 2;
}

.piano .octave {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  font-size: 10px;
  color: #646a78;
  text-align: center;
  pointer-events: none;
}

.status {
  min-height: 1.5em;
  margin: 8px 0 0;
  font-weight: 600;
}

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.chord-name {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 700;
}

.chord-name .notes {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}

.moves {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.moves button {
  flex: 1 1 0;
  min-width: 0;
}

button,
select,
textarea,
input[type='range'] {
  font: inherit;
  color: inherit;
}

button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button[aria-pressed='true'],
#play.playing {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.moves [data-move] {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.moves [data-move] b {
  font-size: 18px;
}

.moves [data-move] span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.voice,
.summary {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.row select,
.row input[type='range'] {
  flex: 1;
  min-width: 0;
}

.row output {
  min-width: 3.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.check {
  gap: 6px;
}

.stack {
  display: block;
  margin: 8px 0 4px;
}

.held-name {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

input[type='text'] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font: inherit;
  color: inherit;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

select {
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

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

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
}

.steps button {
  padding: 3px 7px;
  font-size: 13px;
}

.steps .word {
  display: inline-block;
  margin: 0 2px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.steps button.minor {
  color: var(--minor);
}

footer {
  margin-top: 24px;
  padding-bottom: 24px;
  color: var(--muted);
  font-size: 13px;
}

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

@media (max-width: 860px) {
  main {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    aspect-ratio: 1 / 1;
  }
}
