:root {
  color-scheme: light;
  --bg: #c5c7ca; --sandbox: #dfe0e2; --ink: #30343b; --secondary: #616771;
  --line: #c5c8cd; --accent: #607fab; --accent-dark: #45648d; --accent-light: #c6d4e6;
  --surface: #e5e6e8; --chip: #d0d3d7;
  font-family: Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size: 16px; font-synthesis: none;
}
* { box-sizing:border-box; -webkit-user-select:none; user-select:none; -webkit-tap-highlight-color:transparent; }
*:focus,*:focus-visible { outline:none!important; }
::selection { background:transparent; }
body { margin:0; background:var(--bg); color:var(--ink); -webkit-font-smoothing:antialiased; }
button,input,select { font:inherit; color:inherit; }
button { cursor:pointer; touch-action:manipulation; }
button:disabled { cursor:default; }
button,a,input,select { -webkit-tap-highlight-color:transparent; }
a { color:inherit; }
.icon-defs { position:absolute; width:0; height:0; overflow:hidden; }
.icon { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.65; stroke-linecap:round; stroke-linejoin:round; flex-shrink:0; }
.app { width:calc(100% - 16px); height:calc(100svh - 16px); min-height:660px; margin:8px; padding:12px; background:#cfd1d4; border-radius:22px; display:flex; flex-direction:column; position:relative; }
.header { position:absolute; top:24px; right:24px; z-index:10; height:36px; display:flex; align-items:center; justify-content:flex-end; }
.header-actions { display:flex; align-items:center; gap:12px; }
.control,.icon-button { border:1px solid #c4c7cc; background:#e5e6e8; border-radius:8px; display:inline-flex; align-items:center; justify-content:center; gap:9px; height:36px; font-size:14px; font-weight:450; transition:background .12s,border-color .12s; }
.control:hover,.icon-button:hover { background:#eceef0; border-color:#b4b9c1; }
.control:active,.icon-button:active { background:#cbd0d6; }
.control { padding:0 12px; }
.icon-button { width:36px; padding:0; }
.chevron { width:16px; height:16px; margin-left:auto; color:var(--secondary); }
.audio-control,.settings-control { position:relative; }
.audio-control>.icon-button,.settings-button { background:transparent; border-color:transparent; }
.audio-control>.icon-button:hover,.settings-button:hover,.settings-button[aria-expanded=true] { background:#d2d5da; border-color:#c6c9ce; }
.volume-setting { display:grid; gap:14px; padding:4px 0 9px; }
.setting-row { display:flex; align-items:center; justify-content:space-between; gap:16px; font-size:14px; }
.label-setting { min-height:40px; cursor:pointer; }
.switch { appearance:none; -webkit-appearance:none; width:34px; height:20px; margin:0; flex:none; border:0; border-radius:12px; background:#c7ccd2; position:relative; cursor:pointer; transition:background .12s; }
.switch::after { content:''; position:absolute; top:3px; left:3px; width:14px; height:14px; border-radius:50%; background:#fff; box-shadow:0 1px 2px #30374020; transition:transform .12s; }
.switch:checked { background:#626b78; }
.switch:checked::after { transform:translateX(14px); }
#volume-value { font-size:12px; color:var(--secondary); font-variant-numeric:tabular-nums; }
#volume { appearance:none; -webkit-appearance:none; width:100%; height:4px; margin:0; border-radius:4px; background:linear-gradient(to right,#707783 var(--volume,65%),#d0d4da var(--volume,65%)); cursor:pointer; }
#volume::-webkit-slider-thumb { appearance:none; width:15px; height:15px; border:1px solid #a8aeb8; border-radius:50%; background:#fbfbfc; box-shadow:0 1px 3px #2222; }
#volume::-moz-range-thumb { width:15px; height:15px; border:1px solid #a8aeb8; border-radius:50%; background:#fbfbfc; }
main { flex:1; min-height:0; display:grid; grid-template-rows:clamp(156px,19svh,220px) minmax(220px,1fr) clamp(230px,30svh,310px); gap:12px; }
.chord-section,.staff-panel,.circle-panel,.instrument { background:var(--sandbox); border-radius:14px; }
.chord-section { min-width:0; padding:18px 100px; display:flex; align-items:center; flex-direction:column; justify-content:center; text-align:center; position:relative; gap:16px; }
.chord-section h1 { font-size:54px; font-weight:500; letter-spacing:-2px; line-height:1.05; margin:0; height:59px; display:flex; align-items:center; justify-content:center; }
.chord-section h1.long-chord { font-size:44px; }
.chord-section h1 .chord-suffix { font-size:.64em; letter-spacing:-1px; margin-left:2px; align-self:flex-start; margin-top:4px; }
.chord-notes { display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:center; min-height:45px; font-size:24px; color:#4b535f; }
.chord-notes:empty { display:none; }
.chord-notes span { min-width:45px; height:45px; padding:0 12px; border-radius:8px; background:var(--chip); display:flex; align-items:center; justify-content:center; line-height:1; }
.chord-section.retained h1 { color:#626975; }
.chord-section.retained .chord-notes { color:#69717e; }
.chord-section.retained .chord-notes span { background:#d4d6da; }
.theory { min-height:0; min-width:0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:minmax(0,1fr); gap:12px; }
.staff-panel,.circle-panel { position:relative; min-width:0; min-height:0; padding:24px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.staff { height:100%; width:100%; max-width:1100px; max-height:640px; min-height:0; display:flex; align-items:center; justify-content:center; }
.staff svg { width:100%; height:100%; max-height:100%; overflow:hidden; }
.circle { display:block; height:100%; width:100%; max-width:650px; max-height:650px; overflow:hidden; }
.circle .circle-node circle { fill:var(--sandbox); stroke:#c5c9d0; transition:fill .08s,stroke .08s; }
.circle .circle-node text { font:17px Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; fill:#59616d; }
.circle .circle-node.active circle { fill:#cbd8e9; stroke:#a2b6d1; }
.circle .circle-node.active text { fill:#385b88; font-weight:550; }
.circle .circle-node.root circle { fill:var(--accent); stroke:var(--accent); }
.circle .circle-node.root text { fill:white; }
.circle .circle-node.sustained circle { fill:transparent; stroke:#7f99bc; stroke-width:1.8; }
.circle .circle-node.sustained text { fill:#5c779c; }
.circle .circle-node.root.sustained circle { stroke:#587aa8; stroke-width:2.4; }
.instrument { display:flex; flex-direction:column; min-height:0; min-width:0; position:relative; overflow:hidden; }
.instrument-status { position:absolute; top:8px; left:10px; z-index:3; pointer-events:none; font-size:12px; color:var(--secondary); display:flex; align-items:center; gap:12px; }
.sustain-status { display:inline-flex; align-items:center; gap:6px; }
.sustain-dot { width:6px; height:6px; border:1.5px solid #7794ba; border-radius:50%; }
.instrument-scroll { overflow-x:auto; overflow-y:hidden; flex:1; min-height:0; display:flex; scrollbar-width:thin; scrollbar-color:#a6adb7 transparent; border-radius:14px; scroll-behavior:auto; }
.instrument-surface { min-width:1100px; width:100%; flex-shrink:0; display:flex; flex-direction:column; }
.roll { min-height:72px; flex:1; position:relative; background:linear-gradient(to bottom,#d9dce0,#d1d5db); border:1px solid #cbd0d7; border-bottom:0; border-radius:6px 6px 0 0; overflow:hidden; }
#roll-canvas { width:100%; height:100%; display:block; position:absolute; inset:0; }
.instrument-surface.shift-release,.instrument-surface.shift-release .piano-key { cursor:crosshair; }
.instrument-surface.releasing { user-select:none; touch-action:none; }
.keyboard { height:132px; flex-shrink:0; position:relative; box-shadow:0 -1px 0 #3a3d43,0 3px 5px #2221; isolation:isolate; background:#a9adb3; border-radius:0 0 6px 6px; }
.piano-key { position:absolute; top:0; padding:0; border:0; border-radius:0 0 4px 4px; transition:background .065s,box-shadow .065s; display:flex; align-items:flex-end; justify-content:center; }
.piano-key.white { height:100%; z-index:1; background:linear-gradient(#f8f8f9 0%,#fcfcfd 75%,#f5f5f7 94%); border-right:1px solid #bfc2c8; border-bottom:4px solid #cfd1d6; box-shadow:inset 1px 0 #fff8; }
.piano-key.white:hover { background:#e6ebf1; }
.piano-key.black { height:63%; z-index:2; background:linear-gradient(95deg,#3d4047,#30333a 80%); border:1px solid #292c31; border-top:0; border-bottom:5px solid #1f2227; box-shadow:1px 3px 3px #1b20242b; }
.piano-key.black:hover { background:#454c58; }
.piano-key.white.active { background:linear-gradient(#b9cbe2,#cbd9eb); border-bottom-color:#8da8cd; box-shadow:inset 0 2px 4px #526b8c18; }
.piano-key.black.active { background:linear-gradient(#6686b3,#7996bd); border-color:#48648e; border-bottom-color:#42608b; }
.piano-key.white.sustained { background:#e3eaf3; box-shadow:inset 0 0 0 2px #9db3d0; border-bottom-color:#b2c3d9; }
.piano-key.black.sustained { background:#566579; box-shadow:inset 0 0 0 2px #98b0d0; border-bottom-color:#405168; }
.key-label { font-size:11px; color:#767b85; font-weight:450; position:absolute; bottom:12px; line-height:1; pointer-events:none; white-space:nowrap; }
.piano-key.black .key-label { font-size:10px; color:#e7edf6; bottom:8px; }
.piano-key.active .key-label { color:#3d5c84; font-weight:550; }
.piano-key.black.active .key-label { color:#fff; }
.key-shortcut { position:absolute; bottom:34px; font-size:12px; line-height:1; color:#626b79; pointer-events:none; }
.piano-key.black .key-shortcut { bottom:27px; color:#c7cdd6; }
.piano-key.active .key-shortcut { color:#375982; }
.piano-key.black.active .key-shortcut { color:#fff; }
.keyboard.labels-hidden .key-label,.keyboard.labels-hidden .key-shortcut { display:none; }
.keyboard-status { position:absolute; top:8px; right:10px; z-index:3; pointer-events:none; font-size:13px; color:var(--secondary); background:#dfe2e7ed; padding:6px 9px; border-radius:6px; }
.octave-sub { font-size:.78em; vertical-align:baseline; position:relative; top:1px; margin-left:1px; }
.popover { position:absolute; z-index:10; right:0; top:46px; width:290px; max-height:calc(100svh - 110px); overflow-y:auto; padding:20px; background:#eef0f2; border:1px solid #c5c9d0; border-radius:12px; box-shadow:0 10px 35px #252b3820; display:flex; flex-direction:column; gap:13px; }
.popover h2 { font-size:14px; font-weight:550; }
.connect-button { width:100%; height:38px; }
.popover p { font-size:13px; line-height:1.5; color:var(--secondary); margin:0; }
.popover p.error { color:#8c4948; }
.computer-settings { display:flex; flex-direction:column; gap:10px; font-size:13px; color:var(--secondary); }
kbd { font-family:inherit; }
.computer-settings kbd,.guide-shortcuts kbd { display:inline-flex; align-items:center; justify-content:center; width:23px; height:23px; border:1px solid #b7bec7; border-radius:4px; background:#e8eaed; font-size:12px; }
.computer-settings span>kbd:last-of-type { margin-right:7px; }
.help-dialog { width:min(510px,calc(100% - 32px)); max-height:calc(100svh - 32px); overflow-y:auto; border:1px solid #bfc4cd; border-radius:17px; padding:24px; background:var(--sandbox); color:var(--ink); box-shadow:0 15px 60px #2026322b; }
.help-dialog::backdrop { background:#363d4945; backdrop-filter:blur(3px); }
.dialog-header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:24px; }
.dialog-header h2 { font-size:20px; letter-spacing:-.4px; font-weight:550; margin:0; }
.guide-actions { display:flex; align-items:center; gap:14px; }
.license-link { font-size:12px; text-decoration:none; color:var(--secondary); }
.license-link:hover { text-decoration:underline; text-underline-offset:3px; }
.guide-grid { display:grid; grid-template-columns:1fr 1fr; gap:30px 20px; }
.guide-step { text-align:center; min-width:0; }
.guide-step svg { width:100%; height:106px; margin-bottom:12px; }
.guide-line { fill:none; stroke:#656e7b; stroke-width:1.5; stroke-linejoin:round; stroke-linecap:round; }
.guide-black { fill:#626a76; stroke:#626a76; }
.guide-selected { fill:#a6b9d1; stroke:none; }
.guide-keycap { fill:#e8eaed; stroke:#a7afbb; stroke-width:1.4; }
.guide-step svg text { font:13px Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; fill:#59616e; }
.guide-step svg .guide-key-text { font-size:23px; }
.guide-step h3 { font-size:14px; font-weight:550; margin:0 0 6px; }
.guide-step p { font-size:12px; line-height:1.4; color:var(--secondary); margin:0; }
.guide-computer { grid-column:1/-1; }
.guide-keyboard { position:relative; max-width:360px; margin:0 auto 18px; }
.guide-white-keys { display:flex; gap:2px; }
.guide-white-keys kbd { width:10%; height:88px; padding-bottom:12px; display:flex; align-items:flex-end; justify-content:center; border:1px solid #a7afbb; border-radius:0 0 5px 5px; background:#e8eaed; font-size:13px; color:#59616e; }
.guide-black-keys kbd { position:absolute; left:calc(var(--key)*10% - 3.2%); top:0; width:6.4%; height:48px; padding-bottom:9px; display:flex; align-items:flex-end; justify-content:center; border-radius:0 0 4px 4px; background:#626a76; color:#fff; font-size:12px; }
.guide-shortcuts { display:flex; flex-wrap:wrap; justify-content:center; gap:10px 18px; margin-top:15px; font-size:12px; color:var(--secondary); }
.guide-shortcuts>span { white-space:nowrap; }
.sr-only { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
[hidden] { display:none!important; }
@media(min-height:850px) and (min-width:761px) {
  .keyboard { height:150px; }
}
@media(max-height:760px) and (min-width:761px) {
  .keyboard { height:122px; }
}
@media(max-width:760px) {
  .app { width:calc(100% - 12px); height:calc(100svh - 12px); margin:6px auto; min-height:640px; padding:10px; border-radius:18px; }
  .header { top:18px; right:18px; }
  .header-actions { gap:6px; }
  main,.theory { gap:10px; }
  .chord-section h1 { font-size:48px; }
  .chord-notes { font-size:22px; gap:7px; }
  .chord-notes span { min-width:43px; height:43px; }
  .staff-panel,.circle-panel { padding:16px; }
  .instrument-surface { min-width:1404px; }
  .keyboard { height:125px; }
  .key-label { font-size:12px; }
  .piano-key.black .key-label { font-size:11px; }
  .popover { right:0; }
}
@media(max-width:600px) {
  .app { height:auto; min-height:calc(100svh - 12px); padding:10px; }
  .header-actions { gap:5px; }
  main { grid-template-rows:minmax(174px,auto) auto 248px; }
  .chord-section { padding:44px 16px 18px; gap:12px; }
  .chord-notes { min-height:38px; }
  .chord-notes span { min-width:38px; height:38px; padding:0 10px; }
  .theory { grid-template-columns:1fr; grid-template-rows:220px 280px; }
  .popover { width:280px; right:0; }
  .help-dialog { padding:20px 17px; }
  .guide-grid { gap:24px 12px; }
  .guide-step p { font-size:11px; }
  .guide-actions { gap:10px; }
}
@media(pointer:coarse) {
  .instrument-surface { min-width:1664px; }
  .control,.icon-button { min-height:40px; }
  .piano-key.black { min-width:20px; }
  #volume { height:6px; }
  #volume::-webkit-slider-thumb { width:22px; height:22px; }
}
@media(prefers-reduced-motion:reduce) {
  *,*:before,*:after { transition:none!important; scroll-behavior:auto!important; }
}

.popover h2 { margin:0; }
.midi-devices { list-style:none; padding:0; margin:0; font-size:14px; color:var(--ink); display:grid; gap:7px; }
.guide-button { width:100%; }
