/* 原琴翻谱网页版 - 全局样式（浅色 + 深色 body.dark） */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f7f6fb;
  --card: #ffffff;
  --text: #2b2b3a;
  --sub: #8a8aa0;
  --accent: #3d1e8e;
  --accent2: #5b5bd6;
  --ok: #3bb273;       /* 已匹配绿 */
  --bad: #e05252;      /* 漏音红 */
  --cursor: #f2c744;   /* 指针黄 */
  --line-other: #c9c9d8;
  --border: #e4e3f0;
}
body.dark {
  --bg: #14141c;
  --card: #1e1e2a;
  --text: #e8e8f2;
  --sub: #8a8aa5;
  --line-other: #3a3a4c;
  --border: #2c2c3e;
}
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden; overscroll-behavior: none;
}
#app { height: 100%; display: flex; flex-direction: column; }
#topbar {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--card); border-bottom: 1px solid var(--border);
  flex: none; position: relative; z-index: 20;
}
#topbar.hidden { display: none; }
.tb-btn {
  border: 0; background: none; color: var(--accent2); font-size: 26px;
  padding: 0 6px; cursor: pointer; line-height: 1;
}
#topTitle { flex: 1; font-size: 16px; font-weight: 600; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#topRight { display: flex; gap: 6px; align-items: center; }
#topRight .tb-btn { font-size: 14px; color: var(--accent2); }
#page { flex: 1; overflow-y: auto; position: relative; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border-radius: 12px; padding: 14px;
  margin: 10px 12px; border: 1px solid var(--border);
}
.btn {
  display: block; width: 100%; padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent2); color: #fff; font-size: 16px; cursor: pointer;
  text-align: center;
}
.btn.ghost { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); }
.btn.danger { background: #c0392b; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; margin: 10px 12px; }
.btn-row .btn { flex: 1; }
input, textarea, select {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px;
}
label.f { display: block; margin: 12px 4px 4px; font-size: 13px; color: var(--sub); }
.muted { color: var(--sub); font-size: 12px; }
.hidden { display: none !important; }

/* ---------- 弹窗 ---------- */
#modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#modal .box {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 420px;
  max-height: 86vh; overflow-y: auto; padding: 20px;
}
#modal h3 { margin-bottom: 10px; }
#modal .btns { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(30,30,40,.9); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 200; max-width: 80vw;
}

/* ---------- 首页 / 房间 ---------- */
.room-hero { text-align: center; padding: 26px 16px 6px; }
.room-code {
  font-size: 44px; font-weight: 800; letter-spacing: 8px; color: var(--accent);
  font-family: ui-monospace, monospace;
}
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-dot.off { background: var(--bad); }
.big-input {
  font-size: 22px; letter-spacing: 4px; text-align: center; text-transform: uppercase;
}

/* ---------- 曲谱列表 ---------- */
.sheet-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin: 8px 12px; display: flex; align-items: center; gap: 10px;
}
.sheet-item .nm { flex: 1; font-size: 15px; font-weight: 600; }
.sheet-item .meta { font-size: 12px; color: var(--sub); }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; flex: none;
  background: #ede9fb; color: var(--accent);
}
body.dark .badge { background: #2c2750; }
.tabs { display: flex; margin: 10px 12px 0; gap: 8px; }
.tabs .tab {
  flex: 1; text-align: center; padding: 8px; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--sub); font-size: 14px; cursor: pointer; border: 0;
}
.tabs .tab.on { background: var(--card); color: var(--accent); font-weight: 600; border: 1px solid var(--border); border-bottom: 0; }

/* ---------- 看谱（文本） ---------- */
#viewWrap { height: 100%; display: flex; flex-direction: column; }
#viewToolbar {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--card); border-bottom: 1px solid var(--border); font-size: 13px; color: var(--sub);
}
#viewToolbar .progress { flex: 1; }
#nextHint {
  flex: none; background: var(--accent); color: #fff; border-radius: 8px;
  padding: 4px 12px; font-size: 18px; font-weight: 800; letter-spacing: 1px;
  min-width: 52px; text-align: center;
}
#sheetScroll {
  flex: 1; overflow-y: auto; padding: 8px 4px;
  scroll-behavior: auto; touch-action: pan-y;
}
.line { padding: 2px 14px; line-height: 1.55; }
.line .t { color: var(--sub); font-size: 13px; }
.line .pos { white-space: pre-wrap; word-break: break-all; }
.line .n { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; }
.line .n.matched { color: var(--ok); }
.line .n.skipped { color: var(--bad); }
.line .n.cursor { color: var(--accent); background: var(--cursor); border-radius: 4px; padding: 0 2px; }
.line.other { color: var(--line-other); }
.line.other .t, .line.other .n { color: var(--line-other); }
.line.current { background: transparent; }
.line.current .n { font-size: 1.1em; }

/* ---------- 图片 / PDF ---------- */
#mediaScroll {
  flex: 1; overflow: hidden; position: relative; display: flex;
  align-items: center; justify-content: center; touch-action: pan-y;
}
#mediaScroll canvas, #mediaScroll img {
  max-width: 100%; max-height: 100%; object-fit: contain; display: block;
}
#pageNo { flex: none; text-align: center; padding: 6px; font-size: 13px; color: var(--sub); }
.rec-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--bad); color: #fff; font-size: 13px; flex: none;
}
.rec-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- 设置 ---------- */
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; border-bottom: 1px solid var(--border); font-size: 15px;
}
.set-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { display: none; }
.switch .sl {
  position: absolute; inset: 0; background: var(--border); border-radius: 14px;
  transition: .2s; cursor: pointer;
}
.switch .sl::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .sl { background: var(--accent2); }
.switch input:checked + .sl::after { left: 23px; }
