:root { color-scheme: light; --ink:#14161a; --mute:#6b7280; --line:#e5e7eb; --card:#f7f8fa; --acc:#1769e0; --syn:#f0602a; --now:#14161a; }
  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body { margin: 0; background: #fff; color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
  main { max-width: 1080px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); }
  header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
  h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
  #status { color: var(--mute); font-size: 14px; }
  .top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
  .stage { position: relative; width: 100%; aspect-ratio: 4/3; background: #e9ebef; border-radius: 10px; overflow: hidden; }
  video, canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
  .hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); font-size: 14px; text-align: center; padding: 16px; }
  #fingers { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
  #fingers span { padding: 5px 10px; border-radius: 999px; background: #e9ebef; color: #8a8f98; font-size: 13px; }
  #fingers span.on { background: var(--acc); color: #fff; }
  #fstate { margin-left: auto; font-weight: 600; font-size: 14px; }
  #note { margin-top: 8px; font-size: 14px; color: var(--mute); min-height: 1.4em; }
  .controls { display: grid; gap: 12px; align-content: start; }
  .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  button, select, input[type=number] { font: inherit; color: inherit; border: 1px solid #cfd3da; background: #fff; border-radius: 10px; padding: 10px 14px; min-height: 44px; }
  button { cursor: pointer; font-weight: 600; }
  button.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
  button:disabled { opacity: .45; cursor: default; }
  .field { display: grid; gap: 4px; }
  .field > span { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tempo { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; }
  .tempo button { padding: 0; font-size: 20px; }
  .tempo input { text-align: center; font-size: 18px; font-weight: 600; width: 100%; }
  .check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
  .check input { width: 20px; height: 20px; }
  .seqhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
  .seqhead h2 { font-size: 16px; margin: 0; }
  .seqhead div { display: flex; gap: 8px; }
  .seqhead button { min-height: 36px; padding: 6px 12px; font-size: 14px; }
  .seq { margin-top: 16px; }
  .line { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
  .line > em { font-style: normal; font-size: 13px; color: var(--mute); }
  .line.syn > em { color: var(--syn); font-weight: 600; }
  .cells { display: grid; grid-template-columns: repeat(var(--n, 32), minmax(0, 56px)); gap: 3px; }
  .cells i { height: 30px; border-radius: 5px; background: #e4e6ea; cursor: pointer; touch-action: manipulation; }
  .cells i.q { background: #d3d6dc; }
  .cells i.on { background: var(--acc); }
  .line.syn .cells i.on { background: var(--syn); }
  .cells i.now { outline: 2px solid var(--now); outline-offset: -2px; }
  details { margin-top: 16px; }
  summary { cursor: pointer; font-weight: 600; }
  details p { color: var(--mute); font-size: 14px; margin: 8px 0 0; }
  .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.line > em { position: sticky; left: 0; z-index: 1; background: var(--card); padding-right: 6px; }
@media (max-width: 800px) {
  .top { grid-template-columns: 1fr; }
  #seq { width: max-content; }
  .line { grid-template-columns: 64px max-content; }
  .cells { grid-template-columns: repeat(var(--n, 32), 30px); }
  .cells i { height: 36px; }
  .line > em { font-size: 12px; }
  h1 { font-size: 19px; }
}
#seq[data-len="8"] { --n: 8; }
#seq[data-len="16"] { --n: 16; }
#seq[data-len="8"] .cells i:nth-child(n+9) { display: none; }
#seq[data-len="16"] .cells i:nth-child(n+17) { display: none; }
.len { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--mute); }
.len select { min-height: 36px; padding: 4px 10px; font-size: 14px; }
