:root {
  color-scheme: light;
  --ink: #17181c;
  --muted: #626774;
  --line: #d8dbe2;
  --paper: #f6f3ee;
  --panel: #ffffff;
  --accent: #0b6e69;
  --accent-2: #a84430;
  --accent-3: #365c9a;
  --gold: #c58b28;
  --shadow: 0 18px 50px rgba(25, 26, 31, 0.12);
}

html {
  scroll-padding-top: 112px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

button.secondary {
  background: white;
  color: var(--accent);
}

button.icon-button {
  width: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

button:focus,
a:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(11, 110, 105, 0.25);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px 28px;
  background: rgba(246, 243, 238, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.app-header h1 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.1;
}

.kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.top-nav a {
  border-radius: 6px;
  color: var(--ink);
  padding: 8px 10px;
  text-decoration: none;
}

.top-nav a.active,
.top-nav a:hover {
  background: var(--ink);
  color: white;
}

main {
  padding: 28px;
}

.page {
  display: none;
  scroll-margin-top: 112px;
}

.page.active {
  display: block;
}

.hero {
  min-height: calc(100vh - 165px);
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 1.05fr);
  gap: 28px;
  align-items: center;
}

.hero-copy h2 {
  max-width: 980px;
  margin: 10px 0 16px;
  font-size: clamp(38px, 6vw, 78px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.hero-actions,
.composer-bar,
.diagram-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-diagram,
.big-visualizer,
.visualizer {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-diagram svg,
.big-visualizer svg,
.visualizer svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.dashboard-grid,
.source-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

article,
.diagram-panel,
.control-stack,
.atlas-card,
.mode-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

article h3,
.diagram-panel h3,
.mode-card h3 {
  margin: 0 0 8px;
}

article p,
.mode-card p,
.diagram-panel p {
  color: var(--muted);
  line-height: 1.48;
}

.page-heading {
  max-width: 940px;
  margin-bottom: 20px;
}

.page-heading h2 {
  margin: 4px 0 8px;
  font-size: 42px;
  line-height: 1.05;
}

.page-heading p:last-child {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px 220px;
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
}

.atlas-layout,
.workbench {
  display: grid;
  grid-template-columns: minmax(280px, 370px) 1fr;
  gap: 18px;
  align-items: start;
}

.staff-workbench {
  grid-template-columns: minmax(260px, 320px) 1fr;
}

.staff-lattice-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.05fr);
  gap: 14px;
  align-items: start;
}

.staff-visualizer,
.staff-lattice-visualizer {
  min-height: 430px;
}

.atlas-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 6px;
}

.atlas-card {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.atlas-card:hover,
.atlas-card.active {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.atlas-card h3 {
  margin: 4px 0;
  font-size: 16px;
}

.atlas-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  background: #edf1f4;
  color: #39404d;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.diagram-panel {
  position: sticky;
  top: 98px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 14px;
}

.detail-list dt {
  color: var(--ink);
  font-weight: 800;
}

.control-stack {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 98px;
}

.status-strip,
.controls-key,
.lattice-explainer,
.sequence-readout,
.export-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  margin-top: 12px;
  padding: 12px;
  line-height: 1.5;
}

.controls-key {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: #f7f9f8;
  color: var(--ink);
}

.key-chip {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 5px 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.key-chip kbd {
  display: inline-block;
  min-width: 20px;
  border: 1px solid #a9b0bd;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fffdf8;
  color: var(--ink);
  padding: 1px 5px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.lattice-explainer {
  background: #fffdf8;
  color: var(--ink);
}

.lattice-explainer h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.lattice-explainer p {
  margin: 0;
  color: var(--muted);
}

.lattice-explainer strong {
  color: var(--accent-2);
}

.path-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.path-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
  cursor: pointer;
}

.path-step.active {
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 2px rgba(168, 68, 48, 0.18);
}

.path-step p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.chromatic-panel {
  display: grid;
  gap: 14px;
  min-height: 360px;
  padding: 18px;
}

.chromatic-key {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chromatic-key-item {
  --device-color: var(--accent-2);
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
}

.chromatic-key-item.active {
  border-color: var(--device-color);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--device-color) 18%, transparent);
}

.chromatic-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--device-color);
}

.chromatic-stack {
  --steps: 9;
  display: grid;
  grid-template-columns: 112px repeat(var(--steps), minmax(66px, 1fr));
  gap: 8px;
  align-items: stretch;
}

.chromatic-row-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.chromatic-cell {
  --device-color: var(--accent-2);
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
}

.chromatic-cell strong {
  font-size: 15px;
  line-height: 1.05;
}

.chromatic-cell span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.chromatic-cell.motion {
  border-color: var(--device-color);
  background: color-mix(in srgb, var(--device-color) 15%, white);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--device-color) 16%, transparent);
}

.chromatic-cell.harmony {
  background: #fbf7ed;
}

.chromatic-cell.superimposed.motion {
  background: color-mix(in srgb, var(--device-color) 22%, white);
}

.composer-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(56px, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.step-cell {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px;
  cursor: pointer;
}

.step-cell.active {
  border-color: var(--gold);
  background: #fff6df;
}

.step-index {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.step-notes {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.export-box {
  width: 100%;
  min-height: 160px;
  resize: vertical;
}

footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 12px 28px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.sound-picker {
  grid-template-columns: auto minmax(150px, 190px);
  align-items: center;
  color: var(--ink);
}

.sound-picker select {
  padding: 8px 10px;
}

#nowPlaying {
  color: var(--muted);
  font-size: 14px;
}

.node circle,
.node rect {
  cursor: pointer;
  transition: transform 0.12s, fill 0.12s;
}

.node:hover circle,
.node.selected circle {
  fill: var(--accent-2);
}

.node.highlighted circle {
  fill: #fff0ca;
  stroke: var(--gold);
  stroke-width: 4;
}

.node.selected.highlighted circle {
  fill: var(--accent-2);
  stroke: var(--gold);
}

.node text {
  pointer-events: none;
  font-size: 16px;
  font-weight: 800;
  fill: var(--ink);
}

.node .node-ratio {
  font-size: 10px;
  font-weight: 700;
  fill: var(--muted);
}

.node.compact text {
  font-size: 13px;
}

.node.compact .node-ratio {
  font-size: 8px;
}

.node .node-order {
  font-size: 13px;
  font-weight: 900;
  fill: var(--accent-2);
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 3px;
}

.node.compact .node-order {
  font-size: 12px;
}

.axis-line,
.edge-line {
  stroke: #a9b0bd;
  stroke-width: 2;
}

.triad-shape {
  cursor: pointer;
  fill: rgba(54, 92, 154, 0.06);
  stroke: rgba(54, 92, 154, 0.42);
  stroke-width: 2;
  transition: fill 0.12s, stroke-width 0.12s;
}

.triad-shape.minor {
  fill: rgba(168, 68, 48, 0.06);
  stroke: rgba(168, 68, 48, 0.42);
}

.triad-shape.highlighted {
  fill: rgba(197, 139, 40, 0.24);
  stroke: var(--gold);
  stroke-width: 5;
}

.triad-shape.highlighted.minor {
  fill: rgba(168, 68, 48, 0.18);
  stroke: var(--accent-2);
}

.triad-shape.selected,
.triad-shape:hover {
  fill: rgba(197, 139, 40, 0.22);
  stroke-width: 5;
}

.triad-label {
  pointer-events: none;
  font-size: 13px;
  font-weight: 900;
  fill: var(--ink);
}

.staff-line {
  stroke: #2b2d33;
  stroke-width: 1.5;
}

.staff-barline,
.staff-stem,
.ledger-line {
  stroke: #2b2d33;
  stroke-width: 2;
}

.staff-notehead {
  cursor: pointer;
  fill: #ffffff;
  stroke: #17181c;
  stroke-width: 2;
}

.staff-event {
  cursor: pointer;
}

.staff-event.active .staff-notehead {
  fill: #fff0ca;
  stroke: var(--accent-2);
  stroke-width: 4;
}

.staff-event-label,
.staff-accidental {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.staff-voice-legend text {
  font-size: 12px;
  font-weight: 900;
}

.staff-source-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .app-header,
  .hero,
  .atlas-layout,
  .workbench,
  .staff-lattice-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .diagram-panel,
  .control-stack {
    position: static;
  }

  .composer-grid {
    grid-template-columns: repeat(4, minmax(62px, 1fr));
  }

  .chromatic-stack {
    grid-template-columns: 92px repeat(var(--steps), minmax(54px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 620px) {
  main,
  .app-header,
  footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero-copy h2 {
    font-size: 38px;
  }

  .page-heading h2 {
    font-size: 34px;
  }

  .chromatic-panel {
    padding: 12px;
  }

  .chromatic-stack {
    grid-template-columns: 1fr;
  }

  .chromatic-row-label {
    justify-content: flex-start;
    margin-top: 6px;
  }
}

/* ------------------------------------------------------------------ */
/* Course (Learn section)                                              */
/* ------------------------------------------------------------------ */

.course-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.course-sidebar {
  position: sticky;
  top: 128px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.course-progress-line {
  margin: 2px 4px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.course-part-title {
  margin: 14px 4px 6px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.course-lesson-link {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 0;
  margin: 2px 0;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 14px;
  line-height: 1.25;
}

.course-lesson-link:hover {
  background: rgba(11, 110, 105, 0.08);
}

.course-lesson-link.current {
  border-color: var(--accent);
  background: rgba(11, 110, 105, 0.1);
  font-weight: 700;
}

.course-lesson-link .lesson-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  font-size: 12px;
  font-weight: 800;
}

.course-lesson-link.done .lesson-check {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.course-lesson {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px 30px 30px;
  box-shadow: var(--shadow);
}

.course-lesson-title {
  margin: 6px 0 2px;
  font-size: 30px;
  line-height: 1.15;
}

.course-ref {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.course-prose {
  max-width: 76ch;
  font-size: 16px;
  line-height: 1.62;
}

.activity-card {
  margin: 18px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: var(--paper);
}

.activity-card h4 {
  margin: 0 0 6px;
  font-size: 17px;
}

.activity-note {
  margin: 4px 0 10px;
  max-width: 76ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.activity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.activity-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}

.inline-select select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: white;
}

.overtone-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.overtone-button {
  font-size: 13px;
}

.pulse-rows {
  margin: 10px 0;
}

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

.pulse-tag {
  width: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pulse-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: white;
  transition: background 0.08s, transform 0.08s;
}

.pulse-dot.high { border-color: var(--accent); }
.pulse-dot.low { border-color: var(--accent-2); }

.pulse-dot.hit {
  background: var(--gold);
  transform: scale(1.25);
}

.sing-card {
  border-left-color: var(--gold);
}

.sing-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 8px;
}

.sing-syllable {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  height: 86px;
  padding: 0 12px;
  border: 3px solid var(--gold);
  border-radius: 50%;
  background: white;
  font-size: 26px;
  font-weight: 900;
}

.sing-meta {
  font-size: 15px;
  line-height: 1.5;
}

.tuner {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: white;
}

.tuner-scale {
  position: relative;
  height: 26px;
  border-radius: 13px;
  background: linear-gradient(90deg, rgba(168, 68, 48, 0.18), rgba(11, 110, 105, 0.25) 42%, rgba(11, 110, 105, 0.25) 58%, rgba(168, 68, 48, 0.18));
}

.tuner-center {
  position: absolute;
  left: 50%;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--ink);
}

.tuner-needle {
  position: absolute;
  left: 50%;
  top: -7px;
  bottom: -7px;
  width: 6px;
  margin-left: -3px;
  border-radius: 3px;
  background: var(--accent-2);
  transition: left 0.09s linear;
}

.tuner.in-tune .tuner-needle {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(11, 110, 105, 0.8);
}

.tuner-marks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.course-lattice {
  width: 100%;
  max-height: 380px;
  margin-top: 6px;
}

.course-lattice .node {
  cursor: pointer;
}

.course-lattice text {
  font-size: 15px;
  font-weight: 800;
  pointer-events: none;
}

.course-lattice .node-ratio {
  font-size: 11px;
  font-weight: 600;
  fill: var(--muted);
}

.degree-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.degree-chip {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.degree-chip.active {
  background: var(--gold);
  border-color: var(--gold);
  color: white;
}

.chord-chip {
  min-width: 52px;
  font-size: 15px;
}

.course-table {
  border-collapse: collapse;
  margin: 8px 0;
}

.course-table th,
.course-table td {
  border: 1px solid var(--line);
  padding: 6px 14px;
  text-align: left;
  font-size: 14px;
}

.course-table th {
  background: white;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  margin: 10px 0 4px;
}

.quiz-answer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 54px;
  padding: 8px 10px;
  text-align: left;
}

.quiz-answer span {
  color: var(--muted);
  font-size: 12px;
}

.quiz-answer.right {
  border-color: var(--accent);
  background: rgba(11, 110, 105, 0.14);
}

.quiz-answer.wrong {
  border-color: var(--accent-2);
  background: rgba(168, 68, 48, 0.14);
}

.course-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

#courseHomeCard button {
  margin-top: 6px;
}

@media (max-width: 980px) {
  .course-layout {
    grid-template-columns: 1fr;
  }

  .course-sidebar {
    position: static;
    max-height: 280px;
  }
}

/* Playing highlights — kept last so they win over highlighted/selected states. */

.node.playing circle,
.node.playing rect {
  fill: #fff0ca;
  stroke: var(--accent-2);
  stroke-width: 7;
}

.node.selected.playing circle {
  stroke: var(--accent-2);
  stroke-width: 7;
}

.triad-shape.playing,
.triad-shape.highlighted.playing,
.triad-shape.highlighted.minor.playing {
  fill: rgba(168, 68, 48, 0.3);
  stroke: var(--accent-2);
  stroke-width: 8;
}

/* ------------------------------------------------------------------ */
/* Piano strip, settings, reference, glossary, trainer, pitch trace    */
/* ------------------------------------------------------------------ */

.piano-strip {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.piano-strip-svg {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
}

.piano-key {
  cursor: pointer;
  stroke: var(--ink);
  stroke-width: 1.5;
}

.piano-key.white { fill: #ffffff; }
.piano-key.black { fill: #2b2d33; }
.piano-key.white.mapped { fill: #eef6f5; }
.piano-key.black.mapped { fill: #144440; }
.piano-key.white.conflated { fill: #fff0ca; stroke: var(--gold); stroke-width: 2.5; }
.piano-key.black.conflated { fill: #7a5a16; stroke: var(--gold); stroke-width: 2.5; }

.piano-key-group:hover .piano-key,
.piano-key-group:focus .piano-key {
  stroke: var(--accent-3);
  stroke-width: 3;
}

.piano-key-label,
.piano-key-count {
  pointer-events: none;
  font-size: 12px;
  font-weight: 800;
  fill: var(--ink);
  text-transform: none;
}

.piano-key-count { font-size: 11px; fill: var(--accent-2); }
.piano-key-label.on-black { fill: #ffffff; }
.piano-key-count.on-black { fill: #ffd98a; }

.piano-strip-caption {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.node.strip-hot circle {
  stroke: var(--accent-3);
  stroke-width: 6;
  fill: #eaf0fa;
}

.settings-pop {
  position: relative;
}

.settings-pop summary {
  list-style: none;
  cursor: pointer;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: white;
  color: var(--accent);
  padding: 0 14px;
  font-weight: 600;
}

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

.settings-pop[open] summary {
  background: var(--accent);
  color: white;
}

.settings-panel {
  position: absolute;
  bottom: 52px;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: 280px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.trainer-prompt {
  margin: 4px 0 8px;
  font-size: 18px;
  font-weight: 800;
}

.trace-box {
  margin-top: 8px;
}

.pitch-trace {
  display: block;
  width: 100%;
  max-width: 640px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
}

.trace-band { fill: rgba(11, 110, 105, 0.14); }
.trace-zero { stroke: var(--accent); stroke-width: 1.5; }
.trace-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; }
.trace-tag { font-size: 10px; font-weight: 700; fill: var(--muted); }
.trace-line { fill: none; stroke: var(--accent-2); stroke-width: 2.5; stroke-linejoin: round; }

.gloss-term {
  border-bottom: 1.5px dotted var(--accent-2);
  cursor: help;
}

.gloss-pop {
  position: absolute;
  z-index: 60;
  display: none;
  max-width: 340px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.gloss-pop strong {
  color: var(--accent-2);
  text-transform: capitalize;
}

.gloss-pop.visible { display: block; }

.reference-heading {
  margin: 26px 0 8px;
  font-size: 22px;
}

.reference-block {
  overflow-x: auto;
}

.reference-table {
  background: var(--panel);
}

.reference-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.reference-table th.sortable:hover {
  color: var(--accent);
}

.reference-table td {
  white-space: nowrap;
}

.reference-table td:nth-child(4),
.reference-table td:nth-child(5) {
  font-variant-numeric: tabular-nums;
}

#commaIndex .reference-table td:nth-child(4) {
  white-space: normal;
  min-width: 260px;
}

.table-play {
  min-height: 30px;
  min-width: 36px;
  padding: 0 8px;
  font-size: 12px;
}

.glossary-dl {
  max-width: 860px;
}

.glossary-dl dt {
  margin-top: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.glossary-dl dd {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.course-tools {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.course-tools button {
  flex: 1;
  min-height: 36px;
  font-size: 13px;
  padding: 0 8px;
}

/* ------------------------------------------------------------------ */
/* Onboarding: nav groups, welcome, coach cards, progress map, daily   */
/* ------------------------------------------------------------------ */

.nav-group {
  position: relative;
}

.nav-group-trigger {
  min-height: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
}

.nav-group.active .nav-group-trigger,
.nav-group-trigger:hover {
  background: var(--ink);
  color: white;
}

.nav-group-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.nav-group:hover .nav-group-menu,
.nav-group:focus-within .nav-group-menu,
.nav-group.open .nav-group-menu {
  display: grid;
}

.nav-group-menu a {
  border-radius: 6px;
  color: var(--ink);
  padding: 8px 10px;
  text-decoration: none;
}

.nav-group-menu a.active,
.nav-group-menu a:hover {
  background: var(--ink);
  color: white;
}

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 24, 28, 0.55);
  backdrop-filter: blur(4px);
}

.welcome-card {
  max-width: 560px;
  padding: 30px 34px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.welcome-card h2 {
  margin: 8px 0 12px;
  font-size: 32px;
  line-height: 1.1;
}

.welcome-card p {
  color: var(--muted);
  line-height: 1.55;
}

.welcome-card .hero-actions {
  margin-top: 18px;
}

.welcome-small {
  margin-top: 14px;
  font-size: 13px;
}

.coach-card {
  margin: 0 0 18px;
  padding: 14px 18px;
  border: 1px solid var(--gold);
  border-left-width: 5px;
  border-radius: 10px;
  background: #fffbf0;
  max-width: 720px;
}

.coach-title {
  margin: 0 0 6px;
  font-weight: 800;
  color: var(--accent-2);
}

.coach-tips {
  margin: 0 0 10px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.coach-actions {
  display: flex;
  gap: 8px;
}

.coach-actions button {
  min-height: 36px;
  font-size: 14px;
}

.progress-lattice-svg {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 8px 0;
}

.progress-node circle {
  fill: #f1f1ee;
  stroke: #c9cdd6;
  stroke-width: 1.5;
}

.progress-node text {
  font-size: 12px;
  font-weight: 800;
  fill: #a9adb8;
}

.progress-node.lit circle {
  fill: #fff0ca;
  stroke: var(--gold);
  stroke-width: 3;
}

.progress-node.lit text {
  fill: var(--ink);
}

.faq-card details {
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px 12px;
}

.faq-card summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.faq-card details p {
  margin: 8px 0 2px;
  font-size: 14px;
}

.tuner-privacy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

#modeDuJourCard #modeDuJourName {
  font-size: 17px;
}

.settings-reset {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.settings-reset button {
  min-height: 36px;
  font-size: 13px;
}

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

button.danger:hover {
  background: var(--accent-2);
  color: white;
}

.settings-mix-title {
  margin: 4px 0 -4px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

button.playing-glow,
button.secondary.playing-glow {
  background: var(--gold);
  border-color: var(--gold);
  color: white;
  box-shadow: 0 0 0 4px rgba(197, 139, 40, 0.35);
  transition: box-shadow 0.12s, background 0.12s;
}

.confirm-card {
  max-width: 440px;
}

.confirm-card p {
  margin-top: 0;
}

.node.out-of-mode circle {
  fill: #f1f1ee;
  stroke: #c9cdd6;
}

.node.out-of-mode text {
  fill: #a9adb8;
}

/* ------------------------------------------------------------------ */
/* Tuned keyboard, heatmap, practice room, analysis, sequencer, infra  */
/* ------------------------------------------------------------------ */

.keyboard-visualizer {
  min-height: 260px;
  padding: 14px;
}

.tuned-key {
  cursor: pointer;
  stroke: var(--ink);
  stroke-width: 1.5;
}

.tuned-key.white { fill: #ffffff; }
.tuned-key.black { fill: #2b2d33; }

.tuned-key-group:hover .tuned-key,
.tuned-key-group:focus .tuned-key {
  stroke: var(--accent-3);
  stroke-width: 3;
}

.tuned-key.key-down,
.tuned-key-group .key-down {
  fill: var(--gold);
}

.heat-node circle {
  fill: #f1f1ee;
  stroke: #c9cdd6;
  stroke-width: 2;
}

.heat-node text {
  font-size: 11px;
  font-weight: 800;
  fill: var(--ink);
}

.heat-node .heat-pct {
  font-size: 9px;
  font-weight: 700;
  fill: var(--muted);
}

.heat-node.good circle { fill: rgba(11, 110, 105, 0.22); stroke: var(--accent); }
.heat-node.mid circle { fill: rgba(197, 139, 40, 0.25); stroke: var(--gold); }
.heat-node.weak circle { fill: rgba(168, 68, 48, 0.22); stroke: var(--accent-2); }

.sight-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font-weight: 800;
}

.sight-chip.active {
  border-color: var(--accent-3);
  box-shadow: 0 0 0 3px rgba(54, 92, 154, 0.25);
}

.sight-chip.right {
  background: rgba(11, 110, 105, 0.16);
  border-color: var(--accent);
}

.sight-chip.wrong {
  background: rgba(168, 68, 48, 0.16);
  border-color: var(--accent-2);
}

.session-card {
  border-left-color: var(--accent-3);
}

.session-step-title {
  margin: 4px 0 2px;
  font-size: 19px;
}

.session-nav {
  justify-content: space-between;
}

.journal-box {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}

.journal-entry {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid var(--line);
  color: var(--muted);
  line-height: 1.5;
}

.septimal-card {
  border-left-color: #6b4b9a;
}

.septimal-button {
  border-color: #6b4b9a;
  color: #6b4b9a;
}

.inline-grow {
  min-width: 240px;
  width: auto;
}

.inline-number {
  width: 76px;
}

.voicing-sequence-strip .composer-bar {
  margin-bottom: 8px;
}

.spectrum-canvas {
  display: block;
  width: 100%;
  max-width: 640px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.activity-card {
  position: relative;
}

.activity-link {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  min-height: 34px;
  border-color: var(--line);
  background: white;
  color: var(--muted);
  font-size: 15px;
}

.linked-flash {
  box-shadow: 0 0 0 4px rgba(197, 139, 40, 0.55);
  transition: box-shadow 0.4s;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 720px) {
  .big-visualizer,
  .visualizer {
    min-height: 260px;
  }

  .top-nav a,
  .nav-group-trigger {
    padding: 10px 12px;
  }

  .activity-actions button,
  .composer-bar button {
    min-height: 46px;
  }

  .quiz-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }

  .course-lesson {
    padding: 18px 16px 22px;
  }

  .sing-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .node circle {
    r: 30;
  }
}

button,
.node,
.piano-key-group,
.tuned-key-group {
  touch-action: manipulation;
}

/* ------------------------------------------------------------------ */
/* Folding plane, septimal 3D, mode matrix, progress panel             */
/* ------------------------------------------------------------------ */

.folding-svg {
  display: block;
  width: 100%;
  max-width: 760px;
  margin: 8px 0;
}

.fold-et-line {
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
}

.fold-tag,
.fold-drift {
  font-size: 10px;
  font-weight: 700;
  fill: var(--muted);
}

.fold-path {
  stroke: var(--accent-3);
  stroke-width: 3;
  transition: opacity 1.4s ease;
}

.fold-crease {
  stroke: var(--gold);
  stroke-width: 4;
  opacity: 0;
  transition: opacity 1.4s ease;
}

.folding-svg.folded .fold-path { opacity: 0.15; }
.folding-svg.folded .fold-crease { opacity: 1; }

.fold-lift {
  transition: transform 1.4s ease;
}

.folding-svg.folded .fold-lift {
  transform: translateY(calc(var(--lift) * -1));
}

.fold-lift circle {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 2;
}

.fold-lift text {
  font-size: 13px;
  font-weight: 800;
  fill: var(--ink);
}

.fold-lift.playing-fold circle {
  fill: #fff0ca;
  stroke: var(--accent-2);
  stroke-width: 5;
}

.septimal-3d {
  display: block;
  width: 100%;
  max-height: 420px;
  margin: 8px 0;
}

.septimal-shadow {
  cursor: pointer;
}

.septimal-shadow circle {
  fill: #f4f3f0;
  stroke: #b9bdc7;
  stroke-width: 1.5;
}

.septimal-shadow text {
  font-size: 12px;
  font-weight: 700;
  fill: #8d92a0;
  pointer-events: none;
}

.septimal-strut {
  stroke: #6b4b9a;
  stroke-width: 2;
  stroke-dasharray: 5 4;
  opacity: 0.7;
}

.septimal-node {
  cursor: pointer;
}

.septimal-node circle {
  fill: #f3ecfb;
  stroke: #6b4b9a;
  stroke-width: 3;
}

.septimal-node text {
  font-size: 12px;
  font-weight: 800;
  fill: #4a3470;
  pointer-events: none;
}

.septimal-node .septimal-sub {
  font-size: 9px;
  font-weight: 700;
  fill: #6b4b9a;
}

.mode-matrix-table th {
  background: white;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}

.mode-matrix-cell {
  width: 100%;
  min-height: 44px;
  font-size: 12.5px;
  padding: 0 6px;
  border-color: var(--line);
  color: var(--muted);
}

.mode-matrix-cell.named {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.tuner-target-row td {
  background: #fff6e0;
}

.progress-panel {
  width: 320px;
}

.progress-line {
  margin: 2px 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.progress-line strong {
  color: var(--ink);
}

/* ------------------------------------------------------------------ */
/* Search, pacing, lissajous, waterfall, breath, voice dot, journal    */
/* ------------------------------------------------------------------ */

.nav-search {
  min-width: 42px;
}

.search-card {
  width: min(620px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
}

.search-card input {
  width: 100%;
  font-size: 17px;
  padding: 12px;
}

.search-results {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.search-hit {
  justify-content: flex-start;
  text-align: left;
  min-height: 44px;
  font-size: 14px;
}

.search-type {
  display: inline-block;
  min-width: 64px;
  margin-right: 8px;
  border-radius: 999px;
  background: #edf1f4;
  color: #39404d;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.course-pacing-hint {
  display: block;
  width: 100%;
  min-height: 0;
  margin: 0 0 8px;
  padding: 9px 10px;
  border: 1px dashed var(--accent-2);
  border-radius: 8px;
  background: #fff6f1;
  color: var(--muted);
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.course-pacing-hint strong {
  color: var(--accent-2);
}

.course-part-title.starred {
  color: var(--gold);
}

.lissajous-canvas {
  display: block;
  width: 280px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  margin: 8px 0;
}

.waterfall-canvas {
  display: block;
  width: 100%;
  max-width: 640px;
  height: 64px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.breath-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.voice-dot {
  fill: rgba(168, 68, 48, 0.85);
  stroke: #ffffff;
  stroke-width: 2.5;
  pointer-events: none;
}

.voice-dot.in-tune {
  fill: rgba(11, 110, 105, 0.9);
}

.journal-play {
  margin-left: 8px;
  vertical-align: middle;
}

/* ------------------------------------------------------------------ */
/* Performance mode, voice-leading, voicing lit, thumbs, composer      */
/* ------------------------------------------------------------------ */

body.perf-mode .app-header,
body.perf-mode footer,
body.perf-mode .page-heading,
body.perf-mode .control-stack,
body.perf-mode .status-strip,
body.perf-mode .controls-key,
body.perf-mode .lattice-explainer,
body.perf-mode .piano-strip,
body.perf-mode .coach-card,
body.perf-mode .sequence-readout {
  display: none !important;
}

body.perf-mode main {
  padding: 8px;
}

body.perf-mode .workbench {
  grid-template-columns: 1fr;
}

body.perf-mode .big-visualizer {
  min-height: 94vh;
  box-shadow: none;
}

#perfExit {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
}

body.perf-mode #perfExit {
  display: block;
}

.voice-lead-line {
  stroke: var(--accent-2);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 12 8;
  opacity: 0.85;
  pointer-events: none;
  animation: lead-march 0.7s linear infinite;
}

@keyframes lead-march {
  to { stroke-dashoffset: -20; }
}

.voice-lead-hold {
  fill: none;
  stroke: var(--gold);
  stroke-width: 4;
  stroke-dasharray: 5 5;
  opacity: 0.9;
  pointer-events: none;
}

.node.voicing-lit circle {
  fill: #fff0ca;
  stroke: var(--gold);
  stroke-width: 5;
}

.atlas-thumb {
  display: block;
  width: 100%;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: #fbfaf6;
}

.thumb-dot { fill: #d8dbe2; }
.thumb-hit { fill: rgba(197, 139, 40, 0.75); }
.thumb-bar { fill: rgba(54, 92, 154, 0.6); }

.step-cell.rest {
  opacity: 0.55;
}

.step-len {
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 800;
}

/* Record button, what's new, review toggle */

#recordOutput.recording {
  border-color: var(--accent-2);
  background: var(--accent-2);
  color: white;
}

.whats-new-date {
  margin: 8px 0 2px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.whats-new-date.fresh {
  color: var(--accent-2);
}

.whats-new-items {
  margin: 0 0 4px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.review-toggle {
  margin: 4px 0 10px;
  min-height: 36px;
  font-size: 13px;
}

/* Help page and footer help button */

.footer-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: white;
  color: var(--accent);
  padding: 0 14px;
  text-decoration: none;
  font-weight: 600;
}

.footer-help:hover {
  background: var(--accent);
  color: white;
}

.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.help-toc button {
  min-height: 36px;
  font-size: 13px;
}

.help-section {
  max-width: 860px;
  margin: 0 0 18px;
  scroll-margin-top: 120px;
}

.help-section h3 {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--accent-2);
}

.help-section p,
.help-section li {
  color: var(--muted);
  line-height: 1.6;
}

.help-section li {
  margin-bottom: 6px;
}

.help-section strong {
  color: var(--ink);
}

.help-section code {
  background: #edf1f4;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}
