:root {
  --primary: #c47a2c; --primary-dark: #a3621f; --accent: #2f8f83;
  --bg: #faf7f2; --card: #ffffff; --line: #eadfd2; --text: #2b2622; --muted: #7a6f66;
  --ok: #2f9e5b; --err: #c43c3c; --warn-bg: #fff5e6; --tip-bg: #eef8f6;
  --top-h: 56px; --sb-w: 268px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 12px); }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.65; font-size: 16px; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 28px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: var(--err); font-size: 14px; min-height: 1em; white-space: pre-wrap; }
.only-mobile { display: none !important; }
[hidden] { display: none !important; }
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }

/* 顶栏 */
.top { position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 18px; gap: 20px; z-index: 50; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); }
.brand .logo { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 6px 12px; border-radius: 8px; color: var(--text); }
.topnav a.active, .topnav a:hover { background: #f4ebe0; text-decoration: none; color: var(--primary-dark); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-badge { font-size: 13px; color: var(--accent); }

/* 按钮 */
.btn { background: var(--primary); color: #fff; border: 1px solid var(--primary); border-radius: 8px; padding: 8px 16px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--primary-dark); }
.btn.ghost:hover { background: #f4ebe0; }
.btn.small { padding: 5px 11px; font-size: 14px; }
.btn.big { padding: 12px 22px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: default; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; cursor: pointer; white-space: nowrap; }

/* 布局 */
.layout { display: flex; padding-top: var(--top-h); min-height: 100vh; }
.sidebar { width: var(--sb-w); flex: none; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; background: #fff; border-right: 1px solid var(--line); padding: 14px 10px 30px; }
.sb-title { font-weight: 700; padding: 4px 10px 8px; }
.sb-part { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 12px 10px 4px; text-transform: none; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: 14.5px; }
.sidebar li a:hover { background: #f7f1e8; text-decoration: none; }
.sidebar li a.active { background: #f4e6d2; color: var(--primary-dark); font-weight: 600; }
.sidebar li a.done .sb-no { background: var(--ok); color: #fff; border-color: var(--ok); }
.sb-no { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--muted); }
.view { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1080px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; margin-bottom: 18px; }
.sec-title { margin: 26px 0 12px; }

/* 首页 */
.hero { padding: 10px 0 24px; }
.hero.small { padding-bottom: 10px; }
.hero h1 { font-size: 34px; }
.hero p { font-size: 17px; max-width: 760px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.progress-line { height: 8px; background: #eee4d8; border-radius: 4px; overflow: hidden; max-width: 420px; margin-top: 10px; }
.progress-line span { display: block; height: 100%; background: var(--ok); }
.roadmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.road-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.road-card ol { margin: 0; padding-left: 20px; }
.road-card li { margin: 4px 0; font-size: 14.5px; }
.road-card a.done::after { content: " ✓"; color: var(--ok); }
ul.tips { padding-left: 22px; }
ul.tips li { margin: 6px 0; }

/* 章节 */
.ch-head { margin-bottom: 14px; }
.ch-part { color: var(--muted); font-size: 14px; }
.ch-summary { font-size: 17px; color: #4a423c; margin: 4px 0 0; }
.ch-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.ch-toc a { font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 3px 11px; color: var(--text); }
.prose p { margin: .5em 0 .9em; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose table { border-collapse: collapse; margin: 10px 0; font-size: 15px; width: 100%; max-width: 720px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.prose th { background: #f7f1e8; }
.prose img { max-width: 100%; }
.tip, .warn { padding: 12px 16px; border-radius: 10px; margin: 12px 0; }
.tip { background: var(--tip-bg); border-left: 4px solid var(--accent); }
.warn { background: var(--warn-bg); border-left: 4px solid var(--primary); }
pre.code { background: #2d2a26; color: #f3eee6; padding: 12px 14px; border-radius: 10px; overflow: auto; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.ex .ex-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ex-goal { margin: 4px 0 6px; }
.ex-meta { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.ex-howto ol, .ex-mist ul { margin: 4px 0 10px; padding-left: 22px; font-size: 15px; }
.ex-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.ex-player-host { margin-top: 10px; }
.ch-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.quiz { padding: 10px 0; border-top: 1px dashed var(--line); }
.quiz:first-of-type { border-top: 0; }
.quiz .q { font-weight: 600; margin-bottom: 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.opt:hover { background: #f7f1e8; }
.opt.right { background: #e6f6ec; border-color: var(--ok); }
.opt.wrong { background: #fde9e9; border-color: var(--err); }
.q-why { margin-top: 6px; font-size: 14px; color: var(--muted); }
ul.refs { padding-left: 20px; }

/* 和弦图 / 指板图 */
.chord-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.chord-box { width: 110px; }
.chord-svg { width: 100%; height: auto; }
.chord-svg .chord-name { font-size: 13px; font-weight: 700; fill: var(--text); }
.chord-svg .nut { fill: var(--text); }
.chord-svg .fretline, .chord-svg .stringline { stroke: #7a6f66; stroke-width: 1; }
.chord-svg .dot { fill: var(--primary); }
.chord-svg .barre { fill: var(--primary); opacity: .85; }
.chord-svg .finger { font-size: 9px; fill: #fff; font-weight: 700; }
.chord-svg .mark-x { font-size: 11px; fill: var(--err); font-weight: 700; }
.chord-svg .mark-o { fill: none; stroke: var(--text); stroke-width: 1.2; }
.chord-svg .base-fret, .chord-svg .string-name { font-size: 9px; fill: var(--muted); }
.fretboard { margin: 10px 0; overflow-x: auto; }
.fb-svg { width: 100%; max-width: 760px; height: auto; display: block; }
.fb-svg .fb-string { stroke: #8a7f74; }
.fb-svg .fb-fret { stroke: #c9bdb0; stroke-width: 1.5; }
.fb-svg .fb-nut { stroke: var(--text); stroke-width: 4; }
.fb-svg .fb-sname, .fb-svg .fb-fno { font-size: 10px; fill: var(--muted); }
.fb-svg .fb-inlay { fill: #e6dccf; }
.fb-svg .fb-note { fill: var(--accent); }
.fb-svg .fb-note.root { fill: var(--primary); }
.fb-svg .fb-note.c-1 { fill: #4c7bd9; } .fb-svg .fb-note.c-2 { fill: #8e5bd1; } .fb-svg .fb-note.c-3 { fill: #d1a24c; }
.fb-svg .fb-ntext { font-size: 9px; fill: #fff; font-weight: 700; }

/* 内嵌谱 */
.inline-tex { margin: 10px 0; }
.inline-tex-bar { display: flex; gap: 8px; margin-bottom: 6px; }

/* 播放器 */
.player { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 8px 0; }
.player-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; background: #f7f1e8; border-bottom: 1px solid var(--line); font-size: 14px; }
.p-speed { display: inline-flex; align-items: center; gap: 6px; }
.p-speed input { width: 110px; }
.p-sep { width: 1px; height: 20px; background: var(--line); }
.p-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.p-status { font-size: 13px; color: var(--muted); }
.p-status.err { color: var(--err); }
.player.is-playing .p-play { background: var(--accent); border-color: var(--accent); }
.at-wrap { position: relative; min-height: 120px; }
.player.loading .at-wrap::after { content: "渲染中…"; position: absolute; top: 10px; left: 14px; color: var(--muted); font-size: 13px; }
.at-viewport { overflow: auto; }
.at-main { padding: 6px; }
.p-hint { font-size: 12.5px; color: var(--muted); padding: 6px 12px 8px; border-top: 1px dashed var(--line); }
.p-explain .chk { font-size: 13px; }
.p-tex-wrap { display: none; }
/* alphaTab 光标 */
.at-cursor-bar { background: rgba(196, 122, 44, .12); }
.at-cursor-beat { background: rgba(47, 143, 131, .8); width: 3px; }
.at-highlight * { fill: #1a73e8; stroke: #1a73e8; }
.at-selection div { background: rgba(64, 64, 255, 0.1); }

/* 曲目库 */
.import-row { display: flex; gap: 8px; margin: 6px 0; }
.import-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.song-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; color: var(--text); position: relative; }
.song-card:hover { border-color: var(--primary); text-decoration: none; }
.song-title { font-weight: 700; font-size: 16px; }
.song-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.badge { position: absolute; top: 10px; right: 10px; font-size: 11px; background: var(--warn-bg); color: var(--primary-dark); padding: 2px 8px; border-radius: 10px; }
.sheet-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sheet { overflow: auto; text-align: center; background: #f3efe8; border-radius: 10px; padding: 8px; }
.sheet img { max-width: 100%; height: auto; }
.sheet.zoom img { max-width: none; width: 1400px; }

/* 编谱器 */
.editor { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
.ed-left, .ed-right { min-width: 0; }
.ed-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ed-bar select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 160px; }
#edTex { width: 100%; height: 420px; font-family: Consolas, Menlo, monospace; font-size: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; }
.ed-help pre { font-size: 12.5px; }
.ed-right { position: sticky; top: calc(var(--top-h) + 12px); }

/* 工具 */
.tune-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.metro-ui { max-width: 520px; }
.metro-big { font-size: 64px; font-weight: 700; text-align: center; line-height: 1; margin: 6px 0 10px; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
#metroBpm { width: 100%; }
.metro-row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.metro-row select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; }
.metro-dots { display: flex; gap: 10px; justify-content: center; }
.metro-dots .dot { width: 18px; height: 18px; border-radius: 50%; background: #e6dccf; transition: transform .05s; }
.metro-dots .dot.accent { background: #dcc9ad; }
.metro-dots .dot.on { background: var(--primary); transform: scale(1.3); }
.note-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.note-btn.active { background: var(--primary); color: #fff; }

/* 对话框 / 提示 */
.dlg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; z-index: 200; }
.dlg-box { background: #fff; border-radius: 14px; padding: 22px 24px; width: min(92vw, 360px); }
.dlg-box input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: #2b2622; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 300; font-size: 14px; }
.bnav { display: none; }

/* 手机 */
@media (max-width: 860px) {
  .only-mobile { display: inline-flex !important; }
  .topnav { display: none; }
  .top { padding: 0 12px; }
  .sidebar { position: fixed; left: 0; top: var(--top-h); bottom: 0; transform: translateX(-100%); transition: transform .2s; z-index: 60; width: min(82vw, 320px); box-shadow: 0 0 0 100vw rgba(0,0,0,0); }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vw rgba(0, 0, 0, .3); }
  .view { padding: 16px 12px 90px; }
  .card { padding: 14px 14px; border-radius: 12px; }
  .hero h1 { font-size: 26px; } h1 { font-size: 23px; }
  .editor { grid-template-columns: 1fr; }
  .ed-right { position: static; }
  #edTex { height: 260px; }
  .player-bar { font-size: 13px; gap: 6px 10px; }
  .p-hint { display: none; }
  .bnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 56px; background: #fff; border-top: 1px solid var(--line); z-index: 55; padding-bottom: env(safe-area-inset-bottom); }
  .bnav a { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
  .bnav a.active { color: var(--primary-dark); font-weight: 700; }
  .sheet.zoom img { width: 1000px; }
}
