:root {
  --bg: #0e1016;
  --bg-2: #141824;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-border: rgba(255, 255, 255, 0.08);
  --ink: #ece6da;
  --ink-2: #a9a59c;
  --ink-3: #6f6c66;
  --brass: #d9a441;
  --brass-2: #f0c674;
  --lh: #4fb3d9;
  --rh: #f07b5a;
  --bass: #a98bf5;
  --ivory: #f3ead8;
  --ivory-shade: #d9cfbb;
  --ebony: #15161b;
  --radius: 14px;
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(217, 164, 65, 0.13), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(79, 179, 217, 0.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
}

a {
  color: var(--brass-2);
}

.top,
main,
footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 28px;
  padding-bottom: 18px;
}

h1 {
  margin: 0;
  font: 700 clamp(34px, 6vw, 54px) / 1 var(--font-display);
  letter-spacing: -0.02em;
}

h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--brass);
}

.tagline {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 16px;
}

h1 .home {
  color: inherit;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex: none;
  gap: 6px;
}

.site-nav a {
  padding: 8px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--ink);
  border-color: var(--brass);
}

.site-nav a[aria-current] {
  color: #1b1408;
  background: var(--brass);
  border-color: var(--brass);
}

.gh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}

.gh:hover {
  color: var(--ink);
  border-color: var(--brass);
}

.gh svg {
  width: 18px;
  height: 18px;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.panel,
.now,
.now-detail {
  min-width: 0;
}

.acc {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.78em;
  margin: 0 0.02em;
  position: relative;
  top: -0.32em;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(6px);
}

h2 {
  margin: 0;
  font: 600 22px/1.2 var(--font-display);
}

/* Controls ----------------------------------------------------------------- */

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
}

.play {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(145deg, var(--brass-2), var(--brass));
  color: #1b1408;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 22px rgba(217, 164, 65, 0.35);
  transition: transform 0.12s ease;
}

.play:hover {
  transform: scale(1.05);
}

.play:active {
  transform: scale(0.97);
}

.play svg {
  width: 26px;
  height: 26px;
}

.play .i-stop,
.playing .play .i-play {
  display: none;
}

.playing .play .i-stop {
  display: block;
}

.playing .play {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 6px 30px rgba(217, 164, 65, 0.6);
  }
}

.slider {
  display: grid;
  gap: 4px;
  min-width: 140px;
  flex: 1 1 150px;
  max-width: 280px;
}

.slider label {
  font-size: 12px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.slider output {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--brass);
}

input[type='range']:disabled {
  opacity: 0.35;
}

.grid-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px 14px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 5px;
  align-content: start;
}

.field.wide {
  grid-column: span 2;
}

.field > span {
  font-size: 12px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field.disabled {
  opacity: 0.4;
}

select {
  appearance: none;
  width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  padding: 9px 34px 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a9a59c' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center / 11px,
    var(--bg-2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

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

.toggles .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle span {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  color: var(--ink-3);
  background: var(--bg-2);
  transition: all 0.15s;
}

.toggle input:checked + span {
  color: var(--ink);
  border-color: rgba(217, 164, 65, 0.6);
  background: rgba(217, 164, 65, 0.14);
}

.toggle input:focus-visible + span {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* Stage -------------------------------------------------------------------- */

.now {
  display: grid;
  grid-template-columns: minmax(180px, auto) 1fr;
  gap: 16px 28px;
  align-items: center;
  margin-bottom: 16px;
}

.now-chord {
  display: grid;
  gap: 4px;
}

.now-symbol {
  font: 700 clamp(40px, 7vw, 64px) / 1 var(--font-display);
  color: var(--ivory);
  letter-spacing: -0.01em;
}

.now-form {
  color: var(--brass);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.now-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 8px 22px;
}

.now-detail > div {
  display: grid;
  gap: 3px;
}

.dt {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dd {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-height: 26px;
  align-items: baseline;
}

.dd b {
  font-weight: 600;
  font-size: 17px;
}

.dd small {
  color: var(--ink-3);
  font-size: 11px;
  margin-left: 2px;
}

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

.sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.sw-L {
  background: var(--lh);
}

.sw-R {
  background: var(--rh);
}

.sw-bass {
  background: var(--bass);
}

.keyboard {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 10px;
  background: linear-gradient(#050608, #0b0c10);
  padding: 10px 8px 8px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
  scrollbar-width: thin;
}

.kb-inner {
  position: relative;
  height: 170px;
  min-width: 860px;
}

.key {
  position: absolute;
  top: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.key.white {
  height: 100%;
  background: linear-gradient(var(--ivory) 70%, var(--ivory-shade));
  border-right: 1px solid #b8ae9b;
  border-radius: 0 0 5px 5px;
  z-index: 1;
  padding-bottom: 6px;
}

.key.black {
  height: 62%;
  background: linear-gradient(#2a2b31, var(--ebony) 30%, #000);
  border-radius: 0 0 4px 4px;
  z-index: 2;
  box-shadow: 0 3px 4px rgba(0, 0, 0, 0.5);
  padding-bottom: 5px;
}

.key .octave {
  position: absolute;
  bottom: 4px;
  font-size: 9px;
  color: #8d846f;
}

.key.middle-c::before {
  content: '';
  position: absolute;
  bottom: 18px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #8d846f;
}

.key .badge {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 14px;
  pointer-events: none;
  white-space: nowrap;
}

.key.black .badge {
  margin-bottom: 4px;
  font-size: 9px;
}

.key.is-L {
  background: linear-gradient(#9ed8ec, var(--lh));
}

.key.is-R {
  background: linear-gradient(#f9b8a4, var(--rh));
}

.key.is-bass {
  background: linear-gradient(#d3c4fb, var(--bass));
}

.key.black.is-L {
  background: linear-gradient(#2c7fa0, #1b5872);
}

.key.black.is-R {
  background: linear-gradient(#c4583b, #8f3a24);
}

.key.black.is-bass {
  background: linear-gradient(#7a5bd0, #4f3699);
}

.key.white.is-L .badge,
.key.white.is-R .badge,
.key.white.is-bass .badge {
  color: #10131a;
}

.key.black .badge {
  color: #fff;
}

.key.flash {
  filter: brightness(1.25);
  transform: translateY(2px);
  transition: transform 0.03s;
}

.key.white.flash:not(.is-L):not(.is-R):not(.is-bass) {
  background: linear-gradient(#fff5dc, var(--brass-2));
}

.key.black.flash:not(.is-L):not(.is-R):not(.is-bass) {
  background: linear-gradient(#a37a2d, #6e4f18);
}

.hint {
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--ink-3);
}

kbd {
  font: 11px var(--font-body);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  color: var(--ink-2);
  margin: 0 1px;
}

/* Chart -------------------------------------------------------------------- */

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 14px;
}

.chart-notes {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-left: 2px solid rgba(236, 230, 218, 0.35);
}

.bar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  min-height: 78px;
  border-right: 2px solid rgba(236, 230, 218, 0.35);
  border-bottom: 1px solid var(--panel-border);
}

.bar:nth-child(-n + 4) {
  border-top: 1px solid var(--panel-border);
}

.bar-num {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 10px;
  color: var(--ink-3);
}

.cell {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 18px 10px 8px;
  cursor: pointer;
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  border-radius: 6px;
  margin: 3px;
  transition: background 0.15s;
}

.cell:hover {
  background: rgba(255, 255, 255, 0.05);
}

.cell.active {
  background: rgba(217, 164, 65, 0.16);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.6);
}

.cell .sym {
  font: 600 clamp(16px, 2.4vw, 23px) / 1.1 var(--font-display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell .vnotes {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell.active .vnotes {
  color: var(--brass-2);
}

.editor {
  margin-top: 16px;
}

.editor summary {
  cursor: pointer;
  color: var(--brass-2);
  font-weight: 500;
}

.help {
  color: var(--ink-2);
  font-size: 13px;
}

code {
  font: 12px ui-monospace, 'SF Mono', Menlo, monospace;
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 4px;
}

textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  color: var(--ink);
  padding: 12px;
  font: 15px/1.5 ui-monospace, 'SF Mono', Menlo, monospace;
  resize: vertical;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: var(--brass);
  color: #1b1408;
  font: 600 14px var(--font-body);
  cursor: pointer;
}

.error {
  color: var(--rh);
  font-size: 13px;
}

/* Theory cards ------------------------------------------------------------- */

.cards {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.card {
  text-align: left;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--ink);
  padding: 14px;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover {
  border-color: rgba(217, 164, 65, 0.5);
  transform: translateY(-1px);
}

.card.active {
  border-color: var(--brass);
  background: linear-gradient(rgba(217, 164, 65, 0.1), rgba(217, 164, 65, 0.02)), var(--bg-2);
}

.card h3 {
  margin: 0 0 6px;
  font: 600 17px/1.2 var(--font-display);
  color: var(--ivory);
}

.card p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

footer {
  padding-top: 26px;
  padding-bottom: 40px;
  color: var(--ink-3);
  font-size: 13px;
}

/* Responsive --------------------------------------------------------------- */

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

  .chart {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .transport {
    gap: 12px 16px;
  }

  .bar:nth-child(-n + 4) {
    border-top: 0;
  }

  .bar:nth-child(-n + 2) {
    border-top: 1px solid var(--panel-border);
  }

  .field.wide {
    grid-column: 1 / -1;
  }

  .kb-inner {
    height: 140px;
  }

  .top {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .site-nav {
    order: -1;
    width: 100%;
  }
}

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

  .panel {
    padding: 14px;
  }

  .gh span {
    display: none;
  }
}

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