/* ======================================================================
   AlphaTex 乐谱工作台 /tools/alphatex
   ----------------------------------------------------------------------
   布局：桌面左右双栏（代码编辑 / 资料 + 谱面舞台），中缝可拖拽；
        平板压缩栏宽，手机改成「编辑 | 谱面」单栏切换。
   设计基线：与全站 --accent 主题一致；8px 间距栅格；单一强调色；
            触控目标 ≥40px（手机 ≥44px）；输入框手机端 16px 防 iOS 缩放。
   断点：≥1600 大屏 · 1200~1599 标准 · 1000~1199 紧凑 · 768~999 上下/切换
        ≤767 手机 · ≤420 超小屏
   ====================================================================== */

/* ★ 页面级满屏：style.css 的 body.tools-page 已解除 .app 限宽，这里再补一层
   body overflow:visible —— 站点 body{overflow-y:scroll} 会让 body 变成滚动容器，
   导致页内 position:sticky 全部失效（本站老坑）。 */
body.page-alphatex-full { overflow: visible; }
body.page-alphatex-full .app,
body.page-alphatex-full .main-content,
body.page-alphatex-full .page-container {
    max-width: 100%;
    width: 100%;
}
body.page-alphatex-full .main-content { border-right: 0; min-width: 0; }

/* ---------------- 设计令牌（:root，供 .atx 外的脚注与浮层继承） ---------------- */
:root {
    --atx-bg: var(--bg-secondary, #101318);
    --atx-card: var(--bg-primary, #171a20);
    --atx-card-2: color-mix(in srgb, var(--bg-primary, #171a20) 92%, var(--text-primary, #fff) 8%);
    --atx-line: var(--border-color, #2a2f38);
    --atx-line-2: color-mix(in srgb, var(--text-primary, #fff) 14%, transparent);
    --atx-text: var(--text-primary, #e9edf2);
    --atx-sub: var(--text-secondary, #98a2b3);
    --atx-faint: #8f9bab;
    --atx-accent: var(--accent, #4b8dff);
    --atx-accent-soft: color-mix(in srgb, var(--accent, #4b8dff) 14%, transparent);
    --atx-ok: #3fb950;
    --atx-warn: #e3a008;
    --atx-err: var(--danger, #f4212e);
    --atx-err-soft: color-mix(in srgb, var(--danger, #f4212e) 12%, transparent);
    --atx-sheet-bg: #ffffff;
    --atx-sheet-ink: #14181d;
    --atx-code-bg: #10141a;
    --atx-code-ink: #d7e0ea;
    --atx-code-gutter: #6d7b8c;
    --atx-r-sm: 8px;
    --atx-r: 12px;
    --atx-r-lg: 16px;
    --atx-shadow-1: 0 1px 3px rgba(0, 0, 0, .10);
    --atx-shadow-2: 0 14px 40px rgba(0, 0, 0, .24);
    --atx-left-w: 46%;
    --atx-zebra: rgba(127, 127, 127, .055);
}
[data-theme="light"] {
    --atx-bg: #f4f6f8;
    --atx-card: #ffffff;
    --atx-card-2: #f7f9fb;
    --atx-line: #e3e8ee;
    --atx-line-2: rgba(15, 20, 25, .16);
    --atx-text: #1c2430;
    --atx-sub: #5c6879;
    --atx-faint: #6d7887;
    --atx-ok: #1a7f37;
    --atx-warn: #9a6700;
    --atx-zebra: rgba(15, 20, 25, .038);
    --atx-code-bg: #f8fafc;
    --atx-code-ink: #243044;
    --atx-code-gutter: #8a97a8;
    --atx-shadow-1: 0 1px 3px rgba(15, 20, 25, .07);
    --atx-shadow-2: 0 14px 40px rgba(15, 20, 25, .14);
}

.atx {
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 12px);
    height: calc(100dvh - 12px);
    min-height: 620px;
    padding: 14px 18px 18px;
    background: var(--atx-bg);
    color: var(--atx-text);
    font-size: 13px;
    line-height: 1.6;
}
.atx *, .atx *::before, .atx *::after,
.atx-footnote * { box-sizing: border-box; }

/* ★ 本站老坑：凡声明了 display 的元素用 hidden 控制显隐，必须强制兜底 */
.atx [hidden], .atx-footnote[hidden], .atx-mask[hidden], .atx-modal[hidden] { display: none !important; }

.atx button, .atx input, .atx select, .atx textarea { font-family: inherit; }
.atx button { cursor: pointer; }
.atx a { color: var(--atx-accent); text-decoration: none; }
.atx a:hover { text-decoration: underline; }
.atx :focus-visible {
    outline: 2px solid var(--atx-accent);
    outline-offset: 2px;
}
.atx h1, .atx h2, .atx h3, .atx h4, .atx p { margin: 0; }
.atx ul, .atx ol { margin: 0; padding-left: 20px; }
.atx kbd {
    display: inline-block; padding: 0 5px; min-width: 20px; text-align: center;
    border: 1px solid var(--atx-line); border-bottom-width: 2px; border-radius: 5px;
    background: var(--atx-card-2); font-size: 11px; font-family: inherit; color: var(--atx-text);
}
.atx code {
    padding: 1px 5px; border-radius: 5px; background: var(--atx-card-2);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
    font-size: 12px; color: var(--atx-accent);
    overflow-wrap: anywhere;
}
.atx pre {
    margin: 10px 0; padding: 12px 14px; overflow-x: auto;
    border: 1px solid var(--atx-line); border-radius: var(--atx-r-sm);
    background: var(--atx-code-bg); color: var(--atx-code-ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
    font-size: 12px; line-height: 1.75;
}
.atx pre code { padding: 0; background: none; color: inherit; font-size: inherit; }

/* ---------------- 通用控件 ---------------- */
.atx-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    min-height: 34px; padding: 0 12px;
    border: 1px solid var(--atx-line); border-radius: var(--atx-r-sm);
    background: var(--atx-card); color: var(--atx-text);
    font-size: 12.5px; font-weight: 600; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.atx-btn:hover { background: var(--atx-card-2); border-color: var(--atx-accent); }
.atx-btn:active { transform: translateY(1px); }
.atx-btn:disabled { opacity: .5; cursor: not-allowed; }
.atx-btn-sm { min-height: 30px; padding: 0 9px; font-size: 12px; }
.atx-btn-xs { min-width: 28px; min-height: 28px; padding: 0 6px; font-size: 13px; }
.atx-btn-primary {
    border-color: var(--atx-accent);
    background: var(--atx-accent); color: #fff;
}
.atx-btn-primary:hover { background: color-mix(in srgb, var(--atx-accent) 86%, #fff); border-color: var(--atx-accent); }
.atx-btn-quiet { background: transparent; border-color: var(--atx-line-2); }
.atx-btn-danger { color: var(--atx-err); }
.atx-btn-danger:hover { border-color: var(--atx-err); background: var(--atx-err-soft); }
.atx-select, .atx-input, .atx-num {
    min-height: 32px; padding: 0 8px;
    border: 1px solid var(--atx-line); border-radius: var(--atx-r-sm);
    background: var(--atx-card); color: var(--atx-text); font-size: 12.5px;
}
.atx-select:focus, .atx-input:focus, .atx-num:focus {
    border-color: var(--atx-accent); outline: none;
    box-shadow: 0 0 0 3px var(--atx-accent-soft);
}
.atx-num { width: 68px; }
.atx-range, .atx-seek { accent-color: var(--atx-accent); }
.atx-range { flex: 1 1 auto; min-width: 60px; height: 26px; }
.atx-val { min-width: 42px; font-size: 12px; color: var(--atx-sub); text-align: right; }
.atx-check {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; color: var(--atx-sub); white-space: nowrap; cursor: pointer;
}
.atx-check input { accent-color: var(--atx-accent); width: 15px; height: 15px; }

/* ---------------- 顶部 ---------------- */
.atx-head {
    display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--atx-line); border-radius: var(--atx-r-lg);
    background: var(--atx-card);
    background-image: linear-gradient(135deg, var(--atx-accent-soft), transparent 42%);
    box-shadow: var(--atx-shadow-1);
}
.atx-head-icon {
    flex: 0 0 auto; width: 46px; height: 46px;
    display: grid; place-items: center;
    border-radius: 13px; color: #fff;
    background: linear-gradient(140deg, var(--atx-accent), color-mix(in srgb, var(--atx-accent) 62%, #8b5cf6));
    box-shadow: var(--atx-shadow-1);
}
.atx-head-icon svg { width: 27px; height: 27px; }
.atx-head-text { flex: 1 1 420px; min-width: 0; }
.atx-title { font-size: 20px; font-weight: 750; letter-spacing: .2px; line-height: 1.35; }
.atx-sub { margin-top: 5px; font-size: 12.5px; color: var(--atx-sub); line-height: 1.7; max-width: 92ch; }
.atx-sub b { color: var(--atx-text); }
.atx-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.atx-badges span {
    padding: 2px 9px; border: 1px solid var(--atx-line-2); border-radius: 999px;
    background: var(--atx-card-2); font-size: 11.5px; color: var(--atx-sub);
}
.atx-head-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; flex: 0 1 auto; }
.atx-export-wrap { position: relative; }
.atx-export-pop {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
    width: 310px; max-width: calc(100vw - 32px);
    display: flex; flex-direction: column; gap: 2px;
    padding: 6px; border: 1px solid var(--atx-line); border-radius: var(--atx-r);
    background: var(--atx-card); box-shadow: var(--atx-shadow-2);
}
.atx-export-pop button {
    display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
    width: 100%; padding: 8px 10px; border: 0; border-radius: var(--atx-r-sm);
    background: transparent; color: var(--atx-text); text-align: left;
}
.atx-export-pop button:hover { background: var(--atx-accent-soft); }
.atx-export-pop b { font-size: 12.5px; font-weight: 650; }
.atx-export-pop span { font-size: 11.5px; color: var(--atx-sub); }

/* 统计条：仪表盘式六列 */
.atx-stat {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
    border: 1px solid var(--atx-line); border-radius: var(--atx-r);
    background: var(--atx-card); overflow: hidden;
}
.atx-stat-i {
    display: flex; flex-direction: column; gap: 2px; justify-content: center;
    min-width: 0; padding: 8px 14px;
    border-left: 1px solid var(--atx-line);
}
.atx-stat-i:first-child { border-left: 0; }
.atx-stat-i b { font-size: 18px; font-weight: 750; line-height: 1.25; font-variant-numeric: tabular-nums; }
.atx-stat-i em { font-style: normal; font-size: 11.5px; color: var(--atx-sub); }
.atx-stat-i:nth-child(3) b { color: var(--atx-accent); }
.atx-stat-i:nth-child(5) b { color: var(--atx-ok); }
.atx-stat-i:nth-child(6) b { font-size: 15px; }

/* 移动端视图切换（桌面隐藏） */
.atx-viewseg { display: none; }

/* ---------------- 工作台骨架 ---------------- */
.atx-work {
    display: grid;
    grid-template-columns: minmax(320px, var(--atx-left-w)) 8px minmax(0, 1fr);
    gap: 0;
    flex: 1 1 auto; min-height: 0;
    border: 1px solid var(--atx-line); border-radius: var(--atx-r-lg);
    background: var(--atx-card); overflow: hidden;
}
.atx-work.is-side-hidden { grid-template-columns: 0 0 minmax(0, 1fr); }
.atx-work.is-side-hidden .atx-left, .atx-work.is-side-hidden .atx-splitter { display: none; }
.atx-left { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.atx-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--atx-bg); }
.atx-splitter {
    position: relative; cursor: col-resize; background: var(--atx-line);
    touch-action: none;
}
.atx-splitter::after {
    content: ''; position: absolute; left: 2px; right: 2px; top: 50%;
    height: 30px; transform: translateY(-50%);
    border-radius: 4px; background: var(--atx-line-2);
}
.atx-splitter:hover, .atx-splitter.is-dragging { background: var(--atx-accent); }
body.atx-resizing { cursor: col-resize; user-select: none; }

/* 页签 */
.atx-tabs {
    display: flex; gap: 2px; flex: 0 0 auto;
    padding: 7px 8px 0; border-bottom: 1px solid var(--atx-line);
    background: var(--atx-card); overflow-x: auto; scrollbar-width: thin;
}
.atx-tab {
    flex: 0 0 auto; min-height: 34px; padding: 0 12px;
    border: 0; border-bottom: 2px solid transparent; border-radius: var(--atx-r-sm) var(--atx-r-sm) 0 0;
    background: transparent; color: var(--atx-sub); font-size: 12.5px; font-weight: 600;
    white-space: nowrap;
}
.atx-tab:hover { color: var(--atx-text); background: var(--atx-card-2); }
.atx-tab.is-on { color: var(--atx-accent); border-bottom-color: var(--atx-accent); background: var(--atx-accent-soft); }
.atx-pane { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* ---------------- 代码编辑页签 ---------------- */
.atx-editor-bar {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    flex: 0 0 auto; padding: 8px 10px;
    border-bottom: 1px solid var(--atx-line); background: var(--atx-card);
}
.atx-editor-bar .atx-select { max-width: 190px; flex: 0 1 190px; }
.atx-bar-sep { width: 1px; height: 20px; background: var(--atx-line); margin: 0 2px; }
.atx-check-live { margin-left: auto; }
.atx-render-btn { min-height: 30px; }
.atx-findbar {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    flex: 0 0 auto; padding: 7px 10px;
    border-bottom: 1px solid var(--atx-line); background: var(--atx-card-2);
}
.atx-findbar .atx-input { flex: 1 1 130px; min-width: 100px; }
.atx-find-count { font-size: 11.5px; color: var(--atx-sub); min-width: 52px; text-align: center; }
.atx-sample-info {
    flex: 0 0 auto; padding: 7px 12px;
    border-bottom: 1px solid var(--atx-line);
    background: var(--atx-accent-soft); color: var(--atx-text); font-size: 11.5px; line-height: 1.6;
}
.atx-sample-info b { color: var(--atx-accent); }

.atx-code-wrap {
    display: flex; flex: 1 1 auto; min-height: 140px; overflow: hidden;
    background: var(--atx-code-bg); color: var(--atx-code-ink);
    border-bottom: 1px solid var(--atx-line);
}
.atx-gutter {
    flex: 0 0 46px; overflow: hidden; padding: 10px 6px 40px 0;
    border-right: 1px solid var(--atx-line);
    background: color-mix(in srgb, var(--atx-code-bg) 92%, var(--atx-text) 8%);
    color: var(--atx-code-gutter);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
    font-size: 12px; line-height: 20px; text-align: right; white-space: pre;
    user-select: none;
}
.atx-code {
    flex: 1 1 auto; min-width: 0; display: block;
    width: 100%; height: 100%; margin: 0; padding: 10px 12px 40px;
    border: 0; outline: none; resize: none;
    background: transparent; color: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
    font-size: 12.5px; line-height: 20px; letter-spacing: .1px;
    tab-size: 2; white-space: pre; overflow: auto;
    scrollbar-width: thin;
}
.atx-code::placeholder { color: var(--atx-code-gutter); }
.atx-code::selection { background: var(--atx-accent-soft); }

.atx-diag {
    flex: 0 0 auto; max-height: 152px; overflow: auto;
    border-bottom: 1px solid var(--atx-line); background: var(--atx-card);
}
.atx-diag-head {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 12px; background: var(--atx-card-2);
    border-bottom: 1px solid var(--atx-line); font-size: 12px;
}
.atx-diag.is-ok .atx-diag-head b { color: var(--atx-ok); }
.atx-diag.is-err .atx-diag-head b { color: var(--atx-err); }
.atx-diag-head span { color: var(--atx-sub); font-size: 11.5px; }
.atx-diag-list { list-style: none; margin: 0; padding: 4px 0; }
.atx-diag-list li {
    display: flex; gap: 8px; align-items: baseline;
    padding: 5px 12px; font-size: 11.5px; line-height: 1.6;
    border-bottom: 1px dashed var(--atx-line);
}
.atx-diag-list li:last-child { border-bottom: 0; }
.atx-diag-list li button {
    flex: 0 0 auto; padding: 0 6px; min-height: 22px;
    border: 1px solid var(--atx-line); border-radius: 5px;
    background: var(--atx-card-2); color: var(--atx-accent); font-size: 11px;
}
.atx-diag-list li.is-warn button { color: var(--atx-warn); }
.atx-diag-list li span { min-width: 0; overflow-wrap: anywhere; color: var(--atx-sub); }
.atx-diag-list li.is-warn span { color: var(--atx-text); }
.atx-diag-empty { padding: 8px 12px; color: var(--atx-ok); font-size: 11.5px; }

.atx-status {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    flex: 0 0 auto; min-height: 32px; padding: 5px 12px;
    background: var(--atx-card); color: var(--atx-sub); font-size: 11.5px;
}
.atx-status b { color: var(--atx-text); font-variant-numeric: tabular-nums; }
.atx-status-ok { color: var(--atx-ok); }
.atx-status-err { color: var(--atx-err); }
.atx-status-sub { margin-left: auto; color: var(--atx-faint); }

/* ---------------- 语法速查页签 ---------------- */
.atx-pane-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    flex: 0 0 auto; padding: 9px 10px;
    border-bottom: 1px solid var(--atx-line); background: var(--atx-card);
}
.atx-pane-bar .atx-input { flex: 1 1 220px; min-width: 140px; }
.atx-pane-count { font-size: 11.5px; color: var(--atx-sub); white-space: nowrap; }
.atx-chips {
    display: flex; gap: 6px; flex-wrap: wrap; flex: 0 0 auto;
    padding: 8px 10px; border-bottom: 1px solid var(--atx-line); background: var(--atx-card);
}
.atx-chip {
    min-height: 30px; padding: 0 11px;
    border: 1px solid var(--atx-line-2); border-radius: 999px;
    background: var(--atx-card-2); color: var(--atx-sub); font-size: 12px; font-weight: 600;
}
.atx-chip:hover { border-color: var(--atx-accent); color: var(--atx-text); }
.atx-chip.is-on { background: var(--atx-accent); border-color: var(--atx-accent); color: #fff; }
.atx-syntax-list {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 9px; align-content: start;
    background: var(--atx-bg);
    contain: layout style;
}
.atx-syn-card {
    display: flex; flex-direction: column; gap: 6px; min-width: 0;
    padding: 10px 11px; border: 1px solid var(--atx-line); border-radius: var(--atx-r);
    background: var(--atx-card); box-shadow: var(--atx-shadow-1);
}
.atx-syn-card:hover { border-color: var(--atx-accent); }
.atx-syn-t { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12.5px; font-weight: 700; }
.atx-syn-g { font-size: 10.5px; font-weight: 500; color: var(--atx-sub); padding: 1px 6px; border: 1px solid var(--atx-line); border-radius: 999px; }
.atx-syn-code {
    padding: 6px 8px; border-radius: 6px; background: var(--atx-code-bg); color: var(--atx-code-ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px;
    line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap;
}
.atx-syn-d { font-size: 11.5px; color: var(--atx-sub); line-height: 1.65; }
.atx-syn-acts { display: flex; gap: 6px; margin-top: auto; padding-top: 2px; }
.atx-syn-acts .atx-btn { flex: 1 1 auto; min-height: 28px; padding: 0 6px; font-size: 11.5px; }
.atx-syn-empty { grid-column: 1 / -1; padding: 30px 12px; text-align: center; color: var(--atx-sub); font-size: 12.5px; }
.atx-pane-note {
    flex: 0 0 auto; padding: 8px 12px;
    border-top: 1px solid var(--atx-line); background: var(--atx-card);
    color: var(--atx-faint); font-size: 11.5px; line-height: 1.6;
}

/* ---------------- 作品库页签 ---------------- */
.atx-work-list {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    padding: 10px; display: flex; flex-direction: column; gap: 8px;
    background: var(--atx-bg);
}
.atx-work-item {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 9px 11px; border: 1px solid var(--atx-line); border-radius: var(--atx-r);
    background: var(--atx-card);
}
.atx-work-main { flex: 1 1 180px; min-width: 0; }
.atx-work-name { font-size: 12.5px; font-weight: 700; overflow-wrap: anywhere; }
.atx-work-meta { font-size: 11px; color: var(--atx-sub); }
.atx-work-acts { display: flex; gap: 5px; flex-wrap: wrap; }
.atx-work-empty { padding: 40px 12px; text-align: center; color: var(--atx-sub); font-size: 12.5px; }

/* ---------------- 教程页签 ---------------- */
.atx-docs { overflow-y: auto; padding: 10px; background: var(--atx-bg); }
.atx-doc {
    margin-bottom: 8px; border: 1px solid var(--atx-line); border-radius: var(--atx-r);
    background: var(--atx-card); overflow: hidden;
}
.atx-doc > summary {
    display: flex; align-items: center; min-height: 40px; padding: 0 13px;
    cursor: pointer; list-style: none; font-size: 13px; font-weight: 700;
    background: var(--atx-card-2);
}
.atx-doc > summary::-webkit-details-marker { display: none; }
.atx-doc > summary::marker { content: ''; }
.atx-doc > summary::after { content: '▾'; margin-left: auto; color: var(--atx-sub); transition: transform .18s ease; }
.atx-doc[open] > summary::after { transform: rotate(180deg); }
.atx-doc[open] > summary { border-bottom: 1px solid var(--atx-line); }
.atx-doc-body { padding: 12px 14px 16px; font-size: 12.5px; line-height: 1.85; }
.atx-doc-body > * + * { margin-top: 9px; }
.atx-doc-body h4 { margin-top: 14px; font-size: 13px; color: var(--atx-accent); }
.atx-doc-body p, .atx-doc-body li { color: var(--atx-sub); }
.atx-doc-body b { color: var(--atx-text); }
.atx-doc-body ul, .atx-doc-body ol { padding-left: 22px; }
.atx-table-wrap { overflow-x: auto; border: 1px solid var(--atx-line); border-radius: var(--atx-r-sm); }
.atx-doc-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
.atx-doc-body th, .atx-doc-body td { padding: 7px 10px; border-bottom: 1px solid var(--atx-line); text-align: left; vertical-align: top; }
.atx-doc-body thead th { position: sticky; top: 0; background: var(--atx-card-2); color: var(--atx-text); font-weight: 700; }
.atx-doc-body tbody tr:nth-child(even) { background: var(--atx-zebra); }
.atx-doc-body tbody tr:last-child td { border-bottom: 0; }

/* ---------------- 右栏：曲谱信息 ---------------- */
.atx-score-info {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    flex: 0 0 auto; padding: 8px 14px;
    border-bottom: 1px solid var(--atx-line); background: var(--atx-card);
}
.atx-info-title { font-size: 13.5px; font-weight: 750; min-width: 0; overflow-wrap: anywhere; }
.atx-info-sub { font-size: 11.5px; color: var(--atx-sub); min-width: 0; overflow-wrap: anywhere; }
.atx-info-items { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; font-size: 11.5px; color: var(--atx-sub); }
.atx-info-items b { color: var(--atx-text); font-variant-numeric: tabular-nums; }

/* 设置区 */
.atx-settings-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    flex: 0 0 auto; padding: 6px 12px;
    border-bottom: 1px solid var(--atx-line); background: var(--atx-card);
}
.atx-settings-hint { font-size: 11.5px; color: var(--atx-faint); }
.atx-settings {
    flex: 0 0 auto; max-height: 40vh; overflow-y: auto;
    padding: 10px 12px; border-bottom: 1px solid var(--atx-line); background: var(--atx-card-2);
}
.atx-set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 14px; }
.atx-set-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.atx-set-row label { flex: 0 0 62px; font-size: 11.5px; color: var(--atx-sub); }
.atx-set-row .atx-select { flex: 1 1 auto; min-width: 100px; }
.atx-track-box { margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--atx-line); }
.atx-track-head { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.atx-track-tip { font-weight: 400; font-size: 11px; color: var(--atx-faint); }
.atx-track-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.atx-track {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 5px 8px; border: 1px solid var(--atx-line); border-radius: var(--atx-r-sm);
    background: var(--atx-card); font-size: 11.5px;
}
.atx-track-vis { flex: 1 1 150px; min-width: 0; display: flex; align-items: center; gap: 6px; }
.atx-track-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atx-track-prog { color: var(--atx-sub); font-size: 10.5px; }
.atx-track-btns { display: flex; gap: 4px; margin-left: auto; }
.atx-mini {
    min-width: 27px; min-height: 26px; padding: 0 5px;
    border: 1px solid var(--atx-line-2); border-radius: 6px;
    background: var(--atx-card-2); color: var(--atx-sub); font-size: 11px; font-weight: 700;
}
.atx-mini.is-on { background: var(--atx-accent); border-color: var(--atx-accent); color: #fff; }
.atx-track-empty { color: var(--atx-sub); font-size: 11.5px; padding: 4px 2px; }

/* 播放条 */
.atx-player {
    flex: 0 0 auto; padding: 8px 12px;
    border-bottom: 1px solid var(--atx-line); background: var(--atx-card);
}
.atx-transport { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.atx-play { min-width: 92px; }
.atx-play.is-playing { background: var(--atx-ok); border-color: var(--atx-ok); }
.atx-seek-wrap { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 160px; }
.atx-seek { flex: 1 1 auto; min-width: 70px; }
.atx-time { font-size: 11.5px; color: var(--atx-sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.atx-bar-info { font-size: 11px; color: var(--atx-faint); white-space: nowrap; }
.atx-knobs {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--atx-line);
}
.atx-knob { display: flex; align-items: center; gap: 6px; min-height: 30px; font-size: 11.5px; color: var(--atx-sub); }
.atx-knob input[type=range] { width: 92px; accent-color: var(--atx-accent); }
.atx-knob .atx-select { min-height: 28px; font-size: 11.5px; padding: 0 5px; }

/* 谱面舞台：.atx-sheet 是正常文档流中的滚动容器，
   alphaTab 内置 ScrollMode 才能正确工作（不要用 absolute 内部滚动容器）。 */
.atx-sheet-host {
    position: relative; display: flex; flex: 1 1 auto; min-height: 220px;
    padding: 12px; background: var(--atx-bg);
}
.atx-sheet {
    flex: 1 1 auto; min-width: 0; min-height: 0;
    overflow: auto; padding: 16px 18px 40px;
    background: var(--atx-sheet-bg); color: var(--atx-sheet-ink);
    border-radius: var(--atx-r); box-shadow: var(--atx-shadow-1);
    scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; scrollbar-width: thin;
}
.atx-sheet-dark { --atx-sheet-bg: #10141b; }
.atx-sheet .at-surface { background: transparent; }
.atx-sheet svg, .atx-sheet canvas { max-width: none; }
.atx-sheet .at-system-bracket-box { fill: currentColor; }
.atx-sheet-tools {
    position: absolute; top: 20px; right: 22px; z-index: 8;
    display: flex; gap: 4px; padding: 4px;
    border: 1px solid var(--atx-line); border-radius: 999px;
    background: color-mix(in srgb, var(--atx-card) 88%, transparent);
    backdrop-filter: blur(6px); box-shadow: var(--atx-shadow-1);
}
.atx-tool {
    min-width: 30px; min-height: 30px; padding: 0 6px;
    border: 0; border-radius: 999px; background: transparent;
    color: var(--atx-text); font-size: 14px;
}
.atx-tool:hover, .atx-tool.is-on { background: var(--atx-accent-soft); color: var(--atx-accent); }
.atx-sf-tip {
    position: absolute; right: 24px; bottom: 20px; z-index: 8;
    padding: 3px 9px; border-radius: 999px;
    background: color-mix(in srgb, var(--atx-card) 90%, transparent);
    color: var(--atx-sub); font-size: 11px;
}
.atx-sf-tip:empty { display: none; }
.atx-loading, .atx-empty {
    position: absolute; inset: 12px; z-index: 5;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 24px; text-align: center; border-radius: var(--atx-r);
    background: var(--atx-card);
}
.atx-loading { background: color-mix(in srgb, var(--atx-card) 88%, transparent); z-index: 7; }
.atx-spinner {
    width: 32px; height: 32px; border-radius: 50%;
    border: 3px solid var(--atx-line); border-top-color: var(--atx-accent);
    animation: atx-spin .8s linear infinite;
}
@keyframes atx-spin { to { transform: rotate(360deg); } }
.atx-loading-tip { font-size: 12px; color: var(--atx-sub); }
.atx-empty h2 { font-size: 16px; }
.atx-empty p { max-width: 560px; font-size: 12.5px; line-height: 1.8; color: var(--atx-sub); }
.atx-empty-icon { font-size: 38px; }
.atx-empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.atx-error {
    position: absolute; left: 50%; top: 22px; transform: translateX(-50%); z-index: 9;
    max-width: min(680px, 92%);
    display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px;
    border: 1px solid var(--atx-err); border-radius: var(--atx-r);
    background: var(--atx-card); box-shadow: var(--atx-shadow-2);
}
.atx-error-icon { color: var(--atx-err); font-size: 17px; }
.atx-error-body { flex: 1 1 auto; min-width: 0; }
.atx-error-title { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.atx-error-msg { font-size: 11.5px; color: var(--atx-sub); overflow-wrap: anywhere; line-height: 1.65; }
.atx-error-close { min-width: 30px; min-height: 30px; border: 0; border-radius: 6px; background: none; color: var(--atx-sub); }

/* 弹窗 / toast / 页脚说明 */
.atx-mask {
    position: fixed; inset: 0; z-index: 100000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(0, 0, 0, .55);
}
.atx-modal {
    width: min(440px, 100%); max-height: 90vh; overflow: auto;
    border: 1px solid var(--atx-line); border-radius: var(--atx-r-lg);
    background: var(--atx-card); box-shadow: var(--atx-shadow-2);
}
.atx-modal-sm { width: min(380px, 100%); }
.atx-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--atx-line); font-size: 14px;
}
.atx-modal-x { min-width: 30px; min-height: 30px; border: 0; border-radius: 6px; background: none; color: var(--atx-sub); }
.atx-modal-body { padding: 16px; }
.atx-field-label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--atx-sub); }
.atx-modal-body .atx-input { width: 100%; }
.atx-modal-note, .atx-confirm-text { margin-top: 10px; font-size: 11.5px; color: var(--atx-sub); line-height: 1.7; }
.atx-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--atx-line); }
.atx-toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%); z-index: 100001;
    display: flex; flex-direction: column; gap: 6px; align-items: center;
    pointer-events: none;
}
.atx-toast-i {
    padding: 8px 14px; border-radius: 999px;
    background: var(--atx-card); color: var(--atx-text);
    border: 1px solid var(--atx-line); box-shadow: var(--atx-shadow-2);
    font-size: 12.5px; max-width: min(520px, 90vw); text-align: center;
}
.atx-toast-ok { border-color: var(--atx-ok); }
.atx-toast-err { border-color: var(--atx-err); }
.atx-footnote {
    margin: 14px 18px 30px; border: 1px solid var(--atx-line); border-radius: var(--atx-r);
    background: var(--atx-card); color: var(--atx-text); overflow: hidden;
}
.atx-footnote > summary {
    min-height: 42px; padding: 0 16px; display: flex; align-items: center;
    cursor: pointer; list-style: none; font-size: 12.5px; font-weight: 700;
}
.atx-footnote > summary::-webkit-details-marker { display: none; }
.atx-footnote > summary::marker { content: ''; }
.atx-footnote > summary::after { content: '▾'; margin-left: auto; color: var(--atx-sub); }
.atx-footnote[open] > summary::after { transform: rotate(180deg); }
.atx-footnote-body { padding: 4px 16px 16px; font-size: 12px; line-height: 1.85; color: var(--atx-sub); }
.atx-footnote-body p + p { margin-top: 8px; }
.atx-footnote-body b { color: var(--atx-text); }

/* 专注模式：只留谱面 */
body.atx-focus .atx-head,
body.atx-focus .atx-stat,
body.atx-focus .atx-viewseg,
body.atx-focus .atx-left,
body.atx-focus .atx-splitter,
body.atx-focus .atx-settings-head,
body.atx-focus .atx-settings { display: none !important; }
body.atx-focus .atx-work { grid-template-columns: minmax(0, 1fr); }
body.atx-focus .atx { height: calc(100dvh - 20px); padding: 10px; }

@media (prefers-reduced-motion: reduce) {
    .atx *, .atx *::before, .atx *::after { transition: none !important; animation-duration: .001ms !important; scroll-behavior: auto !important; }
    .atx-spinner { animation: atx-spin 1.6s linear infinite !important; }
}
@media (hover: none) {
    .atx-btn:active { transform: none; }
    .atx-syn-card:hover { border-color: var(--atx-line); }
}
@media print {
    .atx-head, .atx-stat, .atx-viewseg, .atx-left, .atx-splitter,
    .atx-settings-head, .atx-settings, .atx-player, .atx-sheet-tools,
    .atx-toast, .atx-footnote, .atx-empty, .atx-loading, .atx-error { display: none !important; }
    .atx, .atx-work, .atx-sheet-host, .atx-sheet { height: auto; padding: 0; border: 0; box-shadow: none; overflow: visible; }
    .atx-sheet { background: #fff; }
}

/* ---------------- 响应式断点（降序） ---------------- */
@media (min-width: 1600px) {
    .atx { padding: 18px 26px 24px; --atx-left-w: 44%; }
    .atx-title { font-size: 22px; }
    .atx-stat-i { padding: 10px 18px; }
    .atx-syntax-list { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
}

@media (max-width: 1200px) {
    .atx { --atx-left-w: 45%; padding: 12px 12px 16px; }
    .atx-head { padding: 12px 13px; }
    .atx-title { font-size: 18px; }
    .atx-stat-i { padding: 7px 10px; }
    .atx-stat-i b { font-size: 16px; }
    .atx-editor-bar .atx-select { max-width: 150px; flex-basis: 150px; }
}

/* 平板 / 窄桌面：单栏 + 顶部「编辑 | 谱面」切换 */
@media (max-width: 999px) {
    .atx { height: calc(100dvh - 96px); min-height: 560px; }
    .atx-viewseg {
        display: flex; gap: 6px; flex: 0 0 auto;
        padding: 4px; border: 1px solid var(--atx-line); border-radius: var(--atx-r);
        background: var(--atx-card);
    }
    .atx-viewseg button {
        flex: 1 1 0; min-height: 38px;
        border: 0; border-radius: var(--atx-r-sm);
        background: transparent; color: var(--atx-sub); font-size: 12.5px; font-weight: 650;
    }
    .atx-viewseg button.is-on { background: var(--atx-accent); color: #fff; }
    .atx-work,
    .atx-work.is-side-hidden { grid-template-columns: minmax(0, 1fr); }
    .atx-splitter { display: none; }
    .atx.is-view-edit .atx-right { display: none; }
    .atx.is-view-score .atx-left { display: none; }
    .atx.is-view-score .atx-right { display: flex !important; }
    .atx-stat { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .atx-stat-i:nth-child(4) { border-left: 0; }
    .atx-stat-i:nth-child(n+4) { border-top: 1px solid var(--atx-line); }
    .atx-head-actions { flex: 1 1 100%; }
    .atx-export-pop { right: auto; left: 0; }
    .atx-syn-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* 手机 */
@media (max-width: 767px) {
    /* 手机改成整页滚动：头部精简 + 工作区固定 62vh 内部滚动，
       避免固定 100dvh 时头部把谱面区压到不足 200px。 */
    .atx { padding: 10px 10px 14px; gap: 9px; height: auto; min-height: 0; }
    .atx-work { height: 68vh; min-height: 460px; flex: 0 0 auto; }
    .atx-head { gap: 10px; padding: 10px 12px; }
    .atx-head-icon { width: 38px; height: 38px; border-radius: 10px; }
    .atx-head-icon svg { width: 22px; height: 22px; }
    .atx-head-text { flex: 1 1 auto; min-width: 0; }
    .atx-title { font-size: 17px; }
    /* 完整说明在「教程与说明」页签，手机首屏收起长文案与徽章，把高度让给谱面 */
    .atx-sub, .atx-badges { display: none; }
    .atx-head-actions { gap: 6px; }
    .atx-head-actions .atx-btn { flex: 1 1 calc(33.333% - 6px); min-height: 40px; padding: 0 4px; font-size: 11.5px; }
    .atx-export-wrap { flex: 1 1 calc(33.333% - 6px); }
    .atx-export-wrap > .atx-btn { width: 100%; }
    .atx-export-pop { width: min(320px, calc(100vw - 30px)); left: auto; right: 0; }
    .atx-stat { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .atx-stat-i { padding: 6px 8px; border-left: 1px solid var(--atx-line); }
    .atx-stat-i:nth-child(3n+1) { border-left: 0; }
    .atx-stat-i:nth-child(n+4) { border-top: 1px solid var(--atx-line); }
    .atx-stat-i b { font-size: 15px; }
    .atx-tab { min-height: 40px; padding: 0 10px; }
    .atx-btn, .atx-btn-sm, .atx-btn-xs { min-height: 40px; }
    .atx-btn-xs { min-width: 36px; }
    .atx-select, .atx-input, .atx-num { min-height: 40px; font-size: 16px; }
    .atx-code { font-size: 13px; line-height: 21px; }
    .atx-gutter { font-size: 12px; line-height: 21px; flex-basis: 38px; }
    .atx-editor-bar { gap: 5px; padding: 7px 8px; }
    .atx-editor-bar .atx-select { flex: 1 1 100%; max-width: none; }
    .atx-check-live { margin-left: 0; }
    .atx-render-btn { flex: 1 1 100%; }
    .atx-findbar .atx-input { flex: 1 1 100%; }
    .atx-chip { min-height: 38px; }
    .atx-syn-card { padding: 9px; }
    .atx-syn-acts .atx-btn { min-height: 36px; }
    .atx-syntax-list { grid-template-columns: minmax(0, 1fr); }
    .atx-tool { min-width: 38px; min-height: 38px; font-size: 15px; }
    .atx-sheet-tools { top: 16px; right: 16px; }
    /* 顶部留出浮动工具条的位置，避免压住谱面自带的标题行 */
    .atx-sheet { padding: 46px 10px 32px; }
    /* 播放条在手机上不能换行成 4 行，否则会把谱面区压到 200px 以下 */
    .atx-player { padding: 6px 8px; }
    .atx-score-info { padding: 5px 9px; gap: 5px; }
    .atx-info-items { gap: 7px; margin-left: 0; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
    .atx-settings-head { padding: 4px 9px; }
    .atx-transport {
        display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px;
    }
    .atx-transport > .atx-btn { min-width: 0; padding: 0 2px; font-size: 11px; min-height: 38px; }
    .atx-play { min-width: 0; }
    .atx-seek-wrap { grid-column: 1 / -1; min-width: 0; order: 0; }
    .atx-knobs {
        flex-wrap: nowrap; overflow-x: auto; gap: 8px;
        margin-top: 5px; padding-top: 5px; scrollbar-width: none;
    }
    .atx-knobs::-webkit-scrollbar { display: none; }
    .atx-knob { flex: 0 0 auto; }
    .atx-knob input[type=range] { width: 70px; }
    .atx-toast { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
    .atx-footnote { margin: 12px 10px 24px; }
    .atx-mask { padding: 0; align-items: flex-end; }
    .atx-modal { width: 100%; max-width: none; max-height: 92vh; border-radius: var(--atx-r-lg) var(--atx-r-lg) 0 0; }
    .atx-modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
    .atx-doc-body table { min-width: 460px; }
}

/* 超小屏 */
@media (max-width: 420px) {
    .atx-head-actions .atx-btn, .atx-export-wrap { flex: 1 1 calc(50% - 6px); }
    .atx-stat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .atx-stat-i { border-left: 0; }
    .atx-stat-i:nth-child(2n) { border-left: 1px solid var(--atx-line); }
    .atx-stat-i:nth-child(n+3) { border-top: 1px solid var(--atx-line); }
    .atx-info-items { margin-left: 0; gap: 8px; }
    .atx-set-grid { grid-template-columns: minmax(0, 1fr); }
    .atx-set-row label { flex-basis: 58px; }
    .atx-bar-sep { display: none; }
    .atx-status { gap: 8px; }
    .atx-status-sub { display: none; }
    .atx-sf-tip { display: none; }
}
