/* ── 合成器（js/synth/）── */
.synth-modal { z-index: 40; }
.synth-card { width: min(980px, 100%); padding-bottom: 0; }
.synth-head { display: flex; align-items: center; gap: 10px; }
.synth-head .help-title { margin: 0 auto 0 0; display: flex; align-items: center; gap: 6px; }
.synth-head .help-title .ico { width: 28px; height: 28px; }
.synth-play-mini { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 0.85rem; }
.synth-play-mini.on, .modal-card .synth-play.on { border-color: var(--good); color: var(--good); }
.synth-card .help-lead { margin: 6px 0 10px; font-size: 0.9rem; }

/* 播放／停止的小圖 */
[data-play] .tri, [data-play] .sq { display: inline-block; flex: none; }
[data-play] .tri { width: 0; height: 0; border-left: 10px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
[data-play] .sq { width: 10px; height: 10px; background: currentColor; border-radius: 2px; }

/* 示波器、頻譜 */
.synth-screens { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.synth-screens figure { margin: 0; position: relative; }
.synth-screens canvas { display: block; width: 100%; height: 96px; border: 1px solid var(--line); border-radius: 10px; background: #120d0a; }
.synth-screens figcaption { position: absolute; left: 8px; top: 4px; font-size: 0.7rem; color: var(--muted); pointer-events: none; }

/* 分頁、音量 */
.synth-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 0; }
.synth-tabs { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); }
.synth-tabs .seg { padding: 6px 14px; font-size: 0.95rem; }
.synth-tabs .seg small { margin-left: 6px; font-size: 0.68rem; opacity: 0.75; }
.synth-vol { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.synth-vol .ico { width: 20px; height: 20px; }
.synth-vol input { width: 120px; accent-color: var(--accent); }
.synth-status { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
.synth-status.warn { color: var(--bad); font-weight: 700; }
.synth-status[hidden] { display: none; }

/* 每一區 */
.synth-sec { margin-top: 12px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.synth-sec h3 { margin: 0 0 8px; font-size: 1rem; display: flex; align-items: baseline; gap: 8px; }
.synth-sec h3 small { font-size: 0.72rem; font-weight: 700; color: var(--accent-2); }
.synth-sec h4 { margin: 12px 0 6px; font-size: 0.82rem; color: var(--accent-2); }
.synth-chips .chip { padding: 5px 10px; font-size: 0.82rem; background: var(--panel); }
.synth-chips .chip.on { background: var(--accent); }
.synth-chips .chip i { margin-right: 4px; font-style: normal; font-size: 0.68rem; opacity: 0.6; }
.synth-desc { margin: 8px 0 0; min-height: 1.4em; font-size: 0.86rem; color: var(--text); }
.synth-desc:empty { display: none; }
.synth-note { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }
.synth-note kbd { font-size: 0.72rem; }

.synth-slider { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 5em; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.85rem; color: var(--muted); }
.synth-slider input { width: 100%; accent-color: var(--accent); }
.synth-slider output { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }

.synth-adsr { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: center; margin-top: 4px; }
.synth-adsr-svg { width: 100%; height: auto; background: #120d0a; border: 1px solid var(--line); border-radius: 8px; }
.synth-adsr-svg polyline { fill: rgba(232, 163, 61, 0.18); stroke: var(--accent-2); stroke-width: 2; stroke-linejoin: round; }
.synth-adsr-svg .rel { stroke: var(--line); stroke-dasharray: 3 3; }
.synth-adsr-svg text { fill: var(--muted); font-size: 9px; }

.synth-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.synth-seg .seg { padding: 4px 11px; font-size: 0.85rem; }
.synth-seg .seg.playing:not(.active) { box-shadow: inset 0 0 0 2px var(--good); }

/* 音階鎖定：主音、時鐘 */
.synth-roots .chip { min-width: 42px; padding: 4px 8px; background: var(--panel); text-align: center; }
.synth-roots .chip.on { background: var(--accent); }
.synth-clock-row { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.synth-clock-row > div { min-width: 0; }
.synth-clock { flex: none; width: 160px; height: 160px; }
.synth-clock .ring { fill: none; stroke: var(--line); stroke-width: 1.5; }
.synth-clock polygon { fill: rgba(232, 163, 61, 0.22); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.synth-clock circle.in { fill: var(--accent-2); }
.synth-clock circle.home { fill: var(--good); }
.synth-clock circle.out { fill: var(--line); }
.synth-clock text { font-size: 9.5px; text-anchor: middle; font-weight: 700; }
.synth-clock text.in { fill: var(--text); }
.synth-clock text.out { fill: var(--muted); opacity: 0.6; }

/* 鍵盤：在音色、彈奏頁黏在視窗下面，邊調邊彈 */
.synth-kb-wrap { position: sticky; bottom: 0; z-index: 2; margin: 12px -22px 0; padding: 10px 22px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.synth-kb-wrap[hidden] { display: none; }
.synth-oct { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; font-size: 0.82rem; color: var(--muted); }
.synth-oct .chip { min-width: 34px; padding: 2px 8px; font-size: 1rem; line-height: 1.2; }
.synth-kb { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.synth-keys { position: relative; display: flex; height: 120px; }
.synth-keys .wk { flex: 1; position: relative; margin: 0 1px; border-radius: 0 0 6px 6px; background: linear-gradient(180deg, #e9dfcf, #f7f1e6); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15); }
.synth-keys .wk small { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 0.62rem; color: #7a6650; }
.synth-keys .bk { position: absolute; top: 0; width: calc(100% / 15 * 0.62); height: 62%; transform: translateX(-50%); border-radius: 0 0 5px 5px; background: linear-gradient(180deg, #2a221c, #15110d); box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.08); z-index: 1; }
.synth-keys .wk.on { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.synth-keys .bk.on { background: linear-gradient(180deg, var(--accent), #a86a1a); }
.synth-pads { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; height: 110px; }
.synth-pads .pad { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.synth-pads .pad b { font-size: 1.15rem; line-height: 1.1; }
.synth-pads .pad small { font-size: 0.7rem; color: var(--muted); }
.synth-pads .pad.home { border-color: var(--good); }
.synth-pads .pad.home b { color: var(--good); }
.synth-pads .pad.on { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #2a1806; }
.synth-pads .pad.on b, .synth-pads .pad.on small { color: #2a1806; }

/* 鼓機 */
.synth-transport { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.modal-card .btn.synth-play { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: auto; min-width: 140px; margin: 0; padding: 9px 16px; font-size: 0.95rem; }
.modal-card .btn.synth-play.on { background: var(--panel); border: 1px solid var(--good); color: var(--good); }
.synth-transport .synth-slider { flex: 1 1 220px; margin-top: 0; grid-template-columns: 3em minmax(0, 1fr) 3.5em; }
.synth-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.synth-row .chip { background: var(--panel); }
.synth-row .chip.on { background: var(--accent); }

.synth-grid { display: grid; grid-template-columns: 4.6em repeat(var(--steps), minmax(0, 1fr)); gap: 3px 2px; margin-top: 12px; user-select: none; -webkit-user-select: none; }
.sg-name { padding: 0 4px 0 0; border: none; background: none; color: var(--muted); font-size: 0.74rem; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-name:hover { color: var(--accent-2); }
.sg-cell { position: relative; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); touch-action: manipulation; -webkit-touch-callout: none; }
.sg-cell.beat { background: #2a2018; }
.sg-cell.gap { margin-left: 4px; }
.sg-cell.on { border-color: var(--accent); background: rgba(232, 163, 61, calc(0.3 + var(--v) * 0.7)); }
.sg-cell.now { box-shadow: 0 0 0 2px var(--good) inset; }
.sg-cell.on.now { filter: brightness(1.3); }
.sg-cell[data-roll]::after { content: '×' attr(data-roll); position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.6rem; font-weight: 900; color: #2a1806; }
.sg-vol { grid-column: 2 / -1; display: flex; align-items: center; gap: 8px; }
.sg-vol input { flex: 1; accent-color: var(--accent); }
.sg-vol output { width: 3.2em; font-size: 0.78rem; color: var(--muted); text-align: right; }

@media (max-width: 640px) {
  .synth-card { padding: 14px 12px 0; }
  .synth-card .help-lead { display: none; }
  .synth-screens canvas { height: 72px; }
  .synth-tabs .seg { padding: 5px 10px; }
  .synth-tabs .seg small { display: none; }
  .synth-vol input { width: 90px; }
  .synth-sec { padding: 10px; }
  .synth-adsr { grid-template-columns: 1fr; }
  .synth-adsr-svg { max-width: 260px; }
  .synth-clock-row { flex-direction: column; align-items: flex-start; }
  .synth-kb-wrap { margin: 10px -12px 0; padding: 8px 12px 12px; }
  .synth-keys { height: 104px; }
  .synth-pads { grid-template-columns: repeat(8, minmax(0, 1fr)); height: auto; }
  .synth-pads .pad { height: 52px; }
  .synth-grid { grid-template-columns: 3.4em repeat(var(--steps), minmax(0, 1fr)); gap: 3px 1px; }
  .sg-name { font-size: 0.64rem; }
  .sg-cell { height: 22px; border-radius: 3px; }
  .sg-cell.gap { margin-left: 2px; }
  .sg-cell[data-roll]::after { content: attr(data-roll); }
  .synth-play-mini { padding: 5px 9px; font-size: 0.78rem; }
}
