:root {
  --paper: #f6f1e7;
  --card: #fffdf8;
  --card-2: #fbf7ee;
  --ink: #2b2620;
  --ink-2: #6f6456;
  --ink-3: #a89a86;
  --line: #e7dcc9;
  --line-2: #d5c6ad;
  --red: #c14e1d;
  --red-deep: #8f3a15;
  --red-soft: #f8e6da;
  --teal: #0e6e56;
  --teal-soft: #e0f0e8;
  --amber: #9c6408;
  --amber-soft: #f7ecd5;
  --serif: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", monospace;
  --rad: 12px;
  --rad-s: 8px;
  --shadow: 0 1px 2px rgba(80, 60, 30, .06), 0 6px 24px -12px rgba(80, 60, 30, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
}
::selection { background: var(--red-soft); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.35; margin: 0; }
button { font-family: inherit; }
a { color: inherit; }

/* ---------- header ---------- */
.apphead {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.apphead-in {
  max-width: 860px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 22px;
}
.brand {
  font-family: var(--serif); font-weight: 900; font-size: 25px;
  text-decoration: none; letter-spacing: 2px; color: var(--ink);
}
.brand span { color: var(--red); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  text-decoration: none; font-size: 15px; color: var(--ink-2);
  padding: 6px 14px; border-radius: 999px; transition: all .18s;
}
.tabs a:hover { color: var(--ink); background: var(--card-2); }
.tabs a.active { color: var(--card); background: var(--ink); font-weight: 500; }
.head-chips { display: flex; gap: 8px; align-items: center; }

/* ---------- chips & buttons ---------- */
.chip {
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2);
  font-size: 13px; border-radius: 999px; padding: 4px 12px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip.quiet { cursor: default; }
.chip.quiet:hover { border-color: var(--line-2); color: var(--ink-2); }

.btn {
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font-size: 14px; border-radius: var(--rad-s); padding: 8px 18px; cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--red-deep); border-color: var(--red-deep); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.big { font-size: 16px; padding: 12px 26px; }
.btn.icon { padding: 8px 12px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------- layout ---------- */
.page { max-width: 860px; margin: 0 auto; padding: 26px 20px 120px; }
.pagehead { margin: 4px 0 20px; }
.pagehead h1 { font-size: 26px; }
.pagehead .sub { color: var(--ink-2); font-size: 14px; margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--rad);
  padding: 18px 20px; box-shadow: var(--shadow);
  animation: rise .4s cubic-bezier(.2,.7,.3,1) both;
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 18px; margin-bottom: 6px; }
.card h3 { font-size: 16px; }
.card .muted { color: var(--ink-2); font-size: 13.5px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }
.card:nth-child(4) { animation-delay: .15s; }

.rowitem {
  display: flex; align-items: center; gap: 14px; padding: 13px 6px;
  border-top: 1px solid var(--line); cursor: pointer; transition: background .15s;
}
.rowitem:hover { background: var(--card-2); }
.rowitem .ico { font-size: 20px; width: 30px; text-align: center; flex-shrink: 0; }
.rowitem .body { flex: 1; min-width: 0; }
.rowitem .body b { font-weight: 500; font-size: 14.5px; display: block; }
.rowitem .body small { color: var(--ink-3); font-size: 12.5px; }
.rowitem .tail { color: var(--ink-3); font-size: 13px; flex-shrink: 0; }
.rowitem.done .body b { color: var(--ink-3); text-decoration: line-through; }
.rowitem.locked { opacity: .5; cursor: default; }

.badge {
  display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--ink-2);
}
.badge.red { background: var(--red-soft); color: var(--red-deep); border-color: transparent; }
.badge.teal { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }

/* ---------- chord & music elements ---------- */
.chordpill {
  font-family: var(--serif); font-weight: 700; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--line-2); border-radius: var(--rad-s);
  padding: 4px 12px; font-size: 15px; transition: all .15s;
}
.chordpill:hover { border-color: var(--teal); color: var(--teal); }
.chordpill.hot { background: var(--teal); border-color: var(--teal); color: #fff; }

.bigchord {
  font-family: var(--serif); font-weight: 900; font-size: 88px; line-height: 1;
  text-align: center; letter-spacing: -2px;
}
.bigchord .next { font-size: 36px; color: var(--ink-3); font-weight: 700; }

.beatdots { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.beatdots i {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2);
  transition: all .1s;
}
.beatdots i.on { background: var(--red); border-color: var(--red); transform: scale(1.25); }

.notedot { cursor: pointer; }
.notedot:hover { opacity: .8; }

/* ---------- lyrics / playalong ---------- */
.lyric-sheet { max-height: 340px; overflow-y: auto; padding: 10px 4px; scroll-behavior: smooth; }
.lyric-line { display: flex; flex-wrap: wrap; gap: 2px 14px; padding: 7px 10px; border-radius: var(--rad-s); }
.lyric-line.now { background: var(--red-soft); }
.lyric-seg { display: inline-block; }
.lyric-seg .c {
  display: block; font-family: var(--serif); font-weight: 700; font-size: 13px;
  color: var(--red); line-height: 1.1; min-height: 15px;
}
.lyric-seg .w { font-size: 17px; }
.lyric-line.now .lyric-seg.hot .w { color: var(--red-deep); font-weight: 700; }

/* ---------- forms ---------- */
input[type="text"], input[type="password"], select {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line-2); border-radius: var(--rad-s); padding: 8px 12px;
}
input[type="text"]:focus, input[type="password"]:focus { outline: 2px solid var(--red-soft); border-color: var(--red); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px;
  background: var(--line-2); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--red); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line-2);
}
.ctlrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.ctlrow label { font-size: 13px; color: var(--ink-2); }
.ctlrow .val { font-family: var(--mono); font-size: 14px; min-width: 46px; }

.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: .2s;
}
.switch i::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s;
}
.switch input:checked + i { background: var(--teal); }
.switch input:checked + i::after { left: 21px; }

/* ---------- quiz ---------- */
.quiz-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0; }
.quiz-opt {
  border: 1px solid var(--line-2); background: var(--card); border-radius: var(--rad-s);
  padding: 12px; font-size: 15px; cursor: pointer; text-align: center; transition: all .15s;
}
.quiz-opt:hover { border-color: var(--ink-3); }
.quiz-opt.right { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); font-weight: 700; }
.quiz-opt.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red-deep); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- tuner ---------- */
.tuner-gauge { text-align: center; padding: 10px 0; }
.tuner-note { font-family: var(--serif); font-weight: 900; font-size: 72px; line-height: 1.1; }
.tuner-note small { font-size: 22px; color: var(--ink-3); font-weight: 500; }
.tuner-bar { position: relative; height: 46px; margin: 8px 20px; }
.tuner-bar .scaleline { position: absolute; top: 22px; left: 0; right: 0; height: 2px; background: var(--line-2); }
.tuner-bar .center { position: absolute; top: 8px; left: 50%; width: 2px; height: 30px; background: var(--ink-3); }
.tuner-bar .needle {
  position: absolute; top: 4px; left: 50%; width: 4px; height: 38px; border-radius: 2px;
  background: var(--red); transition: left .1s, background .2s; transform: translateX(-50%);
}
.tuner-bar .needle.good { background: var(--teal); }
.tuner-cents { font-family: var(--mono); color: var(--ink-2); font-size: 13px; }
.tuner-strings { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }

/* ---------- heatmap ---------- */
.heatmap { display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; margin: 10px 0; }
.heatmap i { aspect-ratio: 1; border-radius: 3px; background: var(--card-2); border: 1px solid var(--line); }
.heatmap i.l1 { background: #d8ebe2; }
.heatmap i.l2 { background: #94cbb4; }
.heatmap i.l3 { background: var(--teal); }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { background: var(--card-2); border-radius: var(--rad-s); padding: 12px 16px; }
.stat b { font-family: var(--serif); font-size: 26px; font-weight: 900; display: block; }
.stat span { font-size: 12.5px; color: var(--ink-2); }

/* ---------- voice bar & agent ---------- */
.voicebar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #efe9df; font-size: 13px;
  border-radius: 999px; padding: 8px 10px 8px 16px; box-shadow: var(--shadow);
}
.voicebar-dot { width: 9px; height: 9px; border-radius: 50%; background: #7a7264; }
.voicebar-dot.live { background: #4cc98f; animation: pulse 1.4s infinite; }
.voicebar-dot.talk { background: var(--red); animation: pulse .5s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.voicebar .chip { background: transparent; border-color: #57503f; color: #efe9df; }

.agent-drawer {
  position: fixed; right: 18px; bottom: 70px; width: 360px; max-width: calc(100vw - 36px);
  max-height: 64vh; display: flex; flex-direction: column; z-index: 70;
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--rad);
  box-shadow: 0 12px 40px -8px rgba(60, 40, 20, .35);
}
.agent-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-family: var(--serif); }
.agent-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.msg { max-width: 88%; padding: 8px 13px; border-radius: 12px; font-size: 14px; }
.msg.user { align-self: flex-end; background: var(--red-soft); border-bottom-right-radius: 3px; }
.msg.bot { align-self: flex-start; background: var(--card-2); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.act { align-self: center; font-size: 12px; color: var(--teal); background: var(--teal-soft); border-radius: 999px; padding: 2px 12px; }
.agent-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.agent-input input { flex: 1; min-width: 0; }

/* ---------- gesture hud ---------- */
.gesture-hud {
  position: fixed; left: 18px; bottom: 18px; z-index: 60; width: 150px;
  border-radius: var(--rad); overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--line-2); background: #000;
}
.gesture-hud video { width: 100%; display: block; transform: scaleX(-1); opacity: .9; }
.gesture-ring {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.5);
}
.gesture-ring.hold { border-color: var(--red); animation: ringfill .6s linear; }
@keyframes ringfill { from { transform: scale(.6); } to { transform: scale(1); } }
.gesture-label {
  position: absolute; bottom: 0; left: 0; right: 0; font-size: 11.5px; color: #fff;
  background: rgba(0,0,0,.55); padding: 3px 8px; text-align: center;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: #f5efe4; font-size: 14px;
  padding: 9px 20px; border-radius: 999px; box-shadow: var(--shadow);
  animation: rise .25s both;
}
.hidden { display: none !important; }

/* ---------- fretboard svg ---------- */
.fret-svg text { font-family: var(--sans); }
.fret-svg .fretnum { font-size: 11px; fill: var(--ink-3); }
.fret-svg .strname { font-size: 12px; fill: var(--ink-2); }

/* ---------- misc ---------- */
.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.center { text-align: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.backlink { display: inline-block; margin-bottom: 14px; font-size: 13.5px; color: var(--ink-2); text-decoration: none; cursor: pointer; }
.backlink:hover { color: var(--red); }
.kicker { font-size: 12px; letter-spacing: 2px; color: var(--red); font-weight: 700; text-transform: uppercase; }

/* ---------- 「为什么」深挖折叠块 ---------- */
details.why {
  margin: 14px 0; border: 1px dashed var(--line-2); border-radius: 10px;
  background: var(--card-2); transition: background .2s;
}
details.why[open] { background: var(--amber-soft); border-style: solid; }
details.why summary {
  cursor: pointer; padding: 10px 16px; font-weight: 600; color: var(--red-deep);
  list-style: none; user-select: none; font-size: 14.5px;
}
details.why summary::-webkit-details-marker { display: none; }
details.why summary::after { content: '展开 ▾'; float: right; font-size: 12px; color: var(--ink-3); font-weight: 400; }
details.why[open] summary::after { content: '收起 ▴'; }
details.why .why-body { padding: 0 16px 12px; font-size: 14px; line-height: 1.8; }

@media (max-width: 640px) {
  .apphead-in { flex-wrap: wrap; gap: 8px 14px; padding: 8px 14px; }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .head-chips { margin-left: auto; }
  .bigchord { font-size: 64px; }
  .page { padding: 18px 14px 140px; }
}
