/* 从零弹琴：界面是黑白琴键的颜色，唯一的彩色是五根手指 */

:root {
  --ground: #EDF0F4;
  --surface: #FFFFFF;
  --surface-2: #F4F6F9;
  --ink: #1A2130;
  --ink-2: #465063;
  --muted: #687184;
  --line: #D9DFE8;
  --line-strong: #B6BFCD;
  --lacquer: #141925;
  --lacquer-2: #1F2636;
  --ivory: #FBFAF6;
  --felt: #8E1B2B;
  --accent: #2F9FD4;
  --accent-ink: #1B6E98;
  --good: #1F9D5C;
  --bad: #D93B34;
  --star: #E0A800;
  --fig-ink: #3B4458;
  --fig-piano: #2A3140;
  --fig-key: #FBFAF6;
  --fig-bench: #9AA3B2;
  --hand-fill: #F2F4F7;
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", "Times New Roman", serif;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0E1219;
    --surface: #161B26;
    --surface-2: #1B2130;
    --ink: #E6EAF1;
    --ink-2: #B5BECD;
    --muted: #8C96A8;
    --line: #283043;
    --line-strong: #3B4558;
    --lacquer: #0A0D14;
    --lacquer-2: #151B27;
    --accent: #4DB2E3;
    --accent-ink: #86CDF0;
    --good: #35BE78;
    --bad: #F0605A;
    --fig-ink: #C3CBD8;
    --fig-piano: #3A4256;
    --fig-bench: #6C7689;
    --hand-fill: #232A39;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0E1219; --surface: #161B26; --surface-2: #1B2130; --ink: #E6EAF1; --ink-2: #B5BECD; --muted: #8C96A8;
  --line: #283043; --line-strong: #3B4558; --lacquer: #0A0D14; --lacquer-2: #151B27; --accent: #4DB2E3; --accent-ink: #86CDF0;
  --good: #35BE78; --bad: #F0605A; --fig-ink: #C3CBD8; --fig-piano: #3A4256; --fig-bench: #6C7689; --hand-fill: #232A39;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.75 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0 0 0.8em; }
button { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
img, svg { max-width: 100%; }

#app { max-width: 1120px; margin: 0 auto; padding: 0 16px 64px; }

/* ---------- 顶栏 ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.04em; }
.logo { width: 34px; height: 24px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px; font-size: 0.95rem;
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a.on { background: var(--ink); color: var(--surface); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.nav-dot.ok { background: var(--good); }

/* ---------- 通用 ---------- */
.page { padding-top: 8px; }
.page > h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: 18px 0 8px; font-weight: 800; }
.lead { font-size: 1.06rem; max-width: 38em; }
.lead.dark { color: var(--ink-2); }
.muted { color: var(--muted); }
.tip { color: var(--ink-2); border-left: 3px solid var(--line-strong); padding: 2px 0 2px 12px; font-size: 0.95rem; }
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.92rem; margin: 6px 0; }
.back::before { content: "‹ "; }
.back:hover { color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.3;
  transition: background-color 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.primary:hover { background: var(--ink-2); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; border-radius: 8px; }
.btn.big { padding: 14px 24px; font-size: 1.05rem; border-radius: 12px; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }
.link { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:hover { color: var(--ink); }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.stars { display: inline-flex; gap: 4px; font-size: 2rem; line-height: 1; }
.stars span { color: var(--line-strong); }
.stars span.on { color: var(--star); }
.stars.small { font-size: 1rem; gap: 1px; }

/* ---------- 键盘 ---------- */
.kb {
  position: relative; width: 100%;
  aspect-ratio: calc(var(--whites) / 4.7);
  min-height: 96px; max-height: 210px;
  user-select: none; -webkit-user-select: none; touch-action: none;
  border-top: 4px solid var(--felt);
}
.kb-key { position: absolute; top: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: pointer; }
.kb-key.white {
  height: 100%; z-index: 1;
  background: linear-gradient(180deg, #F3F2EE 0%, var(--ivory) 12%, var(--ivory) 88%, #E9E7E0 100%);
  border: 1px solid #A9AFBA; border-top: 0; border-radius: 0 0 6px 6px;
  box-shadow: inset 0 -5px 0 rgba(20, 25, 37, 0.07);
}
.kb-key.black {
  height: 62%; z-index: 2;
  background: linear-gradient(180deg, #11151D 0%, #2B3140 88%, #1A1F2A 100%);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.45), inset 0 -5px 0 rgba(255, 255, 255, 0.07);
}
.kb-key.white.down { background: linear-gradient(180deg, #E1E4EA, #E9EBEF); box-shadow: inset 0 -2px 0 rgba(20, 25, 37, 0.08); }
.kb-key.black.down { background: linear-gradient(180deg, #2C3444, #3D4659); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.kb-key::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--mark, transparent); opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.kb-key.marked::before { opacity: 0.62; }
.kb-key.black.marked::before { opacity: 0.9; }
.kb-key.hinted::before { opacity: 0.4; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.15; } }
.kb-key::after { content: ""; position: absolute; inset: 0; border-radius: inherit; opacity: 0; pointer-events: none; }
.kb-key.good::after { background: var(--good); animation: flash 0.45s ease-out; }
.kb-key.bad::after { background: var(--bad); animation: flash 0.45s ease-out; }
@keyframes flash { 0% { opacity: 0.75; } 100% { opacity: 0; } }
.kb-label { position: relative; font-size: clamp(9px, 1.15vw, 13px); color: #5B6373; margin-bottom: 6px; font-family: var(--num); white-space: nowrap; }
.kb-key.marked .kb-label { color: #1A2130; font-weight: 700; }
.kb-key.middle-c .kb-label { color: var(--accent-ink); font-weight: 700; }
.kb-finger {
  position: relative; display: none; place-items: center;
  width: min(1.7em, 86%); aspect-ratio: 1; border-radius: 50%;
  background: #fff; color: #1A2130; font-weight: 800; font-size: clamp(10px, 1.3vw, 14px);
  margin-bottom: 5px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.kb-finger.on { display: grid; }
.kb-key.black .kb-finger { margin-bottom: 6px; }
.kb-groups .kb-key.black.grp2 { background: linear-gradient(180deg, #16354A, #22607F); }
.kb-groups .kb-key.black.grp3 { background: linear-gradient(180deg, #2D2150, #54409A); }

.kb-frame { background: var(--lacquer); border-radius: 14px; padding: 16px 12px 12px; margin: 16px 0; }

/* ---------- 首页 ---------- */
.hero {
  background:
    radial-gradient(120% 90% at 85% -10%, rgba(47, 159, 212, 0.16), transparent 60%),
    linear-gradient(180deg, var(--lacquer-2), var(--lacquer));
  color: var(--ivory);
  border-radius: 24px;
  padding: clamp(28px, 6vw, 64px) clamp(18px, 4.5vw, 52px) 0;
  overflow: hidden;
}
.hero h1 { font-size: clamp(2.1rem, 5.6vw, 3.7rem); font-weight: 800; line-height: 1.18; max-width: 13em; letter-spacing: 0.01em; }
.hero .lead { color: #C3CAD7; margin: 18px 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn.primary { background: var(--ivory); color: #141925; }
.hero .btn.primary:hover { background: #fff; }
.btn.on-dark { border-color: rgba(255, 255, 255, 0.34); color: var(--ivory); }
.btn.on-dark:hover { background: rgba(255, 255, 255, 0.08); }
.hero-kb { margin-top: clamp(30px, 5vw, 52px); }
.hero-say { color: #C3CAD7; padding: 16px 2px 20px; margin: 0; min-height: 3.6em; display: flex; align-items: center; gap: 14px; }
.say-note { font-family: var(--num); font-size: 2rem; line-height: 1; color: #fff; min-width: 1.4em; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 44px 0 14px; }
.section-head h2, .method h2 { font-size: 1.5rem; font-weight: 800; }
.progress-line { color: var(--muted); margin: 0; }

.chapter { display: grid; grid-template-columns: 11rem 1fr; gap: 8px 28px; padding: 22px 0; border-top: 1px solid var(--line); }
.chapter-head { display: flex; flex-direction: column; gap: 2px; }
.chapter-day { font-family: var(--num); font-size: 1.05rem; color: var(--muted); }
.chapter-head h3 { font-size: 1.15rem; font-weight: 700; }
.chapter-min { font-size: 0.88rem; color: var(--muted); }
.lesson-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.lesson-list li + li { border-top: 1px solid var(--line); }
.lesson-row { display: grid; grid-template-columns: 3.2rem 1fr auto; align-items: center; gap: 10px; padding: 13px 16px; text-decoration: none; }
.lesson-row:hover { background: var(--surface-2); }
.lesson-no { font-family: var(--num); color: var(--muted); }
.lesson-title { font-weight: 600; }
.lesson-meta { font-size: 0.88rem; color: var(--muted); }
.lesson-row.done .lesson-meta { color: var(--good); }
.lesson-row.done .lesson-title { color: var(--ink-2); font-weight: 500; }
.lesson-row.next { box-shadow: inset 4px 0 0 var(--ink); }
.lesson-row.next .lesson-meta { color: var(--ink); font-weight: 700; }

.method { margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--line); }
.method dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px 28px; margin: 16px 0 0; }
.method dt { font-weight: 700; }
.method dd { margin: 4px 0 0; color: var(--ink-2); }

/* ---------- 课程页 ---------- */
.lesson { max-width: 880px; margin: 0 auto; }
.lesson-head { padding: 6px 0 4px; }
.lesson-kicker { color: var(--muted); margin: 8px 0 2px; font-size: 0.95rem; }
.lesson-head h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 800; }
.step-dots { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0 26px; }
.step-dots li { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.step-dots li.past { background: var(--ink-2); }
.step-dots li.on { background: var(--accent); }
.step-body h2 { font-size: 1.45rem; font-weight: 800; margin-bottom: 14px; }
.prose { max-width: 40em; }
.prose ul { padding-left: 1.2em; margin: 0 0 0.9em; }
.prose li { margin: 0.35em 0; }
.prose .big { font-size: 1.15rem; font-weight: 700; font-family: var(--num), var(--font); }
.prose .jp, td.jp { font-family: var(--num); font-size: 1.2rem; letter-spacing: 0.08em; }
table.names, table.beats { border-collapse: collapse; margin: 6px 0 16px; font-family: var(--num), var(--font); }
table.names th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 14px 6px 0; font-family: var(--font); }
table.names td { padding: 6px 10px; text-align: center; border-bottom: 1px solid var(--line); font-size: 1.08rem; }
table.beats td { padding: 6px 22px 6px 0; }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 18px; display: grid; gap: 12px; justify-items: center; }
.fig { width: 100%; max-width: 520px; height: auto; }
.fig.legend { max-width: 460px; }
.fig-label { font-size: 15px; fill: var(--ink-2); font-family: var(--font); }
.fig-label.small { font-size: 13px; }
.fig-num { font-size: 14px; font-weight: 800; fill: #fff; font-family: system-ui, sans-serif; }
.hand-shape { fill: var(--hand-fill); stroke: var(--fig-ink); stroke-width: 2; }
.step-body.celebrate h2::before { content: ""; display: block; width: 56px; height: 8px; border-radius: 4px; margin-bottom: 18px;
  background: linear-gradient(90deg, #E8743B 0 20%, #E0A800 20% 40%, #2F9FD4 40% 60%, #7C5CC4 60% 80%, #D6457A 80%); }

.q { font-size: 1.15rem; font-weight: 600; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.choice { min-width: 64px; padding: 12px 20px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1.05rem; }
.choice:hover:not(:disabled) { border-color: var(--ink-2); }
.choice.right { background: var(--good); border-color: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); color: var(--bad); opacity: 0.6; }
.feedback { min-height: 1.75em; font-weight: 600; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.find-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 6px; }
.find-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.find-prompt { font-size: 1.3rem; font-weight: 700; margin: 0; }
.find-big { font-family: var(--num); font-size: 2.2rem; }
.find-sub { color: var(--muted); margin: 2px 0 0; }
.find-prog { display: flex; gap: 6px; padding-top: 10px; flex-wrap: wrap; justify-content: flex-end; max-width: 50%; }
.find-prog i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-strong); }
.find-prog i.on { background: var(--good); border-color: var(--good); }
.find-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }

.lesson-nav {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  margin-top: 26px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--ground); border-top: 1px solid var(--line);
}
.lesson-nav .grow { flex: 1; }
.skip { font-size: 0.9rem; }

/* ---------- 练习器 ---------- */
.practice { display: grid; gap: 12px; margin-top: 8px; }
.pr-bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.seg-btn { border: 0; background: none; padding: 6px 16px; border-radius: 999px; color: var(--ink-2); cursor: pointer; font-weight: 600; }
.seg-btn.on { background: var(--ink); color: var(--surface); }
.tempo { display: inline-flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--ink-2); }
.tempo input { width: 130px; accent-color: var(--ink); }
.tempo-out { font-variant-numeric: tabular-nums; color: var(--muted); }
.pr-mode-hint { color: var(--muted); margin: -4px 0 0; font-size: 0.93rem; }

.pr-sheet-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; }
.pr-sheet { max-height: 250px; overflow-y: auto; }
.practice.compact .pr-sheet { max-height: 180px; }
.pr-range { display: flex; gap: 12px; align-items: center; padding: 4px 8px 6px; font-size: 0.9rem; color: var(--accent-ink); font-weight: 600; }

.sheet { --beat-w: 30px; }
.sheet-line { display: flex; gap: 6px; align-items: stretch; padding: 4px 4px; border-radius: 8px; }
.sheet-line[role="button"] { cursor: pointer; }
.sheet-line[role="button"]:hover { background: var(--surface-2); }
.sheet-line.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sheet-no { flex: none; width: 1.5em; font-size: 0.75rem; color: var(--muted); padding-top: 26px; text-align: center; font-family: var(--num); }
.sheet-bars { flex: 1; display: flex; overflow-x: auto; scrollbar-width: thin; }
.sheet-bar { position: relative; flex-basis: 0; border-right: 1.5px solid var(--ink-2); padding: 0 6px; display: flex; flex-direction: column; }
.sheet-bar:last-child { border-right-width: 3px; }
.sheet-lane { position: relative; height: 76px; }
.sheet-lane.hand-L { height: 58px; border-top: 1px dashed var(--line); }
.sheet-lane.hand-L .jp-lyric { display: none; }
.jp-ev {
  position: absolute; top: 0; bottom: 0;
  display: grid; grid-template-rows: 20px auto 1fr; justify-items: center; align-items: start;
  border-radius: 6px; transition: background-color 0.15s;
}
.jp-fingers { display: flex; gap: 1px; height: 20px; align-items: center; }
.jp-f { width: 16px; height: 16px; border-radius: 50%; background: var(--fc); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; line-height: 1; }
.jp-mid { display: flex; flex-direction: column; align-items: center; }
.jp-stack { display: flex; flex-direction: column; align-items: center; position: relative; font-family: var(--num); font-size: 1.28rem; line-height: 1.05; font-weight: 600; }
.sheet-lane.hand-L .jp-stack { font-size: 1.05rem; }
.is-chord .jp-stack { font-size: 0.95rem; line-height: 1; }
.jp-n { position: relative; display: block; padding: 5px 1px 1px; }
.jp-n.rest { color: var(--muted); font-weight: 400; }
.jp-acc { font-size: 0.6em; position: relative; top: -0.2em; margin-right: 1px; }
.jp-dot-up { position: absolute; top: -3px; left: 50%; transform: translateX(-50%); font-size: 8px; letter-spacing: -2px; line-height: 1; }
.jp-dot-down { display: block; font-size: 7px; line-height: 0.8; text-align: center; letter-spacing: -2px; }
.jp-aug { position: absolute; right: -0.45em; top: 45%; }
.jp-under { display: flex; flex-direction: column; gap: 2px; align-items: center; width: 100%; margin-top: 1px; }
.jp-under i { display: block; height: 1.5px; width: 1.1em; background: currentColor; }
.jp-dot-low { font-size: 8px; line-height: 1; letter-spacing: -2px; margin-top: 1px; }
.jp-lyric { font-size: 0.82rem; color: var(--muted); align-self: end; padding-bottom: 2px; }
.jp-dash { position: absolute; top: 24px; text-align: center; font-family: var(--num); font-size: 1.1rem; color: var(--ink-2); }
.sheet-lane.hand-L .jp-dash { top: 22px; }
.jp-ev.now { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.jp-ev.now .jp-stack { color: var(--accent-ink); }
.jp-ev.done .jp-stack, .jp-ev.hit .jp-stack { color: var(--good); }
.jp-ev.miss .jp-stack { color: var(--bad); }
.jp-ev.off { opacity: 0.28; }

.pr-stage { background: var(--lacquer); border-radius: 16px; padding: 0 10px 10px; overflow: hidden; }
.pr-roll-wrap { position: relative; height: clamp(180px, 36vh, 360px); margin: 0 -10px; }
.practice.compact .pr-roll-wrap { height: clamp(150px, 28vh, 270px); }
.pr-roll { display: block; width: 100%; height: 100%; }
.pr-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(8, 11, 18, 0.55); z-index: 3; }
.ov-card { background: var(--surface); color: var(--ink); border-radius: 14px; padding: 20px 22px; max-width: 440px; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.ov-card p { margin: 6px 0; }
.ov-title { font-size: 1.2rem; font-weight: 800; }
.ov-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.ov-card > .btn { margin-top: 12px; }
.pr-count { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--num); font-size: clamp(3rem, 12vw, 6rem); color: rgba(255, 255, 255, 0.85); pointer-events: none; z-index: 2; }

.pr-foot { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: flex-start; justify-content: space-between; }
.pr-foot-main { flex: 1 1 320px; }
.pr-status { font-size: 1.08rem; font-weight: 700; min-height: 1.75em; }
.pr-prog { color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.pr-foot-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 1 1 260px; }
.pr-heard { font-size: 0.88rem; color: var(--muted); min-height: 1.5em; font-family: var(--num), var(--font); }

/* ---------- 输入面板 ---------- */
.inp { display: grid; gap: 6px; }
.inp-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inp.compact .inp-row { justify-content: flex-end; }
.inp-lead { color: var(--ink-2); font-size: 0.92rem; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.9rem; }
.chip.ok { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
.dot.live { animation: live 1.6s ease-in-out infinite; }
@keyframes live { 50% { opacity: 0.35; } }
.meter { width: 56px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; display: inline-block; }
.meter > span { display: block; height: 100%; width: 0; background: var(--good); transition: width 0.06s linear; }
.meter-note { font-family: var(--num); min-width: 2.2em; }
.inp-note { font-size: 0.9rem; color: var(--ink-2); margin: 0; }
.inp-note.warn { color: var(--bad); }

/* ---------- 曲库 ---------- */
.song-group { margin-top: 32px; }
.song-group h2 { font-size: 1.25rem; font-weight: 800; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 10px; }
.song-group h2 .muted { font-size: 0.95rem; font-weight: 400; }
.song-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.song-list li + li { border-top: 1px solid var(--line); }
.song-row { display: grid; grid-template-columns: minmax(9rem, 1.3fr) minmax(120px, 1fr) auto auto; gap: 16px; align-items: center; padding: 14px 18px; text-decoration: none; }
.song-row:hover { background: var(--surface-2); }
.song-title { font-weight: 700; display: flex; flex-direction: column; line-height: 1.4; }
.song-title small { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.song-meta { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.mini-range { width: 100%; max-width: 220px; height: 22px; }
.mr-w { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 0.4; }
.mr-b { fill: var(--ink-2); }
.mr-on { fill: var(--accent); }
.song-head { margin: 4px 0 10px; }
.song-head h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 800; }

/* ---------- 连接乐器 ---------- */
.setup { max-width: 880px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-top: 18px; }
.card h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 10px; }
.steps, .tips { padding-left: 1.3em; margin: 0 0 12px; }
.steps li, .tips li { margin: 4px 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.check input { margin-top: 0.45em; width: 18px; height: 18px; accent-color: var(--ink); }
.check small { display: block; color: var(--muted); font-size: 0.86rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.tuner { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; align-items: center; margin: 16px 0 6px; padding: 14px 16px; background: var(--surface-2); border-radius: 10px; }
.tuner-note { font-family: var(--num); font-size: 2.4rem; line-height: 1; min-width: 2.2em; }
.tuner-scale { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--muted); }
.tuner-track { position: relative; flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.tuner-track::after { content: ""; position: absolute; left: 50%; top: -5px; width: 2px; height: 16px; background: var(--ink-2); transform: translateX(-50%); }
.tuner-needle { position: absolute; left: 50%; top: -8px; width: 6px; height: 22px; border-radius: 3px; background: var(--bad); transform: translateX(-50%); transition: left 0.08s linear; }
.tuner-needle.ok { background: var(--good); }
.tuner-text { grid-column: 1 / -1; margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.keymap { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0; }
.keymap span { display: inline-flex; gap: 6px; align-items: center; font-family: var(--num); }
kbd { font-family: var(--font); background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 3px; border-radius: 6px; padding: 1px 8px; font-size: 0.9rem; }
.radios { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.radios label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.radios input { accent-color: var(--ink); }
.slider { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.slider input { width: 200px; accent-color: var(--ink); }
.reset { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.reset span { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 窄屏 ---------- */
@media (max-width: 720px) {
  .chapter { grid-template-columns: 1fr; }
  .chapter-head { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
  .song-row { grid-template-columns: 1fr auto; }
  .song-row .mini-range { grid-column: 1 / -1; grid-row: 2; max-width: 100%; }
  .song-row .song-meta { grid-column: 1; grid-row: 3; }
  .song-row .stars { grid-column: 2; grid-row: 1; }
  .pr-foot-side { align-items: flex-start; }
  .inp.compact .inp-row { justify-content: flex-start; }
  .find-head { flex-direction: column; }
  .find-prog { max-width: 100%; justify-content: flex-start; padding-top: 0; }
  .tempo input { width: 100px; }
  .sheet { --beat-w: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- 账号 ---------- */
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acct { display: flex; align-items: center; min-height: 34px; }
.acct-in { display: inline-flex; align-items: center; gap: 10px; font-size: 0.92rem; }
.acct-name { font-weight: 700; text-decoration: none; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: 1px; }
.sync-hint { margin-left: 12px; font-size: 0.9rem; color: var(--accent-ink); }

.auth { display: grid; place-items: start center; padding-top: 24px; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 26px 24px; }
.auth-card h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.auth-form { display: grid; gap: 14px; margin-top: 16px; }
.auth-form .btn { width: 100%; }
.auth-switch { margin: 14px 0 6px; }
.field { display: grid; gap: 4px; align-content: start; }
.field > span { font-weight: 600; font-size: 0.95rem; }
.input {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px;
}
.input:focus { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; }
textarea.input { resize: vertical; line-height: 1.6; min-height: 5.5em; }
.small { font-size: 0.86rem; }

/* ---------- 曲库 ---------- */
.lib-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lib-head h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: 18px 0 8px; font-weight: 800; }
.lib-head .btn { margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 4px; overflow-x: auto; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 600; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs a:hover { color: var(--ink); }
.lib-tools { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 22px 0 14px; }
.lib-tools .input { max-width: 320px; }
.lib-body > .song-list { margin-bottom: 12px; }
.empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 22px; text-align: center; margin: 12px 0; }
.empty p { color: var(--ink-2); }
.badge { display: inline-block; font-size: 0.8rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); margin-right: 8px; }
.badge.on { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); color: var(--good); }
.favs { margin-left: 8px; color: var(--bad); }
.song-actions { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin: 0 0 12px; }

/* ---------- 编辑器 ---------- */
.editor { max-width: 920px; margin: 0 auto; }
.editor > h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 10px 0 6px; font-weight: 800; }
.ed-form { display: grid; gap: 18px; margin-top: 18px; }
.ed-grid { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr; gap: 12px 16px; }
.ed-part, .ed-left { display: grid; gap: 12px; }
.ed-left, .ed-help { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.ed-left[open] { padding-bottom: 16px; }
.ed-left summary, .ed-help summary { cursor: pointer; font-weight: 700; }
.ed-left[open] summary { margin-bottom: 8px; }
.ed-finger-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.help-table { border-collapse: collapse; margin: 10px 0; }
.help-table td { padding: 5px 16px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.help-table td.mono { white-space: nowrap; color: var(--accent-ink); }
.ed-h2 { font-size: 1.2rem; font-weight: 800; }
.ed-rec { display: grid; gap: 10px; }
.ed-rec-bar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.ed-rec-opts { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.ed-rec .kb-frame { margin: 0; }
.check.inline { margin: 0; align-items: center; }
.check.inline input { margin-top: 0; }
.ed-preview { display: grid; gap: 8px; }
.ed-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ed-status { margin: 0; font-weight: 600; }
.ed-status.ok { color: var(--good); }
.ed-status.bad { color: var(--bad); }
.ed-sheet .pr-sheet, .ed-sheet .sheet { max-height: none; }

@media (max-width: 720px) {
  .ed-grid { grid-template-columns: 1fr 1fr; }
  .ed-grid > :nth-child(-n+2) { grid-column: 1 / -1; }
  .ed-finger-row { grid-template-columns: 1fr; }
  .top-right { width: 100%; justify-content: space-between; }
}
