:root {
  --page: #f6f3ee; --panel: #fff; --ink: #1f1d1b; --ink-soft: #57524d; --ink-faded: #8f8882; --rule: #ddd6cc;
  --red: #A82020; --red-deep: #7a1818; --navy: #0f1c2b; --yellow: #e8b923; --blue: #2a6fdb;
  --good: #0d904f; --good-tint: #e6f4ea; --bad: #d93025; --bad-tint: #fce8e6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Manrope', system-ui, sans-serif; background: var(--page); color: var(--ink); line-height: 1.5; min-height: 100vh; }
header { background: linear-gradient(135deg, var(--red-deep), var(--red)); color: #fff; padding: 1.4rem 1.5rem 1.2rem; }
.wrap { max-width: 1180px; margin: 0 auto; }
header .eyebrow { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.8; margin-bottom: 6px; }
header h1 { font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; text-wrap: balance; }
header a.back { color: #fff; opacity: 0.8; font-size: 13px; text-decoration: none; display: inline-block; margin-top: 8px; margin-right: 14px; }
header a.back:hover { opacity: 1; text-decoration: underline; }
main { padding: 1.25rem 1rem 3rem; }
h2 { font-size: 20px; font-weight: 800; margin: 2rem 0 0.5rem; display: flex; align-items: center; gap: 10px; }
h2 .n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: var(--red); color: #fff; font: 700 15px 'JetBrains Mono', monospace; }
.lede { color: var(--ink-soft); font-size: 15px; max-width: 820px; margin-bottom: 0.8rem; }
canvas { display: block; width: 100%; height: auto; border-radius: 8px; }

.player { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 10px; }
.stage-wrap { position: relative; }
.bigplay { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; border-radius: 50%; border: none; background: rgba(168,32,32,0.92); color: #fff; font-size: 38px; cursor: pointer; box-shadow: 0 8px 30px rgba(0,0,0,0.25); }
.bigplay[hidden] { display: none; }
.controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
button { font: 700 14px 'Manrope', sans-serif; border-radius: 8px; border: 1px solid var(--rule); background: #fff; color: var(--ink); cursor: pointer; padding: 8px 12px; }
button:hover { border-color: var(--red); }
.controls .play { background: var(--red); color: #fff; border-color: var(--red); min-width: 88px; }
.controls input[type=range] { flex: 1; min-width: 160px; accent-color: var(--red); }
.controls .time { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--ink-soft); }
label { font-size: 13px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }

.trainer { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.inst { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 10px; }
.inst canvas { background: transparent; touch-action: manipulation; outline: none; }
.helpline { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.side { display: grid; gap: 10px; }
.side > canvas { background: #fff; border: 1px solid var(--rule); border-radius: 10px; touch-action: none; }

/* floating question card over the instrument's right-hand keys */
.inst { position: relative; }
.qpop { position: absolute; z-index: 2; background: #fff; border: 2px solid var(--yellow); border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(20,16,10,0.28); }
.qpop[hidden] { display: none; }
.qpop .ql { font: 700 10.5px 'JetBrains Mono', monospace; letter-spacing: 0.1em; text-transform: uppercase; color: var(--red); margin-bottom: 4px; }
.qpop .qq { font-size: 15.5px; font-weight: 800; line-height: 1.3; text-wrap: balance; }
.qpop .qs { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.qpop .nums { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin-top: 10px; }
.qpop .nums button, .qpop .yn button { padding: 7px 0; font: 700 15px 'JetBrains Mono', monospace; }
.qpop .yn { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.qpop .yn button { font-family: 'Manrope', sans-serif; }
.qpop .fb { font-size: 13.5px; margin-top: 8px; }
.qpop .ex { font-size: 13.5px; color: var(--ink-soft); margin-top: 8px; }
.qpop .big { font-size: 26px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.qpop .go { margin-top: 10px; width: 100%; background: var(--red); color: #fff; border-color: var(--red); }
.qpop a.go { display: block; text-align: center; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 700; font-size: 14px; border: 1px solid var(--red); }
.qpop.mini .qq { font-size: 14.5px; font-weight: 700; }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 12px; }
.ph { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.steps { list-style: none; counter-reset: s; display: grid; gap: 6px; }
.steps li { counter-increment: s; position: relative; padding: 7px 10px 7px 36px; border-radius: 8px; border: 1px solid transparent; font-size: 14px; color: var(--ink-faded); }
.steps li::before { content: counter(s); position: absolute; left: 8px; top: 7px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; font: 700 11px 'JetBrains Mono', monospace; }
.steps li.now { color: var(--ink); border-color: var(--yellow); background: #fff8e1; font-weight: 600; }
.steps li.done { color: var(--good); }
.steps li.done::before { content: '✓'; background: var(--good); color: #fff; border-color: var(--good); }
.steps .tip { font-size: 13px; font-weight: 500; color: var(--ink-soft); margin-top: 4px; }
.done { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--good-tint); border: 1px solid var(--good); color: var(--good); font-weight: 700; font-size: 14px; }
.done[hidden] { display: none; }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.panel h3 { font-size: 15px; font-weight: 800; margin-bottom: 6px; }
table.ws { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.ws th, table.ws td { border-bottom: 1px solid var(--rule); padding: 6px 4px; text-align: left; }
table.ws th { font-size: 11px; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faded); }
table.ws select { font: 600 13px 'Manrope', sans-serif; padding: 3px; border-radius: 5px; border: 1px solid var(--rule); }
.ok { color: var(--good); font-weight: 800; } .no { color: var(--bad); font-weight: 800; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 18px; }
.card ul { padding-left: 1.2em; font-size: 15px; color: var(--ink-soft); display: grid; gap: 4px; }
.card b { color: var(--ink); }
@media (max-width: 900px) {
  .trainer { grid-template-columns: 1fr; }
  .side { grid-template-columns: 1fr; }
  .inst { overflow-x: auto; }
  .qpop, .qpop.mini { position: static; width: auto !important; margin-top: 10px; }
  .qpop .nums { grid-template-columns: repeat(5, 1fr); }
  .inst canvas { min-width: 720px; }
  main { padding: 1rem 0.6rem 3rem; }
}

/* embed mode (?embed): standalone in an iframe, no link out to the hub */
body.embed header a.back { display: none; }

/* recording mode: only the video canvas at 1920x1080 */
body.record { background: #f6f3ee; overflow: hidden; }
body.record > header { display: none; }
body.record main { padding: 0; max-width: none; }
body.record main > *:not(.player) { display: none; }
body.record .player { border: 0; padding: 0; border-radius: 0; }
body.record .player > *:not(.stage-wrap) { display: none; }
body.record #vid { width: 1920px; height: 1080px; border-radius: 0; }
body.record .bigplay { display: none; }
