/* ===== テーマ：ライト（既定） ===== */
:root {
  --bg: #f5f3ee;
  --surface: #fffdf9;
  --surface-2: #f0ede6;
  --ink: #33373c;
  --ink-soft: #6a6f75;
  --muted: #a19e96;
  --line: #e7e2d7;
  --accent-l: #5a9e8e;
  --accent-d: #7cc2b0;
  --accent: var(--accent-l);
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --perfect: #3f9e86;
  --good: #6d8ed6;
  --bad: #e0896a;
  --miss: #b2ada4;
  --score-ink: #2f3337;
  --rep: #d39a3c;
  --rep-soft: rgba(211, 154, 60, 0.1);
  --rep-tag: #fbf0dc;
  --rep-ink: #855510;
  --shadow: 0 1px 2px rgba(70, 60, 40, 0.05), 0 10px 30px rgba(70, 60, 40, 0.06);
  --radius: 22px;
  --font: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Yu Gothic UI', system-ui, sans-serif;
  --font-num: 'Quicksand', 'Zen Maru Gothic', system-ui, sans-serif;
  color-scheme: light;
}

/* ===== アクセントカラー ===== */
:root[data-accent="blue"]     { --accent-l: #5b7fc7; --accent-d: #8ea9e8; }
:root[data-accent="coral"]    { --accent-l: #d2725a; --accent-d: #ee9a83; }
:root[data-accent="lavender"] { --accent-l: #8672c2; --accent-d: #b3a2e6; }
:root[data-accent="rose"]     { --accent-l: #c46a8a; --accent-d: #e59bb6; }
:root[data-accent="ink"]      { --accent-l: #4a5058; --accent-d: #c9c6bf; }

/* ===== テーマ：ダーク（「ダーク」指定時、または「自動」で端末がダークのとき） ===== */
:root[data-theme="dark"] {
  --bg: #1b1d20;
  --surface: #24272b;
  --surface-2: #2d3035;
  --ink: #ebe8e1;
  --ink-soft: #b5b2aa;
  --muted: #85837d;
  --line: #363a3f;
  --accent: var(--accent-d);
  --accent-ink: #14181a;
  --perfect: #6fcab0;
  --good: #95abf2;
  --bad: #f1a286;
  --miss: #78746e;
  --score-ink: #e7e4dd;
  --rep: #e2b35e;
  --rep-soft: rgba(226, 179, 94, 0.12);
  --rep-tag: #3a3224;
  --rep-ink: #f3cf8a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1d20;
    --surface: #24272b;
    --surface-2: #2d3035;
    --ink: #ebe8e1;
    --ink-soft: #b5b2aa;
    --muted: #85837d;
    --line: #363a3f;
    --accent: var(--accent-d);
    --accent-ink: #14181a;
    --perfect: #6fcab0;
    --good: #95abf2;
    --bad: #f1a286;
    --miss: #78746e;
    --score-ink: #e7e4dd;
    --rep: #e2b35e;
    --rep-soft: rgba(226, 179, 94, 0.12);
    --rep-tag: #3a3224;
    --rep-ink: #f3cf8a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

/* 色見本 */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; border: 0; padding: 0; position: relative;
  background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); transition: transform .15s;
}
.swatch:active { transform: scale(.92); }
.swatch.on::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--sw);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.logo svg { width: 20px; height: 20px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt strong { font-family: var(--font-num); font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.brand-txt small { color: var(--muted); font-size: 11.5px; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--ink-soft); transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }

/* ---------- transport ---------- */
.transport {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px 22px;
  padding: 14px 18px 14px 22px;
}
.bpm-wrap { display: flex; align-items: center; gap: 8px; }
.round-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-size: 17px; line-height: 1; color: var(--ink-soft); transition: all .15s;
}
.round-btn:hover { border-color: var(--accent); color: var(--accent); }
.round-btn:active { transform: scale(.93); }
.bpm { display: flex; flex-direction: column; align-items: center; min-width: 74px; }
.bpm input {
  width: 78px; border: 0; background: transparent; text-align: center; color: var(--ink);
  font-family: var(--font-num); font-weight: 700; font-size: 34px; line-height: 1; padding: 0;
  -moz-appearance: textfield; appearance: textfield;
}
.bpm input::-webkit-outer-spin-button, .bpm input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bpm input:focus { outline: none; color: var(--accent); }
.bpm small { font-family: var(--font-num); font-size: 10.5px; letter-spacing: .18em; color: var(--muted); font-weight: 600; }
.quick { display: flex; align-items: center; gap: 10px; }
.pill-select {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 14px; border-radius: 999px;
  background: var(--surface-2); font-size: 13px; color: var(--ink-soft);
}
.pill-select span { font-family: var(--font-num); font-weight: 600; font-size: 12px; letter-spacing: .05em; }
.pill-select select {
  border: 0; background: transparent; color: var(--ink); font-family: var(--font-num); font-weight: 700;
  font-size: 15px; padding: 4px 4px; cursor: pointer;
}
.pill-select select:focus { outline: none; }
.play-btn {
  width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform .15s, box-shadow .2s;
}
.play-btn:hover { transform: translateY(-1px); }
.play-btn:active { transform: scale(.95); }
.play-btn svg { width: 26px; height: 26px; grid-area: 1/1; }
.play-btn .i-stop { display: none; }
.playing .play-btn .i-play { display: none; }
.playing .play-btn .i-stop { display: block; }

/* range */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--line) var(--p, 50%)); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; margin-top: -7px;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.range:focus { outline: none; }

/* segmented */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 999px; }
.seg button {
  border: 0; background: transparent; padding: 6px 13px; border-radius: 999px; font-size: 13px; color: var(--ink-soft);
  transition: background .2s, color .2s, box-shadow .2s; white-space: nowrap;
}
.seg-full { display: flex; }
.seg-full button { flex: 1 1 auto; padding: 7px 6px; }
.chip.na { opacity: .4; }
.chip.na span::after { content: '（この拍子では無し）'; display: block; font-size: 9.5px; font-weight: 400; }
.swing-mark { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; margin-left: 2px; color: var(--ink-soft); }
.swing-mark svg { height: 22px; width: auto; }
.swing-mark i { font-style: normal; font-family: var(--font-num); font-weight: 700; font-size: 12px; margin: 0 1px; }
.legend { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend .lg-key { margin-right: 2px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 700; }

/* ---------- score ---------- */
.score { position: relative; padding: 12px 16px 14px; flex: 0 0 auto; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.score-head { display: flex; justify-content: space-between; align-items: center; min-height: 26px; padding: 0 4px 2px; gap: 10px; }
.legend { font-size: 12px; color: var(--muted); }
.live { display: flex; align-items: center; gap: 12px; font-family: var(--font-num); font-size: 13px; color: var(--ink-soft); }
.lv { display: inline-flex; align-items: center; gap: 5px; }
.lv i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.lv b { font-weight: 700; min-width: 1ch; }
.lv-perfect i { background: var(--perfect); }
.lv-good i { background: var(--good); }
.lv-bad i { background: var(--bad); }
.lv-miss i { background: var(--miss); }
.combo { font-weight: 700; color: var(--accent); min-width: 64px; text-align: right; }
.show-judge .live, body:not(.show-judge) .live .combo { }
body:not(.show-judge) .live { visibility: hidden; }

.slots { display: flex; flex-direction: column; gap: 2px; }
.slot { position: relative; border-radius: 16px; transition: background .3s; }
.slot::before {
  content: ''; position: absolute; left: -10px; top: 32%; bottom: 32%; width: 3px; border-radius: 3px;
  background: var(--accent); opacity: 0; transition: opacity .25s;
}
.playing .slot.active::before { opacity: .8; }
.slot > div { animation: slotIn .45s ease both; }
.slot svg {
  display: block; width: 100%; height: auto; color: var(--score-ink); overflow: visible;
  max-height: max(80px, calc((100svh - var(--chrome, 330px)) / var(--lines, 2)));
}
@keyframes slotIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bar-hl { fill: var(--accent-soft); opacity: 0; transition: opacity .15s; }
.hl-bar .bar-hl.on { opacity: 1; }
.slot svg .vf-stavenote { transition: color .08s; }
.hl-note .is-now { color: var(--accent); }
.show-judge .j-perfect { color: var(--perfect); }
.show-judge .j-good { color: var(--good); }
.show-judge .j-bad { color: var(--bad); }
.show-judge .j-miss { color: var(--miss); }
.rep { display: none; }
body.rep-always .rep, body.rep-after.review .rep { display: inline; }
.rep-band { fill: var(--rep-soft); stroke: var(--rep); stroke-width: 1.2; stroke-dasharray: 4 3; }
.rep-tag rect { fill: var(--rep-tag); stroke: var(--rep); stroke-width: 1; }
.rep-tag text { fill: var(--rep-ink); font-family: var(--font); font-size: 10.5px; font-weight: 700; }
.chord { font-family: var(--font-num); font-size: 15px; font-weight: 700; fill: var(--ink-soft); }
.chord-q { font-size: 11.5px; font-weight: 600; }
.hide-chords .chords { display: none; }

/* judge popup */
.judge {
  position: absolute; left: 50%; top: 6px; transform: translateX(-50%); pointer-events: none;
  display: flex; flex-direction: column; align-items: center; opacity: 0; z-index: 3;
}
.judge .j-label { font-family: var(--font-num); font-weight: 700; font-size: 26px; letter-spacing: .04em; line-height: 1; }
.judge .j-sub { font-family: var(--font-num); font-size: 11px; color: var(--ink-soft); margin-top: 3px; font-weight: 600; letter-spacing: .06em; }
.judge.pop { animation: pop .62s cubic-bezier(.2,.8,.3,1) both; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(.86); }
  14% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  28% { transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px) scale(1); }
}
.judge.g-perfect .j-label { color: var(--perfect); }
.judge.g-good .j-label { color: var(--good); }
.judge.g-bad .j-label { color: var(--bad); }
.judge.g-miss .j-label { color: var(--miss); }
body:not(.show-judge) .judge { display: none; }

.countin {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-num); font-weight: 700; font-size: 84px; color: var(--accent); opacity: 0; z-index: 2;
}
.countin.show { opacity: .9; }
.countin.tick { animation: cnt .5s ease-out both; }
@keyframes cnt { from { transform: scale(1.18); opacity: 0; } 30% { opacity: .9; } to { transform: scale(1); opacity: .55; } }
.countin::before { content: ''; position: absolute; inset: 0; background: var(--surface); opacity: .55; z-index: -1; }
.countin:not(.show)::before { display: none; }

.rotate-hint { display: none; text-align: center; font-size: 12px; color: var(--muted); padding-top: 6px; }

/* ---------- tap pad ---------- */
.tap-pad {
  position: relative; overflow: hidden; flex: 1 1 auto; min-height: 112px; border: 0; border-radius: var(--radius);
  background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: background .2s;
  border: 1.5px dashed var(--line);
}
.tap-pad:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--accent) 6%); }
.tap-main { font-size: 17px; font-weight: 700; color: var(--ink-soft); letter-spacing: .03em; position: relative; }
.tap-sub { font-size: 11.5px; color: var(--muted); position: relative; }
.playing .tap-pad { border-style: solid; border-color: transparent; }
.tap-ripple {
  position: absolute; left: 50%; top: 50%; width: 260px; height: 260px; margin: -130px 0 0 -130px; border-radius: 50%;
  background: var(--accent); opacity: 0; transform: scale(.2); pointer-events: none;
}
.tap-pad.hit .tap-ripple { animation: ripple .4s ease-out; }
@keyframes ripple { from { opacity: .22; transform: scale(.2); } to { opacity: 0; transform: scale(2.2); } }

/* ---------- panel ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 20, 18, .25); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 20; backdrop-filter: blur(2px); }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%); background: var(--surface); z-index: 21;
  transform: translateX(104%); transition: transform .32s cubic-bezier(.2,.8,.3,1); display: flex; flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,.08); border-radius: 26px 0 0 26px;
}
.panel-open .scrim { opacity: 1; pointer-events: auto; }
.panel-open .panel { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 24px; }
.panel-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.panel-body { overflow-y: auto; padding: 4px 24px 40px; overscroll-behavior: contain; }
.group { padding: 16px 0 18px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.group:last-child { border-bottom: 0; }
.group h3 { margin: 0; font-size: 12px; letter-spacing: .14em; color: var(--accent); font-weight: 700; }
.hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 8px 4px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); transition: all .18s;
}
.chip .chip-ico { height: 34px; display: grid; place-items: center; }
.chip .chip-ico svg { height: 34px; width: auto; max-width: 84px; color: currentColor; }
.chip span { font-size: 12px; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.chip.on span { font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-row { display: flex; justify-content: space-between; font-size: 14px; }
.field-row output { font-family: var(--font-num); font-weight: 700; color: var(--ink-soft); }
.field-inline { flex-direction: row; justify-content: space-between; align-items: center; font-size: 14px; gap: 10px; }
.select {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 7px 12px; font-family: var(--font-num);
  font-weight: 700; font-size: 15px; color: var(--ink); min-width: 96px;
}
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.toggle i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .22s cubic-bezier(.2,.8,.3,1);
}
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(18px); }
.toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.range.sub { margin-top: -6px; }

/* ---------- result modal ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; background: rgba(20,20,18,.28); opacity: 0; pointer-events: none; transition: opacity .25s; padding: 16px; backdrop-filter: blur(3px); }
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: min(420px, 100%); background: var(--surface); border-radius: 28px; padding: 26px 24px 22px; box-shadow: var(--shadow);
  text-align: center; transform: translateY(10px) scale(.98); transition: transform .3s cubic-bezier(.2,.8,.3,1);
}
.modal.open .modal-card { transform: none; }
.r-eyebrow { margin: 0; font-family: var(--font-num); letter-spacing: .3em; font-size: 11px; color: var(--muted); font-weight: 700; }
.r-score { font-family: var(--font-num); font-weight: 700; font-size: 64px; line-height: 1.1; color: var(--accent); margin: 4px 0 14px; }
.r-score small { font-size: 24px; margin-left: 2px; }
.r-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.r-tile { background: var(--surface-2); border-radius: 16px; padding: 10px 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.r-tile b { font-family: var(--font-num); font-size: 22px; }
.r-tile span { font-family: var(--font-num); font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.t-perfect b { color: var(--perfect); } .t-good b { color: var(--good); } .t-bad b { color: var(--bad); } .t-miss b { color: var(--miss); }
.r-detail { font-size: 13px; color: var(--ink-soft); line-height: 1.7; margin: 14px 0 6px; }
.link-btn { border: 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }
.r-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn { flex: 1; border-radius: 14px; padding: 12px 10px; font-size: 14px; font-weight: 700; border: 0; transition: transform .12s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .3s; z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .app { padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); gap: 10px; }
  .transport { grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 14px; }
  .bpm-range { grid-column: 1 / -1; grid-row: 2; }
  .quick { grid-column: 1 / -1; grid-row: 3; justify-content: space-between; }
  .play-btn { grid-column: 2; grid-row: 1; width: 54px; height: 54px; }
  .score { padding: 10px 8px 12px; }
  .slot::before { left: -6px; }
  .legend { font-size: 11px; }
  .legend .lg-key { display: none; }
  .live { gap: 8px; }
  .quick { gap: 6px; }
  .pill-select { padding: 0 2px 0 10px; }
  .tap-pad { min-height: 120px; }
  .panel { top: auto; width: 100%; height: 86vh; border-radius: 26px 26px 0 0; transform: translateY(104%); }
}
@media (max-width: 760px) and (orientation: portrait) {
  .rotate-hint { display: block; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { display: none; }
  .app { --chrome: 150px; gap: 8px; padding-top: 8px; }
  .transport { padding: 8px 14px; }
  .score-head { min-height: 20px; }
  .tap-pad { min-height: 56px; }
  .tap-sub { display: none; }
}

/* ===== Bass Reader：モード ===== */
.play-badge {
  display: none; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 3px 10px 3px 7px; border-radius: 999px;
}
.play-badge svg { width: 15px; height: 15px; }
.mode-play .play-badge { display: inline-flex; }
.mode-play .live, .mode-play .judge { display: none; }
.mode-play .tap-only { display: none !important; }
.mode-play.playing .tap-pad { border-style: dashed; border-color: var(--line); }

/* ===== コード進行 ===== */
.prog-sel { flex: 1; min-width: 0; max-width: 240px; font-family: var(--font); font-size: 14px; }
.prog-view { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pv-bar { background: var(--surface-2); border-radius: 12px; padding: 7px 7px 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pv-n { font-family: var(--font-num); font-size: 10px; font-weight: 700; color: var(--muted); }
.pv-chord { display: flex; flex-direction: column; min-width: 0; }
.pv-chord b { font-family: var(--font-num); font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-chord small { font-size: 10px; color: var(--ink-soft); line-height: 1.35; overflow-wrap: anywhere; }
.btn-row { display: flex; gap: 8px; }
.btn.sm { padding: 9px 8px; font-size: 13px; border-radius: 12px; }
.btn:disabled { opacity: .4; pointer-events: none; }
.pe-card { width: min(560px, 100%); max-height: calc(100svh - 32px); overflow-y: auto; text-align: left; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.pe-card > * { flex-shrink: 0; }
.pe-title { margin: 0 0 4px; font-size: 18px; }
.pe-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-top: 4px; }
.pe-input {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px;
  padding: 9px 12px; font-size: 15px; font-family: inherit;
}
.pe-input:focus { outline: none; border-color: var(--accent); }
.pe-text { font-family: var(--font-num); font-weight: 600; font-size: 16px; resize: vertical; line-height: 1.5; }
.pe-err { margin: 0; min-height: 1.2em; font-size: 12.5px; font-weight: 700; color: var(--bad); }
.pe-card { width: min(600px, 100%); }
.pe-opts { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.pe-opt { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.pe-opt .select { min-width: 0; font-size: 14px; padding: 6px 10px; }

/* 小節グリッド */
.pe-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pe-bar { background: var(--surface-2); border-radius: 12px; padding: 4px 5px 5px; display: flex; flex-direction: column; gap: 4px; border: 1.5px solid transparent; min-width: 0; }
.pe-bar.sel { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.pe-bn { font-family: var(--font-num); font-size: 10px; font-weight: 700; color: var(--muted); padding-left: 2px; }
.pe-chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 9px; padding: 5px 6px; text-align: left;
  display: flex; flex-direction: column; gap: 1px; min-width: 0; color: var(--ink); transition: background .15s, border-color .15s;
}
.pe-chip b { font-family: var(--font-num); font-size: 14px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; }
.pe-chip small { font-size: 9.5px; color: var(--ink-soft); line-height: 1.3; overflow-wrap: anywhere; }
.pe-chip small.manual { color: var(--accent); font-weight: 700; }
.pe-chip.empty { border-style: dashed; background: transparent; }
.pe-chip.empty b { color: var(--muted); font-size: 12px; }
.pe-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.pe-chip.playing { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pe-chip.playing small { color: inherit; }

/* 入力パレット */
.pe-pal { border: 1.5px solid var(--line); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pe-cur { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pe-cur-main { display: flex; flex-direction: column; min-width: 0; }
.pe-cur-main small { font-size: 11px; color: var(--muted); font-weight: 700; }
.pe-cur-main strong { font-family: var(--font-num); font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
.pe-cur-main strong.empty { font-family: var(--font); font-size: 15px; color: var(--muted); padding: 5px 0; }
.pe-next { flex: none; padding: 8px 14px !important; }
.pe-scale-row { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.pe-scale { flex: 1; min-width: 0; font-family: var(--font); font-size: 13px; padding: 6px 8px; }
.pe-scale:disabled { opacity: .6; }
.pe-scale.manual { border-color: var(--accent); }
.pe-lab { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin-top: 2px; }
.pe-lab small { letter-spacing: 0; font-weight: 500; }

.piano { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); grid-template-rows: 42px 44px; gap: 4px 3px; }
.pk {
  border-radius: 9px; border: 1.5px solid var(--line); font-family: var(--font-num); font-weight: 700; font-size: 15px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; padding: 0; transition: background .12s;
}
.pk.white { background: var(--surface); color: var(--ink); }
.pk.black { background: color-mix(in srgb, var(--ink) 80%, var(--surface)); border-color: transparent; color: var(--surface); }
.pk.black span { font-size: 10.5px; opacity: .5; }
.pk.black span.cur { opacity: 1; font-size: 12px; }
.pk.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pk:disabled { opacity: .35; }
.pe-piano-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 20px; }
.pe-piano-foot .pb { flex: none; font-family: var(--font); font-size: 12px; padding: 6px 10px; }

.pe-btns { display: grid; gap: 5px; }
.pe-btns.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.pe-btns.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pe-btns.c7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.pb {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px 2px;
  font-family: var(--font-num); font-weight: 700; font-size: 14px; transition: background .12s, opacity .12s; min-width: 0;
}
.pb:hover:not(:disabled) { border-color: var(--accent); }
.pb.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pb:disabled { opacity: .28; }
#peQual .pb[data-v=""], #peDeg .pb[data-v=""] { font-family: var(--font); font-size: 12px; }
.pe-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pe-acts .pb { flex: 1 1 auto; font-family: var(--font); font-size: 12.5px; padding: 8px 10px; }

.pe-play { flex: none; }
.pe-play.on { background: var(--accent); color: var(--accent-ink); }
.pe-textbox summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); font-weight: 700; padding: 4px 0; }
.pe-textbox[open] { display: flex; flex-direction: column; gap: 6px; }
.pe-textbox .btn { flex: none; }

@media (max-width: 480px) {
  .pe-card { padding: 20px 14px 16px; }
  .pe-btns.c6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pe-chip { padding: 4px 4px; }
  .pe-chip b { font-size: 12.5px; }
  .pe-chip small { font-size: 8.5px; }
  .pk { font-size: 13px; }
  .pk.black span { font-size: 9px; }
  .pk.black span.cur { font-size: 10.5px; }
}
