/* REAPER 课程共享样式 —— 每节课和参考文档都链接这个文件 */
:root {
  --bg: #fffff8;
  --fg: #1f1f1f;
  --muted: #6b6b6b;
  --rule: #d9d6c8;
  --accent: #b5452b;          /* REAPER 录音红 */
  --accent-soft: #f6e6df;
  --ok: #2f7d4a;
  --ok-soft: #e3f1e7;
  --bad: #a3302a;
  --bad-soft: #f7e1df;
  --code-bg: #f1efe4;
  --measure: 38rem;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Iowan Old Style", Georgia, serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", -apple-system, "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a17; --fg: #e8e5da; --muted: #a09c8f; --rule: #3a3833;
    --accent: #e0775c; --accent-soft: #3a261f; --ok: #6cc28a; --ok-soft: #1f3226;
    --bad: #e7837b; --bad-soft: #3b2020; --code-bg: #2a2925;
  }
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--serif); line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
main { max-width: calc(var(--measure) + 16rem); margin: 0 auto; padding: 3rem 1rem 5rem; }
main > * { max-width: var(--measure); }

/* 头部 */
.kicker { font-family: var(--sans); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0; }
h1 { font-weight: 600; font-size: 2rem; line-height: 1.3; margin: .3rem 0 .6rem; }
.subtitle { font-style: italic; color: var(--muted); margin-top: 0; font-size: 1.1rem; }
h2 { font-weight: 600; font-size: 1.35rem; margin: 2.8rem 0 .6rem; border-top: 1px solid var(--rule); padding-top: 1.4rem; }
h3 { font-weight: 600; font-size: 1.08rem; margin: 1.8rem 0 .4rem; }
a { color: var(--accent); text-underline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* 旁注（Tufte 风格）：宽屏在右边栏，窄屏内联 */
.sidenote {
  float: right; clear: right; width: 14rem; margin: .2rem -16rem 1rem 0;
  font-family: var(--sans); font-size: .8rem; line-height: 1.55; color: var(--muted);
}
@media (max-width: 62rem) {
  .sidenote { float: none; display: block; width: auto; margin: .5rem 0 1rem 1rem; padding-left: .8rem; border-left: 2px solid var(--rule); }
}

/* 行内元素 */
code, kbd, .path { font-family: var(--mono); font-size: .86em; }
code, .path { background: var(--code-bg); padding: .08em .35em; border-radius: 3px; }
kbd { border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--bg); white-space: nowrap; }
.ui { font-family: var(--sans); font-size: .9em; font-weight: 600; white-space: nowrap; } /* REAPER 界面上的字 */
.ui::before { content: "‹"; color: var(--muted); font-weight: 400; margin-right: .1em; }
.ui::after  { content: "›"; color: var(--muted); font-weight: 400; margin-left: .1em; }
pre { background: var(--code-bg); padding: .9rem 1rem; border-radius: 6px; overflow-x: auto; font-size: .85rem; line-height: 1.5; }
dfn { font-style: normal; font-weight: 600; border-bottom: 1px dotted var(--accent); }

/* 提示框 */
.callout { font-family: var(--sans); font-size: .92rem; line-height: 1.6; border-left: 3px solid var(--accent); background: var(--accent-soft); padding: .8rem 1rem; margin: 1.4rem 0; border-radius: 0 6px 6px 0; }
.callout.win { border-color: var(--ok); background: var(--ok-soft); }
.callout strong:first-child { display: block; margin-bottom: .2rem; }

/* 步骤清单（配合 assets/steps.js，可勾选） */
ol.steps { list-style: none; counter-reset: step; padding: 0; }
ol.steps > li { counter-increment: step; position: relative; padding: .6rem 0 .6rem 2.6rem; border-bottom: 1px dashed var(--rule); }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: .65rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 1.5px solid var(--accent);
  color: var(--accent); font-family: var(--sans); font-size: .85rem; text-align: center; line-height: 1.7rem; cursor: pointer;
}
ol.steps > li.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
ol.steps > li.done > :first-child { color: var(--muted); }

/* 测验（配合 assets/quiz.js） */
.quiz { font-family: var(--sans); font-size: .95rem; border: 1px solid var(--rule); border-radius: 8px; padding: 1rem 1.2rem; margin: 1.4rem 0; }
.quiz .q { font-weight: 600; margin: 0 0 .7rem; }
.quiz button.opt {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--fg);
  background: transparent; border: 1px solid var(--rule); border-radius: 6px; padding: .55rem .8rem; margin: .4rem 0; cursor: pointer;
}
.quiz button.opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz button.opt.right { background: var(--ok-soft); border-color: var(--ok); }
.quiz button.opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
.quiz .why { display: none; margin: .6rem 0 0; color: var(--muted); font-size: .88rem; }
.quiz.answered .why { display: block; }
.quiz-score { font-family: var(--sans); color: var(--muted); font-size: .9rem; }

/* 表格（参考文档常用） */
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .88rem; margin: 1rem 0; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; border-bottom: 2px solid var(--fg); }

/* 课程导航与页脚 */
nav.course { font-family: var(--sans); font-size: .85rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--rule); margin-top: 3rem; padding-top: 1rem; }
.source { font-family: var(--sans); font-size: .9rem; border: 1px solid var(--rule); border-radius: 8px; padding: .8rem 1rem; }
.ask { font-family: var(--sans); font-size: .9rem; color: var(--muted); }

@media print {
  :root { --bg: #fff; --fg: #000; }
  main { padding: 0; max-width: none; }
  .sidenote { float: none; width: auto; margin: .3rem 0 .6rem 1rem; }
  .quiz button.opt { border: 1px solid #999; }
  nav.course, .ask { display: none; }
  h2 { break-after: avoid; }
}

/* 合成器试听台 / 听音练习（配合 assets/synth.js） */
.synth-lab, .ear-quiz { font-family: var(--sans); font-size: .9rem; border: 1px solid var(--rule); border-radius: 8px; padding: 1rem 1.2rem; margin: 1.4rem 0; outline: none; }
.synth-lab:focus-within, .synth-lab:focus { border-color: var(--accent); }
.synth-lab .row, .ear-quiz .row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
button.chip, button.hold {
  font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--rule);
  border-radius: 999px; padding: .35rem .85rem; cursor: pointer;
}
button.chip:hover, button.hold:hover { border-color: var(--accent); }
button.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
button.chip.right { background: var(--ok-soft); border-color: var(--ok); }
button.chip.wrong { background: var(--bad-soft); border-color: var(--bad); }
button.hold { border-radius: 6px; padding: .5rem 1.2rem; font-weight: 600; user-select: none; touch-action: none; }
.synth-lab .sliders { display: grid; gap: .3rem; margin: .8rem 0; }
.synth-lab .sliders label { display: grid; grid-template-columns: 8.5rem 1fr 3.5rem; align-items: center; gap: .6rem; }
.synth-lab .sliders output { font-family: var(--mono); font-size: .8rem; color: var(--muted); text-align: right; }
.synth-lab input[type=range] { width: 100%; accent-color: var(--accent); }
.env-curve { width: 100%; height: 80px; display: block; margin: .4rem 0; }
.env-curve path { fill: none; stroke: var(--accent); stroke-width: 2; }
.synth-lab .hint, .ear-quiz .status { color: var(--muted); font-size: .85rem; margin: .4rem 0; }
.ear-quiz .feedback { min-height: 1.4em; margin: .4rem 0; }
@media print { .synth-lab, .ear-quiz { display: none; } }

/* 节奏听写（配合 assets/rhythm.js） */
.rhythm-dictation { font-family: var(--sans); font-size: .9rem; border: 1px solid var(--rule); border-radius: 8px; padding: 1rem 1.2rem; margin: 1.4rem 0; }
.rgrid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; margin: .5rem 0 0; }
.rgrid .cell { aspect-ratio: 1; min-width: 0; border: 1px solid var(--rule); border-radius: 4px; background: transparent; cursor: pointer; padding: 0; }
.rgrid .cell.beat { border-color: var(--fg); }
.rgrid .cell:nth-child(4n+1):not(:first-child) { margin-left: 4px; }
.rgrid .cell.on { background: var(--accent); border-color: var(--accent); }
.rgrid .cell.now { outline: 2px solid var(--accent); outline-offset: 1px; }
.rgrid .cell.right { background: var(--ok); border-color: var(--ok); }
.rgrid .cell.wrong { background: var(--bad); border-color: var(--bad); }
.rgrid .cell.missed { border: 2px dashed var(--ok); }
.rgrid.labels { margin: .15rem 0 .6rem; color: var(--muted); font-size: .72rem; text-align: center; }
.rgrid.labels span:nth-child(4n+1) { color: var(--fg); font-weight: 600; }
.rgrid.labels span:nth-child(4n+1):not(:first-child) { margin-left: 4px; }
@media print { .rhythm-dictation { display: none; } }

/* 带标注的截图：<figure class="annot"><svg viewBox="0 0 W H"><image …/><g class="mark">…</g></svg></figure> */
figure.annot { margin: 1.2rem 0; }
figure.annot svg { width: 100%; height: auto; display: block; border-radius: 6px; }
figure.annot .mark rect { fill: none; stroke: #ffd400; stroke-width: 5; rx: 10; }
figure.annot .mark circle { fill: #ffd400; stroke: #000; stroke-width: 3; }
figure.annot .mark text { fill: #000; font: 700 34px var(--sans, sans-serif); text-anchor: middle; dominant-baseline: central; }
figure.annot figcaption { font-family: var(--sans); font-size: .82rem; color: var(--muted); margin-top: .4rem; }
ol.legend { font-family: var(--sans); font-size: .92rem; padding-left: 0; list-style: none; counter-reset: lg; }
ol.legend > li { counter-increment: lg; position: relative; padding: .3rem 0 .3rem 2.2rem; }
ol.legend > li::before { content: counter(lg); position: absolute; left: 0; top: .3rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #ffd400; color: #000; font-weight: 700; text-align: center; line-height: 1.5rem; font-size: .8rem; }

/* 泛音实验台（配合 assets/harmonics.js） */
.harmonic-lab { font-family: var(--sans); font-size: .9rem; border: 1px solid var(--rule); border-radius: 8px; padding: 1rem 1.2rem; margin: 1.4rem 0; }
.hl-bars { display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; margin: .8rem 0 .2rem; }
.hl-bars label { display: flex; flex-direction: column; align-items: center; gap: .2rem; font-size: .72rem; color: var(--muted); }
.hl-bars input[type=range] { writing-mode: vertical-lr; direction: rtl; width: 1.4rem; height: 110px; accent-color: var(--accent); margin: 0; }
.hl-wave { width: 100%; height: auto; display: block; margin: .4rem 0; }
.harmonic-lab .hint { color: var(--muted); font-size: .82rem; margin: .3rem 0 .6rem; font-family: var(--mono); }
button.hold.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media print { .harmonic-lab { display: none; } }
