:root {
  color-scheme: light;
  --ink: #292522;
  --muted: #6d665f;
  --paper: #f7f4ed;
  --panel: #fffdf8;
  --line: #ddd4c8;
  --accent: #186d75;
  --accent-strong: #0d535b;
  --active: #f0b84e;
  --active-2: #e2563f;
  --soft-line: rgba(136, 126, 112, 0.24);
  --glass: rgba(255, 253, 248, 0.82);
  --shadow: 0 16px 46px rgba(56, 47, 37, 0.1);
  --shadow-soft: 0 8px 26px rgba(56, 47, 37, 0.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(31, 127, 132, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 244, 237, 0.96)),
    repeating-linear-gradient(90deg, rgba(41, 37, 34, 0.018) 0 1px, transparent 1px 88px);
  color: var(--ink);
}

button,
select {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.stage {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 9px;
}

.stage.waterfall-mode {
  min-height: calc(100vh - 34px);
  min-height: calc(100dvh - 34px);
  display: flex;
  flex-direction: column;
}

.control-card {
  background: var(--glass);
  border: 1px solid var(--soft-line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.stage.waterfall-mode .control-card {
  border-bottom-color: transparent;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 12px 32px rgba(56, 47, 37, 0.08);
}

.topbar {
  min-height: 66px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--soft-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: block;
  flex: 0 0 auto;
  background: #080807;
  box-shadow: 0 8px 18px rgba(41, 37, 34, 0.14);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(14px, 1.8vw, 21px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  margin-bottom: 5px;
}

.field span {
  color: var(--muted);
}

.status-row {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-row p {
  margin-top: 0;
}

#statusText {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--soft-line);
  border-radius: 0;
  padding: 7px 12px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#statusText.status-alert {
  border-color: #e7a8a2;
  background: #fff0ef;
  color: #b7352c;
  font-weight: 700;
}

.version-badge {
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 11px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 750;
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 18px rgba(24, 109, 117, 0.18);
}

.primary:active {
  background: var(--accent-strong);
}

.record-button {
  background: #b7352c;
  color: white;
  box-shadow: 0 8px 18px rgba(183, 53, 44, 0.16);
}

.record-button:active {
  background: #8f261f;
}

.ghost {
  background: rgba(255, 255, 255, 0.62);
  border-color: var(--soft-line);
  color: var(--ink);
}

.ghost:not(:disabled):active,
.primary:not(:disabled):active,
.record-button:not(:disabled):active {
  transform: translateY(1px);
}

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

.trial-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(18, 17, 14, 0.46);
}

.trial-modal.hidden {
  display: none;
}

.trial-modal-panel {
  position: relative;
  width: min(360px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 18px 45px rgba(40, 34, 23, 0.2);
}

.trial-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.trial-modal-panel h2 {
  margin: 0 36px 8px 0;
  font-size: 18px;
  line-height: 1.2;
}

.trial-modal-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.trial-score-list {
  display: grid;
  gap: 8px;
}

.trial-score-button {
  width: 100%;
  min-height: 42px;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
}

.trial-purchase-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--soft-line);
}

.trial-unlock-button,
.trial-restore-button {
  width: 100%;
  justify-content: center;
  min-height: 42px;
  font-size: 14px;
  font-weight: 800;
}

.hidden {
  display: none;
}

.file-input {
  display: none;
}

.settings-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  overflow: hidden;
}

.settings-panel summary {
  min-height: 40px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

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

.settings-panel summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transform-origin: center;
  transition: transform 0.18s ease;
}

.settings-panel[open] summary::after {
  transform: rotate(225deg) translate(-2px, -1px);
}

.panel-strip {
  border-top: 1px solid var(--soft-line);
  background: rgba(255, 253, 248, 0.48);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  align-items: end;
  gap: 8px;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  align-items: end;
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.settings-group {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  box-shadow: var(--shadow-soft);
}

.settings-group-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

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

.field.hidden {
  display: none;
}

.field span {
  font-size: 11px;
  font-weight: 700;
}

.tolerance-field strong {
  font-weight: 800;
}

.slider-control {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: white;
}

.slider-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 34px 0 11px;
}

.field input[type="number"] {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 11px;
  font: inherit;
  font-weight: 750;
}

.hand-split-button {
  width: 100%;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}

.segmented {
  min-height: 34px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

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

.time-field .segmented {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.mode-option {
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 0 10px;
  background: white;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.mode-option + .mode-option {
  border-left: 1px solid var(--soft-line);
}

.mode-option.active {
  background: var(--accent);
  color: white;
}

.key-options {
  min-height: 38px;
  display: grid;
  grid-template-columns: repeat(12, minmax(54px, 1fr));
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.key-option {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  padding: 0 6px;
  background: white;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.key-option + .key-option {
  border-left: 1px solid var(--soft-line);
}

.key-option.active {
  background: var(--accent);
  color: white;
}

.mistake-log {
  border-top: 1px solid var(--soft-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mistake-log-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 0;
  flex: 0 0 auto;
}

.mistake-log-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.mistake-log-empty {
  color: var(--muted);
  font-size: 13px;
}

.mistake-log-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-top: 3px;
  padding-right: 6px;
}

.mistake-log-button {
  appearance: none;
  border: 1px solid #e4a6a0;
  background: #fff5f3;
  color: #b7352c;
  border-radius: 6px;
  min-height: 28px;
  padding: 4px 12px 4px 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.mistake-log-button:active {
  transform: translateY(1px);
}

.mistake-log-remove {
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e4a6a0;
  border-radius: 999px;
  background: #fffdf8;
  color: #b7352c;
  box-shadow: 0 2px 8px rgba(183, 53, 44, 0.14);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.mistake-log-remove:active {
  transform: scale(0.94);
}

.score-board {
  position: relative;
  aspect-ratio: 1760 / 880;
  min-height: 0;
  border-radius: 8px;
  border: 1px solid var(--soft-line);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 252, 245, 0.94));
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: pan-y;
}

.score-board.waterfall-playback {
  aspect-ratio: auto;
  min-height: 0;
  height: 0;
  padding: 0;
  margin-top: -9px;
  margin-bottom: -9px;
  overflow: visible;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  z-index: 6;
}

.score-board.waterfall-playback #staffSvg {
  display: none;
}

.score-board.waterfall-playback .measure-tools {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
}

.measure-tools {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(221, 212, 200, 0.7);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
  box-shadow: 0 12px 30px rgba(56, 47, 37, 0.08);
  backdrop-filter: blur(12px);
}

.measure-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  max-width: 100%;
}

.playback-scrubber {
  width: 100%;
  min-height: 24px;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  align-items: center;
  gap: 8px;
  background: transparent;
  padding: 2px 0;
}

.playback-scrubber input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.playback-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.measure-status,
.chord-status,
.measure-play,
.tempo-control,
.tempo-save-button,
.playback-instrument-select,
.silent-playback-toggle,
.live-sound-toggle,
.robot-performance-toggle,
.white-key-mode-toggle,
.waterfall-toggle {
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.measure-status,
.chord-status {
  padding: 5px 12px;
  pointer-events: none;
}

.chord-status {
  color: var(--ink);
  font-weight: 800;
  flex: 0 0 132px;
  width: 132px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
}

.measure-play {
  min-height: 32px;
  padding: 0 10px;
  color: var(--ink);
  box-shadow: none;
}

.tempo-control {
  height: 32px;
  min-height: 32px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tempo-control span {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.tempo-step {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  font-size: 17px;
  line-height: 1;
  touch-action: none;
  user-select: none;
}

.tempo-step:disabled {
  color: rgba(35, 34, 31, 0.28);
  cursor: not-allowed;
}

.tempo-save-button {
  min-height: 32px;
  padding: 0 11px;
  box-shadow: none;
  font-weight: 800;
  color: var(--ink);
}

.playback-instrument-select {
  width: 108px;
  height: 32px;
  min-height: 32px;
  padding: 0 24px 0 10px;
  color: var(--ink);
  font-size: 12px;
}

.playback-instrument-field .playback-instrument-select {
  width: 100%;
  max-width: 100%;
}

.silent-playback-toggle,
.live-sound-toggle,
.robot-performance-toggle,
.white-key-mode-toggle,
.waterfall-toggle {
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.silent-playback-toggle input,
.live-sound-toggle input,
.robot-performance-toggle input,
.white-key-mode-toggle input,
.waterfall-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.silent-playback-toggle.active,
.silent-playback-toggle:has(input:checked),
.live-sound-toggle.active,
.live-sound-toggle:has(input:checked),
.robot-performance-toggle.active,
.robot-performance-toggle:has(input:checked),
.white-key-mode-toggle.active,
.white-key-mode-toggle:has(input:checked),
.waterfall-toggle.active,
.waterfall-toggle:has(input:checked) {
  border-color: var(--accent);
  background: rgba(31, 127, 132, 0.12);
}

.silent-playback-toggle span,
.live-sound-toggle span,
.robot-performance-toggle span,
.white-key-mode-toggle span,
.waterfall-toggle span {
  font-size: 12px;
  font-weight: 700;
}

.silent-playback-toggle.disabled,
.silent-playback-toggle:has(input:disabled) {
  opacity: 0.56;
  cursor: not-allowed;
}

.waterfall-board {
  position: relative;
  height: clamp(180px, 30vh, 320px);
  margin-top: 0;
  margin-bottom: -1px;
  border-radius: 0;
  border: 1px solid var(--soft-line);
  border-top-color: transparent;
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(250, 253, 253, 0.82), rgba(255, 253, 248, 0.96)),
    repeating-linear-gradient(90deg, rgba(39, 126, 133, 0.08) 0 1px, transparent 1px 38px);
  overflow: hidden;
  pointer-events: auto;
}

.stage.waterfall-mode .waterfall-board {
  flex: 1 1 auto;
  height: auto;
  min-height: clamp(280px, 44vh, 760px);
  margin-top: -1px;
}

.waterfall {
  position: relative;
  height: 100%;
  min-width: 900px;
}

.waterfall-note {
  position: absolute;
  top: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(38, 36, 33, 0.92), rgba(25, 23, 21, 0.72));
  border: 1px solid rgba(25, 23, 21, 0.28);
  box-shadow: 0 3px 10px rgba(25, 23, 21, 0.12);
  will-change: transform;
  pointer-events: none;
}

.waterfall-note-label {
  color: rgba(255, 253, 248, 0.9);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.waterfall-key-label {
  position: absolute;
  bottom: 24px;
  z-index: 4;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 199, 82, 0.94);
  border: 1px solid rgba(154, 105, 18, 0.36);
  color: rgba(31, 27, 23, 0.84);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(25, 23, 21, 0.1);
}

.waterfall-note.black-note {
  background: linear-gradient(180deg, rgba(38, 36, 33, 0.96), rgba(11, 10, 9, 0.78));
}

.waterfall-note.active,
.waterfall-note.matched {
  background: linear-gradient(180deg, rgba(246, 199, 82, 0.96), rgba(235, 174, 48, 0.78));
  border-color: rgba(154, 105, 18, 0.34);
}

.waterfall-note.cue {
  background: linear-gradient(180deg, rgba(127, 199, 232, 0.98), rgba(72, 171, 211, 0.76));
  border-color: rgba(22, 118, 165, 0.38);
  box-shadow: 0 3px 10px rgba(44, 148, 196, 0.16);
}

.waterfall-note.cue .waterfall-note-label,
.waterfall-note.active .waterfall-note-label,
.waterfall-note.matched .waterfall-note-label {
  color: rgba(31, 27, 23, 0.82);
}

.icon-button {
  width: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.control-icon {
  display: block;
}

.stop-icon {
  width: 12px;
  height: 12px;
  background: currentColor;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid currentColor;
  margin-left: 2px;
}

.pause-icon {
  width: 14px;
  height: 14px;
  border-left: 5px solid currentColor;
  border-right: 5px solid currentColor;
}

#staffSvg {
  width: 100%;
  height: 100%;
  display: block;
  transform: translateY(96px);
}

.staff-line {
  stroke: #3d3731;
  stroke-width: 3;
}

.bar-line {
  stroke: #81776d;
  stroke-width: 3;
}

.beat-grid-line {
  stroke: #8f857a;
  stroke-width: 2;
  stroke-dasharray: 5 10;
  opacity: 0.46;
}

.practice-playhead-line {
  stroke: var(--accent);
  stroke-width: 5;
  opacity: 0.86;
}

.measure-grid-line {
  stroke: #8f857a;
  stroke-width: 2;
  stroke-dasharray: 5 10;
  opacity: 0.46;
}

.clef {
  font-family: "Times New Roman", serif;
  font-size: 142px;
  fill: var(--ink);
}

.note-head {
  fill: #fffdf8;
  stroke: var(--ink);
  stroke-width: 2;
}

.target-note {
  stroke: var(--ink);
}

.practice-note-head {
  stroke: var(--ink);
  stroke-width: 2;
}

.export-note-head {
  stroke-width: 1.6;
  transform: none;
}

.note-duration-line {
  fill: none;
  stroke: rgba(35, 34, 31, 0.42);
  stroke-width: 10;
  stroke-linecap: round;
  opacity: 0.34;
  mix-blend-mode: multiply;
}

.note-duration-line.secondary-track-line {
  stroke: rgba(35, 34, 31, 0.32);
  opacity: 0.3;
}

.note-duration-line.active-duration-line {
  stroke: #f0b84e;
  opacity: 0.4;
}

.note-duration-line.cue-duration-line {
  stroke: #62c1ea;
  opacity: 0.38;
}

.filled-note {
  fill: var(--ink);
}

.open-note {
  fill: #fffdf8;
}

.secondary-track-note {
  stroke: var(--ink);
}

.secondary-track-note.filled-note {
  fill: var(--ink);
}

.secondary-track-note.open-note {
  fill: #fffdf8;
  stroke: var(--ink);
}

.matched-note {
  fill: var(--ink);
  stroke: var(--ink);
}

.secondary-track-note.matched-note {
  fill: var(--ink);
  stroke: var(--ink);
}

.practice-note-head.active-note {
  fill: var(--active);
  stroke: #80530d;
}

.active-input-note {
  fill: var(--active);
  stroke: #80530d;
  stroke-width: 3;
}

.active-input-note.wrong-note {
  fill: #f07a72;
  stroke: #b7352c;
  stroke-width: 3;
}

.active-input-label {
  fill: #1f1b17;
}

.practice-note-head.cue-note {
  fill: #7fc7e8;
  stroke: #1676a5;
}

.arpeggio-mark {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note-stem {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}

.secondary-track-stem {
  stroke: #85817b;
}

.matched-stem {
  stroke: #17653a;
}

.pedal-label {
  fill: #5f574f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-style: italic;
  font-weight: 700;
}

.pedal-line,
.pedal-release {
  fill: none;
  stroke: #8f857a;
  stroke-width: 3;
  stroke-linecap: round;
}

.pedal-line {
  opacity: 0.72;
}

.octave-mark {
  fill: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 24px;
  font-weight: 800;
  text-anchor: middle;
}

.octave-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-dasharray: 8 7;
  stroke-linecap: round;
}

.ledger-line {
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}

.ledger-line.secondary-track-line,
.octave-line.secondary-track-line {
  stroke: #85817b;
}

.accidental {
  fill: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 56px;
  font-weight: 700;
  text-anchor: middle;
}

.accidental.secondary-track-text,
.octave-mark.secondary-track-text {
  fill: #85817b;
}

.key-signature {
  fill: var(--ink);
  font-family: "Times New Roman", Georgia, serif;
  font-size: 52px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}

.time-signature {
  fill: var(--ink);
  font-family: "Times New Roman", Georgia, serif;
  font-size: 58px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

.white-key-center-label {
  fill: var(--accent);
  font-size: 20px;
  font-weight: 850;
  text-anchor: middle;
  dominant-baseline: middle;
}

.note-inner-label {
  fill: var(--ink);
  font-size: 22px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.light-note-label {
  fill: white;
}

.empty-note {
  fill: #958b80;
  font-size: 24px;
  text-anchor: middle;
}

.keyboard-board {
  margin-top: 7px;
  border-radius: 8px;
  border: 1px solid #24211e;
  box-shadow: 0 18px 42px rgba(45, 38, 29, 0.14);
  background: rgba(18, 16, 14, 0.04);
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.waterfall-board:not(.hidden) + .keyboard-board {
  margin-top: -1px;
  border-radius: 0 0 8px 8px;
  border-top-color: rgba(36, 33, 30, 0.72);
  flex: 0 0 auto;
}

.keyboard-board::-webkit-scrollbar {
  display: none;
  height: 0;
}

.keyboard {
  position: relative;
  height: clamp(132px, 19vh, 198px);
  min-width: 900px;
  user-select: none;
}

.key {
  position: absolute;
  border: 1px solid rgba(25, 23, 21, 0.92);
  border-radius: 0 0 6px 6px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0;
  touch-action: none;
  color: transparent;
}

.keyboard-board.paused-scroll .key {
  touch-action: none;
}

.c-key-label {
  color: #8a8178;
  font-size: 12px;
  font-weight: 700;
}

.key.active.c-key-label {
  color: #8a8178;
}

.middle-c-key {
  color: #c8322a;
  font-size: 13px;
  font-weight: 800;
}

.key.active.middle-c-key {
  color: #c8322a;
}

.white-key {
  height: 100%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.06), transparent 12%, transparent 88%, rgba(0, 0, 0, 0.06)),
    linear-gradient(180deg, #fff 0%, #f4efe7 66%, #e7ded3 100%);
  z-index: 1;
  box-shadow: inset 0 -14px 20px rgba(45, 38, 29, 0.08);
}

.black-key {
  height: 62%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent 18%, transparent 78%, rgba(0, 0, 0, 0.36)),
    linear-gradient(180deg, #3a3632 0%, #0b0a09 100%);
  z-index: 3;
  border-color: #050505;
  border-radius: 0 0 5px 5px;
  padding: 0;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.12) inset, 0 7px 12px rgba(0, 0, 0, 0.22);
}

.key.active {
  background: var(--active);
  border-color: #80530d;
  box-shadow: inset 0 -10px 18px rgba(255, 255, 255, 0.28), 0 0 0 2px rgba(240, 184, 78, 0.3);
}

.black-key.active {
  background: linear-gradient(180deg, #f5c96a 0%, #c9851f 100%);
  border-color: #80530d;
  box-shadow: inset 0 -8px 14px rgba(255, 244, 210, 0.24), 0 0 0 2px rgba(240, 184, 78, 0.28);
}

.key.cue {
  background: linear-gradient(180deg, #d8f0ff 0%, #7fc7e8 100%);
  border-color: #1676a5;
  box-shadow: inset 0 -8px 16px rgba(255, 255, 255, 0.24), 0 0 0 2px rgba(44, 148, 196, 0.24);
}

.black-key.cue {
  background: linear-gradient(180deg, #1f799d 0%, #0b3347 100%);
  border-color: #4fb8e1;
}

.key.input-active {
  background: var(--active);
  border-color: #80530d;
  box-shadow: inset 0 -10px 18px rgba(255, 255, 255, 0.28), 0 0 0 2px rgba(240, 184, 78, 0.3);
}

.black-key.input-active {
  background: linear-gradient(180deg, #f5c96a 0%, #c9851f 100%);
  border-color: #80530d;
  box-shadow: inset 0 -8px 14px rgba(255, 244, 210, 0.24), 0 0 0 2px rgba(240, 184, 78, 0.28);
}

.key.wrong,
.black-key.wrong {
  background: linear-gradient(180deg, #ffaaa3 0%, #d9473b 100%);
  border-color: #a62d24;
  box-shadow: inset 0 -8px 14px rgba(255, 235, 232, 0.28), 0 0 0 2px rgba(217, 71, 59, 0.24);
}

.pdf-export-root {
  display: none;
}

body.pdf-previewing {
  background: white;
}

body.pdf-previewing .app-shell {
  display: none;
}

body.pdf-previewing .pdf-export-root {
  display: block;
  padding: 8px;
  background: white;
}

.pdf-export-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 44px;
  margin: 0 auto 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  font-size: 13px;
}

.pdf-export-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.pdf-export-toolbar button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 6px;
}

.pdf-page {
  width: 200mm;
  min-height: 287mm;
  margin: 0 auto;
  box-sizing: border-box;
  page-break-after: always;
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
  background: white;
}

.pdf-page:last-child {
  page-break-after: auto;
}

.pdf-title {
  min-height: 5mm;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8mm;
  color: #292522;
  font-size: 9pt;
  font-weight: 700;
}

.pdf-title span:last-child {
  color: #81776d;
  font-size: 8pt;
  font-weight: 600;
}

.score-export-row {
  width: 100%;
  break-inside: avoid;
}

.score-export-row svg {
  width: 100%;
  height: 92mm;
  display: block;
  overflow: visible;
  border: 0;
  box-shadow: none;
  background: #fffdf8;
  transform: none;
}

@page {
  size: A4 portrait;
  margin: 5mm;
}

@media print {
  body {
    background: white;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body.print-exporting .app-shell {
    display: none;
  }

  body.print-exporting .pdf-export-root {
    display: block;
    padding: 0;
  }

  body.print-exporting .pdf-export-toolbar {
    display: none;
  }

  body.print-exporting .note-inner-label {
    font-weight: 600;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
  }

  .actions {
    justify-content: stretch;
    gap: 7px;
  }

  .actions button {
    flex: 1 1 112px;
    padding: 0 10px;
    min-height: 36px;
    font-size: 14px;
  }

  .panel-strip {
    grid-template-columns: 1fr;
  }

  .control-row {
    grid-template-columns: 1fr;
  }

  .key-options {
    grid-template-columns: repeat(6, minmax(42px, 1fr));
  }

  .key-option:nth-child(7) {
    border-left: 0;
  }

  .score-board {
    aspect-ratio: auto;
    height: clamp(450px, 82vw, 540px);
  }

  #staffSvg {
    transform: translateY(0);
  }

  .measure-tools {
    width: calc(100% - 24px);
  }

  .measure-actions {
    flex-wrap: wrap;
  }

  .keyboard {
    min-width: 820px;
  }

}
