:root {
  --ink: #1d2430;
  --paper: #f3efe6;
  --dim: #5d6573;
  --line: #d8d1c2;
  --lamp-off: #e4ddcf;
  --focus: #2b6cb0;
  --r1: #e8a317;
  --r2: #d9541e;
  --r3: #6f9fb8;
  --r4: #7d6b4f;
  --r5: #a85a8a;
  --r6: #3f8f6b;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 2rem;
}

.top h1 {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.sub { margin: 0.25rem 0 1rem; color: var(--dim); }

.field {
  border-radius: 10px;
  overflow: hidden;
  background: #1d2430;
  aspect-ratio: 16 / 9;
}

.field canvas { display: block; width: 100%; height: 100%; }

.desk { margin-top: 1rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

button {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  touch-action: manipulation;
}

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

button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

button.big { font-weight: 700; padding: 0.6rem 1.1rem; }

#chinook[aria-pressed="true"] { background: #c46a2b; border-color: #c46a2b; color: #fff; }

.tempo {
  display: flex;
  flex-direction: column;
  flex: 1 1 12rem;
  font-size: 0.85rem;
  color: var(--dim);
}

.tempo output { font-weight: 700; color: var(--ink); }

.tempo input { width: 100%; accent-color: var(--ink); }

.grid {
  margin-top: 1rem;
  display: grid;
  gap: 0.35rem;
}

.row {
  display: grid;
  grid-template-columns: 6.5rem repeat(8, 1fr);
  gap: 0.3rem;
  align-items: center;
}

.row .name {
  font-size: 0.8rem;
  line-height: 1.15;
  font-weight: 600;
  border-left: 6px solid var(--c);
  padding-left: 0.4rem;
}

.row .name small { display: block; font-weight: 400; color: var(--dim); }

.step {
  aspect-ratio: 1;
  width: 100%;
  max-width: 3.2rem;
  justify-self: center;
  min-height: 2.1rem;
  padding: 0;
  border: 2px solid var(--line);
  background: var(--lamp-off);
  border-radius: 50%;
}

.step:nth-of-type(4n + 1) { border-color: #bdb4a1; }

.step[aria-pressed="true"] {
  background: var(--c);
  border-color: var(--ink);
  color: inherit;
}

.step.now { box-shadow: 0 0 0 3px var(--ink); }

.step.now[aria-pressed="true"] { transform: scale(1.12); }

.presets, .share {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.presets .label { font-size: 0.85rem; color: var(--dim); }

.presets button { font-size: 0.9rem; padding: 0.3rem 0.65rem; border-width: 1px; }

#link { flex: 1 1 14rem; font: inherit; font-size: 0.85rem; padding: 0.4rem; border: 1px solid var(--line); border-radius: 6px; }

.status { margin: 0; font-size: 0.85rem; color: var(--dim); min-height: 1.3em; flex-basis: 100%; }

.about { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 1rem; }

.about h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }

.keys { color: var(--dim); font-size: 0.9rem; }

kbd {
  font: 0.8rem ui-monospace, Menlo, monospace;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.3rem;
  background: #fff;
}

footer { margin-top: 2rem; color: var(--dim); font-size: 0.85rem; }

a { color: inherit; }

.lost { text-align: center; padding-top: 4rem; }

@media (max-width: 30rem) {
  .row { grid-template-columns: 4.6rem repeat(8, 1fr); gap: 0.2rem; }
  .row .name { font-size: 0.72rem; }
  .row .name small { display: none; }
  .step { min-height: 1.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .step.now[aria-pressed="true"] { transform: none; }
}
