/* =============================================================================
   Roo — Audio → LilyPond
   Vanilla CSS. Dark "engraving workshop" aesthetic.
   ============================================================================= */

:root {
  --bg:           #0e0d0b;
  --bg-2:         #161412;
  --bg-3:         #1d1b17;
  --line:         #2a2622;
  --line-2:       #3a352d;
  --ink:          #f1ece0;
  --ink-2:        #c9c2b1;
  --ink-3:        #8a8377;
  --ink-4:        #5b554a;
  --gold:         #d6a25c;
  --gold-2:       #e8b871;
  --gold-soft:    rgba(214, 162, 92, 0.12);
  --red:          #d97a6a;
  --green:        #8fb37a;
  --blue:         #7a9bd0;
  --shadow:       0 12px 40px rgba(0,0,0,0.5);
  --shadow-soft:  0 6px 20px rgba(0,0,0,0.35);
  --radius:       12px;
  --radius-sm:    8px;
  --serif:        "Cormorant Garamond", "Times New Roman", serif;
  --sans:         "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:         "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute should always win over our `display: flex/grid` rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body { display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; }

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-2); }
code, pre { font-family: var(--mono); font-size: 13px; }

/* Subtle staff-line background motif ---------------------------------------- */
.staff-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 72px,
      rgba(214, 162, 92, 0.018) 72px,
      rgba(214, 162, 92, 0.018) 73px,
      transparent 73px,
      transparent 76px,
      rgba(214, 162, 92, 0.012) 76px,
      rgba(214, 162, 92, 0.012) 77px,
      transparent 77px,
      transparent 80px,
      rgba(214, 162, 92, 0.018) 80px,
      rgba(214, 162, 92, 0.018) 81px,
      transparent 81px,
      transparent 84px,
      rgba(214, 162, 92, 0.012) 84px,
      rgba(214, 162, 92, 0.012) 85px,
      transparent 85px,
      transparent 88px
    );
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.7) 0%, transparent 80%);
}

/* Topbar -------------------------------------------------------------------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 40px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 13, 11, 0.7);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { color: var(--gold); display: inline-flex; }
.brand-text h1 {
  font-family: var(--serif); font-weight: 500; font-size: 26px; line-height: 1; margin: 0;
  letter-spacing: 0.01em;
}
.brand-text p { margin: 4px 0 0; font-size: 11px; color: var(--ink-3); letter-spacing: 0.12em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.toggle:hover { color: var(--ink); border-color: var(--gold); }
.toggle input { accent-color: var(--gold); cursor: pointer; }
.toggle input:checked + span { color: var(--gold-2); }
.ghost-link { color: var(--ink-3); display: inline-flex; padding: 4px; }
.ghost-link:hover { color: var(--ink); }

/* Main layout --------------------------------------------------------------- */
main {
  position: relative; z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 40px 96px;
}
.view { display: none; }
.view-active { display: block; animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Hero ---------------------------------------------------------------------- */
.hero { margin-bottom: 40px; }
.hero-compact { margin-bottom: 28px; }
.eyebrow {
  margin: 0 0 12px;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold);
}
.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.05;
  margin: 0 0 18px;
  letter-spacing: -0.01em;
}
.hero-title em { color: var(--gold); font-style: italic; }
.hero-sub {
  font-size: 17px; color: var(--ink-2);
  max-width: 60ch; margin: 0;
}

/* Dropzone ------------------------------------------------------------------ */
.dropzone {
  position: relative;
  display: block;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 56px 32px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--ink-4); }
.dropzone.is-drag {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.dropzone-icon { color: var(--ink-3); margin-bottom: 16px; }
.dropzone-headline {
  font-family: var(--serif); font-style: italic;
  font-size: 26px; font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
}
.dropzone-sub {
  margin: 0 0 22px;
  font-size: 13px; color: var(--ink-3);
  letter-spacing: 0.04em;
}
.dropzone-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.dropzone-hint {
  margin: 18px 0 0;
  font-size: 12px; color: var(--ink-3);
  font-style: italic;
  max-width: 44ch;
  line-height: 1.5;
}
.dropzone-file { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.file-row { display: flex; align-items: center; gap: 18px; }
.file-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.file-name { font-family: var(--mono); font-size: 15px; color: var(--ink); }
.file-size { font-size: 12px; color: var(--ink-3); }

/* iReal input -------------------------------------------------------------- */
.input-mode-divider {
  display: flex; align-items: center; gap: 14px;
  margin: 22px auto 0;
  max-width: 360px;
  color: var(--ink-3);
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
}
.input-mode-divider::before, .input-mode-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.ireal-toggle { display: flex; justify-content: center; margin-top: 12px; }
.ireal-input {
  margin-top: 18px;
  padding: 18px 18px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  display: flex; flex-direction: column; gap: 10px;
}
.ireal-headline {
  margin: 0; font-size: 13px; color: var(--ink-2);
  letter-spacing: 0.02em;
}
.ireal-headline code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 12px;
}
#ireal-text {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
#ireal-text:focus { border-color: var(--gold); }
.ireal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ireal-hint {
  margin: 0; font-size: 11.5px; color: var(--ink-3);
  font-style: italic;
}

/* Book / playlist header (iReal results view) ------------------------------- */
.book-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin: 8px 0 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.book-header-info { min-width: 0; }
.book-eyebrow {
  margin: 0 0 6px;
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.book-title {
  margin: 0 0 4px;
  font: 400 30px/1.1 var(--serif);
  color: var(--ink);
  letter-spacing: -0.01em;
}
.book-title em { color: var(--gold); font-style: italic; }
.book-sub {
  margin: 0;
  font: 400 13px/1.4 var(--sans);
  color: var(--ink-2);
}
.book-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.book-songs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 18px;
}
.book-song-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  text-align: left;
  color: var(--ink-2);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.book-song-chip:hover { background: var(--paper-3); color: var(--ink); border-color: var(--line-2); }
.book-song-chip.active {
  background: rgba(199, 158, 70, 0.12);
  border-color: var(--gold);
  color: var(--ink);
}
.book-song-chip.active .book-song-num { background: var(--gold); color: #1a1611; }
.book-song-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--paper-3);
  font: 600 11px/1 var(--sans);
  color: var(--ink-2);
  flex-shrink: 0;
}
.book-song-meta { display: flex; flex-direction: column; min-width: 0; }
.book-song-title {
  font: 500 14px/1.2 var(--serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.book-song-sub {
  font: 400 11px/1.3 var(--sans);
  color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.book-song-chords {
  font: 500 12px/1 var(--mono);
  color: var(--ink-2);
  padding-left: 4px;
  border-left: 1px solid var(--line-2);
}
.book-song-chords .unit { color: var(--ink-3); font-size: 10px; }

/* Audio player (iReal chord chart) ---------------------------------------- */
.audio-player {
  margin: 0 0 18px;
  padding: 18px 20px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.audio-player-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 14px; gap: 16px;
}
.audio-player-eyebrow {
  margin: 0;
  font: 500 10px/1 var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.audio-player-sub {
  margin: 0;
  font: 400 12px/1.2 var(--sans);
  color: var(--ink-3);
}

.audio-player-controls {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.ap-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.ap-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.04);
  border-color: var(--ink-3);
  color: var(--ink);
}
.ap-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ap-btn-primary {
  background: var(--gold);
  color: #1a1611;
  border-color: var(--gold);
  min-width: 96px;
  justify-content: center;
}
.ap-btn-primary:hover:not(:disabled) { background: var(--gold-2); color: #1a1611; }
.ap-btn-primary.is-playing { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.ap-meter {
  flex: 1 1 200px;
  display: flex; align-items: center; gap: 10px;
  min-width: 180px;
}
.ap-meter-time {
  font: 500 11px/1 var(--mono);
  color: var(--ink-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.ap-meter-bar {
  flex: 1;
  height: 4px;
  background: var(--paper-3);
  border-radius: 2px;
  overflow: hidden;
}
.ap-meter-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.08s linear;
}

.audio-player-knobs {
  display: flex; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  padding: 12px 0 4px;
  border-top: 1px solid var(--line);
}
.ap-knob { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.ap-knob-label {
  font: 500 10px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ap-knob input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--paper-3);
  border-radius: 2px;
  outline: none;
}
.ap-knob input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
.ap-knob input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
.ap-knob select {
  height: 32px;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font: 500 13px/1 var(--sans);
  cursor: pointer;
}
.ap-knob-value {
  font: 500 11px/1 var(--mono);
  color: var(--ink-2);
}
.ap-knob-value span { color: var(--ink); }

.audio-player-status {
  margin: 12px 0 0;
  font: 400 11.5px/1.5 var(--sans);
  color: var(--ink-3);
  font-style: italic;
}
.audio-player-status strong { color: var(--ink-2); font-style: normal; }
.audio-player-status.is-loading { color: var(--gold); }
.audio-player-status.is-error  { color: #d97a6b; font-style: normal; }

/* Read-only banner shown in the notation toolbar for chord charts */
.notation-readonly-banner {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 12px 0 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(199, 158, 70, 0.10);
  border: 1px solid rgba(199, 158, 70, 0.30);
  color: var(--gold-2);
  font: 500 11.5px/1 var(--sans);
  letter-spacing: 0.02em;
}
.notation-readonly-banner svg { color: var(--gold); }
.notation-readonly-banner #notation-readonly-detail {
  color: var(--ink-2);
  font-weight: 400;
}

/* Buttons ------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: 500 14px/1 var(--sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--gold); color: #1a1611;
}
.btn-primary:hover { background: var(--gold-2); color: #1a1611; }
.btn-primary:disabled { background: var(--ink-4); color: var(--ink-2); cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--ink-2); border-color: var(--line-2);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-3); background: rgba(255,255,255,0.02); }
.btn-large { padding: 14px 26px; font-size: 15px; }

/* Feature row --------------------------------------------------------------- */
.features {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 20px; margin-top: 56px;
}
.feature {
  padding: 24px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.feature-num {
  font-family: var(--serif); font-style: italic; font-size: 24px;
  color: var(--gold); margin-bottom: 8px;
}
.feature h3 { font-family: var(--serif); font-weight: 500; font-size: 19px; margin: 0 0 8px; }
.feature p  { margin: 0; color: var(--ink-2); font-size: 14px; }

/* Progress view ------------------------------------------------------------- */
.progress-shell { margin-bottom: 32px; }
.progress-bar {
  height: 4px; background: var(--bg-3);
  border-radius: 2px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-meta {
  display: flex; justify-content: space-between;
  margin-top: 10px;
  font-size: 12px; color: var(--ink-3);
  letter-spacing: 0.05em;
  font-family: var(--mono);
}
#progress-stage { color: var(--ink-2); text-transform: uppercase; }
#progress-pct { color: var(--gold); }

.stage-list {
  list-style: none; margin: 0 0 40px; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  counter-reset: stage;
}
.stage-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-3);
  counter-increment: stage;
  transition: color 0.2s, border-color 0.2s;
}
.stage-item::before {
  content: counter(stage, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
  min-width: 20px;
}
.stage-item.is-active {
  color: var(--ink);
  border-color: var(--gold);
  background: var(--gold-soft);
}
.stage-item.is-active::before { color: var(--gold); }
.stage-item.is-done { color: var(--ink-2); }
.stage-item.is-done::before { color: var(--green); }
.stage-item .stage-mark { margin-left: auto; font-size: 12px; }
.stage-item .stage-mark::before { content: "\00a0\00a0"; }
.stage-item.is-done .stage-mark::before { content: "\2713  "; color: var(--green); }
.stage-item.is-active .stage-mark::before { content: "\25CF  "; color: var(--gold); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Stem cards ---------------------------------------------------------------- */
.stems-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 32px;
}
.stem-card {
  padding: 18px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.stem-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--line-2);
  transition: background 0.3s;
}
.stem-card.is-active::before { background: var(--gold); }
.stem-card.is-done::before   { background: var(--green); }
.stem-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.stem-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-4);
  transition: background 0.3s;
}
.stem-card.is-active .stem-dot { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.stem-card.is-done   .stem-dot { background: var(--green); }
.stem-card h3 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0; }
.stem-line { margin: 0 0 8px; font-size: 12px; color: var(--ink-3); }
.stem-status { margin: 0; font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.stem-card.is-active .stem-status { color: var(--gold-2); }
.stem-card.is-done   .stem-status { color: var(--green); }

.progress-actions { display: flex; justify-content: center; }

/* Results ------------------------------------------------------------------- */
.result-summary {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 32px;
}
.summary-card {
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.summary-card .k { font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.summary-card .v { font-family: var(--serif); font-size: 24px; color: var(--ink); }
.summary-card .v .unit { font-size: 13px; color: var(--ink-3); margin-left: 4px; }

.result-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.tab {
  background: transparent; border: none; cursor: pointer;
  padding: 12px 18px;
  font: 500 14px var(--sans);
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--gold); border-color: var(--gold); }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.3s ease-out; }

/* Stem sub-tabs ------------------------------------------------------------- */
.stem-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.stem-tab {
  padding: 7px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font: 500 13px var(--sans);
  cursor: pointer;
  transition: all 0.15s;
}
.stem-tab:hover { color: var(--ink); border-color: var(--ink-3); }
.stem-tab.active { background: var(--gold-soft); color: var(--gold-2); border-color: var(--gold); }

.stem-panel { display: none; }
.stem-panel.active { display: block; }

.code-card {
  margin-bottom: 20px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-3);
}
.code-card-head h3 {
  font-family: var(--mono); font-size: 13px; font-weight: 500; margin: 0;
  color: var(--ink-2);
}
.code-actions { display: flex; gap: 8px; }
.code-actions .btn { padding: 6px 12px; font-size: 12px; }
.code-block {
  margin: 0;
  padding: 18px 20px;
  max-height: 420px; overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--bg);
  white-space: pre;
}
.code-block code { font-family: inherit; }

/* LilyPond syntax highlight ------------------------------------------------- */
.code-block .ly-keyword  { color: #c89b6e; }
.code-block .ly-string   { color: #a8c590; }
.code-block .ly-comment  { color: #6b6557; font-style: italic; }
.code-block .ly-markup   { color: #b08ccc; }
.code-block .ly-property { color: #7a9bd0; }
.code-block .ly-pitch    { color: #d6a25c; }
.code-block .ly-number   { color: #d97a6a; }

.code-block .xml-tag     { color: #7a9bd0; }
.code-block .xml-attr    { color: #c89b6e; }
.code-block .xml-string  { color: #a8c590; }
.code-block .xml-comment { color: #6b6557; font-style: italic; }

.code-block .json-key    { color: #7a9bd0; }
.code-block .json-string { color: #a8c590; }
.code-block .json-num    { color: #d97a6a; }
.code-block .json-bool   { color: #c89b6e; }
.code-block .json-null   { color: #c89b6e; }

/* Render frame -------------------------------------------------------------- */
.render-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.render-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-3);
}
.render-card-head h3 { font-family: var(--mono); font-size: 13px; font-weight: 500; margin: 0; color: var(--ink-2); }
.render-frame {
  width: 100%;
  min-height: 600px;
  background: #f7f3ea;
  display: flex; align-items: center; justify-content: center;
}
.render-frame iframe { width: 100%; min-height: 800px; border: none; background: #fff; }
.render-empty {
  color: #6b6557;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  padding: 60px;
}

.result-actions { display: flex; justify-content: center; margin-top: 40px; }

/* Error view ---------------------------------------------------------------- */
.error-card {
  max-width: 540px; margin: 0 auto;
  text-align: center;
  padding: 56px 40px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.error-icon { color: var(--red); margin-bottom: 18px; }
.error-card h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; margin: 0 0 12px; }
.error-card p { color: var(--ink-2); margin: 0 0 28px; }

/* Footer -------------------------------------------------------------------- */
.footer {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 40px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3);
  background: rgba(14, 13, 11, 0.7);
}
.backend-status { font-family: var(--mono); letter-spacing: 0.04em; }
.backend-status.online { color: var(--green); }
.backend-status.demo   { color: var(--gold); }
.backend-status.offline{ color: var(--red); }

/* Toast --------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-3); color: var(--ink);
  padding: 12px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  font-size: 13px; box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================================
   Notation editor (Edit notation tab)
   ============================================================================ */

.notation-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.notation-stem-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.notation-toolbar-actions { display: flex; align-items: center; gap: 10px; }
.notation-edit-badge {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold-2);
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 3px 10px;
}

.notation-editor {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
  margin-bottom: 18px;
}
.notation-canvas-wrap {
  background: #f7f3ea;            /* music paper */
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-height: 460px;
  overflow: auto;
  position: relative;
  color: #1a1611;
}
.notation-canvas-wrap img,
.notation-canvas-wrap svg { display: block; max-width: 100%; height: auto; }
.notation-canvas { /* OSMD mounts here */ }
.notation-empty {
  text-align: center;
  font-family: var(--serif); font-style: italic; font-size: 18px;
  color: #6b6557;
  padding: 80px 0;
}
.notation-empty-mini {
  font-size: 12px; color: var(--ink-3); font-style: italic;
  margin: 4px 0 0;
}

.notation-side {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 18px;
  align-self: start;
  position: sticky; top: 16px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}
.notation-side-section { display: flex; flex-direction: column; gap: 8px; }
.notation-side-label {
  margin: 0;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.notation-note-info {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 64px;
}
.notation-note-info .info-line { display: flex; justify-content: space-between; gap: 12px; }
.notation-note-info .info-key { color: var(--ink-3); }
.notation-note-info .info-val { color: var(--ink); font-weight: 500; }
.notation-note-info .info-pitch { color: var(--gold-2); font-size: 22px; line-height: 1; margin: 4px 0 6px; font-family: var(--serif); }

.notation-btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.notation-dur-row { display: grid; grid-template-columns: repeat(6, 1fr); }

.edit-btn {
  flex: 1;
  min-width: 36px;
  padding: 7px 8px;
  background: var(--bg-3);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.05s;
}
.edit-btn:hover:not(:disabled) {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-2);
}
.edit-btn:active:not(:disabled) { transform: translateY(1px); }
.edit-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.edit-btn.is-active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-2);
}
.edit-btn-wide { font-size: 12px; padding: 8px 10px; }

.notation-hints ul {
  list-style: none; padding: 0; margin: 0;
  font-size: 12px; color: var(--ink-3); line-height: 1.7;
}
.notation-hints kbd {
  display: inline-block;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 6px;
  font: 500 11px/1 var(--mono);
  color: var(--ink-2);
}

.notation-foot {
  margin: 4px 2px 0;
  font-size: 12px; color: var(--ink-3);
  text-align: center;
}
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gold); font: inherit; padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--gold-2); }

/* OSMD cursor highlight — make the selection visible against the light canvas */
.notation-canvas-wrap .osmd-cursor { /* OSMD provides this */ }

/* When the editor is loading, dim the canvas */
.notation-canvas-wrap.is-loading::after {
  content: "loading notation…";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-style: italic; font-size: 18px;
  color: #6b6557;
  background: rgba(247, 243, 234, 0.7);
  pointer-events: none;
}

/* Responsive ---------------------------------------------------------------- */
@media (max-width: 860px) {
  .topbar { padding: 16px 22px; }
  main { padding: 36px 22px 64px; }
  .features { grid-template-columns: 1fr; }
  .stems-grid, .result-summary { grid-template-columns: repeat(2, 1fr); }
  .stage-list { grid-template-columns: 1fr; }
  .notation-editor { grid-template-columns: 1fr; }
  .notation-side { position: static; max-height: none; }
  .footer { padding: 16px 22px; flex-direction: column; gap: 6px; }
}
@media (max-width: 520px) {
  .stems-grid, .result-summary { grid-template-columns: 1fr; }
  .hero-title { font-size: 36px; }
  .notation-dur-row { grid-template-columns: repeat(3, 1fr); }
}
