/* Chord Play (chords.html lab). Same language as the rest of the site: flat panels with hairlines, mono labels, one orange accent.
   Orange only marks what is playing, what is picked and what the button does. Chord function (home / tense / away) is a thin coloured edge, never a fill.
   Only transform and opacity move. */
.cp { --fn-home: oklch(0.74 0.12 160); --fn-tension: oklch(0.72 0.15 12); --fn-away: oklch(0.82 0.10 92); display: grid; gap: var(--s-5); min-width: 0; font-family: var(--font); }
.cp > * { min-width: 0; }
.cp [data-fn="home"] { --fn: var(--fn-home); } .cp [data-fn="tension"] { --fn: var(--fn-tension); } .cp [data-fn="away"] { --fn: var(--fn-away); }

/* panels: a header row (mono label left, meta right) over a hairline, like the lesson lists */
.cp-panel { min-width: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.cp-panel > :not(.cp-panel-head) { margin-inline: var(--s-4); }
.cp-panel > :last-child { margin-bottom: var(--s-4); }
.cp-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); background: var(--surface-3); }
.cp-panel-title { margin: 0; font: 500 var(--fs-xs)/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cp-panel-meta { font: 500 var(--fs-xs)/1.2 var(--mono); letter-spacing: .06em; color: var(--faint); text-align: right; }
.cp-mini { margin: var(--s-4) 0 var(--s-2); font: 500 var(--fs-xs)/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.cp-sub { margin: 0 0 var(--s-3); font: 500 var(--fs-xs)/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cp-help { margin: 0 0 var(--s-3); color: var(--muted); font-size: var(--fs-sm); }

/* layout: the row and the chord box on the left, the selected chord on the right (stacked on a phone) */
.cp-main { display: grid; gap: var(--s-4); align-items: start; }
.cp-col { display: grid; gap: var(--s-4); min-width: 0; }
/* on a phone the selected chord sits right under the row it belongs to, the chord box last */
@media (max-width: 61.99rem) { .cp-main, .cp-col { display: contents; } .cp-stage { order: 1; } .cp-inspector { order: 2; } .cp-tray { order: 3; } .cp-locked-slot { order: 4; } }
@media (min-width: 62rem) { .cp-main { grid-template-columns: minmax(0, 1fr) 21rem; } .cp-inspector { position: sticky; top: calc(var(--header-h, 4rem) + var(--s-4)); } }

/* starters: a plain strip of choices */
.cp-starter-list { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: var(--s-2); scroll-snap-type: x proximity; scrollbar-width: thin; }
.cp-starter { flex: 0 0 auto; scroll-snap-align: start; display: grid; gap: var(--s-2); justify-items: start; min-width: 9rem; min-height: 64px; padding: var(--s-3) var(--s-4); text-align: left; color: inherit; font: inherit; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); transition: border-color var(--fast) ease, background-color var(--fast) ease; }
@media (hover: hover) { .cp-starter:hover { border-color: var(--line-strong); background: var(--surface-3); } }
.cp-starter[aria-checked="true"] { border-color: var(--accent); }
.cp-starter-name { font-weight: 600; font-size: var(--fs-ui); }
.cp-dots { display: flex; gap: 4px; } .cp-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--fn); }
.cp-starter-tag { font: 500 var(--fs-xs)/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); min-height: 1em; }
.cp-starter-tag[data-kind="lock"]::before { content: "🔒 "; }

/* the row of chord blocks */
.cp-ruler { display: grid; grid-auto-flow: column; justify-content: start; margin-bottom: var(--s-2); color: var(--faint); font: 500 var(--fs-xs)/1 var(--mono); }
.cp-ruler:empty { display: none; }
.cp-tick { min-width: 1.5rem; }
.cp-lane-wrap { position: relative; }
.cp-lane { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: var(--s-2); margin: 0; padding: var(--s-2); list-style: none; min-height: 7rem;
  border-radius: var(--radius-lg); background: var(--bg); border: 1px solid var(--line); }
.cp-block { position: relative; display: grid; align-content: space-between; justify-items: start; min-height: 5.75rem; padding: var(--s-3) var(--s-3) var(--s-3) calc(var(--s-3) + 3px); border-radius: var(--radius); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line-strong); overflow: hidden;
  transition: border-color var(--fast) ease, background-color var(--fast) ease, opacity var(--fast) ease; }
.cp-block::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--fn); }
.cp-block:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cp-name { font: 600 clamp(1.25rem, 3vw, 1.6rem)/1 var(--font); letter-spacing: -.01em; }
.cp-num { font: 500 var(--fs-xs)/1 var(--mono); color: var(--muted); }
.cp-pips { display: flex; gap: 3px; } .cp-pips i { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
@media (hover: hover) and (pointer: fine) { .cp-block:hover { border-color: var(--control-border); background: var(--surface-3); } }
.cp-block.is-picked { border-color: var(--text); }
.cp-block.on { border-color: var(--accent); background: var(--accent-soft); }
.cp-block.on .cp-pips i { background: var(--accent); }
.cp-block.is-lifted { opacity: .3; border-style: dashed; }
.cp-block.is-ghost { opacity: .6; border: 1px dashed var(--accent); animation: cp-ghost 900ms ease-in-out infinite alternate; }
@keyframes cp-ghost { to { opacity: .9; } }
.cp-block.is-target { border-color: var(--accent); background: var(--accent-soft); }
.cp-block.is-doomed { --fn: var(--danger); opacity: .45; border-style: dashed; }

/* the copy that hangs from the finger */
.cp-fly { position: fixed; left: 0; top: 0; z-index: 90; margin: 0; pointer-events: none; cursor: grabbing; will-change: transform; transition: none; background: var(--surface-3); border-color: var(--accent);
  box-shadow: 0 calc(6px + var(--cp-lift, 0) * 14px) calc(12px + var(--cp-lift, 0) * 18px) -8px rgb(0 0 0 / .7); }
body.cp-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.cp-poof { z-index: 90; }

/* short entrances */
.cp-deal { animation: cp-deal 260ms var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes cp-deal { from { opacity: 0; transform: translateY(8px); } }
.cp-land { animation: cp-land 240ms var(--ease-out); }
@keyframes cp-land { 0% { transform: scale(1.04); } 100% { transform: scale(1); } }
.cp-cheer-pop { animation: cp-hop 360ms var(--ease-out); }
@keyframes cp-hop { 0% { transform: translateY(0); } 40% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
.cp-cheer { height: 1.4rem; margin: var(--s-2) 0 0; font: 500 var(--fs-xs)/1.4rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); opacity: 0; transition: opacity var(--fast) ease; }
.cp-cheer.go { opacity: 1; }

/* controls */
.cp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); margin-top: var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.cp-play { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-5) 0 var(--s-4); border: 0; border-radius: 999px; cursor: pointer; font: 600 var(--fs-ui)/1 var(--font); color: var(--on-accent); background: var(--accent); transition: transform var(--fast) var(--ease-out), background-color var(--fast) ease; }
@media (hover: hover) { .cp-play:hover { background: var(--accent-hover); } }
.cp-play:active { transform: scale(0.97); }
.cp-ico { width: 0; height: 0; border-style: solid; border-width: 7px 0 7px 12px; border-color: transparent transparent transparent currentColor; }
.cp-ico.stop { width: 12px; height: 12px; border: 0; border-radius: 2px; background: currentColor; }
.cp-ctl { display: flex; align-items: center; gap: var(--s-2); }
.cp-label { color: var(--muted); font: 500 var(--fs-xs)/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.cp-step { width: 44px; height: 44px; font-size: 1.2rem; color: inherit; cursor: pointer; background: transparent; border: 1px solid var(--control-border); border-radius: var(--radius); transition: background-color var(--fast) ease; }
@media (hover: hover) { .cp-step:hover { background: var(--surface-3); } }
.cp-step:active { transform: scale(0.96); }
.cp-key-name { min-width: 3rem; text-align: center; font: 500 1.05rem/1 var(--mono); }
.cp-feel-ctl { gap: var(--s-1); flex-wrap: wrap; }
.cp-seg { min-height: 40px; padding: 0 var(--s-3); border-radius: var(--radius); cursor: pointer; font: 500 var(--fs-sm)/1 var(--font); color: var(--muted); background: transparent; border: 1px solid var(--line-strong); transition: background-color var(--fast) ease, color var(--fast) ease, border-color var(--fast) ease; }
@media (hover: hover) { .cp-seg:hover { color: var(--text); background: var(--surface-3); } }
.cp-seg[aria-checked="true"] { color: var(--text); background: var(--surface-3); border-color: var(--accent); }
.cp-tempo-ctl input { width: 8rem; accent-color: var(--accent); }
.cp-bpm { font: 500 var(--fs-sm)/1 var(--mono); min-width: 4.8rem; }
.cp-extras { display: contents; }
.cp-export { min-height: 44px; padding: 0 var(--s-4); border-radius: 999px; cursor: pointer; font: 600 var(--fs-sm)/1 var(--font); color: var(--text); background: transparent; border: 1px solid var(--control-border); transition: background-color var(--fast) ease; }
@media (hover: hover) { .cp-export:hover { background: var(--surface-3); } }
.cp-export.is-locked { color: var(--muted); } .cp-export.is-locked::before { content: "🔒 "; }
.cp-link { color: var(--text); text-underline-offset: 3px; }
.cp-status { min-height: 1.2em; margin: var(--s-2) 0 0; color: var(--muted); font-size: var(--fs-sm); }
.cp-mission { margin: var(--s-3) 0 0; padding: var(--s-3) var(--s-4); border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line); font-size: var(--fs-sm); }
.cp-mission b { margin-right: var(--s-2); font: 500 var(--fs-xs)/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; } .cp-mission[data-done="true"] b { color: var(--ok); } .cp-hint { display: block; margin-top: var(--s-1); color: var(--muted); }
.cp-import-note { margin: var(--s-3) 0 0; padding: var(--s-2) var(--s-4); border-radius: var(--radius); border: 1px dashed var(--line-strong); font-size: var(--fs-sm); color: var(--muted); }

/* the chord box */
.cp-tabs { display: flex; gap: var(--s-1); flex-wrap: wrap; margin-bottom: var(--s-3); }
.cp-tab { min-height: 36px; padding: 0 var(--s-3); border-radius: 999px; cursor: pointer; font: 500 var(--fs-sm)/1 var(--font); color: var(--muted); background: transparent; border: 1px solid var(--line-strong); transition: background-color var(--fast) ease, color var(--fast) ease, border-color var(--fast) ease; }
@media (hover: hover) { .cp-tab:hover { color: var(--text); background: var(--surface-3); } }
.cp-tab[aria-selected="true"] { color: var(--text); background: var(--surface-3); border-color: var(--text); }
.cp-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cp-tray-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.8rem, 1fr)); gap: var(--s-2); margin: 0 0 var(--s-3); padding: 0; list-style: none; }
.cp-chip { min-height: 4rem; padding: var(--s-2) var(--s-3) var(--s-2) calc(var(--s-3) + 3px); align-content: center; gap: var(--s-1); }
.cp-chip .cp-name { font-size: 1.1rem; }
.cp-legend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin: 0; padding: 0; list-style: none; font: 500 var(--fs-xs)/1 var(--mono); letter-spacing: .04em; color: var(--muted); }
.cp-key::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--s-2); border-radius: 50%; background: var(--fn); }
.cp-locked-slot:empty { display: none; }

/* the selected chord */
.cp-empty { margin: 0 var(--s-4) var(--s-4); color: var(--muted); font-size: var(--fs-sm); }
.cp-inspector-body { display: grid; gap: 0; }
.cp-inspector-body[hidden], .cp-empty[hidden], .cp-subs[hidden], .cp-mini[hidden] { display: none; }
.cp-inspector-top { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.cp-big-name { margin: 0; font: 600 2rem/1 var(--font); letter-spacing: -.02em; }
.cp-chipbtn { margin-left: auto; min-height: 36px; padding: 0 var(--s-3); border-radius: 999px; cursor: pointer; font: 600 var(--fs-sm)/1 var(--font); color: var(--text); background: transparent; border: 1px solid var(--control-border); }
@media (hover: hover) { .cp-chipbtn:hover { background: var(--surface-3); } }
.cp-subs { display: grid; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }
.cp-sub-btn { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s-3); align-items: baseline; width: 100%; padding: var(--s-2) var(--s-3); text-align: left; cursor: pointer; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color var(--fast) ease, background-color var(--fast) ease; }
@media (hover: hover) { .cp-sub-btn:hover { border-color: var(--control-border); background: var(--surface-3); } }
.cp-sub-btn:active { transform: scale(0.99); }
.cp-sub-name { font-weight: 600; } .cp-sub-btn .cp-num { justify-self: end; }
.cp-sub-why { grid-column: 1 / -1; color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.cp-voicings { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.cp-voicings .cp-seg { min-height: 36px; }

/* keyboard */
.cp-piano { position: relative; height: 5.5rem; margin-top: var(--s-4); border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--line-strong); }
.cp-pkey { position: absolute; top: 0; display: grid; align-items: end; justify-items: center; padding-bottom: 4px; font: 500 10px/1 var(--mono); box-sizing: border-box; }
.cp-pkey.is-white { height: 100%; background: #e9eaec; border-right: 1px solid #b6b9be; color: #1b1c1f; }
.cp-pkey.is-black { z-index: 1; height: 60%; background: #1b1c1f; border-radius: 0 0 3px 3px; color: #eceef0; }
.cp-pkey.is-white.on { background: var(--accent); color: var(--on-accent); }
.cp-pkey.is-black.on { background: color-mix(in oklab, var(--accent) 70%, black); }

@media (max-width: 40rem) {
  .cp-lane { grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr)); padding: var(--s-2); }
  .cp-block { min-height: 4.75rem; padding: var(--s-2) var(--s-2) var(--s-2) calc(var(--s-2) + 3px); } .cp-bar { gap: var(--s-3); } .cp-tempo-ctl input { width: 6rem; }
  .cp-big-name { font-size: 1.6rem; }
}
@media (max-height: 30rem) and (orientation: landscape) {
  .cp { gap: var(--s-3); } .cp-block { min-height: 4rem; } .cp-lane { min-height: 5rem; } .cp-inspector { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  .cp *, .cp *::before, .cp-fly { animation: none !important; transition-duration: 0.01ms !important; }
}
