/* ============================================================
   钢琴系统学习教程 — 统一样式表
   设计目标：清爽、零基础友好、适合长期使用、护眼
   ============================================================ */

:root {
  /* 颜色：浅色主题 */
  --bg: #f6f5f1;
  --bg-soft: #efeee8;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --paper: #fffdf6;            /* 乐谱"纸张"底色，深浅色都用这个 */
  --ink: #23211c;
  --ink-soft: #5b574d;
  --ink-faint: #8b857a;
  --line: #e3e0d6;
  --line-strong: #d2cebf;

  --accent: #2f6f6a;           /* 沉静的青灰绿 */
  --accent-soft: #e4efed;
  --accent-ink: #1d4f4b;
  --gold: #b8893b;             /* 暖金，点缀 */
  --gold-soft: #f6ecd8;
  --rose: #b4564f;             /* 提醒红 */
  --rose-soft: #f7e6e3;
  --blue: #3a6ea5;
  --blue-soft: #e6eef7;

  --shadow-sm: 0 1px 3px rgba(35,33,28,.06), 0 1px 2px rgba(35,33,28,.04);
  --shadow-md: 0 4px 16px rgba(35,33,28,.08);
  --shadow-lg: 0 12px 36px rgba(35,33,28,.12);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;

  --maxw: 1060px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC",
          system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #1c1b18;
  --bg-soft: #232220;
  --surface: #26241f;
  --surface-2: #2c2a25;
  --ink: #ece9e1;
  --ink-soft: #b6b1a4;
  --ink-faint: #8b857a;
  --line: #383530;
  --line-strong: #46423a;
  --accent: #6fb4ad;
  --accent-soft: #243634;
  --accent-ink: #9ed3cd;
  --gold: #d6a85a;
  --gold-soft: #322a1c;
  --rose: #d98079;
  --rose-soft: #34211f;
  --blue: #7ba6d6;
  --blue-soft: #1f2a36;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 36px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  font-size: 16.5px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶部导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 11px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-ink));
  display: grid; place-items: center; color: #fff; font-size: 17px;
  box-shadow: var(--shadow-sm);
}
.nav-links { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav-links a {
  color: var(--ink-soft); padding: 6px 11px; border-radius: 8px; font-size: 14.5px;
}
.nav-links a:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.nav-links a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.theme-toggle {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer; font-size: 16px;
  display: grid; place-items: center; transition: .15s;
}
.theme-toggle:hover { background: var(--bg-soft); }

/* ---------- 容器与排版 ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 34px 20px 90px; }
.narrow { max-width: 800px; }

h1, h2, h3, h4 { line-height: 1.35; color: var(--ink); font-weight: 700; }
h1 { font-size: 2.05rem; letter-spacing: -.01em; margin: .2em 0 .5em; }
h2 { font-size: 1.5rem; margin: 1.9em 0 .7em; padding-bottom: .35em; border-bottom: 2px solid var(--line); }
h3 { font-size: 1.18rem; margin: 1.5em 0 .5em; }
h4 { font-size: 1.02rem; margin: 1.2em 0 .4em; color: var(--accent-ink); }
p { margin: .7em 0; }
ul, ol { padding-left: 1.4em; margin: .6em 0; }
li { margin: .35em 0; }
strong { color: var(--ink); font-weight: 700; }
.lead { font-size: 1.12rem; color: var(--ink-soft); }
.muted { color: var(--ink-faint); }
code {
  font-family: var(--mono); font-size: .9em; background: var(--bg-soft);
  padding: .12em .4em; border-radius: 5px; border: 1px solid var(--line);
}
kbd {
  font-family: var(--mono); font-size: .85em; background: var(--surface);
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  padding: .1em .45em; border-radius: 6px; box-shadow: var(--shadow-sm);
}

/* ---------- 面包屑 ---------- */
.crumbs { font-size: 14px; color: var(--ink-faint); margin-bottom: 8px; }
.crumbs a { color: var(--ink-faint); }
.crumbs a:hover { color: var(--accent-ink); }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-ink) 70%);
  color: #fff; border-radius: var(--radius-lg); padding: 46px 40px;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.hero::after {
  content: "♪"; position: absolute; right: 26px; bottom: -22px;
  font-size: 200px; opacity: .08; line-height: 1;
}
.hero h1 { color: #fff; margin-top: 0; font-size: 2.3rem; }
.hero p { color: rgba(255,255,255,.92); max-width: 640px; font-size: 1.1rem; }
.hero .pillrow { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .pill {
  background: rgba(255,255,255,.16); color: #fff; padding: 6px 13px;
  border-radius: 999px; font-size: 13.5px; backdrop-filter: blur(4px);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 18px;
  font-size: 15px; font-weight: 600; font-family: var(--font);
  transition: .15s; text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-ink); }
.btn-light { background: #fff; color: var(--accent-ink); }
.btn-light:hover { background: #f0f0ec; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { padding: 6px 12px; font-size: 13.5px; border-radius: 8px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow-sm); margin: 16px 0;
}
.card-grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }

/* ---------- 提示框（callout） ---------- */
.callout {
  border-radius: var(--radius); padding: 16px 18px 16px 18px; margin: 18px 0;
  border: 1px solid var(--line); background: var(--surface-2);
  display: flex; gap: 13px; align-items: flex-start;
}
.callout .ico { font-size: 21px; line-height: 1.5; flex-shrink: 0; }
.callout .body { flex: 1; }
.callout .body > :first-child { margin-top: 0; }
.callout .body > :last-child { margin-bottom: 0; }
.callout .tag { font-weight: 700; display: block; margin-bottom: 2px; }
.callout.key   { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.callout.key .tag { color: var(--accent-ink); }
.callout.tip   { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 30%, var(--line)); }
.callout.tip .tag { color: var(--blue); }
.callout.warn  { background: var(--rose-soft); border-color: color-mix(in srgb, var(--rose) 30%, var(--line)); }
.callout.warn .tag { color: var(--rose); }
.callout.goal  { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 35%, var(--line)); }
.callout.goal .tag { color: var(--gold); }

/* ---------- 乐谱 / 键盘"纸张"容器 ---------- */
.figure {
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 18px; margin: 18px 0; box-shadow: var(--shadow-sm); text-align: center;
}
.figure svg { max-width: 100%; height: auto; }
.figure .cap { font-size: 13.5px; color: #6b6557; margin-top: 10px; }
.figure[data-clickable]::before {
  content: "🔊 点击琴键可试听"; display: inline-block; font-size: 12px; color: #8a8474;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 10px; margin-bottom: 8px;
}

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 15px; }
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--line); }
th { background: var(--bg-soft); font-weight: 700; color: var(--ink); }
tr:hover td { background: var(--surface-2); }
td.center, th.center { text-align: center; }

/* ---------- 路线图 / 阶段卡 ---------- */
.roadmap { display: grid; gap: 14px; margin: 22px 0; }
.stage-card {
  display: flex; gap: 18px; align-items: stretch; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); transition: .18s; position: relative;
}
.stage-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.stage-num {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-ink)); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
.stage-card .meta { flex: 1; }
.stage-card .meta h3 { margin: 0 0 3px; }
.stage-card .meta p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }
.stage-card .week { color: var(--gold); font-size: 13px; font-weight: 700; }
.stage-progress { font-size: 13px; color: var(--ink-faint); margin-top: 8px; }

/* ---------- 进度条 ---------- */
.bar { height: 9px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); width: 0; transition: width .5s ease; }
.bar.lg { height: 13px; }

/* ---------- 总进度仪表盘 ---------- */
.dash {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px; box-shadow: var(--shadow-md); margin: 22px 0;
}
.dash-top { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.ring { position: relative; width: 116px; height: 116px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .pct {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 25px; font-weight: 800; color: var(--accent-ink);
}
.dash-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat .n { font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--ink-faint); }

/* ---------- 打卡 / 任务清单 ---------- */
.checklist { list-style: none; padding: 0; margin: 14px 0; }
.checklist li {
  display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; margin: 8px 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: .15s; cursor: pointer;
}
.checklist li:hover { border-color: var(--line-strong); }
.checklist li.done { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.checklist .box {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px; margin-top: 2px;
  border: 2px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; color: #fff; font-size: 14px; transition: .15s;
}
.checklist li.done .box { background: var(--accent); border-color: var(--accent); }
.checklist .txt { flex: 1; }
.checklist li.done .txt { color: var(--ink-soft); }
.checklist .txt small { display: block; color: var(--ink-faint); font-size: 13px; }

/* ---------- 课内小节 ---------- */
.lesson-block { margin: 30px 0; }
.lesson-block > h2:first-child { margin-top: 0; }
.pill-tag {
  display: inline-block; background: var(--gold-soft); color: var(--gold);
  font-size: 12.5px; font-weight: 700; padding: 3px 11px; border-radius: 999px; margin-bottom: 8px;
}
.step-list { counter-reset: step; list-style: none; padding: 0; }
.step-list > li {
  counter-increment: step; position: relative; padding: 4px 0 4px 44px; margin: 12px 0;
}
.step-list > li::before {
  content: counter(step); position: absolute; left: 0; top: 2px;
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}

/* ---------- 课程内导航（上一/下一课） ---------- */
.lesson-nav { display: flex; justify-content: space-between; gap: 14px; margin-top: 50px; }
.lesson-nav a {
  flex: 1; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm); transition: .15s;
}
.lesson-nav a:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.lesson-nav .dir { font-size: 12.5px; color: var(--ink-faint); }
.lesson-nav .t { font-weight: 700; color: var(--ink); }
.lesson-nav .next { text-align: right; }

/* ---------- 浮动节拍器 ---------- */
.metro-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--gold), #9c6f28); color: #fff; font-size: 24px;
  box-shadow: var(--shadow-lg); display: grid; place-items: center; transition: .2s;
}
.metro-fab:hover { transform: scale(1.06); }
.metro-fab.beating { animation: pulse .12s ease; }
@keyframes pulse { 50% { transform: scale(1.14); } }

.metro-panel {
  position: fixed; right: 20px; bottom: 86px; z-index: 60; width: 290px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 20px; display: none;
}
.metro-panel.open { display: block; animation: slideup .2s ease; }
@keyframes slideup { from { opacity: 0; transform: translateY(10px); } }
.metro-panel h4 { margin: 0 0 4px; display: flex; align-items: center; justify-content: space-between; }
.metro-panel .close { cursor: pointer; color: var(--ink-faint); background: none; border: none; font-size: 20px; }
.bpm-display { text-align: center; margin: 6px 0; }
.bpm-display .v { font-size: 46px; font-weight: 800; color: var(--accent-ink); line-height: 1; }
.bpm-display .u { font-size: 13px; color: var(--ink-faint); }
.metro-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.metro-row input[type=range] { flex: 1; accent-color: var(--accent); }
.metro-dots { display: flex; gap: 7px; justify-content: center; margin: 10px 0; }
.metro-dots .d { width: 13px; height: 13px; border-radius: 50%; background: var(--line-strong); transition: .08s; }
.metro-dots .d.on { background: var(--gold); transform: scale(1.25); }
.metro-dots .d.accent.on { background: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: var(--surface); color: var(--ink-soft); padding: 5px 11px; cursor: pointer; font-size: 13px; font-family: var(--font); }
.seg button.on { background: var(--accent); color: #fff; }
.tempo-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.tempo-btns button {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer; font-family: var(--font);
}
.tempo-btns button:hover { background: var(--bg-soft); }

/* ---------- 杂项 ---------- */
.divider { height: 1px; background: var(--line); border: 0; margin: 30px 0; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.chip {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--ink-soft);
}
.footer { text-align: center; color: var(--ink-faint); font-size: 13.5px; padding: 30px 20px; border-top: 1px solid var(--line); }
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 10px;
  box-shadow: var(--shadow-lg); opacity: 0; transition: .25s; z-index: 80; font-size: 14.5px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 键盘上的手指编号小圆点说明 */
.finger-legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.finger-legend b { color: var(--accent-ink); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .hero { padding: 32px 22px; }
  .hero h1 { font-size: 1.8rem; }
  .container { padding: 24px 15px 80px; }
  .nav-links { display: none; }
  h1 { font-size: 1.7rem; }
}
