:root {
  --paper: #f4f0e8;
  --paper-deep: #e9e3d8;
  --ink: #152633;
  --ink-soft: #657078;
  --coral: #e65f4e;
  --coral-dark: #c94739;
  --mint: #83bdb2;
  --mint-strong: #3f9184;
  --mint-strong-dark: #286f65;
  --white: #fffdf8;
  --line: rgba(21, 38, 51, 0.16);
  --shadow: 0 24px 80px rgba(31, 45, 50, 0.1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 10%, rgba(131, 189, 178, 0.13), transparent 23rem),
    var(--paper);
  font-family: "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, select { font: inherit; }
button { color: inherit; }

.site-header {
  width: min(1380px, calc(100% - 64px));
  height: 56px;
  margin: auto;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 13px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-family: "Outfit", sans-serif;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.brand-mark { display: flex; width: 28px; height: 30px; gap: 3px; align-items: stretch; }
.brand-mark i { width: 6px; border-radius: 1px; background: var(--coral); transform: skewY(-28deg); }
.brand-mark i:nth-child(2) { background: var(--ink); }
.brand-mark i:nth-child(3) { background: var(--mint); }
.brand-sub { margin: 0 0 0 22px; color: var(--ink-soft); font: 12px "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.help-button { margin-left: auto; border: 0; background: transparent; cursor: pointer; font-size: 13px; letter-spacing: .05em; }
.help-button span { display: inline-grid; width: 25px; height: 25px; margin-right: 8px; place-items: center; border: 1px solid var(--ink); border-radius: 50%; font: 500 13px "DM Mono", monospace; }
.site-header .help-button { margin-left: 12px; }
.site-header .shortcut-button { margin-left: auto; }

main { width: min(1380px, calc(100% - 64px)); margin: auto; }

.help-panel {
  position: relative;
  margin: -24px 0 32px auto;
  max-width: 540px;
  padding: 22px 58px 22px 24px;
  border-left: 4px solid var(--mint);
  background: var(--white);
  box-shadow: 0 12px 35px rgba(31,45,50,.08);
  font-size: 13px;
}
.help-panel p { margin: 7px 0 0; color: var(--ink-soft); line-height: 1.8; }
.help-panel button { position: absolute; top: 12px; right: 14px; border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: 12px; }

.shortcut-panel { position: fixed; z-index: 50; top: 70px; right: max(20px, calc((100vw - 1380px) / 2)); width: min(650px, calc(100vw - 30px)); padding: 18px; border: 1px solid var(--line); border-top: 3px solid var(--coral); border-radius: 4px; background: rgba(255,253,248,.98); box-shadow: 0 24px 70px rgba(21,38,51,.2); backdrop-filter: blur(12px); }
.shortcut-panel-heading { display: flex; align-items: center; justify-content: space-between; }
.shortcut-panel-heading small { display: block; color: var(--coral); font: 500 8px "DM Mono", monospace; letter-spacing: .16em; }
.shortcut-panel-heading strong { display: block; margin-top: 2px; font-size: 14px; }
.shortcut-panel-heading button { width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--paper-deep); cursor: pointer; }
.shortcut-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 15px; }
.shortcut-columns section + section { padding-left: 18px; border-left: 1px solid var(--line); }
.shortcut-columns h3 { margin: 0 0 8px; font-size: 9px; }
.shortcut-columns p { display: flex; min-height: 25px; margin: 0; align-items: center; gap: 4px; color: var(--ink-soft); font-size: 8px; }
.shortcut-columns p span { margin-right: 5px; }
.shortcut-columns p > small { margin-left: auto; color: #939894; font-size: 6px; }
kbd { display: inline-grid; min-width: 22px; height: 20px; padding: 0 5px; place-items: center; border: 1px solid #c7c4ba; border-bottom-width: 2px; border-radius: 3px; background: white; color: var(--ink); font: 500 8px "DM Mono", monospace; box-shadow: 0 1px 0 white inset; }
.shortcut-toast { position: fixed; z-index: 60; right: 24px; bottom: 24px; max-width: calc(100vw - 48px); padding: 9px 14px; border-radius: 4px; background: var(--ink); color: white; box-shadow: 0 8px 25px rgba(21,38,51,.22); opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .16s ease, transform .16s ease; font: 500 10px "DM Mono", monospace; }
.shortcut-toast.visible { opacity: 1; transform: translateY(0); }

.workspace { display: grid; grid-template-columns: 360px 1fr; height: calc(100svh - 56px); min-height: 640px; max-height: 840px; border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow); }
.controls-panel { padding: 18px 22px; border-right: 1px solid var(--line); background: rgba(233, 227, 216, .3); overflow-y: auto; }
.step-heading { display: flex; align-items: center; gap: 14px; }
.step-heading > span { font: 500 12px "DM Mono", monospace; color: var(--coral); }
.step-heading small, .chord-name-wrap small { display: block; color: var(--ink-soft); font: 500 10px "DM Mono", monospace; letter-spacing: .15em; }
.step-heading h2 { margin: 3px 0 0; font-size: 16px; letter-spacing: .03em; }

.field-group { margin-top: 14px; }
.field-group > label { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 600; }
.root-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.root-button {
  min-height: 32px;
  padding: 5px 2px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  font: 500 13px "DM Mono", monospace;
  transition: .18s ease;
}
.root-button small { font-size: 7px; }

.root-selector-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.root-selector-heading > label { font-size: 10px; font-weight: 600; }
.root-view-tabs, .circle-order-tabs { display: flex; padding: 2px; border-radius: 4px; background: var(--paper-deep); }
.root-view-tabs button, .circle-order-tabs button { height: 25px; padding: 0 10px; border: 0; border-radius: 3px; background: transparent; cursor: pointer; font-size: 8px; }
.root-view-tabs button.active, .circle-order-tabs button.active { color: white; background: var(--ink); }
.circle-order-tabs { width: fit-content; margin: 7px 0 0 auto; }
.circle-order-tabs[hidden] { display: none; }
.root-selector { margin-top: 7px; }

.root-piano { position: relative; display: flex; height: 69px; padding: 0 3px 3px; border-radius: 3px 3px 5px 5px; background: var(--ink); overflow: hidden; }
.root-piano-key { cursor: pointer; }
.root-piano-key.white { position: relative; flex: 1; border: 1px solid #ccc8be; border-top: 0; border-radius: 0 0 3px 3px; background: var(--white); color: var(--ink); }
.root-piano-key.white + .root-piano-key.white { margin-left: -1px; }
.root-piano-key.black { position: absolute; z-index: 2; top: 0; width: 8.6%; height: 60%; transform: translateX(-50%); border: 1px solid #0b151b; border-radius: 0 0 3px 3px; background: var(--ink); color: white; box-shadow: 0 3px 4px rgba(0,0,0,.25); }
.root-piano-key span { position: absolute; right: 0; bottom: 5px; left: 0; font: 500 8px "DM Mono", monospace; text-align: center; }
.root-piano-key.black span { bottom: 4px; font-size: 6px; }
.root-piano-key.key-tonic { background: var(--coral); color: white; }
.root-piano-key.chord-root::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 1px var(--white); }
.root-piano-key.black.chord-root::after { right: 3px; bottom: 3px; }
.diatonic-heading { margin: 6px 0 4px; color: var(--ink-soft); font: 500 7px "DM Mono", monospace; letter-spacing: .1em; }
.diatonic-chords { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.diatonic-chords button { position: relative; min-width: 0; height: 37px; padding: 3px 1px; border: 1px solid var(--line); border-radius: 3px; background: var(--white); cursor: pointer; overflow: hidden; }
.diatonic-chords button small, .diatonic-chords button span { display: block; overflow: hidden; font: 500 6px "DM Mono", monospace; text-overflow: ellipsis; }
.diatonic-chords button span { margin-top: 3px; color: var(--ink-soft); font-size: 7px; }
.diatonic-chords button.active { color: white; border-color: var(--coral); background: var(--coral); }
.diatonic-chords button.active span { color: white; }

.root-selector.circle-view { min-height: 236px; }
.chord-circle { position: relative; width: 236px; height: 236px; margin: -3px auto 0; border: 1px solid var(--line); border-radius: 50%; background: radial-gradient(circle, var(--white) 0 25%, rgba(131,189,178,.11) 26% 50%, rgba(233,227,216,.45) 51% 73%, transparent 74%); }
.circle-note { position: absolute; z-index: 2; top: 50%; left: 50%; display: grid; place-items: center; border: 1px solid #aaa9a2; border-radius: 50%; background: var(--white); cursor: pointer; box-shadow: 0 2px 5px rgba(21,38,51,.1); }
.circle-note.outer { width: 31px; height: 31px; transform: translate(-50%,-50%) rotate(var(--angle)) translateY(-96px) rotate(var(--counter)); }
.circle-note.inner { width: 27px; height: 27px; transform: translate(-50%,-50%) rotate(var(--angle)) translateY(-63px) rotate(var(--counter)); background: #e1efeb; }
.circle-note span { font: 500 7px "DM Mono", monospace; }
.circle-note.inner span { font-size: 6px; }
.circle-note:hover { z-index: 3; border-color: var(--coral); }
.circle-note.active { z-index: 3; color: white; border-color: var(--coral-dark); background: var(--coral); box-shadow: 0 3px 8px rgba(230,95,78,.28); }
.circle-center { position: absolute; top: 50%; left: 50%; display: grid; width: 52px; height: 52px; transform: translate(-50%,-50%); place-items: center; align-content: center; border-radius: 50%; background: var(--ink); color: white; text-align: center; }
.circle-center small { font: 5px "DM Mono", monospace; letter-spacing: .08em; }
.circle-center strong { max-width: 46px; margin-top: 2px; overflow: hidden; color: var(--coral); font: 600 12px "Outfit", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.circle-legend { display: flex; justify-content: center; gap: 14px; margin-top: 3px; color: var(--ink-soft); font: 6px "DM Mono", monospace; }
.circle-legend span { display: inline-flex; align-items: center; gap: 4px; }
.circle-legend i { display: inline-block; width: 7px; height: 7px; border: 1px solid #aaa9a2; border-radius: 50%; background: var(--white); }
.circle-legend i.inner { background: #e1efeb; }

.chord-builder { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--line); }
.builder-row { margin-top: 10px; }
.builder-row label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 10px; font-weight: 600; }
.builder-row label small { color: var(--ink-soft); font-size: 8px; font-weight: 400; }
.inline-builder { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; }
.choice-chips { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.choice-chips button { min-width: 0; height: 29px; padding: 0 5px; border: 1px solid var(--line); border-radius: 3px; background: var(--white); cursor: pointer; font: 500 9px "DM Mono", monospace; }
.choice-chips button:hover { border-color: var(--mint); }
.choice-chips button.active { color: white; border-color: var(--ink); background: var(--ink); }
.choice-chips.presets button.active { border-color: var(--coral); background: var(--coral); }
.extension-controls { display: grid; grid-template-columns: .85fr 2.15fr; gap: 4px; }
.core-extensions { min-width: 0; gap: 2px; }
.core-extensions button { padding: 0 2px; font-size: 8px; }
.tension-groups { display: grid; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.tension-group { display: grid; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; }
.tension-group button { min-width: 0; height: 29px; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: var(--white); cursor: pointer; font: 500 6px "DM Mono", monospace; }
.tension-group button:hover { border-color: var(--mint); }
.core-extensions button.active, .tension-group button.active { border-color: #4c968b; background: var(--mint); color: var(--ink); }
.chord-pad-group { margin-top: 8px; }
.chord-pad-group > label { display: flex; justify-content: space-between; margin-bottom: 3px; font-size: 9px; font-weight: 600; }
.chord-pad-group > label small { color: var(--ink-soft); font-size: 7px; font-weight: 400; }
.chord-pad { display: flex; flex-direction: column; gap: 2px; }
.chord-pad-row { display: grid; width: calc(100% - 7px); grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
.chord-pad-row + .chord-pad-row { margin-left: 7px; }
.chord-pad button { position: relative; min-width: 0; height: 25px; padding: 8px 1px 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 3px; background: var(--white); cursor: pointer; color: var(--ink-soft); font: 500 7px "DM Mono", monospace; }
.chord-pad button:hover { border-color: var(--mint); }
.chord-pad button.active { border-color: var(--coral); background: var(--coral); color: white; }
.shortcut-hint { position: absolute; top: 2px; right: 3px; display: block; min-width: 0; width: auto; height: auto; padding: 0; border: 0; background: transparent; box-shadow: none; color: currentColor; opacity: .4; font: 500 6px "DM Mono", monospace; line-height: 1; }
.diatonic-chords .shortcut-hint { right: 3px; }
.inversion-group { margin-top: 9px; }
.inversion-chips { grid-auto-flow: initial; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inversion-chips button { font-size: 8px; }
.root-button:hover { border-color: var(--coral); transform: translateY(-1px); }
.root-button.active { color: white; border-color: var(--coral); background: var(--coral); box-shadow: 0 5px 12px rgba(230, 95, 78, .22); }

.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; top: 50%; right: 14px; transform: translateY(-57%); pointer-events: none; }
select { width: 100%; height: 46px; appearance: none; padding: 0 40px 0 14px; border: 1px solid var(--line); border-radius: 4px; outline: none; background: var(--white); color: var(--ink); font-size: 13px; }
select:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(131, 189, 178, .16); }
.notation-toggle { display: flex; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); }
.notation-toggle button { flex: 1; height: 34px; border: 1px solid var(--line); border-right: 0; background: transparent; cursor: pointer; font-size: 11px; }
.notation-toggle button:first-child { border-radius: 4px 0 0 4px; }
.notation-toggle button:last-child { border-right: 1px solid var(--line); border-radius: 0 4px 4px 0; }
.notation-toggle button.active { color: white; border-color: var(--ink); background: var(--ink); }

.diagram-panel { display: flex; min-width: 0; min-height: 0; padding: 18px 22px 16px; flex-direction: column; overflow: hidden; }
.diagram-topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.rotation-control { display: flex; align-items: center; gap: 10px; }
.rotation-control > small { color: var(--ink-soft); font: 500 9px "DM Mono", monospace; letter-spacing: .12em; }
.rotation-tabs { display: flex; padding: 3px; border-radius: 5px; background: var(--paper-deep); }
.rotation-tabs button { min-width: 43px; height: 30px; padding: 0 8px; border: 0; border-radius: 3px; background: transparent; cursor: pointer; font: 500 10px "DM Mono", monospace; }
.rotation-tabs button.active { color: white; background: var(--ink); box-shadow: 0 2px 8px rgba(21,38,51,.16); }
.instrument-tabs { display: flex; padding: 4px; border-radius: 5px; background: var(--paper-deep); }
.instrument-tabs button { padding: 8px 14px; border: 0; border-radius: 3px; background: transparent; cursor: pointer; font-size: 11px; white-space: nowrap; }
.instrument-tabs button.active { background: var(--white); box-shadow: 0 2px 9px rgba(21,38,51,.08); font-weight: 600; }
.instrument-tabs.compact { flex-shrink: 0; }
.instrument-tabs.compact button { padding: 6px 9px; font-size: 9px; }

.chord-summary { display: grid; grid-template-columns: 105px 1fr auto; align-items: center; gap: 20px; margin-top: 12px; padding: 9px 14px; border: 1px solid var(--line); background: #f9f6ef; }
.chord-name { margin-top: 2px; color: var(--coral); font: 600 27px "Outfit", sans-serif; letter-spacing: -.03em; white-space: nowrap; }
.tone-list { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tone-chip { display: grid; min-width: 34px; height: 34px; padding: 3px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--white); font: 600 10px "DM Mono", monospace; }
.tone-chip.bass-tone { color: white; border-color: var(--mint-strong-dark); background: var(--mint-strong); box-shadow: 0 2px 7px rgba(40,111,101,.22); }
.tone-separator { color: #a8a8a2; }
.sound-button { display: inline-flex; align-items: center; gap: 10px; padding: 10px 13px; border: 0; background: transparent; cursor: pointer; color: var(--ink-soft); font-size: 11px; }
.sound-icon { display: flex; align-items: center; gap: 2px; height: 16px; }
.sound-icon i { display: block; width: 2px; height: 7px; background: var(--coral); }
.sound-icon i:nth-child(2) { height: 15px; }
.sound-button.playing .sound-icon i { animation: sound .55s ease-in-out infinite alternate; }
.sound-button.playing .sound-icon i:nth-child(2) { animation-delay: .15s; }
.sound-button.playing .sound-icon i:nth-child(3) { animation-delay: .3s; }
@keyframes sound { to { height: 15px; } }

.board-wrap { display: flex; min-height: 0; margin-top: 9px; flex: 1; flex-direction: column; }
.board-meta { display: flex; justify-content: space-between; color: var(--ink-soft); font: 10px "DM Mono", monospace; letter-spacing: .08em; }
.legend-dot { display: inline-block; width: 9px; height: 9px; margin: 0 5px 0 12px; border-radius: 50%; background: var(--mint); }
.legend-dot.bass { margin-left: 0; background: var(--mint-strong); box-shadow: inset 0 0 0 1px var(--mint-strong-dark); }
.legend-dot.alternative { background: #e1ece8; box-shadow: inset 0 0 0 1px #9dbdb5; }
.board-hint { margin: 13px 0 0; text-align: center; color: var(--ink-soft); font-size: 11px; }

.orientation-axis { display: none; }
.orientation-axis i { position: relative; width: 1px; height: 22px; background: var(--line); }
.orientation-axis i::before, .orientation-axis i::after { content: ""; position: absolute; top: -3px; width: 7px; height: 7px; border-top: 1px solid var(--ink-soft); border-left: 1px solid var(--ink-soft); }
.orientation-axis i::before { top: 0; left: -3px; transform: rotate(45deg); }
.orientation-axis i::after { top: auto; right: -3px; bottom: 0; transform: rotate(225deg); }
.orientation-axis.rotation-90, .orientation-axis.rotation-270 { gap: 9px; }
.orientation-axis.rotation-90 { flex-direction: row-reverse; }
.orientation-axis.rotation-180 { flex-direction: column-reverse; }
.orientation-axis.rotation-270 { flex-direction: row; }
.orientation-axis.rotation-90 i, .orientation-axis.rotation-270 i { width: 62px; height: 1px; }
.orientation-axis.rotation-90 i::before, .orientation-axis.rotation-270 i::before { top: -3px; left: 0; transform: rotate(-45deg); }
.orientation-axis.rotation-90 i::after, .orientation-axis.rotation-270 i::after { top: -3px; right: 0; bottom: auto; transform: rotate(135deg); }

.instrument-stage { display: flex; align-items: stretch; width: 100%; height: auto; min-height: 460px; flex: 1; border: 1px solid var(--line); border-radius: 6px; background: #f7f3eb; overflow: hidden; }
.instrument-stage.rotation-0 { flex-direction: row; }
.instrument-stage.rotation-90 { flex-direction: column; }
.instrument-stage.rotation-180 { flex-direction: row-reverse; }
.instrument-stage.rotation-270 { flex-direction: column-reverse; }
.hand-panel { display: flex; flex: 1 1 0; min-width: 0; padding: 9px; flex-direction: column; background: rgba(255,253,248,.7); }
.hand-heading { display: flex; min-height: 38px; align-items: center; justify-content: space-between; gap: 10px; }
.hand-heading small { display: block; margin-bottom: 3px; color: var(--coral); font: 500 9px "DM Mono", monospace; letter-spacing: .13em; }
.hand-heading strong { display: block; font-size: 12px; white-space: nowrap; }
.hand-board { display: flex; min-width: 0; min-height: 0; margin-top: 5px; flex: 1; align-items: center; justify-content: center; overflow: hidden; scrollbar-width: thin; scrollbar-color: var(--paper-deep) transparent; }
.hand-hint { min-height: 18px; margin: 4px 0 0; color: var(--ink-soft); text-align: center; font-size: 8px; line-height: 1.5; }
.bellows { display: flex; width: 24px; flex: 0 0 24px; justify-content: space-evenly; overflow: hidden; border-right: 1px solid rgba(21,38,51,.2); border-left: 1px solid rgba(21,38,51,.2); background: var(--ink); }
.bellows i { width: 1px; background: rgba(255,255,255,.22); }
.instrument-stage.rotation-90 .bellows, .instrument-stage.rotation-270 .bellows { width: 100%; height: 18px; flex: 0 0 18px; flex-direction: column; border: 0; border-top: 1px solid rgba(21,38,51,.2); border-bottom: 1px solid rgba(21,38,51,.2); }
.instrument-stage.rotation-90 .bellows i, .instrument-stage.rotation-270 .bellows i { width: 100%; height: 1px; }
.instrument-stage.rotation-90 .hand-panel, .instrument-stage.rotation-270 .hand-panel { min-height: 0; }
.instrument-stage.rotation-90 .hand-panel, .instrument-stage.rotation-270 .hand-panel { padding: 6px 9px; }
.instrument-stage.rotation-90 .hand-heading, .instrument-stage.rotation-270 .hand-heading { min-height: 32px; }
.instrument-stage.rotation-90 .hand-hint, .instrument-stage.rotation-270 .hand-hint { display: none; }

.piano { position: relative; display: flex; width: 100%; height: 150px; padding: 0 7px 7px; border-radius: 3px 3px 8px 8px; background: var(--ink); }
.piano.horizontal.axis-reversed { flex-direction: row-reverse; }
.white-key { position: relative; flex: 1; height: 100%; border: 1px solid #c8c6be; border-top: 0; border-radius: 0 0 5px 5px; background: linear-gradient(#fffef9, #ece9e0); cursor: pointer; }
.white-key + .white-key { margin-left: -1px; }
.black-key { position: absolute; z-index: 2; top: 0; width: 4.1%; height: 61%; transform: translateX(-50%); border: 1px solid #0c171e; border-radius: 0 0 4px 4px; background: linear-gradient(100deg, #20323c, #0c171e); box-shadow: 0 7px 7px rgba(0,0,0,.25); cursor: pointer; }
.key.active-tone { background: linear-gradient(#9accc3, #70b2a5); }
.key.active-bass { background: linear-gradient(#56a89a, #348a7d); }
.black-key.active-tone { background: linear-gradient(100deg, #9accc3, #5b9e92); }
.black-key.active-bass { background: linear-gradient(100deg, #59aa9c, #28766b); }
.key-note { position: absolute; left: 50%; bottom: 15px; transform: translateX(-50%); color: rgba(21,38,51,.78); font: 500 9px "DM Mono", monospace; }
.black-key .key-note { bottom: 10px; color: var(--white); }
.octave-label { position: absolute; z-index: 5; bottom: 5px; left: 50%; transform: translateX(-50%); color: #8a8b87; font: 8px "DM Mono", monospace; }

.piano.vertical { display: flex; width: clamp(145px, 34%, 170px); min-width: 145px; height: 100%; max-height: 570px; padding: 7px 7px 7px 0; flex-direction: column; border-radius: 8px 3px 3px 8px; }
.piano.vertical.axis-reversed { flex-direction: column-reverse; }
.piano.vertical .white-key { width: 100%; height: auto; min-height: 0; flex: 1; border: 1px solid #c8c6be; border-left: 0; border-radius: 0 5px 5px 0; }
.piano.vertical .white-key + .white-key { margin-top: -1px; margin-left: 0; }
.piano.vertical .black-key { top: auto; left: 0 !important; width: 61%; height: 4.1%; transform: translateY(-50%); border-radius: 0 4px 4px 0; background: linear-gradient(10deg, #20323c, #0c171e); }
.piano.vertical .black-key.active-tone { background: linear-gradient(10deg, #9accc3, #5b9e92); }
.piano.vertical .black-key.active-bass { background: linear-gradient(10deg, #59aa9c, #28766b); }
.piano.vertical .key-note { top: 50%; right: 12px; bottom: auto; left: auto; transform: translateY(-50%); }
.piano.vertical .black-key .key-note { right: 8px; bottom: auto; }
.piano.vertical .octave-label { top: 50%; right: 5px; bottom: auto; left: auto; transform: translateY(-50%); }

.button-board { position: relative; min-width: 650px; height: 150px; padding: 5px 0; background: linear-gradient(135deg, rgba(233,227,216,.55), rgba(255,253,248,.2)); border: 1px solid var(--line); border-radius: 5px; }
.button-board.horizontal { width: 100%; }
.button-board.horizontal.axis-reversed .button-row { flex-direction: row-reverse; padding-right: 5px; padding-left: 0; }
.button-board.horizontal.axis-reversed .button-row:nth-child(even) { padding-right: 28px; padding-left: 0; }
.button-row { position: relative; display: flex; height: 27px; gap: 13px; align-items: center; }
.button-row:nth-child(even), .button-row:nth-child(odd) { padding-left: 20px; }
.note-button { position: relative; display: grid; flex: 0 0 25px; height: 25px; place-items: center; border: 1px solid #aaa9a2; border-radius: 50%; background: linear-gradient(145deg, #fff, #dedbd2); box-shadow: 1px 2px 3px rgba(21,38,51,.12); color: #6d7273; font: 500 7px "DM Mono", monospace; cursor: pointer; }
.note-button.active-tone { color: var(--ink); border-color: #579d91; background: var(--mint); }
.note-button.active-bass { color: white; border-color: var(--mint-strong-dark); background: var(--mint-strong); box-shadow: 0 2px 6px rgba(40,111,101,.25); }
.row-label { position: absolute; right: 12px; color: #9a9d99; font: 9px "DM Mono", monospace; }

.button-board.vertical { display: flex; width: clamp(185px, 40%, 205px); min-width: 185px; height: 100%; max-height: 570px; padding: 7px 12px; justify-content: center; gap: 2px; }
.button-board.vertical .button-row { width: 30px; height: auto; padding: 0; flex-direction: column; gap: 6px; justify-content: center; }
.button-board.vertical.axis-reversed .button-row { flex-direction: column-reverse; }
.button-board.vertical .note-button { flex: 0 0 24px; width: 24px; height: 24px; transform: translateY(var(--grid-offset)); }
.button-board.vertical.axis-reversed .note-button { transform: translateY(calc(var(--grid-offset) * -1)); }
.button-board.vertical .row-label { right: auto; bottom: -1px; }

.bass-board { display: flex; width: 100%; height: 350px; min-width: 220px; padding: 5px; justify-content: center; gap: 3px; border: 1px solid var(--line); border-radius: 5px; background: linear-gradient(145deg, #e8e2d7, #faf8f2); }
.bass-board.vertical { width: clamp(205px, 45%, 225px); min-width: 205px; height: 100%; max-height: 570px; padding: 6px 8px; gap: 1px; }
.bass-board.vertical.cross-axis-reversed { flex-direction: row-reverse; }
.bass-column { position: relative; display: flex; width: 29px; padding: 20px 0 10px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.bass-column-label { position: absolute; top: 2px; left: 50%; width: 54px; transform: translateX(-50%); color: var(--ink-soft); text-align: center; font: 8px "DM Mono", monospace; white-space: nowrap; }
.bass-button { position: relative; display: grid; width: 24px; height: 24px; flex: 0 0 24px; place-items: center; border: 1px solid #aaa9a2; border-radius: 50%; background: linear-gradient(145deg, #fff, #d9d6ce); box-shadow: 1px 2px 3px rgba(21,38,51,.12); color: #5e686c; font: 500 7px "DM Mono", monospace; cursor: pointer; }
.bass-button.reference-primary { box-shadow: inset 0 0 0 2px var(--ink), 1px 2px 3px rgba(21,38,51,.12); }
.bass-button.reference-secondary { box-shadow: inset 0 0 0 1px rgba(21,38,51,.52), 1px 2px 3px rgba(21,38,51,.12); }
.bass-button.active-tone { color: var(--ink); border-color: #579d91; background: var(--mint); }
.bass-button.active-bass { color: white; border-color: var(--mint-strong-dark); background: var(--mint-strong); box-shadow: 0 2px 6px rgba(40,111,101,.25); }
.bass-button.alternative-tone { color: #4f6d66; border-color: #9dbdb5; background: #e1ece8; }
.bass-board.horizontal { min-width: 650px; width: 100%; height: 160px; padding: 4px 10px; flex-direction: column; gap: 2px; }
.bass-board.horizontal.cross-axis-reversed { flex-direction: column-reverse; }
.bass-board.horizontal .bass-column { width: 100%; height: 24px; padding: 0 28px 0 60px; flex-direction: row; gap: 6px; }
.bass-board.horizontal.axis-reversed .bass-column { flex-direction: row-reverse; }
.bass-board.vertical.axis-reversed .bass-column { flex-direction: column-reverse; }
.bass-board.horizontal .bass-column-label { top: 50%; left: 3px; width: 60px; transform: translateY(-50%); text-align: left; }
.bass-board.horizontal .bass-button { flex: 0 0 22px; width: 22px; height: 22px; }
.bass-board.vertical .bass-button { transform: translateY(var(--grid-offset)); }
.bass-board.vertical.axis-reversed .bass-button { transform: translateY(calc(var(--grid-offset) * -1)); }
.bass-board.horizontal .bass-button { transform: translateX(var(--grid-offset)); }
.bass-board.horizontal.axis-reversed .bass-button { transform: translateX(calc(var(--grid-offset) * -1)); }

.hand-hint[hidden], .board-hint[hidden] { display: none; }

.tip-card { position: relative; display: flex; align-items: center; gap: 22px; max-width: 680px; margin: 48px auto 64px; padding: 22px 30px; border-left: 3px solid var(--coral); background: rgba(255,253,248,.65); }
.tip-number { color: var(--coral); font: 10px "DM Mono", monospace; letter-spacing: .12em; }
.tip-number strong { font-size: 21px; }
.tip-card p { margin: 0; font-size: 12px; line-height: 1.9; }
.tip-line { flex: 1; height: 1px; min-width: 35px; background: var(--line); }

footer { display: flex; justify-content: space-between; width: min(1380px, calc(100% - 64px)); margin: auto; padding: 25px 0 34px; border-top: 1px solid var(--line); color: var(--ink-soft); font: 9px "DM Mono", monospace; letter-spacing: .1em; }
footer p { margin: 0; }
footer span { color: var(--coral); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); width: 100%; height: auto; min-width: 0; max-height: none; }
  .workspace > * { min-width: 0; }
  .controls-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .root-grid { grid-template-columns: repeat(6, 1fr); }
  .controls-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
  .controls-panel .step-heading, .controls-panel .root-grid, .controls-panel .notation-toggle { grid-column: 1 / -1; }
  .controls-panel .field-group:first-of-type { grid-column: 1 / -1; }
  .instrument-stage { min-height: 0; }
}

@media (max-width: 650px) {
  .site-header, main, footer { width: calc(100% - 30px); max-width: 1260px; }
  .site-header { height: 56px; }
  .brand-sub { display: none; }
  .site-header .shortcut-button { margin-left: auto; }
  .site-header .help-button { margin-left: 5px; font-size: 0; }
  .site-header .help-button span { margin-right: 0; }
  .shortcut-panel { top: 62px; right: 15px; max-height: calc(100svh - 78px); overflow-y: auto; }
  .shortcut-columns { grid-template-columns: 1fr; gap: 12px; }
  .shortcut-columns section + section { padding: 12px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .controls-panel { display: block; width: 100%; padding: 26px 20px; overflow: hidden; }
  .root-grid { grid-template-columns: repeat(4, 1fr); }
  .diagram-panel { padding: 26px 18px; }
  .diagram-topbar { align-items: flex-start; flex-direction: column; }
  .rotation-control { width: 100%; align-items: flex-start; flex-direction: column; }
  .rotation-tabs { width: 100%; }
  .rotation-tabs button { flex: 1; min-width: 0; }
  .instrument-tabs { width: 100%; }
  .instrument-tabs button { flex: 1; padding-inline: 7px; }
  .chord-summary { grid-template-columns: 80px 1fr; gap: 16px; padding: 16px; }
  .sound-button { grid-column: 1 / -1; justify-self: end; margin-top: -12px; }
  .tone-list { flex-wrap: wrap; }
  .tone-chip { min-width: 43px; height: 43px; }
  .board-wrap { width: 100%; overflow: hidden; }
  .instrument-stage { width: 100%; min-width: 0; min-height: 570px; }
  .instrument-stage.rotation-90, .instrument-stage.rotation-270 { min-height: 640px; }
  .instrument-stage.rotation-90 .hand-panel, .instrument-stage.rotation-270 .hand-panel { min-height: 290px; }
  .hand-panel { min-width: 0; padding: 6px; }
  .hand-heading { min-height: 78px; align-items: stretch; flex-direction: column; justify-content: flex-start; gap: 7px; }
  .hand-heading strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; }
  .instrument-tabs.compact button { min-width: 0; padding: 5px 2px; }
  .bellows { width: 18px; flex-basis: 18px; }
  .instrument-stage.rotation-90 .bellows, .instrument-stage.rotation-270 .bellows { height: 18px; flex-basis: 18px; }
  .hand-board { margin-top: 5px; overflow: hidden; }
  .hand-hint { min-height: 28px; font-size: 7px; }
  .piano.vertical { width: 130px; min-width: 0; height: 420px; }
  .piano.horizontal { width: 100%; min-width: 0; height: 150px; }
  .piano.vertical .key-note { right: 8px; font-size: 7px; }
  .piano.vertical .black-key .key-note { right: 6px; }
  .button-board.vertical { width: 130px; min-width: 0; height: 420px; padding-inline: 2px; gap: 0; }
  .button-board.vertical .button-row { width: 25px; gap: 4px; }
  .button-board.vertical .note-button { width: 22px; height: 22px; flex-basis: 22px; font-size: 6px; }
  .button-board.horizontal { width: 100%; min-width: 0; height: 190px; padding: 6px 0; }
  .button-board.horizontal .button-row { height: 34px; gap: 3px; padding-left: 2px; }
  .button-board.horizontal .button-row:nth-child(even) { padding-left: 14px; }
  .button-board.horizontal.axis-reversed .button-row { padding-right: 2px; padding-left: 0; }
  .button-board.horizontal.axis-reversed .button-row:nth-child(even) { padding-right: 14px; padding-left: 0; }
  .button-board.horizontal .note-button { width: 20px; height: 20px; flex-basis: 20px; font-size: 6px; }
  .bass-board.vertical { width: 136px; min-width: 0; height: 420px; padding: 3px; gap: 1px; }
  .bass-board.vertical .bass-column { width: 21px; padding: 20px 0 12px; gap: 4px; }
  .bass-board.vertical .bass-column-label { width: 24px; font-size: 6px; }
  .bass-board.vertical .bass-button { width: 20px; height: 20px; flex-basis: 20px; font-size: 6px; }
  .bass-board.horizontal { width: 100%; min-width: 0; height: 206px; padding: 5px; gap: 2px; }
  .bass-board.horizontal .bass-column { height: 29px; padding: 0 4px 0 43px; gap: 2px; }
  .bass-board.horizontal .bass-column:nth-child(even) { padding-left: 43px; transform: none; }
  .bass-board.horizontal .bass-column-label { width: 38px; font-size: 6px; }
  .bass-board.horizontal .bass-button { width: 18px; height: 18px; flex-basis: 18px; font-size: 6px; }
  .board-meta { align-items: flex-start; flex-direction: column; gap: 8px; }
  .tip-card { margin-bottom: 45px; padding: 18px; }
  .tip-line { display: none; }
  footer { gap: 14px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
