:root {
  --bg: #16161c; --card: #22222b; --raised: #2c2c37; --line: #383844;
  --text: #f1efe9; --dim: #a3a3b0;
  --mel: #ffd27a; --acc: #7ab8ff; --blue: #4f74e3; --red: #e0564a; --green: #8fd68f;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: contain;
}
#app { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); min-height: 100%; }
#app.wide { max-width: none; padding: 0; height: 100%; }
h1 { font-size: 22px; margin: 0; line-height: 1.3; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--dim); font-weight: 600; letter-spacing: .02em; }
p { margin: 6px 0; }
a { color: var(--acc); }
.dim { color: var(--dim); }
.small { font-size: 14px; }
.center { text-align: center; }
.err { color: #ff9a8c; }
.ok { color: var(--green); }
.gold { color: var(--mel); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-height: 44px; }
.topbar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.banner { border-radius: 12px; padding: 10px 14px; font-size: 15px; background: var(--card); border: 1px solid var(--line); }
.banner.warn { border-color: #6b4a2a; background: #2b241c; color: #ffcf9c; }
.banner.good { border-color: #2f5a36; background: #1c2a1f; color: var(--green); }

button, .btn {
  font: inherit; min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--raised); color: var(--text); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; touch-action: manipulation;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; transform: none; }
button.primary { background: var(--blue); border-color: var(--blue); font-weight: 600; }
button.danger { color: #ff9a8c; border-color: #5c2f2a; background: transparent; }
button.ghost { background: transparent; }
button.link { background: none; border: none; color: var(--acc); padding: 8px; min-height: 44px; }
button.big { min-height: 56px; font-size: 18px; padding: 12px 28px; }
button.block { width: 100%; }
:focus-visible { outline: 2px solid var(--mel); outline-offset: 2px; }

label { display: block; font-size: 14px; color: var(--dim); margin-bottom: 4px; }
input[type=text], textarea {
  width: 100%; font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #1b1b22; color: var(--text);
}
textarea { resize: vertical; min-height: 48px; }
.field + .field { margin-top: 14px; }

.fab {
  position: fixed; right: max(16px, calc(50vw - 344px)); bottom: calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
}

/* 曲库 */
.piece-list { list-style: none; margin: 0; padding: 0; }
.piece-list li + li { margin-top: 10px; }
.piece { background: var(--card); border-radius: var(--radius); display: flex; align-items: stretch; overflow: hidden; }
.piece-main {
  flex: 1; min-width: 0; text-align: left; padding: 14px 16px; background: none; border: none; border-radius: 0;
  display: block; min-height: 72px;
}
.piece-title { font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piece-score { font-size: 26px; font-weight: 700; color: var(--mel); padding: 0 6px; align-self: center; font-variant-numeric: tabular-nums; }
.piece-actions { display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--line); }
.piece-actions button { border: none; border-radius: 0; background: none; color: var(--dim); font-size: 14px; min-height: 44px; padding: 4px 14px; }
.empty { text-align: center; padding: 48px 16px; color: var(--dim); }

.file-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.file-row:first-child { border-top: none; }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.login { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.login img { width: 96px; height: 96px; border-radius: 22px; }

/* 弹奏屏幕 */
.play { height: 100dvh; display: flex; flex-direction: column; padding: 8px max(12px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); }
.play-top { margin-bottom: 4px; }
.play-body { flex: 1; min-height: 0; display: flex; }
.play-center { margin: auto; text-align: center; max-width: 440px; padding: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; min-width: 96px; }
.seg button[aria-pressed=true] { background: var(--mel); color: #1b1b22; font-weight: 700; }
.live { flex: 1; min-width: 0; display: flex; gap: 12px; }
.live-left { width: 30%; min-width: 120px; max-width: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.live-mark { font: italic 700 clamp(64px, 18vw, 132px)/1 Georgia, "Times New Roman", serif; color: var(--mel); min-height: 1em; }
.live-meter { width: 100%; height: 14px; background: #101014; border-radius: 7px; overflow: hidden; }
.live-meter div { height: 100%; width: 0; background: linear-gradient(90deg, #6bb86b, #e0b030, #d9483a); transition: width .12s linear; }
.live-clock { font-variant-numeric: tabular-nums; }
.live-right { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.live-canvas { flex: 1; min-height: 0; width: 100%; background: #101014; border-radius: 12px; }
.live-legend { display: flex; align-items: center; gap: 12px; }
@media (orientation: portrait) {
  .live { flex-direction: column; }
  .live-left { width: 100%; max-width: none; flex-direction: row; justify-content: flex-start; }
  .live-left .live-meter { flex: 1; }
  .live-mark { font-size: 72px; min-width: 110px; text-align: center; }
}

/* 点评屏幕 */
.whole-canvas { width: 100%; height: 150px; display: block; background: #101014; border-radius: 10px; }
.score { display: flex; gap: 18px; align-items: center; }
.score-total { text-align: center; min-width: 96px; }
.score-num { font-size: 60px; font-weight: 800; line-height: 1; color: var(--mel); font-variant-numeric: tabular-nums; }
.score-stars { flex: 1; min-width: 0; }
.score-stars .row { padding: 2px 0; }
.score-stars .gold { letter-spacing: 2px; white-space: nowrap; }
.previous { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.item-n { width: 30px; height: 30px; border-radius: 50%; background: var(--mel); color: #1b1b22; font-weight: 800; display: grid; place-items: center; flex: none; }
.item-title { font-size: 18px; font-weight: 700; }
.item p { margin: 10px 0 0; }
.item-label { display: inline-block; font-size: 13px; color: var(--dim); border: 1px solid var(--line); border-radius: 8px; padding: 0 7px; margin-right: 8px; }
svg.mini { width: 100%; height: 72px; margin-top: 12px; background: #1b1b22; border-radius: 8px; display: block; }
button.gold-btn { border-color: var(--mel); color: var(--mel); }
button[data-playing] { background: var(--red); border-color: var(--red); color: #fff; }
.one-thing { border: 1px solid var(--mel); background: #2b2618; }
.one-thing h2 { color: var(--mel); }
.one-thing p { font-size: 19px; font-weight: 600; line-height: 1.5; }
.chat-log { display: flex; flex-direction: column; gap: 8px; }
.chat-log:empty { display: none; }
.bubble { max-width: 86%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.child { align-self: flex-end; background: var(--blue); border-bottom-right-radius: 4px; }
.bubble.teacher { align-self: flex-start; background: var(--raised); border-bottom-left-radius: 4px; }

/* 练习记录、对比 */
svg.chart { width: 100%; height: auto; display: block; }
.star-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.practice-list { list-style: none; margin: 0; padding: 0; }
.practice { display: flex; align-items: stretch; background: var(--card); border-radius: 12px; }
.practice + .practice { margin-top: 8px; }
.pick { display: grid; place-items: center; width: 48px; margin: 0; cursor: pointer; }
.pick input { width: 22px; height: 22px; accent-color: var(--mel); }
.practice-main { flex: 1; min-width: 0; text-align: left; display: block; background: none; border: none; border-radius: 0; padding: 10px 4px; min-height: 60px; }
.row-score { font-size: 22px; font-weight: 800; color: var(--mel); font-variant-numeric: tabular-nums; }
.tag { font-size: 13px; color: var(--dim); border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.one-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-playing { outline: 2px solid var(--mel); }
.card .whole-canvas { margin-top: 10px; }

/* 分享给老师的页面 */
.shared-score { display: block; width: 100%; height: auto; border-radius: 8px; background: #fff; }
