:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #161917;
  color: #f4f1e9;
  --line: #414740;
  --accent: #d4e3a8;
  --muted: #b4bdb2;
}
* { box-sizing: border-box; }
body { margin: 0; }
.frame { width: min(1350px, calc(100% - 80px)); margin-inline: auto; }
.top { border-bottom: 1px solid var(--line); }
.masthead { display: flex; align-items: center; justify-content: space-between; min-height: 68px; }
.wordmark { font-family: Georgia, serif; font-size: 1.8rem; }
.wordmark span { color: var(--accent); margin-inline-end: .25rem; }
button {
  font: inherit; color: inherit; background: #272e28; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; min-height: 44px;
}
button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid #d4e3a8; outline-offset: 3px; }
button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #202719; font-weight: 700; }
button:disabled { opacity: .5; cursor: default; }
.languages { display: flex; gap: .375rem; }
.languages button { padding-inline: .75rem; font-size: .875rem; }
h1 {
  font: 400 clamp(2.15rem, 5.5vw, 5rem)/.98 Georgia, serif;
  letter-spacing: -.045em; margin: clamp(1.75rem, 4vw, 3.5rem) 0 2rem;
}
h1 em { color: var(--accent); }
.workspace { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 22px; align-items: start; margin-bottom: 2rem; }
.controls, .sheet { background: #202621; border: 1px solid var(--line); border-radius: 12px; }
.controls { padding: 18px; }
.controls h2, .controls h3 { font-size: .9rem; margin: 0 0 .625rem; color: var(--muted); }
.controls h3 { margin-top: 1.4rem; }
.types, .keys, .numbers { display: grid; gap: 6px; }
.numbers { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.types { grid-template-columns: repeat(2, 1fr); }
.keys { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sheet { min-width: 0; overflow: clip; }
.sheet-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .25rem 1rem; padding: 16px 20px; }
.sheet-header h2, .sheet-header p { margin: 0; }
.sheet-header h2 { font-size: 1.15rem; }
.sheet-header p { font-size: .9rem; color: var(--muted); }
.study { padding: 12px 20px; border-top: 1px solid var(--line); }
.study-heading, .study-controls, .study-actions { display: flex; align-items: center; gap: 8px; }
.study-heading { justify-content: space-between; margin-bottom: 8px; }
.study-heading h3, .study-heading p { margin: 0; font-size: .9rem; }
.study-heading p { color: var(--accent); text-align: end; }
.study-controls { flex-wrap: wrap; gap: 10px 18px; }
.study-actions button { padding-inline: .85rem; }
#study-play { color: #202719; background: var(--accent); font-weight: 700; }
.study-tempo { flex: 1 1 152px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.study-tempo input { grid-column: 1 / -1; width: 100%; margin: 0; }
.study input { accent-color: var(--accent); }
.study-loop { display: flex; align-items: center; min-height: 44px; gap: .35rem; }
.sample-info { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: .85rem; color: var(--muted); }
.sample-info a { color: inherit; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 20px 12px; }
.midi-action { padding-inline: .75rem; }
.midi-option { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.midi-option input, .midi-option select {
  min-height: 44px; max-width: 100%; color: inherit; background: #272e28;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; padding: 0 .5rem;
}
.midi-option input { width: 5rem; }
.midi-readout { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.midi-readout:has([data-midi="targetBox"][hidden]) { grid-template-columns: 1fr; }
[data-midi="grading"] { margin-top: .75rem; }
.midi-readout p { margin: 0; padding: .65rem; border: 1px solid var(--line); border-radius: 6px; }
.midi-readout strong, .midi-readout span { display: block; }
.midi-readout strong, .midi-status { color: var(--muted); font-size: .9rem; }
.midi-progress { color: var(--accent); margin-bottom: 0; }
.midi-status { margin: .5rem 0; min-height: 1.3em; }
.notation { background: #fffefa; color: #171917; padding: .5rem; }
.notation img { display: block; width: 100%; height: auto; min-height: 6rem; }
#score-art > svg { display: block; width: 100%; height: auto; overflow: visible; }
:root { --left-hand: #2e67a7; --right-hand: #197447; }
#score-art .notehead[data-hand="left"] { fill: var(--left-hand); }
#score-art .notehead[data-hand="right"] { fill: var(--right-hand); }
.score-cursor { stroke: #896324; stroke-width: 2px; opacity: .48; vector-effect: non-scaling-stroke; pointer-events: none; }
.piano-panel {
  position: sticky; bottom: 0; z-index: 1; padding: 8px 12px 10px;
  background: #252b26; border-top: 1px solid var(--line);
}
.piano-heading, .hand-legend { display: flex; align-items: center; gap: 10px; }
.piano-heading { justify-content: space-between; margin-bottom: 6px; }
.piano-heading h3, .hand-legend { margin: 0; font-size: .85rem; }
.hand-legend span::before { display: inline-block; width: .65em; height: .65em; margin-inline-end: .35em; border-radius: 50%; content: ""; }
.left-swatch::before { background: #76aff5; }
.right-swatch::before { background: #79cda1; }
.midi-swatch::before { background: #e4bc75; }
.piano-window { width: 100%; overflow-x: auto; border-radius: 3px; overscroll-behavior-x: contain; background: #121513; }
.piano-bed { position: relative; width: 100%; height: clamp(68px, 9vw, 112px); }
.piano-key {
  position: absolute; top: 0; display: flex; align-items: end; justify-content: center;
  left: calc(var(--key-position) * 100% / 52); border-radius: 0 0 3px 3px;
  user-select: none;
}
.white-key {
  width: calc(100% / 52); height: 100%; padding-bottom: 3px;
  border: 1px solid #858980; font-size: .62rem; color: #30352e;
  background: linear-gradient(#dddcd2, #fffefa 45%, #eeeee6);
}
.black-key {
  z-index: 1; width: calc(62% / 52); height: 62%; transform: translateX(-50%);
  border: 1px solid #111612; background: linear-gradient(#181d19, #2a302b 78%, #141815);
}
.piano-key[data-hand="left"] { color: #132940; background: #76aff5; }
.piano-key[data-hand="right"] { color: #12301f; background: #79cda1; }
.piano-key[data-hand="both"] { color: #132940; background: linear-gradient(90deg, #76aff5 50%, #79cda1 50%); }
.piano-key[data-hand="midi"] { color: #36260b; background: #e4bc75; }
[hidden] { display: none !important; }
#error { margin: 1rem; }
@media (max-width: 900px) {
  .frame { width: calc(100% - 32px); }
  .workspace { grid-template-columns: 1fr; gap: 12px; }
  .controls { padding: 12px; }
  .controls h3 { margin-top: .8rem; }
  .keys { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .piano-bed { min-width: 832px; }
}
@media (max-width: 480px) {
  .frame { width: calc(100% - 20px); }
  .masthead { min-height: 56px; }
  h1 { margin-bottom: 1.25rem; }
  .notation { padding: .125rem; }
  .sheet-header { padding: 11px 12px; }
  .study { padding-inline: 12px; }
  .mode-switch { padding-inline: 12px; }
  .study-tempo { order: 1; flex-basis: 100%; }
}

#current-plan { color: var(--accent); font-size: .85rem; margin-inline-start: auto; margin-inline-end: 1rem; }
.score-locked::after { content: '🔒'; display: inline-block; margin-inline-start: .2em; font-size: .62em; }
#locked-score h3 { color: var(--accent); }
#dev-plans:not(:empty) { display: grid; gap: .5rem; margin-top: 1rem; font-size: .9rem; }
#dev-plans select { max-width: 100%; color: inherit; background: #272e28; font: inherit; padding: .4rem; }

#license-panel { margin-top: 1.2rem; padding-top: .8rem; border-top: 1px solid #454d43; }
#license-form:not([hidden]) { display: grid; gap: .45rem; }
#license-panel input, #license-panel select { width: 100%; min-width: 0; padding: .45rem; border: 1px solid #596455; border-radius: .3rem; color: inherit; background: #272e28; font: inherit; }
#license-panel a { display: inline-block; margin-top: .6rem; color: var(--accent); }
#license-panel [hidden] { display: none; }
#license-status { margin-bottom: 0; font-size: .85rem; }
