:root {
  --ink: #0a0908;
  --ivory: #f2e9dc;
  --ivory-dim: #c9bfae;
  --gold: #c8a464;
  --gold-bright: #e4c584;
  --crimson: #a03b3b;
  --sage: #6b8e6b;
  --paper: #1a1614;
  --line: #2a2420;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--ink);
  color: var(--ivory);
  font-family: 'Cormorant Garamond', serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(200, 164, 100, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(160, 59, 59, 0.06), transparent 50%),
    var(--ink);
  background-attachment: fixed;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 3rem;
}

.wordmark {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 1.8rem;
  letter-spacing: 0.02em;
}

.wordmark em {
  font-style: italic;
  color: var(--gold);
  font-weight: 400;
}

.meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.mode-toggle {
  background: transparent;
  border: none;
  color: var(--ivory-dim);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  padding: 0.15rem 0.4rem;
  margin: 0 0 0 0.1rem;
  cursor: pointer;
  border-bottom: 1px dotted var(--line);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mode-toggle:hover { background: transparent; color: var(--gold); border-color: var(--gold); }
.mode-toggle[data-mode="midi"] { color: var(--gold); }

/* Main stage */
.stage {
  text-align: center;
  padding: 3rem 0 2rem;
  position: relative;
}

.label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin-bottom: 1rem;
}

.chord-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(2rem, 6vw, 4.5rem);
  flex-wrap: nowrap;
}

.chord-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.chord-col-next .label {
  margin-bottom: 0.5rem;
}

.chord-col-current .chord-display {
  margin: 0;
}

.chord-sep {
  align-self: stretch;
  width: 1px;
  background: var(--line);
  margin: 1.2rem 0 2rem;
  flex-shrink: 0;
}

.chord-row:has(.chord-display-next:empty) .chord-sep,
.chord-row:has(.chord-display-next:empty) .chord-col-next {
  display: none;
}

.chord-display {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: clamp(5rem, 14vw, 11rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  margin: 0.5rem 0;
  min-height: 1em;
  transition: color 0.3s ease;
}

.chord-display .accent {
  color: var(--gold);
  font-style: italic;
  font-weight: 400;
}

/* Upcoming chord shown alongside the current one, visibly secondary. */
.chord-display-next {
  opacity: 0.28;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 0.9;
  transition: opacity 0.3s ease;
}

.chord-display-next:empty {
  display: none;
}

.chord-display-next .accent {
  color: var(--gold);
}

/* Success: the chord briefly swells and glows in bright gold. */
@keyframes flashSuccess {
  0%   { text-shadow: 0 0 0 rgba(228, 197, 132, 0); transform: scale(1); color: inherit; }
  20%  { text-shadow: 0 0 48px rgba(228, 197, 132, 0.85), 0 0 20px rgba(228, 197, 132, 0.6); transform: scale(1.09); color: var(--gold-bright); }
  55%  { text-shadow: 0 0 32px rgba(228, 197, 132, 0.55); transform: scale(1.05); color: var(--gold-bright); }
  100% { text-shadow: 0 0 0 rgba(228, 197, 132, 0); transform: scale(1); color: inherit; }
}

.chord-display.flash-success {
  animation: flashSuccess 0.8s ease-out;
}

.chord-display.flash-success .accent {
  color: var(--gold-bright);
}

/* Big ◆ sigil that blooms from the chord's center and fades out. */
.success-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.3);
  color: var(--gold-bright);
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(6rem, 18vw, 14rem);
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 40px rgba(228, 197, 132, 0.8);
}

@keyframes successBurst {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  15%  { opacity: 0.85; transform: translate(-50%, -50%) scale(1.1); }
  45%  { opacity: 0.55; transform: translate(-50%, -50%) scale(1.5); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
}

.success-burst.burst {
  animation: successBurst 0.9s cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* Subtle full-stage gold wash during success. */
.stage.flash-success::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(228, 197, 132, 0.12) 0%, transparent 60%);
  pointer-events: none;
  animation: stageWash 0.8s ease-out;
}

@keyframes stageWash {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 600px) {
  .chord-display-next { display: none; }
}

.chord-notes {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  color: var(--ivory-dim);
  margin-top: 0.5rem;
}

.chord-notes .note {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  margin: 0 0.2rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.chord-notes .note.heard {
  border-color: var(--sage);
  color: var(--sage);
  background: rgba(107, 142, 107, 0.08);
}

.chord-notes .note.wrong {
  border-color: var(--crimson);
  color: var(--crimson);
}

/* Progression info (shown under chord-notes when a chord came from a progression) */
.progression-info {
  margin-top: 0.8rem;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  color: var(--ivory-dim);
  letter-spacing: 0.02em;
}

.progression-info em {
  color: var(--gold);
  font-style: italic;
  font-weight: 500;
}

.progression-info .prog-pos {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--ivory-dim);
  margin-left: 0.4rem;
  opacity: 0.7;
}

/* Sub-option (indented checkbox shown under a parent toggle) */
.checkbox-item.sub-option {
  margin-left: 1.5rem;
  font-size: 0.95rem;
  opacity: 0.85;
}

/* Status */
.status {
  margin-top: 2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  min-height: 1.5em;
  transition: all 0.3s ease;
}

.status.success { color: var(--sage); }
.status.wrong { color: var(--crimson); }
.status.listening { color: var(--gold); }

/* Piano visualization */
.piano-wrap {
  margin: 2rem auto;
  max-width: 900px;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.piano {
  position: relative;
  display: flex;
  height: 140px;
  user-select: none;
}

.key-white {
  flex: 1;
  background: linear-gradient(180deg, #f2e9dc 0%, #e6dcc9 100%);
  border: 1px solid #1a1614;
  border-radius: 0 0 3px 3px;
  position: relative;
  margin-right: -1px;
  transition: all 0.1s ease;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.15);
}

.key-white.target {
  background: linear-gradient(180deg, #e4c584 0%, #c8a464 100%);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2), 0 0 20px rgba(200, 164, 100, 0.4);
}

.key-white.heard {
  background: linear-gradient(180deg, #a8c8a8 0%, #6b8e6b 100%);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2);
}

.key-white.target.heard {
  background: linear-gradient(180deg, #c8e0a4 0%, #8bb46a 100%);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2), 0 0 25px rgba(139, 180, 106, 0.6);
}

.key-white.wrong {
  background: linear-gradient(180deg, #c88585 0%, #a03b3b 100%);
}

.key-label {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  color: #1a1614;
  opacity: 0.4;
  letter-spacing: 0.05em;
}

.black-keys {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 85px;
  pointer-events: none;
}

.key-black {
  position: absolute;
  width: 4%;
  height: 100%;
  background: linear-gradient(180deg, #0a0908 0%, #1a1614 100%);
  border-radius: 0 0 3px 3px;
  box-shadow: inset 0 -4px 0 rgba(255,255,255,0.08), 0 2px 4px rgba(0,0,0,0.4);
  transition: all 0.1s ease;
}

.key-black.target {
  background: linear-gradient(180deg, #8a6d3c 0%, #c8a464 100%);
  box-shadow: inset 0 -4px 0 rgba(255,255,255,0.08), 0 0 20px rgba(200, 164, 100, 0.5);
}

.key-black.heard {
  background: linear-gradient(180deg, #4a6b4a 0%, #6b8e6b 100%);
}

.key-black.target.heard {
  background: linear-gradient(180deg, #6a9048 0%, #8bb46a 100%);
  box-shadow: inset 0 -4px 0 rgba(255,255,255,0.08), 0 0 25px rgba(139, 180, 106, 0.6);
}

.key-black.wrong {
  background: linear-gradient(180deg, #6a2525 0%, #a03b3b 100%);
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: 720px;
  margin: 2rem auto 0;
}

@media (max-width: 700px) {
  .controls { grid-template-columns: 1fr; }
}

/* Tempo control — sits inside .controls grid, next to the metronome button */
.controls .tempo-control {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  grid-column: span 2;
  padding: 0 1rem;
  border: 1px dotted var(--line);
  border-radius: 3px;
}

.controls .tempo-control label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.controls .tempo-control input[type="range"] {
  flex: 1;
  min-width: 80px;
}

.controls .tempo-control .bpm-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--gold);
  min-width: 5em;
  text-align: right;
}

@media (max-width: 700px) {
  .controls .tempo-control { grid-column: span 1; }
}

/* Beat indicator (4 dots that flash with the metronome) */
.beat-indicator {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin: 1rem auto;
}

.beat-indicator .beat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.05s ease, transform 0.08s ease;
}

.beat-indicator .beat-dot.active {
  background: var(--gold);
  transform: scale(1.4);
  box-shadow: 0 0 12px rgba(200, 164, 100, 0.6);
}

/* Input readout (detected notes from any source) */
.input-readout {
  margin: 1.2rem auto 0;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.input-readout #detectedNotes {
  color: var(--gold);
  letter-spacing: 0.1em;
}

/* MIDI status */
.midi-status {
  margin: 0.8rem auto 0;
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ivory-dim);
}

button {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  padding: 1rem 1.5rem;
  background: transparent;
  color: var(--ivory);
  border: 1px solid var(--gold);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

button:hover {
  background: var(--gold);
  color: var(--ink);
}

button.primary {
  background: var(--gold);
  color: var(--ink);
  font-weight: 500;
}

button.primary:hover {
  background: var(--gold-bright);
}

button.danger {
  border-color: var(--crimson);
}

button.danger:hover {
  background: var(--crimson);
  color: var(--ivory);
}

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

/* Settings */
.settings {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.settings-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin-bottom: 1.5rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-group > label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin-bottom: 0.3rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.3rem 0;
  font-size: 1.05rem;
}

.checkbox-item input {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.checkbox-item input:checked {
  background: var(--gold);
}

.checkbox-item input:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Chord queue (upcoming chords) */
.chord-queue {
  margin: 1.5rem auto 0;
  max-width: 700px;
  padding: 1rem 1.5rem;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  border-top: 1px dotted var(--line);
  border-bottom: 1px dotted var(--line);
}

.chord-queue.active { display: flex; }

.queue-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  flex-shrink: 0;
}

.queue-items {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.queue-item {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.1rem;
  color: var(--ivory-dim);
  letter-spacing: -0.01em;
  line-height: 1;
  transition: all 0.3s ease;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.queue-item:not(:last-child)::after {
  content: '→';
  color: var(--line);
  font-size: 1.2rem;
  margin-left: 0.8rem;
}

.queue-item .position {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  color: var(--line);
  letter-spacing: 0.1em;
  vertical-align: super;
}

.queue-item .accent {
  color: var(--gold);
  font-style: italic;
  opacity: 0.75;
}

/* Collapsible roots section (<details>) */
.setting-group-wide {
  grid-column: 1 / -1;
}

.roots-details {
  border: 1px dotted var(--line);
  border-radius: 2px;
  padding: 0.6rem 0.9rem;
}

.roots-details[open] {
  border-style: solid;
}

.roots-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  outline: none;
}

.roots-details summary::-webkit-details-marker { display: none; }

.roots-details summary::after {
  content: '▾';
  color: var(--gold);
  font-size: 0.9rem;
  transition: transform 0.25s ease;
  margin-left: auto;
}

.roots-details[open] summary::after {
  transform: rotate(180deg);
}

.roots-details .details-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.roots-details .details-summary {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--gold);
  margin-left: 0.8rem;
}

.roots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.3rem 1rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dotted var(--line);
}

/* Advanced section (bottom of page) */
.advanced-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.advanced-toggle {
  margin-top: 0;
  text-align: center;
}

.advanced-toggle button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: 0.6rem 1.5rem;
  background: transparent;
  color: var(--ivory-dim);
  border: 1px dotted var(--line);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.advanced-toggle button:hover {
  color: var(--gold);
  border-color: var(--gold);
  border-style: solid;
  background: transparent;
}

.advanced-toggle button .chevron {
  display: inline-block;
  margin-left: 0.5rem;
  transition: transform 0.3s ease;
}

.advanced-toggle button.expanded .chevron {
  transform: rotate(180deg);
}

.advanced-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.advanced-content.expanded {
  max-height: 2000px;
}

/* Sensitivity panel */
.sensitivity-panel {
  margin-top: 2rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(0,0,0,0.2);
}

.sensitivity-panel .dimmed-notice {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--ivory-dim);
  font-size: 0.95rem;
  text-align: center;
  padding: 1rem;
  opacity: 0.7;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.2rem;
}

.panel-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

.reset-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  text-decoration: underline;
}

.reset-link:hover { color: var(--gold); background: none; }

.slider-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
}

@media (max-width: 700px) {
  .slider-grid { grid-template-columns: 1fr; }
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.slider-value {
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.slider-hint {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ivory-dim);
  margin-top: 0.2rem;
  opacity: 0.7;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--gold);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--gold-bright);
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--gold);
}

/* Debug panel */
.debug-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--ivory-dim);
  max-height: 120px;
  overflow-y: auto;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  border-bottom: 1px dotted rgba(255,255,255,0.05);
}

.debug-row:last-child { border-bottom: none; }

.debug-freq { color: var(--ivory); }
.debug-note { color: var(--gold); }
.debug-mag { color: var(--ivory-dim); font-size: 0.65rem; }

/* Level meter */
.level-meter {
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(0,0,0,0.2);
}

.meter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.meter-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sage), var(--gold), var(--crimson));
  width: 0%;
  transition: width 0.05s ease;
}

/* Decorative elements */
.ornament {
  text-align: center;
  color: var(--gold);
  font-size: 1.2rem;
  margin: 1.5rem 0;
  letter-spacing: 1em;
  opacity: 0.5;
}

footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

footer em {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: none;
  color: var(--gold);
}

.footer-links {
  margin-top: 1.2rem;
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--ivory-dim);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.footer-link:hover {
  color: var(--gold);
  border-color: var(--gold);
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.listening-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  margin-right: 0.5rem;
  animation: pulse 1.2s infinite;
  vertical-align: middle;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chord-display, .chord-notes { animation: fadeInUp 0.4s ease; }

@media (max-width: 600px) {
  .controls { grid-template-columns: 1fr; }
  header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  .piano { height: 100px; }
  .black-keys { height: 60px; }
}

.instrument-actions {
  display: flex;
  justify-content: center;
  margin: 0.8rem 0 1.2rem;
}

.instrument-toggle {
  background: transparent;
  border: 1px dotted var(--line);
  color: var(--ivory-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.instrument-toggle:hover {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold);
}

.progressions-warning {
  margin: 0.4rem 0 0.6rem;
  padding: 0.6rem 0.8rem;
  background: rgba(160, 59, 59, 0.1);
  border-left: 2px solid var(--crimson);
  color: var(--ivory-dim);
  font-size: 0.78rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

/* Guitar visualization */
.guitar-wrap {
  margin: 2rem auto;
  max-width: 900px;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  border: 1px solid var(--line);
  border-radius: 3px;
}

#guitarSvg {
  width: 100%;
  height: auto;
  display: block;
}

.gtr-string {
  stroke: var(--ivory-dim);
  opacity: 0.7;
}

.gtr-fret {
  stroke: var(--line);
  stroke-width: 1.2;
}

.gtr-fret.gtr-nut {
  stroke: var(--ivory-dim);
  stroke-width: 4;
}

.gtr-fret-num {
  fill: var(--ivory-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-anchor: middle;
  opacity: 0.6;
}

.gtr-string-label {
  fill: var(--ivory-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-anchor: middle;
  opacity: 0.7;
}

.gtr-dot {
  fill: var(--gold);
  stroke: var(--ink);
  stroke-width: 1.5;
  transition: all 0.2s ease;
}

.gtr-dot.heard {
  fill: var(--gold-bright);
  filter: drop-shadow(0 0 6px rgba(228, 197, 132, 0.6));
}

.gtr-dot.open {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
}

.gtr-dot.open.heard {
  stroke: var(--gold-bright);
  filter: drop-shadow(0 0 6px rgba(228, 197, 132, 0.6));
}

.gtr-dot-label {
  fill: var(--ink);
  font-family: 'Cormorant Garamond', serif;
  font-size: 13px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
}

/* Circle of fifths */
.circle-wrap {
  margin: 2rem auto;
  max-width: 360px;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  border: 1px solid var(--line);
  border-radius: 3px;
  display: flex;
  justify-content: center;
}

#circleSvg {
  width: 280px;
  height: 280px;
  display: block;
}

.cof-wedge {
  fill: var(--paper);
  stroke: var(--line);
  stroke-width: 1;
  transition: all 0.2s ease;
}

.cof-slot:hover .cof-wedge {
  fill: rgba(200, 164, 100, 0.1);
}

.cof-slot.active .cof-wedge {
  fill: var(--gold);
  stroke: var(--gold-bright);
  filter: drop-shadow(0 0 8px rgba(200, 164, 100, 0.5));
}

.cof-label {
  fill: var(--ivory-dim);
  font-family: 'Cormorant Garamond', serif;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  transition: fill 0.2s ease;
}

.cof-label-major {
  font-size: 16px;
  font-weight: 500;
}

.cof-label-minor {
  font-size: 12px;
  font-style: italic;
}

.cof-slot.active .cof-label {
  fill: var(--ink);
  font-weight: 600;
}
