/* ============================================================
   Design tokens
   Palette grounded in the instrument itself: deep ink-indigo
   cabinet, warm ivory keybed, brass hardware accent, and a
   soft verdigris for secondary actions (the patina on old
   brass fittings). Avoids the generic cream+terracotta and
   near-black+neon defaults.
   ============================================================ */
:root {
  --ink:        #1B1E2B;   /* cabinet / background */
  --ink-panel:  #232838;   /* raised panel surface */
  --ivory:      #F3ECDD;   /* keybed / card surface */
  --ivory-dim:  #E4DAC2;
  --brass:      #C9A227;   /* primary accent */
  --brass-soft: #E4C25C;
  --verdigris:  #4F8C82;   /* secondary accent */
  --staff-line: #B9AE93;
  --muted:      #8A8470;
  --accent:     #C9622B;   /* active note / playhead (warm copper) */
  --danger:     #B5482F;

  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

/* ---------- Hero / header ---------- */
.hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass-soft);
  margin: 0 0 8px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: 0.01em;
  margin: 0 0 10px;
  color: var(--ivory);
}

.hero p {
  font-size: 14.5px;
  color: var(--ivory-dim);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.55;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  justify-content: center;
  margin: 26px 0 18px;
  padding: 18px;
  background: var(--ink-panel);
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 39, 0.18);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}

.field label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-soft);
}

select {
  background: var(--ivory);
  color: var(--ink);
  border: none;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
}

select:focus-visible,
button:focus-visible,
.key:focus-visible {
  outline: 3px solid var(--brass-soft);
  outline-offset: 2px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

button.action {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  background: var(--brass);
  color: var(--ink);
  transition: transform 0.08s ease, background 0.15s ease;
}

button.action:hover { background: var(--brass-soft); }
button.action:active { transform: translateY(1px); }

button.action.secondary {
  background: transparent;
  color: var(--verdigris);
  border: 1px solid var(--verdigris);
}

button.action.secondary:hover { background: rgba(79, 140, 130, 0.12); }

/* ---------- Card / notation panel ---------- */
.panel {
  background: var(--ivory);
  border-radius: 10px;
  padding: 18px 16px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--ink);
  margin-bottom: 6px;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0;
  font-weight: 400;
}

.panel-head .scale-formula {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

#staffSvg { width: 100%; display: block; }

/* ---------- Piano ---------- */
.piano-frame {
  background: var(--ink-panel);
  border-radius: 10px;
  padding: 16px 16px 20px;
  border: 1px solid rgba(201, 162, 39, 0.18);
}

.piano-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.piano {
  position: relative;
  height: 150px;
  width: max-content;
  margin: 0 auto;
  user-select: none;
}

.key {
  position: absolute;
  top: 0;
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  transition: background 0.08s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}

.key.white {
  width: 51px;
  height: 150px;
  background: var(--ivory);
  border: 1px solid #C9BC9C;
  z-index: 1;
}

.key.white .deg {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.key.black .deg {
  font-size: 10px;
  color: var(--ivory-dim);
  font-family: var(--font-mono);
}

.key.black {
  width: 30px;
  height: 84px;
  background: #15161C;
  border: 1px solid #000;
  z-index: 2;
}

.key.white.in-scale { background: var(--brass-soft); }
.key.black.in-scale { background: var(--brass); }

.key.root.in-scale { background: var(--accent) !important; }

.key.active { box-shadow: inset 0 0 0 3px var(--verdigris); }

/* ---------- Footer note ---------- */
.foot-note {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 6px;
}

.progress-line {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--brass-soft);
  margin-top: 18px;
}

.complete-banner {
  display: none;
  text-align: center;
  background: rgba(79, 140, 130, 0.15);
  border: 1px solid var(--verdigris);
  color: var(--ivory);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-top: 14px;
}

.complete-banner.show { display: block; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 560px) {
  .controls { padding: 14px; }
  .field { min-width: 130px; flex: 1 1 45%; }
}
