:root {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: #111827;
    --text: #f8fafc;
    --field: #020617;
    --muted: #cbd5e1;
    --line: #334155;
    --blue: #60a5fa;
    --green: #22c55e;
    --red: #fb7185;
    --soft-blue: #1e293b;
    --soft-green: #052e16;
    --status: #1e293b;
    --status-text: #e2e8f0;
}
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: #111827;
    --text: #f8fafc;
    --field: #020617;
    --muted: #cbd5e1;
    --line: #334155;
    --blue: #60a5fa;
    --green: #22c55e;
    --red: #fb7185;
    --soft-blue: #1e293b;
    --soft-green: #052e16;
    --status: #1e293b;
    --status-text: #e2e8f0;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}
main {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}
.top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 0 0 20px;
    border-bottom: 1px solid var(--line);
}
.top-title {
    display: grid;
    gap: 8px;
}
h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 52px);
    line-height: 1.02;
    letter-spacing: 0;
}
.lead {
    margin: 0;
    color: var(--muted);
    font-size: 16px;
}
.cat-status {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    background: var(--soft-green);
    color: var(--text);
    font-weight: 800;
}
.cat-status.busy {
    border-color: var(--red);
    background: #3f1d2a;
    color: #fff;
}
.zzmap-launch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    font-weight: 900;
    white-space: nowrap;
}
.zzmap-launch:hover { filter: brightness(1.08); }
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 18px;
    justify-items: center;
}
.top, .grid > section {
    width: min(1440px, 100%);
}
section, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}
h2 {
    margin: 0 0 12px;
    font-size: 18px;
}
.lines {
    display: grid;
    gap: 8px;
    color: var(--status-text);
    font-size: 15px;
    line-height: 1.55;
}
.rule {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--soft-blue);
    color: var(--text);
}
.choice-row, .action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
button, .download {
    border: 0;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-weight: 800;
    padding: 11px 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
}
button.secondary {
    background: #e2e8f0;
    color: #0f172a;
}
html[data-theme="dark"] button.secondary {
    background: #334155;
    color: #f8fafc;
}
button.active {
    background: var(--green);
    color: #fff;
}
button:disabled {
    opacity: .55;
    cursor: not-allowed;
}
label {
    display: grid;
    gap: 7px;
    color: var(--status-text);
    font-weight: 700;
    margin-top: 14px;
}
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
}
.input-grid label {
    align-content: start;
}
input[type="url"], input[type="text"], input[type="file"] {
    width: 100%;
    height: 66px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
    color: var(--text);
    font: inherit;
}
input[type="url"], input[type="text"] {
    padding: 0 14px;
}
input[type="file"] {
    padding: 13px 14px;
}
input[type="file"]::file-selector-button {
    border: 0;
    border-radius: 4px;
    margin-right: 10px;
    padding: 10px 12px;
    background: #e2e8f0;
    color: #0f172a;
    font: inherit;
    font-weight: 800;
}
html[data-theme="dark"] input[type="file"]::file-selector-button {
    background: #475569;
    color: #f8fafc;
}
.hint {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}
.status {
    margin-top: 14px;
    border-radius: 8px;
    padding: 12px;
    background: var(--status);
    color: var(--status-text);
    white-space: pre-wrap;
    line-height: 1.55;
    min-height: 48px;
}
.status.error {
    background: #fef2f2;
    color: var(--red);
}
html[data-theme="dark"] .status.error {
    background: #3f1d2a;
}
.status.ok {
    background: var(--soft-green);
    color: var(--text);
}
.source-info {
    margin-top: 14px;
}
.source-info h2 {
    margin-top: 0;
}
.source-info-body {
    display: grid;
    gap: 10px;
}
.source-thumb {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--field);
}
.source-video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
}
.source-lines {
    display: grid;
    gap: 7px;
    color: var(--status-text);
    line-height: 1.45;
}
.source-lines strong {
    color: var(--text);
}
.player-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.player-controls input[type="range"] {
    flex: 1 1 220px;
    accent-color: var(--green);
}
.player-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}
.player-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--field);
}
.choice-intro {
    margin: 0 0 10px;
    color: var(--status-text);
    font-weight: 800;
}

#screenSharePanel {
    width: min(1440px, 100%);
    justify-self: center;
}
.screen-share-shell {
    display: grid;
    gap: 14px;
}
.screen-share-head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}
.screen-share-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.screen-share-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    background: var(--field);
    color: var(--status-text);
    font-size: 13px;
    font-weight: 800;
}
.screen-share-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: end;
}
.screen-share-toolbar label {
    min-width: min(260px, 100%);
    margin-top: 0;
}
.screen-share-toolbar input[type="text"] {
    height: 42px;
}
.screen-share-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 540px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #020617;
}
.screen-share-stage video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #020617;
    display: block;
}
.screen-share-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-weight: 800;
    pointer-events: none;
}
.screen-share-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.screen-share-picker button {
    background: #334155;
}
.screen-share-picker button.active {
    background: var(--green);
}
.screen-share-quality {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}
.screen-share-chat {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: var(--field);
}
.screen-share-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--status-text);
    font-size: 13px;
    font-weight: 900;
}
.screen-share-chat-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.screen-share-chat-messages {
    display: grid;
    align-content: start;
    gap: 8px;
    min-height: 96px;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: #020617;
}
.screen-share-chat-empty {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}
.screen-share-chat-message {
    display: grid;
    gap: 5px;
    padding: 8px 10px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 10px;
    background: rgba(15, 23, 42, .72);
}
.screen-share-chat-message.own {
    border-color: rgba(34, 197, 94, .55);
}
.screen-share-chat-meta {
    color: var(--muted);
    font-size: 15px;
    font-weight: 850;
}
.screen-share-chat-text {
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.screen-share-chat-form {
    display: flex;
    gap: 8px;
}
.screen-share-chat-form input[type="text"] {
    flex: 1 1 auto;
    height: 42px;
}
.screen-share-chat-form button {
    flex: 0 0 auto;
}

.hidden { display: none !important; }
@media (max-width: 760px) {
    main { width: min(100% - 22px, 1440px); padding-top: 22px; }
    .top, .grid > section { width: 100%; }
    #screenSharePanel { width: 100%; }
    .screen-share-stage { min-height: auto; }
    .grid { grid-template-columns: 1fr; }
    .top { align-items: stretch; flex-direction: column; }
    .input-grid { grid-template-columns: 1fr; }
    section, .panel { padding: 14px; }
    .screen-share-chat-form { flex-direction: column; }
    .screen-share-chat-form button { width: 100%; }
    .choice-row button { flex: 1 1 100%; }
}


/* 功能 D：四音軌播放器 */
.stem-player-panel {
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: color-mix(in srgb, var(--panel) 88%, #7c3aed 12%);
}
.stem-player-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.stem-title-wrap h2 { margin: 0 0 5px; }
.stem-title-wrap p { margin: 0; color: var(--muted); font-size: 13px; }
.stem-track-list { display: grid; }
.stem-track-row {
    display: grid;
    grid-template-columns: minmax(92px, 130px) minmax(150px, 1fr) minmax(132px, 172px) 72px 88px;
    align-items: center;
    gap: 14px;
    min-height: 74px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
}
.stem-track-label {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}
.stem-track-color {
    display: inline-block;
    width: 4px;
    height: 36px;
    border-radius: 999px;
    flex: 0 0 auto;
}
.stem-color-0 { background: #7c3aed; }
.stem-color-1 { background: #06b6d4; }
.stem-color-2 { background: #f59e0b; }
.stem-color-3 { background: #ec4899; }
.stem-waveform {
    position: relative;
    display: block;
    width: 100%;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
}
.stem-wave-base,
.stem-wave-progress {
    position: absolute;
    inset: 0;
    background-image: var(--wave-image, linear-gradient(90deg, transparent, transparent)), repeating-linear-gradient(90deg, rgba(148,163,184,.45) 0 2px, transparent 2px 5px);
    background-position: center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    pointer-events: none;
}
.stem-wave-base { opacity: .33; filter: grayscale(1); }
.stem-wave-progress {
    width: 100%;
    right: 0;
    clip-path: inset(0 100% 0 0);
    opacity: .96;
    filter: var(--stem-wave-filter, none);
}
.stem-volume-control {
    display: grid;
    grid-template-columns: minmax(86px, 1fr) 30px;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.stem-volume-control input[type="range"] {
    width: 100%;
    min-width: 0;
    margin: 0;
    accent-color: #8b5cf6;
    cursor: pointer;
}
.stem-volume-value {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.stem-color-bg-0 { background-color: rgba(124,58,237,.12); }
.stem-color-bg-1 { background-color: rgba(6,182,212,.12); }
.stem-color-bg-2 { background-color: rgba(245,158,11,.12); }
.stem-color-bg-3 { background-color: rgba(236,72,153,.12); }
.stem-toggle {
    min-width: 72px;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid rgba(248,250,252,.66);
    border-radius: 9px;
    background: rgba(248,250,252,.22);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.16),
        0 0 10px rgba(248,250,252,.07);
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.stem-toggle:hover {
    border-color: rgba(255,255,255,.82);
    background: rgba(248,250,252,.28);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.20),
        0 0 12px rgba(248,250,252,.10);
}
.stem-toggle:active {
    transform: translateY(1px);
}
.stem-toggle.muted {
    border-color: rgba(148,163,184,.24);
    background: rgba(15,23,42,.22);
    color: transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.stem-toggle.muted:hover {
    border-color: rgba(148,163,184,.38);
    background: rgba(30,41,59,.34);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.stem-download-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid rgba(34,197,94,.55);
    border-radius: 10px;
    background: rgba(34,197,94,.14);
    color: #bbf7d0;
    font-weight: 900;
    text-decoration: none;
    white-space: nowrap;
}
.stem-download-all:hover { background: rgba(34,197,94,.25); }
.stem-download {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 82px;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid rgba(139,92,246,.55);
    border-radius: 9px;
    background: rgba(124,58,237,.12);
    color: #c4b5fd;
    font-weight: 900;
    text-decoration: none;
    white-space: nowrap;
}
.stem-download:hover { background: rgba(124,58,237,.24); }
.stem-master-controls {
    display: grid;
    grid-template-columns: 48px auto minmax(160px, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 16px 18px 10px;
}
.stem-play-button {
    width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font-size: 17px;
}
.stem-master-controls input[type="range"] { width: 100%; accent-color: #8b5cf6; }
.stem-player-status { padding: 0 18px 16px; color: var(--muted); font-size: 13px; }

/* D 執行中只鎖定輸入與功能按鈕；進度顯示在「轉檔貓咪」狀態文字，不遮住整頁。 */
@media (max-width: 1000px) {
    .stem-track-row {
        grid-template-columns: 92px minmax(0, 1fr) minmax(118px, 148px) 68px 82px;
        gap: 10px;
    }
}
@media (max-width: 620px) {
    .stem-player-head { align-items: stretch; flex-direction: column; }
    .stem-download-all { width: 100%; }
    .stem-track-row {
        grid-template-columns: 1fr auto;
        gap: 9px 12px;
        padding: 14px;
    }
    .stem-track-label { grid-column: 1; grid-row: 1; }
    .stem-download { grid-column: 2; grid-row: 1; }
    .stem-waveform { grid-column: 1 / -1; grid-row: 2; }
    .stem-volume-control { grid-column: 1 / -1; grid-row: 3; }
    .stem-toggle { grid-column: 1; grid-row: 4; justify-self: start; }
    .stem-master-controls { grid-template-columns: 46px 1fr auto; }
    .stem-master-controls #stemCurrent { display: none; }
    .stem-master-controls #stemSeek { grid-column: 2; }
}


/* D 功能說明旁的小型試聽入口 */
.stem-demo-line {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}
.stem-demo-open {
    appearance: none;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #bfdbfe;
    font: inherit;
    font-size: 12px;
    line-height: inherit;
    font-weight: 900;
    box-shadow: none;
}
.stem-demo-open:hover {
    background: transparent;
    color: #dbeafe;
    text-decoration: underline;
}
.stem-demo-open:focus-visible {
    outline: 2px solid rgba(147,197,253,.85);
    outline-offset: 2px;
}


/* D 功能試聽彈窗 */
body.stem-demo-modal-open { overflow: hidden; }
.stem-demo-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 20px;
}
.stem-demo-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(2,6,23,.78);
    backdrop-filter: blur(8px);
    cursor: default;
}
.stem-demo-dialog {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: auto;
    border: 1px solid rgba(139,92,246,.5);
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel) 90%, #7c3aed 10%);
    box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.stem-demo-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.stem-demo-dialog-head h2 { margin: 2px 0 5px; }
.stem-demo-dialog-head p { margin: 0; color: var(--muted); font-size: 13px; }
.stem-demo-eyebrow {
    color: #c4b5fd !important;
    font-size: 12px !important;
    font-weight: 900;
    letter-spacing: .08em;
}
.stem-demo-close {
    flex: 0 0 auto;
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(148,163,184,.12);
    color: var(--text);
    font-size: 25px;
    line-height: 1;
}
.stem-demo-close:hover { background: rgba(148,163,184,.24); }
.stem-demo-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 18px 16px;
}
.stem-demo-footer .stem-player-status { padding: 0; }
.stem-demo-track-row {
    grid-template-columns: minmax(92px, 120px) minmax(160px, 1fr) minmax(132px, 172px) 72px;
    gap: 12px;
}
.stem-demo-track-row .stem-waveform { min-width: 0; }

@media (max-width: 820px) and (min-width: 761px) {
    .stem-demo-track-row {
        grid-template-columns: 92px minmax(0, 1fr) 132px 68px;
        gap: 9px;
    }
}

.stem-demo-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}
.stem-demo-choose,
.stem-demo-random {
    min-height: 36px;
    padding: 8px 12px;
}
.stem-demo-song-picker {
    position: absolute;
    inset: 0;
    z-index: 3;
    overflow: auto;
    padding: 18px;
    border-radius: inherit;
    background: color-mix(in srgb, var(--panel) 94%, #7c3aed 6%);
}
.stem-demo-song-picker-head {
    position: sticky;
    top: -18px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: -18px -18px 16px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 96%, #7c3aed 4%);
}
.stem-demo-song-picker-head h2 { margin: 2px 0 0; }
.stem-demo-song-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
}
.stem-demo-song-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    min-height: 64px;
    padding: 12px 14px;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(148,163,184,.08);
    color: var(--text);
}
.stem-demo-song-item:hover {
    border-color: rgba(167,139,250,.75);
    background: rgba(139,92,246,.16);
}
.stem-demo-song-item.is-current {
    border-color: rgba(167,139,250,.9);
    background: rgba(139,92,246,.23);
}
.stem-demo-song-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stem-demo-song-duration {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

@media (max-width: 760px) {
    .stem-demo-modal { padding: 10px; }
    .stem-demo-dialog { max-height: calc(100vh - 20px); }
    .stem-demo-dialog-head { padding: 15px; }
    .stem-demo-track-row {
        grid-template-columns: 1fr auto;
        gap: 9px;
        padding: 12px 15px;
    }
    .stem-demo-track-row .stem-track-label { grid-column: 1; grid-row: 1; }
    .stem-demo-track-row .stem-toggle { grid-column: 2; grid-row: 1; justify-self: end; }
    .stem-demo-track-row .stem-waveform { grid-column: 1 / -1; grid-row: 2; }
    .stem-demo-track-row .stem-volume-control { grid-column: 1 / -1; grid-row: 3; }
    .stem-demo-master-controls { grid-template-columns: 46px 1fr auto; }
    .stem-demo-master-controls #stemDemoCurrent { display: none; }
    .stem-demo-master-controls #stemDemoSeek { grid-column: 2; }
    .stem-demo-footer { align-items: stretch; flex-direction: column; }
    .stem-demo-footer-actions { width: 100%; }
    .stem-demo-choose, .stem-demo-random { flex: 1 1 0; }
    .stem-demo-song-picker { padding: 14px; }
    .stem-demo-song-picker-head {
        top: -14px;
        align-items: stretch;
        flex-direction: column;
        margin: -14px -14px 14px;
        padding: 14px;
    }
    .stem-demo-song-list { grid-template-columns: 1fr; }
}

/* 功能 E：和弦辨識結果／試用操作面板 */
.chord-demo-line { margin-top: 2px; }
.chord-demo-open { color: #d8b4fe; }
.chord-demo-open:hover { color: #f3e8ff; }
.chord-feature-host {
    width: 100%;
    margin-top: 16px;
}
.chord-feature-host-demo {
    margin: 0;
    padding: 18px;
}
.chord-result-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
}
.chord-result-heading h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chord-result-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}
.chord-workspace {
    display: grid;
    gap: 16px;
    width: 100%;
}
.chord-player-card {
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.045);
    border-radius: 14px;
    background: #202020;
    color: #fff;
    box-shadow: 0 14px 34px rgba(0,0,0,.2);
    color-scheme: dark;
}
.chord-player-inner { padding: 26px; }
.chord-audio-row {
    display: flex;
    align-items: center;
    gap: 14px;
}
.chord-play-button {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    background: rgba(255,255,255,.92);
    color: #1c1917;
    font-size: 17px;
    box-shadow: none;
}
.chord-play-button:hover { background: #fff; }
.chord-time {
    flex: 0 0 auto;
    color: rgba(255,255,255,.68);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.chord-time-separator { color: rgba(255,255,255,.28); }
.chord-seek-wrap {
    position: relative;
    display: flex;
    min-width: 110px;
    flex: 1 1 360px;
    align-items: center;
}
.chord-seek-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    pointer-events: none;
}
.chord-seek-progress {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #fff;
}
.chord-seek {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 18px;
    margin: 0;
    appearance: none;
    background: transparent;
    cursor: pointer;
}
.chord-seek::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.chord-seek::-webkit-slider-thumb {
    width: 13px;
    height: 13px;
    margin-top: -4.5px;
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: #fff;
}
.chord-seek::-moz-range-track { height: 4px; background: transparent; }
.chord-seek::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: 0;
    border-radius: 999px;
    background: #fff;
}
.chord-volume-control {
    display: grid;
    min-width: 166px;
    height: 18px;
    flex: 0 1 190px;
    grid-template-columns: auto minmax(76px, 1fr) 30px;
    align-items: center;
    align-self: center;
    gap: 7px;
    color: rgba(255,255,255,.64);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    margin-top: 0;
    white-space: nowrap;
}
.chord-volume-label { color: rgba(255,255,255,.55); }
.chord-volume {
    display: block;
    width: 100%;
    height: 18px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    appearance: none;
    background: transparent;
    accent-color: #a78bfa;
}
.chord-volume::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
}
.chord-volume::-webkit-slider-thumb {
    width: 13px;
    height: 13px;
    margin-top: -4.5px;
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 5px rgba(0,0,0,.35);
}
.chord-volume::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
}
.chord-volume::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: 0;
    border-radius: 999px;
    background: #fff;
}
.chord-volume-value {
    min-width: 30px;
    color: rgba(255,255,255,.78);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.chord-card-divider {
    width: 100%;
    height: 1px;
    margin: 17px 0;
    background: rgba(255,255,255,.09);
}
.chord-progression-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.chord-progression-title {
    min-width: 0;
    margin: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
}
.chord-progression-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
}
.chord-text-button {
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: rgba(255,255,255,.66);
    font-size: 12px;
    font-weight: 800;
    box-shadow: none;
}
.chord-text-button:hover { background: rgba(255,255,255,.07); color: #fff; }
.chord-text-button.is-active {
    border-color: rgba(167,139,250,.46);
    background: rgba(124,58,237,.12);
    color: #c4b5fd;
}
.chord-collapse-icon {
    display: inline-block;
    margin-left: 3px;
    font-size: 13px;
    transition: transform .18s ease;
}
.chord-text-button[aria-expanded="false"] .chord-collapse-icon { transform: rotate(180deg); }
.chord-grid-wrap {
    max-height: 220px;
    margin-top: 13px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 3px;
    scrollbar-color: #525252 transparent;
    scrollbar-width: thin;
    transition: max-height .2s ease, opacity .2s ease, margin .2s ease;
}
.chord-grid-wrap::-webkit-scrollbar { width: 6px; height: 5px; }
.chord-grid-wrap::-webkit-scrollbar-thumb { border-radius: 999px; background: #525252; }
.chord-grid-wrap.is-collapsed {
    /* 74px 按鈕 + 上下留白 + 橫向捲軸；高度不足會把按鈕下緣裁掉。 */
    max-height: 94px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 1px;
    padding-right: 0;
    padding-bottom: 13px;
    box-sizing: border-box;
    opacity: 1;
}
.chord-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 6px;
}
.chord-grid-wrap.is-collapsed .chord-grid {
    display: flex;
    width: max-content;
    min-width: 100%;
    box-sizing: border-box;
    flex-wrap: nowrap;
}
.chord-grid-wrap.is-collapsed .chord-grid-button {
    width: 104px;
    min-width: 104px;
}
.chord-grid-button {
    position: relative;
    display: flex;
    min-width: 0;
    height: 74px;
    min-height: 74px;
    padding: 7px 10px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 6px;
    background: #292929;
    color: #f5f5f4;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    box-shadow: none;
    white-space: nowrap;
}
.chord-grid-button:hover {
    border-color: #a78bfa;
    background: rgba(124,58,237,.16);
    color: #ddd6fe;
}
.chord-grid-button.is-silence {
    background: #252525;
    color: rgba(255,255,255,.34);
}
.chord-grid-button.is-current {
    border-color: #7c3aed;
    background: #7c3aed;
    color: #fff;
    box-shadow: 0 3px 10px rgba(124,58,237,.26);
}
.chord-grid-main {
    --chord-fit-min-font: 10px;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    font-size: 20px;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -.1px;
    overflow: hidden;
    text-align: center;
    text-overflow: clip;
    white-space: nowrap;
}
.chord-grid-degree {
    --chord-fit-min-font: 8px;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    color: rgba(255,255,255,.58);
    font-size: 15px;
    font-weight: 900;
    line-height: 1.05;
    overflow: hidden;
    text-align: center;
    text-overflow: clip;
    white-space: nowrap;
}
.chord-grid-button.is-silence .chord-grid-degree { color: rgba(255,255,255,.28); }
.chord-grid-button.is-current .chord-grid-degree { color: rgba(255,255,255,.82); }
.chord-diagram-panel {
    border: 1px solid rgba(255,255,255,.045);
    border-radius: 14px;
    background: #202020;
    color: #fff;
    padding: 18px;
    box-shadow: 0 14px 34px rgba(0,0,0,.2);
}
.chord-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.chord-segmented {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 9px;
    background: rgba(255,255,255,.055);
}
.chord-segmented-button {
    min-height: 34px;
    padding: 7px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: rgba(255,255,255,.46);
    font-size: 14px;
    font-weight: 800;
    box-shadow: none;
}
.chord-segmented-button:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.82); }
.chord-segmented-button.is-active { background: rgba(255,255,255,.15); color: #fff; }
.chord-advanced-toggle {
    display: inline-flex;
    min-height: 34px;
    padding: 0;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: #fff;
    box-shadow: none;
}
.chord-advanced-toggle:hover { background: transparent; }
.chord-switch-track {
    position: relative;
    display: inline-flex;
    width: 40px;
    height: 22px;
    align-items: center;
    border-radius: 999px;
    background: #52525b;
    transition: background .18s ease;
}
.chord-switch-thumb {
    width: 18px;
    height: 18px;
    margin-left: 2px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    transition: transform .18s ease;
}
.chord-advanced-toggle[aria-checked="true"] .chord-switch-track { background: #7c3aed; }
.chord-advanced-toggle[aria-checked="true"] .chord-switch-thumb { transform: translateX(18px); }
.chord-advanced-label { font-size: 14px; font-weight: 800; white-space: nowrap; }
.chord-key-control {
    position: relative;
    margin-left: auto;
}
.chord-key-button {
    display: inline-flex;
    min-height: 38px;
    padding: 8px 12px;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(167,139,250,.52);
    border-radius: 9px;
    background: rgba(124,58,237,.3);
    color: #ddd6fe;
    font-size: 14px;
    font-weight: 800;
    box-shadow: none;
}
.chord-key-button:hover { background: rgba(124,58,237,.42); }
.chord-key-icon { font-size: 14px; }
.chord-key-caret { font-size: 11px; opacity: .8; }
.chord-key-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    right: 0;
    width: 230px;
    max-height: 354px;
    padding: 4px 4px 20px;
    overflow: hidden;
    border: 1px solid rgba(167,139,250,.28);
    border-radius: 10px;
    background: #252525;
    box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
.chord-key-options {
    max-height: 326px;
    overflow-y: auto;
    scrollbar-color: #525252 transparent;
    scrollbar-width: thin;
}
.chord-key-options::-webkit-scrollbar { width: 5px; }
.chord-key-options::-webkit-scrollbar-thumb { border-radius: 999px; background: #525252; }
.chord-key-option {
    display: flex;
    width: 100%;
    min-height: 36px;
    padding: 7px 9px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #f5f5f4;
    font-size: 13px;
    font-weight: 800;
    text-align: left;
    box-shadow: none;
}
.chord-key-option:hover { background: rgba(255,255,255,.07); }
.chord-key-option.is-current { background: rgba(124,58,237,.34); color: #fff; }
.chord-key-option-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chord-key-option-offset { flex: 0 0 auto; color: rgba(255,255,255,.42); font-weight: 900; }
.chord-key-option.is-current .chord-key-option-offset {
    padding: 2px 6px;
    border-radius: 5px;
    background: rgba(124,58,237,.55);
    color: #c4b5fd;
    font-size: 11px;
}
.chord-key-menu-cue {
    position: absolute;
    right: 0;
    bottom: 2px;
    left: 0;
    color: rgba(255,255,255,.38);
    font-size: 13px;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}
.chord-dynamic-stage {
    display: flex;
    min-height: 470px;
    padding-top: 20px;
    align-items: flex-start;
    justify-content: center;
}
.chord-dynamic-grid {
    display: grid;
    width: min(680px, 100%);
    grid-template-columns: minmax(0, 1fr) minmax(0, .82fr);
    gap: 44px;
    align-items: start;
}
.chord-diagram-slot { min-width: 0; }
.chord-diagram-slot-label {
    margin: 0 0 10px;
    color: rgba(255,255,255,.72);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
}
.chord-diagram-slot.is-next .chord-diagram-slot-label { color: rgba(255,255,255,.38); }
.chord-diagram-slot-label [data-chord-next-countdown] {
    margin-left: 3px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.chord-diagram-card {
    position: relative;
    width: min(308px, 100%);
    margin: 0 auto;
    overflow: hidden;
    border-radius: 9px;
    background: #fff;
    aspect-ratio: 3 / 4;
    box-shadow: 0 10px 24px rgba(0,0,0,.24);
    transition: transform .28s ease, opacity .28s ease;
}
.chord-diagram-slot.is-next .chord-diagram-card {
    margin-top: 37px;
    opacity: .9;
    transform: scale(.82);
    transform-origin: top center;
}
.chord-diagram-motion {
    width: 100%;
    height: 100%;
    will-change: transform, opacity;
}
.chord-diagram-empty-content {
    display: grid;
    place-items: center;
    padding: 20px;
    text-align: center;
}
.chord-diagram-card svg { display: block; width: 100%; height: 100%; }
.chord-diagram-card.is-empty {
    display: grid;
    place-items: center;
    padding: 20px;
    color: #78716c;
    text-align: center;
}
.chord-diagram-empty-name { display: block; margin-bottom: 8px; color: #1c1917; font-size: 25px; font-weight: 800; }
.chord-diagram-empty-text { font-size: 13px; }
.chord-all-stage { padding-top: 20px; }
.chord-all-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    padding: 8px;
}
.chord-all-item { min-width: 0; }
.chord-all-item .chord-diagram-card {
    width: 100%;
    transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
}
.chord-all-item.is-current .chord-diagram-card {
    box-shadow:
        0 0 0 4px #fdba74,
        0 0 0 7px rgba(253,186,116,.24),
        0 12px 28px rgba(0,0,0,.34);
}
.chord-all-item.is-next .chord-diagram-card {
    box-shadow:
        0 0 0 4px #fca5a5,
        0 0 0 7px rgba(252,165,165,.18),
        0 12px 26px rgba(0,0,0,.3);
}
.chord-all-item.is-current .chord-all-item-label {
    color: #fdba74;
}
.chord-all-item.is-next .chord-all-item-label {
    color: #fca5a5;
}
.chord-all-item-label {
    margin: 8px 0 0;
    overflow: hidden;
    color: rgba(255,255,255,.72);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chord-panel-status {
    margin: 10px 0 0;
    color: rgba(255,255,255,.46);
    font-size: 12px;
    text-align: center;
}
.chord-demo-dialog {
    width: min(1380px, calc(100vw - 32px));
    max-height: calc(100vh - 24px);
    border-color: rgba(167, 139, 250, .56);
    background: #151515;
}
.chord-demo-dialog-head { background: #181818; }
.chord-demo-footer {
    padding: 0 18px 18px;
}
.chord-demo-modal .stem-demo-song-picker { background: #181818; }
.chord-demo-modal .stem-demo-song-picker-head { background: #181818; }

@media (max-width: 760px) {
    .chord-feature-host-demo { padding: 12px; }
    .chord-player-inner { padding: 18px 15px; }
    .chord-audio-row { gap: 10px; flex-wrap: wrap; }
    .chord-play-button { width: 42px; height: 42px; min-height: 42px; }
    .chord-time { font-size: 12px; }
    .chord-seek-wrap { min-width: 150px; flex: 1 1 calc(100% - 118px); }
    .chord-volume-control { min-width: 150px; flex: 1 1 100%; margin-left: 52px; }
    .chord-grid { grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); }
    .chord-grid-button { height: 70px; min-height: 70px; padding-inline: 8px; }
    .chord-grid-main { --chord-fit-min-font: 9px; font-size: 18px; }
    .chord-grid-degree { --chord-fit-min-font: 7.5px; font-size: 14px; }
    .chord-grid-wrap.is-collapsed .chord-grid-button { width: 90px; min-width: 90px; }
    .chord-grid-wrap { max-height: 180px; }
    .chord-diagram-panel { padding: 13px; }
    .chord-toolbar { gap: 8px; }
    .chord-segmented { flex: 1 1 auto; }
    .chord-segmented-button { flex: 1 1 auto; padding: 7px 9px; font-size: 13px; }
    .chord-advanced-toggle { order: 3; }
    .chord-key-control { order: 4; width: 100%; margin-left: 0; }
    .chord-key-button { width: 100%; justify-content: center; }
    .chord-key-menu { left: 0; right: auto; width: 100%; }
    .chord-dynamic-stage { min-height: 360px; padding-top: 17px; }
    .chord-dynamic-grid { grid-template-columns: minmax(0, 1fr) minmax(0, .82fr); gap: 12px; }
    .chord-diagram-slot-label { font-size: 12px; }
    .chord-diagram-slot.is-next .chord-diagram-card { margin-top: 25px; transform: scale(.86); }
    .chord-all-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .chord-result-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 430px) {
    .chord-player-inner { padding: 15px 12px; }
    .chord-time { min-width: 62px; }
    .chord-time-total { display: none; }
    .chord-seek-wrap { min-width: 120px; }
    .chord-volume-control { margin-left: 0; grid-template-columns: auto minmax(80px, 1fr) 30px; }
    .chord-progression-head { align-items: flex-start; }
    .chord-progression-actions { gap: 1px; }
    .chord-text-button { padding: 4px 6px; }
    .chord-diagram-panel { padding: 11px; }
    .chord-advanced-label { font-size: 13px; }
    .chord-dynamic-grid { gap: 8px; }
    .chord-diagram-slot.is-next .chord-diagram-card { margin-top: 22px; }
}

