:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #26312b;
  background: #ece9e1;
  font-synthesis: none;
  --paper: #f5f2eb;
  --line: #d9d5ca;
  --ink: #263a30;
  --accent: #a67b42;
  --muted: #65705f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; overflow: hidden; }
button, select, input { font: inherit; }
button, select { min-height: 36px; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, select:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid #b18952; outline-offset: 3px; }
button, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  padding: 8px 12px;
  font-size: 13px;
}
:where(button:not(.live-key)):hover:not(:disabled) { border-color: #a6b1a5; background: #e9ede5; }
select { width: 100%; max-width: 100%; padding-right: 22px; }
a { color: #63745f; text-underline-offset: 3px; }
.app-header {
  height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.brand { display: flex; align-items: baseline; gap: 18px; }
.brand strong { font-family: Georgia, serif; font-size: 24px; letter-spacing: .12em; font-weight: 400; }
.brand span { color: var(--muted); font-size: 12px; }
.reference-link { font-size: 12px; white-space: nowrap; }
main { display: grid; grid-template-columns: minmax(0, 1fr) 310px; height: calc(100dvh - 58px); min-height: 0; }
.stage-column { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-width: 0; min-height: 0; }
#view { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #313633; }
canvas { display: block; width: 100%; height: 100%; }
.scene-tools { display: flex; flex-wrap: wrap; gap: 5px; padding: 9px 16px; background: #e4e6dd; border-bottom: 1px solid #cbd1c4; }
.scene-tools button { pointer-events: auto; background: #f5f2ebed; border-color: #d8ded3; min-height: 32px; font-size: 12px; padding: 6px 11px; }
.scene-tools button[aria-pressed="true"] { background: #263a30; color: #f6f4e9; border-color: #6a826e; }
.scene-footer { position: absolute; bottom: 16px; left: 20px; right: 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; color: #edece1; pointer-events: none; }
.scene-footer p { margin: 0; font-size: 12px; line-height: 1.5; }
.scene-footer > div, #quality-state { padding: 5px 8px; border-radius: 5px; background: #18221bd6; }
.scene-footer small { display: none; }
#quality-state { font-size: 11px; color: #d4ddcf; white-space: nowrap; }
.panel { min-height: 0; overflow: auto; padding: 20px; background: var(--paper); border-left: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: #c0c5b8 transparent; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; background: #e6e8df; border-radius: 10px; gap: 3px; margin-bottom: 18px; }
.mode-switch button { border: 0; background: transparent; font-size: 13px; }
.mode-switch button[aria-pressed="true"] { background: #fffdf8; box-shadow: 0 1px 4px #263a3014; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.panel-section { margin-top: 19px; padding-top: 17px; border-top: 1px solid var(--line); }
.panel-heading { margin: 0 0 11px; font-weight: 500; font-size: 13px; color: #63715f; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; font-size: 13px; }
.control-row select { width: 134px; }
.range-label { display: flex; align-items: center; justify-content: space-between; font-size: 12px; margin: 0 0 5px; gap: 8px; }
output { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; }
input[type="range"] { display: block; width: 100%; height: 22px; margin: 0; accent-color: var(--accent); }
.primary { background: var(--ink); color: #fffaf0; border-color: var(--ink); }
.primary:hover:not(:disabled) { background: #36513e; border-color: #36513e; }
#live-enable { width: 100%; }
#live-status { margin: 11px 0 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }
#live-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; background: #b3a989; }
#live-status[data-state="ready"]::before { background: #699269; }
.player { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fcfaf4; }
.player select { border: 0; padding-left: 0; background: transparent; font-family: Georgia, serif; font-size: 18px; min-height: 32px; }
#piece-composer { margin: 2px 0 14px; font-size: 11px; line-height: 1.4; color: var(--muted); }
.player-actions { display: flex; gap: 7px; margin: 12px 0 16px; }
#live-song { flex: 1; }
#live-song::before { content: "▶"; font-size: 10px; margin-right: 8px; }
#live-song[data-playing="true"]::before { content: "Ⅱ"; }
#live-stop { padding-inline: 13px; }
.buttons { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.cycle-select { display: block; font-size: 12px; margin-bottom: 12px; }
.cycle-select select { margin-top: 7px; }
#time { margin-top: 12px; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.55; margin: 12px 0 0; }
.pedal-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 25px; padding: 11px 24px 10px; background: #e4e5dc; border-top: 1px solid #c9cec1; }
.pedal-strip .range-label { color: #42523e; }
.pedal-strip output { color: #5f6c56; }
.keyboard-dock { background: #202c25; color: #cad4c5; padding-top: 7px; min-width: 0; }
.keyboard-caption { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 18px 7px; font-size: 11px; }
.keyboard-caption span:last-child { color: #94a490; }
#key-scroll { overflow-x: auto; scrollbar-width: thin; scrollbar-color: #7c8a75 #26392b; padding: 0 5px 5px; }
#live-keys { position: relative; min-width: 1040px; height: 76px; touch-action: none; }
.live-key { position: absolute; top: 0; transform: translateX(-50%); display: flex; align-items: flex-end; justify-content: center; padding: 0 0 5px; border-radius: 0 0 3px 3px; font-size: 11px; min-height: 0; }
.live-key.white { height: 76px; background: linear-gradient(#e7e2d4, #f9f6ec 65%, #e4decf); color: #6d7566; border: 1px solid #a8ad9e; box-shadow: inset 0 -3px #cbc7b7; }
.live-key.black { z-index: 2; height: 49px; background: linear-gradient(90deg, #222c27, #424c42 70%, #17241b); color: #c5cebd; border: 1px solid #152016; box-shadow: 1px 2px 3px #0006, inset 0 -3px #0f1d12; }
.live-key.white[aria-pressed="true"] { background: #d8c49d; box-shadow: inset 0 3px 5px #75664944; }
.live-key.black[aria-pressed="true"] { background: #9e8458; color: #fffaf0; }
.live-key:disabled { opacity: 1; }
details { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; color: #737d6c; font-size: 11px; line-height: 1.6; }
summary { cursor: pointer; font-size: 12px; color: #586951; }
details p { margin: 10px 0; }
.metric { display: flex; justify-content: space-between; gap: 10px; }
#anatomy-card { border-left: 2px solid #c3985a; padding-left: 12px; margin-top: 15px; }
#anatomy-card h2 { margin: 6px 0 12px; font-family: Georgia, serif; font-size: 19px; font-weight: 400; line-height: 1.25; }
#anatomy-card p { font-size: 12px; line-height: 1.6; margin: 9px 0; }
#anatomy-card .anatomy-location { color: #746349; font-size: 11px; }
#anatomy-card .hint, #anatomy-source { font-size: 11px; }
#anatomy-missing { color: #884c28; }
#anatomy-feedback:empty { display: none; }
.study-tabs { margin-top: 20px; }
.cycle-navigation { display: flex; justify-content: space-between; gap: 12px; }
#cycle-phase { font-family: Georgia, serif; font-weight: 400; font-size: 19px; line-height: 1.25; margin: 17px 0 9px; }
#cycle-description { font-size: 12px; line-height: 1.6; margin: 0; }
.cycle-metrics { margin: 15px 0; font-size: 12px; line-height: 1.6; }
.cycle-metrics > div { display: flex; justify-content: space-between; gap: 10px; margin: 5px 0; }
.cycle-metrics dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
#cycle-warning { font-size: 12px; color: #884c28; line-height: 1.5; }
#cycle-plot { display: block; width: 100%; height: auto; margin-top: 12px; touch-action: pan-y; cursor: crosshair; }
#cycle-plot:focus-visible { outline: 2px solid #b18952; outline-offset: 3px; }
#cycle-plot text { font-family: "Segoe UI", Arial, sans-serif; font-size: 10px; fill: #52624e; }
.plot-grid { fill: none; stroke: #d2d7ca; stroke-width: .7; }
.plot-key, .plot-gap { fill: none; stroke-width: 1.2; stroke-linejoin: round; }
.plot-key { stroke: #3e6248; }
.plot-gap { stroke: #a67b42; }
.plot-cursor { stroke: #8e4c37; stroke-width: 1; stroke-dasharray: 2 2; }
.cycle-force-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 11px; }
.cycle-force-table th { text-align: left; font-weight: 400; }
.cycle-force-table td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cycle-force-table th, .cycle-force-table td { padding: 6px 3px; border-bottom: 1px solid #e0ded6; }
.cycle-force-table tr[data-active="true"] { background: #e6eadf; color: #31513a; }
.cycle-export { margin-top: 18px; width: 100%; }
@media (max-width: 1050px) {
  main { grid-template-columns: minmax(0, 1fr) 274px; }
  .panel { padding: 16px; }
  .pedal-strip { gap: 16px; padding-inline: 16px; }
  .scene-tools { top: 12px; left: 12px; right: 12px; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .app-header { height: 54px; padding-inline: 15px; }
  .brand strong { font-size: 21px; }
  .brand span { display: none; }
  main { display: flex; flex-direction: column; height: auto; }
  .stage-column { display: block; }
  #view { height: clamp(340px, 52vh, 480px); }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 18px; }
  .pedal-strip { gap: 12px; padding: 10px 13px; }
  .pedal-strip .range-label { font-size: 11px; }
  .scene-footer { left: 14px; right: 14px; bottom: 12px; }
  .scene-footer small { display: none; }
  .keyboard-caption { padding-inline: 12px; }
  .keyboard-caption span:last-child { display: none; }
}
@media (pointer: coarse) {
  button, select { min-height: 44px; }
  .scene-tools button { min-height: 40px; }
  .live-key { min-height: 0; }
}
