/* Pianoroll Lab: a calm reading surface for long study sessions. Paper-toned light theme, graphite notes,
   one indigo accent for "now" (playhead, sounding notes, the active range, primary actions). */

:root {
    --paper: #f6f4ef;
    --surface: #fdfcf9;
    --sunken: #eeebe4;
    --ink: #23211d;
    --ink-2: #5c574e;
    --ink-3: #847e73;
    --rule: #e1dcd2;
    --rule-strong: #cdc6b8;
    --accent: #2b59a1;
    --accent-ink: #ffffff;
    --danger: #a8402b;
    --roll-bg: #f1eee8;
    --roll-black: #e7e2d9;
    --roll-line: #d4cdc0;
    --roll-lane: #f9f7f3;
    --note: #463f35;
    --key-white: #fdfcf9;
    --key-black: #39362f;
    --key-line: #c9c1b3;
    --key-label: #6b655b;
    --kb-white: #fffefb;
    --kb-black: #2e2b26;
    --shadow: 0 12px 32px rgba(40, 32, 20, 0.14);
    --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    --chord: "Avenir Next Condensed", "Bahnschrift SemiCondensed", "Roboto Condensed", "Arial Narrow", -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
    --th: 61px;
    --sticky-h: 61px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #1a1917;
        --surface: #22211e;
        --sunken: #151413;
        --ink: #ece8e0;
        --ink-2: #b8b1a5;
        --ink-3: #8c857a;
        --rule: #33302b;
        --rule-strong: #4a463e;
        --accent: #86aae6;
        --accent-ink: #0f1520;
        --danger: #e08a72;
        --roll-bg: #161513;
        --roll-black: #1e1d1a;
        --roll-line: #35322c;
        --roll-lane: #1c1b18;
        --note: #d6cfc2;
        --key-white: #d4cfc5;
        --key-black: #24221e;
        --key-line: #8f887b;
        --key-label: #3e3a33;
        --kb-white: #d9d4ca;
        --kb-black: #2a2824;
        --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 17px/1.75 var(--font);
    overflow-x: hidden;
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; z-index: 100; padding: 6px 12px; background: var(--accent); color: var(--accent-ink); border-radius: 6px; }
.skip:focus { top: 8px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
kbd { font: 600 12px/1 var(--font); padding: 3px 6px; border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }

/* chord symbols and roman numerals: condensed, tabular, legible */
.sym { font-family: var(--chord); font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0.005em; }
.rn { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- controls */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    font-size: 14px; line-height: 1.25; white-space: nowrap; text-decoration: none;
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--rule-strong); border-radius: 8px;
    cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.icon-btn { width: 34px; height: 34px; justify-content: center; padding: 0; font-weight: 700; }

select {
    appearance: none; -webkit-appearance: none;
    padding: 6px 26px 6px 10px;
    font-size: 14px; line-height: 1.3;
    color: var(--ink);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23847e73' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 9px center;
    border: 1px solid var(--rule-strong); border-radius: 8px;
    cursor: pointer;
    max-width: 100%;
    text-overflow: ellipsis;
}

.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { padding: 4px 10px; font-size: 13px; line-height: 1.3; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:disabled { opacity: 0.4; cursor: default; }
.seg.zoom button { width: 32px; padding: 3px 0; font-size: 16px; }

/* ---------------------------------------------------------------- index page */
.index-page main { max-width: 880px; margin: 0 auto; padding: 56px 24px 96px; }
.masthead h1 { margin: 0; font-size: 44px; line-height: 1.15; font-weight: 800; letter-spacing: -0.015em; }
.masthead .sub { margin: 14px 0 0; max-width: 34em; color: var(--ink-2); font-size: 18px; }
.masthead .count { margin: 10px 0 0; color: var(--ink-3); font-size: 14px; }
.hero-roll { display: block; width: 100%; height: 96px; margin: 28px 0 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--roll-bg); }
.list-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 36px 0 4px; }
.list-tools .seg button { padding: 5px 12px; font-size: 14px; }
.list-tools .seg .n { margin-left: 4px; font-variant-numeric: tabular-nums; opacity: 0.7; }
.song-list { list-style: none; padding: 0; margin: 12px 0 0; }
.song-list > li { border-top: 1px solid var(--rule); }
.song-list > li:last-child { border-bottom: 1px solid var(--rule); }
.song {
    display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 0 16px;
    padding: 22px 4px 22px 0;
    color: inherit; text-decoration: none;
}
a.song:hover .song-title { color: var(--accent); }
a.song:focus-visible { outline-offset: -2px; border-radius: 8px; }
.song-num { font-size: 30px; line-height: 1.15; font-weight: 300; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.song-title-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.song-title { margin: 0; font-size: 22px; line-height: 1.4; font-weight: 700; }
.status { font-size: 12px; line-height: 1.6; padding: 1px 8px; border-radius: 4px; white-space: nowrap; }
.status.transcribed { color: var(--ink-2); background: var(--sunken); }
.status.pending { color: var(--ink-3); border: 1px dashed var(--rule-strong); }
.song.is-pending { cursor: default; }
.song.is-pending .song-title { color: var(--ink-2); }
.meta-line { display: flex; flex-wrap: wrap; list-style: none; margin: 4px 0 0; padding: 0; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.meta-line li + li::before { content: ""; display: inline-block; width: 1px; height: 12px; margin: 0 10px; background: var(--rule-strong); vertical-align: -1px; }
.song-summary { margin: 8px 0 0; color: var(--ink-2); font-size: 16px; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 10px 0 0; padding: 0; }
.tags li { padding: 1px 9px; font-size: 13px; line-height: 1.7; border-radius: 999px; background: var(--sunken); color: var(--ink-2); }
.empty-list { padding: 24px 0; color: var(--ink-3); }
.site-foot { margin-top: 40px; font-size: 13px; color: var(--ink-3); }

/* ---------------------------------------------------------------- song header */
.song-head { max-width: 1680px; margin: 0 auto; padding: 18px 24px 14px; }
.back { font-size: 14px; color: var(--ink-2); text-decoration: none; }
.back:hover { color: var(--accent); }
.song-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; margin-top: 4px; }
.song-title-row h1 { margin: 0; font-size: 32px; line-height: 1.3; font-weight: 800; letter-spacing: 0.01em; }
.artist { color: var(--ink-2); font-size: 15px; }
.song-facts { display: flex; flex-wrap: wrap; list-style: none; margin: 4px 0 0; padding: 0; font-size: 14px; color: var(--ink-2); }
.song-facts li + li::before { content: ""; display: inline-block; width: 1px; height: 12px; margin: 0 10px; background: var(--rule-strong); vertical-align: -1px; }
.song-tempo { margin: 0; font-size: 14px; color: var(--ink-2); }
.song-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fatal-msg { color: var(--ink-2); }
.accuracy-note { margin: 10px 0 0; max-width: 46em; padding: 8px 12px; font-size: 14px; line-height: 1.6; color: var(--ink-2); background: color-mix(in srgb, #c0822c 12%, var(--paper)); border-radius: 8px; }
.accuracy-note .label { background: color-mix(in srgb, #c0822c 26%, transparent); color: var(--ink); }

/* ---------------------------------------------------------------- transport (sticky) */
.transport {
    position: sticky; top: 0; z-index: 30;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
    padding: 8px max(24px, calc((100vw - 1680px) / 2 + 24px));
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}
.play-btn {
    flex: none; display: grid; place-items: center;
    width: 44px; height: 44px; padding: 0;
    color: var(--accent-ink); background: var(--accent);
    border: 0; border-radius: 50%; cursor: pointer;
}
.play-btn svg { width: 22px; height: 22px; fill: currentColor; }
.play-btn .i-pause, .play-btn .i-wait { display: none; }
.play-btn.is-playing .i-play, .play-btn.is-waiting .i-play { display: none; }
.play-btn.is-playing .i-pause { display: block; }
.play-btn.is-waiting .i-wait { display: block; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.time { flex: none; font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
#tCur { color: var(--ink); display: inline-block; min-width: 3.4em; }
.time-sep { margin: 0 4px; color: var(--ink-3); }

.seek { position: relative; flex: 1 1 220px; min-width: 120px; height: 30px; cursor: pointer; touch-action: none; }
.seek-track { position: absolute; left: 0; right: 0; top: 11px; height: 8px; overflow: hidden; border-radius: 4px; background: var(--sunken); }
.seek-sec { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--c) 42%, transparent); box-shadow: inset 1px 0 0 var(--paper); }
.seek-fill { position: absolute; left: 0; top: 14px; height: 2px; border-radius: 1px; background: var(--ink); opacity: 0.6; pointer-events: none; }
.seek-range { position: absolute; top: 6px; height: 18px; border: 2px solid var(--accent); border-radius: 5px; pointer-events: none; }
.seek-thumb { position: absolute; top: 5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--accent); pointer-events: none; box-shadow: 0 0 0 2px var(--paper); }

.range-chip {
    display: flex; align-items: center; gap: 8px;
    min-width: 0; max-width: 380px;
    padding: 3px 4px 3px 12px;
    font-size: 14px; line-height: 1.4;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 13%, var(--paper));
}
.rc-kind { color: var(--accent); font-weight: 700; white-space: nowrap; }
.rc-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.rc-exit { flex: none; padding: 3px 10px; font-size: 13px; color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 999px; cursor: pointer; }

.t-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.t-controls .toggle svg { width: 16px; height: 16px; fill: currentColor; }
#loopBtn { padding: 6px 10px; }
.sound-chip {
    max-width: 180px; overflow: hidden; text-overflow: ellipsis;
    padding: 6px 12px;
    font-size: 13px; line-height: 1.3; white-space: nowrap; font-variant-numeric: tabular-nums;
    color: var(--ink-2); background: var(--surface);
    border: 1px solid var(--rule-strong); border-radius: 999px;
    cursor: pointer;
}
.sound-chip.is-cta { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.sound-chip.is-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent); }

.pop-wrap { position: relative; }
.popover {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
    width: 310px;
    max-width: calc(100vw - 32px);
    padding: 14px 16px;
    font-size: 14px; line-height: 1.6;
    background: var(--surface);
    border: 1px solid var(--rule-strong); border-radius: 12px;
    box-shadow: var(--shadow);
}
.pop-status { margin: 0 0 10px; color: var(--ink-2); }
.field { display: grid; grid-template-columns: 3em 1fr; align-items: center; gap: 8px; margin: 8px 0; }
.field select { width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.help dl { margin: 0; display: grid; gap: 6px; }
.help dl div { display: grid; grid-template-columns: 7.5em 1fr; align-items: center; }
.help dt { white-space: nowrap; }
.help dd { margin: 0; }
.help p { margin: 10px 0 0; color: var(--ink-2); }

.notice {
    position: fixed; left: 50%; bottom: 18px; z-index: 50; transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px;
    width: max-content; max-width: min(620px, calc(100vw - 32px));
    padding: 10px 10px 10px 16px;
    font-size: 14px; line-height: 1.55;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--rule-strong); border-left: 4px solid var(--danger); border-radius: 10px;
    box-shadow: var(--shadow);
}
.notice-close { flex: none; width: 28px; height: 28px; border: 0; background: none; color: var(--ink-3); font-size: 20px; line-height: 1; cursor: pointer; }

/* ---------------------------------------------------------------- stage: video, roll, minimap */
.layout { max-width: 1680px; margin: 0 auto; padding: 12px 24px 96px; }
.stage { background: var(--paper); }
.videobox { margin: 0 0 8px; }
.video-frame { position: relative; width: min(100%, calc(34vh * 16 / 9)); aspect-ratio: 16 / 9; margin: 0 auto; overflow: hidden; border-radius: 10px; background: #000; }
.video-frame iframe, .video-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.videobox.collapsed .video-frame { height: 0; aspect-ratio: auto; }
.video-msg { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 10px 14px; font-size: 14px; color: var(--ink-2); background: var(--sunken); border-radius: 10px; }

.rolltools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 2px 0 8px; }
.now { display: flex; align-items: baseline; gap: 10px; min-width: 0; min-height: 30px; }
.now-sec { padding: 0 8px; font-size: 13px; font-weight: 600; line-height: 1.6; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 20%, transparent); border-radius: 0 5px 5px 0; white-space: nowrap; }
.now-sec:empty { display: none; }
.now-chord { font-size: 23px; line-height: 1.2; white-space: nowrap; }
.now-rn { font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.rt-right { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.rollwrap { position: relative; height: 36vh; min-height: 210px; overflow: hidden; border: 1px solid var(--rule); border-radius: 10px; background: var(--roll-bg); }
.rollwrap canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.minimap { display: block; width: 100%; height: 34px; margin-top: 6px; border-radius: 6px; cursor: pointer; touch-action: none; }

/* ---------------------------------------------------------------- analysis panel */
.panel { min-width: 0; }
.tabs {
    position: sticky; top: var(--sticky-h); z-index: 15;
    display: flex; gap: 4px;
    margin: 0 0 20px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}
.tab { position: relative; padding: 10px 12px 9px; font-size: 16px; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.tab::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: transparent; }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 700; }
.tab[aria-selected="true"]::after { background: var(--accent); }
.tab-count { margin-left: 4px; font-size: 12px; font-weight: 400; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tabpanel { outline: none; }
.tabpanel p { margin: 0 0 12px; }
.ph { margin: 30px 0 10px; font-size: 15px; font-weight: 700; color: var(--ink); }
.lead { font-size: 18px; line-height: 1.85; }
.lead.empty { color: var(--ink-2); }
.small-text { font-size: 15px; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--ink-3); }
.ts {
    padding: 0 3px; margin: 0 1px;
    font: inherit; font-variant-numeric: tabular-nums;
    color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent);
    border: 0; border-radius: 4px; cursor: pointer;
}
.ts:hover { text-decoration: underline; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); gap: 10px 18px; margin: 18px 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.facts div { min-width: 0; }
.facts div.wide { grid-column: 1 / -1; }
.facts dt { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.facts dd { margin: 0; font-size: 15px; line-height: 1.5; }
.takeaways { list-style: none; margin: 0; padding: 0; }
.takeaways li { position: relative; padding: 10px 0 10px 20px; border-top: 1px solid var(--rule); }
.takeaways li:last-child { border-bottom: 1px solid var(--rule); }
.takeaways li::before { content: ""; position: absolute; left: 0; top: 23px; width: 10px; height: 2px; background: var(--accent); }

.tech-index { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 1px; }
.tech-index a { display: grid; grid-template-columns: 8px 4.6em minmax(0, 1fr); align-items: baseline; gap: 10px; padding: 6px 8px; font-size: 15px; line-height: 1.5; color: var(--ink); text-decoration: none; border-radius: 8px; }
.tech-index a:hover { background: var(--sunken); }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); align-self: center; }
.ti-cat { font-size: 12px; color: color-mix(in srgb, var(--c) 75%, var(--ink)); white-space: nowrap; }

/* 曲式 */
.sections { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.sec-card { padding: 12px 16px; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--c); border-radius: 6px 10px 10px 6px; }
.sec-card.is-current { border-color: var(--accent); border-left-color: var(--c); box-shadow: 0 0 0 1px var(--accent); }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 6px; }
.sec-name { font-size: 17px; font-weight: 700; }
.sec-meta { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sec-head .btn { margin-left: auto; }
.sec-card p { margin: 6px 0 0; font-size: 16px; }
.texture { color: var(--ink-2); }
.label { display: inline-block; margin-right: 8px; padding: 0 6px; font-size: 12px; line-height: 1.7; color: var(--ink-2); background: var(--sunken); border-radius: 4px; vertical-align: 1px; }

/* 和弦 */
.chord-now { margin: 0 0 8px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.cn-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; min-height: 40px; }
.cn-label { font-size: 12px; color: var(--ink-3); }
.cn-sym { font-size: 28px; line-height: 1.3; }
.cn-rn { font-size: 18px; color: var(--ink-2); }
.cn-note { flex-basis: 100%; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.cn-none { font-size: 14px; color: var(--ink-3); }
.cgroup { margin: 0 0 20px; }
.cg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 8px; padding-left: 10px; border-left: 3px solid var(--c); }
.cg-head .sec-name { font-size: 16px; }
.cg-head .btn { margin-left: auto; }
.cgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.cchip {
    display: flex; flex-direction: column; gap: 1px;
    width: 100%; height: 100%;
    padding: 6px 9px 7px;
    text-align: left;
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--rule); border-radius: 8px;
    cursor: pointer;
}
.cchip:hover { border-color: var(--ink-3); }
.cchip .sym { font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.cchip .rn { font-size: 13px; line-height: 1.35; color: var(--ink-2); overflow-wrap: anywhere; }
.cchip .cnote { margin-top: 3px; font-size: 11.5px; line-height: 1.4; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cchip.cont { border-style: dashed; }
.cchip.is-current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, var(--surface)); box-shadow: inset 0 0 0 1px var(--accent); }
.cchip.is-current .sym { color: var(--accent); }

/* 技巧: the protagonists, set as articles rather than boxes */
.tech { margin-top: 34px; padding-top: 18px; border-top: 3px solid var(--c); scroll-margin-top: calc(var(--sticky-h) + 60px); outline: none; }
.tech-head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.cat { padding: 0 8px; font-size: 12px; font-weight: 700; line-height: 1.8; color: color-mix(in srgb, var(--c) 72%, var(--ink)); background: color-mix(in srgb, var(--c) 15%, transparent); border-radius: 4px; }
.tech-title { margin: 0; font-size: 21px; line-height: 1.45; font-weight: 800; }
.tech-sum { margin: 8px 0 14px !important; font-size: 17px; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.row-label { flex-basis: 100%; font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.ex-btn { max-width: 100%; }
.ex-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ex-icon { font-size: 11px; color: var(--accent); }
.ex-time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ex-btn.is-active { border-color: var(--accent); }
.ex-btn.is-playing { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.ex-btn.is-playing .ex-icon, .ex-btn.is-playing .ex-time { color: inherit; opacity: 0.85; }
details.more { border-top: 1px solid var(--rule); }
details.more:last-of-type { border-bottom: 1px solid var(--rule); }
details.more summary { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 15px; font-weight: 700; list-style: none; cursor: pointer; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: ""; width: 7px; height: 7px; margin: 0 2px 2px 2px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); transition: transform 0.15s; }
details.more[open] summary::before { transform: rotate(45deg); }
.more-body { padding: 0 0 12px 19px; font-size: 16px; }
.tech-sub { margin-top: 16px; padding: 14px 16px; background: var(--sunken); border-radius: 10px; }
.tech-sub h4 { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.tech-sub > p { font-size: 16px; }
.practice { margin: 6px 0 0; padding-left: 1.3em; font-size: 15px; }
.practice li { margin: 3px 0; }

.vz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.voicing { margin: 0; padding: 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; min-width: 0; }
.vz-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.vz-label { font-size: 19px; }
.vz-time, .vz-at { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.vz-at .sym { font-size: 13px; color: var(--ink-2); }
.vz-play { margin-left: auto; }
.vz-note { margin: 4px 0 8px !important; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.vz-body { display: grid; gap: 8px; margin-top: 6px; min-height: 250px; align-content: start; }
.vz-loading { color: var(--ink-3); }
.kb { display: block; width: 100%; height: auto; margin: 0 auto; }
.k-w { fill: var(--kb-white); stroke: var(--rule-strong); stroke-width: 0.6; }
.k-b { fill: var(--kb-black); }
.k-w.on, .k-b.on { fill: var(--accent); }
.k-w.on.soft, .k-b.on.soft { fill: color-mix(in srgb, var(--accent) 40%, var(--kb-white)); }
@media (prefers-color-scheme: dark) { .k-w.on.soft, .k-b.on.soft { fill: color-mix(in srgb, var(--accent) 60%, #4a4740); } }
.k-lab { font: 700 6.4px var(--chord); fill: var(--accent-ink); }
.k-w.soft + .k-lab { fill: var(--ink); }
.k-lab-b { fill: var(--accent); }
.k-c { font: 500 5.4px var(--font); fill: #8a8378; }
.vz-staff { color: var(--ink); max-width: 300px; }
.vz-tones { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.vz-tones .sym { font-size: 15px; }
.vz-tones li.soft { color: var(--ink-3); }
.vz-legend { margin: 0 !important; font-size: 12px; color: var(--ink-3); }

.demo { margin-top: 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; min-width: 0; }
.demo-head { display: flex; flex-direction: column; gap: 8px; }
.demo-title { font-size: 16px; font-weight: 700; line-height: 1.5; }
.demo-kicker { margin-right: 8px; padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 4px; vertical-align: 1px; }
.demo-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.demo-play { min-width: 7.5em; justify-content: center; }
.demo-play.is-playing { filter: none; }
.demo-tr-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.demo-tempo { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.demo-chords { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 12px 0 4px; padding: 0; }
.demo-chords li { padding: 1px 8px; font-size: 15px; line-height: 1.6; background: var(--sunken); border-radius: 6px; }
.demo-chords li.is-current { color: var(--accent-ink); background: var(--accent); }
.demo-staff { color: var(--ink); overflow: hidden; min-height: 150px; }
.demo-abc { min-height: 0; }
.demo-staff svg { display: block; }
.demo-roll { margin-top: 6px; }
.demo-canvas { display: block; width: 100%; border-radius: 6px; }
.demo-abc { margin-top: 8px; }
.abcjs-container { color: var(--ink); }
.vz-staff svg, .demo-staff svg { overflow: visible; }
text.abcjs-chord, .abcjs-chord text { font-family: var(--chord) !important; font-weight: 600; }

/* ---------------------------------------------------------------- layouts */
@media (min-width: 1100px) {
    .song-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; align-items: end; }
    .song-head > * { grid-column: 1; }
    .song-head > .song-links { grid-column: 2; grid-row: 2 / span 3; align-self: end; margin: 0 0 2px; }
    .layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 31rem); gap: 32px; align-items: start; }
    .stage { position: sticky; top: calc(var(--th) + 10px); display: flex; flex-direction: column; height: calc(100vh - var(--th) - 20px); }
    .rollwrap { flex: 1 1 auto; height: auto; min-height: 260px; }
    #pinBtn { display: none; }
    .tabs { top: var(--th); }
}
@media (max-width: 1099.98px) {
    body:not(.unpinned) .stage { position: sticky; top: var(--th); z-index: 20; margin: 0 -24px; padding: 0 24px 8px; border-bottom: 1px solid var(--rule); }
    .panel { margin-top: 18px; }
    .layout > .videobox { margin-bottom: 10px; }
    .layout > .videobox .video-frame { width: min(100%, calc(56vh * 16 / 9)); }
}
@media (max-width: 760px) {
    body { font-size: 16px; }
    .song-head { padding: 14px 16px 10px; }
    .song-title-row h1 { font-size: 26px; }
    .transport { padding: 6px 16px 8px; gap: 6px 10px; }
    .play-btn { width: 40px; height: 40px; }
    .time { font-size: 14px; }
    .seek { flex: 1 1 120px; }
    .range-chip { order: 4; flex: 1 1 100%; max-width: none; }
    .t-controls { order: 5; flex: 1 1 100%; margin-left: 0; gap: 6px; }
    #loopBtn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    #speedSel { padding-right: 22px; background-position: right 7px center; }
    #sourceSel { max-width: 150px; padding-right: 22px; background-position: right 7px center; }
    .sound-chip { max-width: 128px; padding: 6px 10px; }
    .t-controls .pop-wrap:last-child { margin-left: auto; }
    .layout { padding: 8px 16px 80px; }
    body:not(.unpinned) .stage { margin: 0 -16px; padding: 0 16px 8px; }
    .rollwrap { height: 27vh; min-height: 170px; }
    .rolltools { flex-wrap: nowrap; padding-bottom: 6px; }
    .now { flex: 1 1 auto; overflow: hidden; gap: 8px; }
    .now-chord { font-size: 19px; }
    .rt-right { flex: none; gap: 4px; }
    .seg button { padding: 3px 8px; font-size: 12px; }
    .seg.zoom button { width: 28px; font-size: 15px; }
    #pinBtn, #videoBtn { padding: 3px 8px; font-size: 12px; }
    .minimap { height: 26px; margin-top: 4px; }
    .index-page main { padding: 36px 16px 72px; }
    .masthead h1 { font-size: 34px; }
    .masthead .sub { font-size: 16px; }
    .hero-roll { height: 72px; margin-top: 22px; }
    .song { grid-template-columns: 2.4rem minmax(0, 1fr); gap: 0 10px; }
    .song-num { font-size: 22px; }
    .song-title { font-size: 19px; }
    .tech-title { font-size: 19px; }
    .lead { font-size: 17px; }
    .tab { padding: 10px 10px 9px; font-size: 15px; }
    .cgrid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}
@media (max-width: 420px) {
    .t-controls .pop-wrap:last-child { display: none; }
    .t-controls > * { min-width: 0; }
    .t-controls .pop-wrap { flex: 0 1 auto; }
    #sourceSel { max-width: 128px; }
    .sound-chip { max-width: 100%; }
    .cta-long { display: none; }
    .now-rn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
