/* 歌颂上主 —— 长辈友好：大字、大按钮、高对比 */
:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #5b5b5b;
  --line: #dcd8cf;
  --primary: #1e3a8a;
  --primary-text: #ffffff;
  --accent: #b45309;
  --accent-soft: #fff1dc;
  --num-bg: #e8edf8;
  --num-text: #1e3a8a;
  --danger: #b91c1c;
  --tab-h: 74px;
  --mini-h: 72px;
  --radius: 16px;
  --fs: 20px;
}
html.font-large { --fs: 23px; }
html.font-xl    { --fs: 27px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --card: #172033; --text: #f3f4f6; --muted: #b8bfcc;
    --line: #2b3648; --primary: #3b82f6; --primary-text: #ffffff;
    --accent: #f59e0b; --accent-soft: #3a2a10; --num-bg: #1f2a44; --num-text: #93c5fd;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --card: #172033; --text: #f3f4f6; --muted: #b8bfcc;
  --line: #2b3648; --primary: #3b82f6; --primary-text: #ffffff;
  --accent: #f59e0b; --accent-soft: #3a2a10; --num-bg: #1f2a44; --num-text: #93c5fd;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: var(--fs); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  line-height: 1.45; overscroll-behavior-y: none;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }

/* 顶栏 */
.top {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 60px; padding: env(safe-area-inset-top) 8px 0;
  background: var(--primary); color: var(--primary-text);
}
.top-title { margin: 0; font-size: 1.15rem; font-weight: 700; grid-column: 2; text-align: center; white-space: nowrap; }
.top-back { grid-column: 1; justify-self: start; font-size: 1.05rem; padding: 12px 10px; min-height: 52px; }
.top-font { grid-column: 3; justify-self: end; min-width: 56px; min-height: 52px; font-weight: 700; font-size: 0.95rem; }
.top-font span { font-size: 1.3rem; }

.view { padding: 14px 16px 24px; max-width: 720px; margin: 0 auto; }
.section-title { font-size: 0.9rem; color: var(--muted); margin: 18px 4px 8px; font-weight: 600; }

/* 搜索框 */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 4px 6px 4px 14px;
}
.search input {
  flex: 1; min-width: 0; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 1.05rem; min-height: 52px; outline: none;
}
.search button { min-width: 52px; min-height: 52px; font-size: 1.2rem; border-radius: 12px; }
.search button:active { background: var(--num-bg); }

/* 数字键盘 */
.dial-display {
  margin: 14px 0 8px; padding: 12px 16px; min-height: 84px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  display: flex; align-items: center; gap: 14px;
}
.dial-num { font-size: 2.2rem; font-weight: 800; color: var(--num-text); min-width: 2.2em; letter-spacing: 2px; }
.dial-hint { flex: 1; min-width: 0; font-size: 1.05rem; color: var(--muted); }
.dial-hint.hit { color: var(--text); font-weight: 600; }
.dial-hint .cat { display: block; font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.dial { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dial button {
  min-height: 68px; font-size: 1.7rem; font-weight: 700;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
}
.dial button:active { background: var(--num-bg); }
.dial .del { font-size: 1.3rem; color: var(--danger); }
.dial .go { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-size: 1.3rem; }
.dial .go:active { filter: brightness(1.15); }
.dial .go[disabled] { opacity: .45; }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 70px; padding: 8px 12px 8px 8px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
}
.row:active { background: var(--num-bg); }
.row .num {
  flex: 0 0 auto; min-width: 3.2em; height: 52px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--num-bg); color: var(--num-text); font-weight: 800; font-size: 1.15rem; border-radius: 12px;
}
.row .txt { flex: 1; min-width: 0; }
.row .title { display: block; font-size: 1.1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { display: block; font-size: 0.8rem; color: var(--muted); }
.row .play { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: var(--primary-text); font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }
.row .play.noaudio { background: var(--line); color: var(--muted); }
.row.playing { border-color: var(--primary); }
.row.playing .title { color: var(--primary); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 1rem; }

/* 分类卡 */
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-card {
  min-height: 84px; padding: 12px 14px; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.cat-card:active { background: var(--num-bg); }
.cat-card .name { font-size: 1.1rem; font-weight: 700; }
.cat-card .count { font-size: 0.85rem; color: var(--muted); }
.big-btn {
  width: 100%; min-height: 64px; margin-top: 8px; font-size: 1.1rem; font-weight: 700;
  background: var(--primary); color: var(--primary-text); border-radius: var(--radius);
}
.big-btn.secondary { background: var(--card); color: var(--text); border: 2px solid var(--line); }

/* 歌曲页 */
/* 歌曲页标题：一行搞定，把地方留给歌谱和歌词 */
.song-head { display: flex; align-items: center; gap: 8px; padding: 2px 0 8px; min-width: 0; }
.song-head .num { flex: 0 0 auto; background: var(--num-bg); color: var(--num-text); font-weight: 800; font-size: 0.95rem; padding: 3px 10px; border-radius: 8px; }
.song-head h2 { margin: 0; font-size: 1.15rem; line-height: 1.3; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-head .cat { flex: 0 0 auto; color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

.player { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 14px 10px; }
.player .noaudio { text-align: center; color: var(--muted); padding: 10px 0; }
.controls { display: flex; align-items: center; justify-content: center; gap: 18px; }
.controls button { border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.controls .side { width: 64px; height: 64px; font-size: 1.5rem; background: var(--num-bg); color: var(--num-text); }
.controls .main { width: 92px; height: 92px; font-size: 2.4rem; background: var(--primary); color: var(--primary-text); box-shadow: 0 4px 14px rgba(30,58,138,.35); }
.controls .main:active { transform: scale(.96); }
.progress { margin-top: 12px; }
.progress input[type=range] { width: 100%; height: 44px; accent-color: var(--primary); margin: 0; }
.times { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); }
.player-opts { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.chip { min-height: 46px; padding: 6px 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); font-size: 0.9rem; font-weight: 600; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.fav.on { color: var(--danger); border-color: var(--danger); background: #fde8e8; }
:root[data-theme="dark"] .chip.fav.on { background: #3a1414; }

.seg { display: flex; margin: 16px 0 10px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { flex: 1; min-height: 56px; font-size: 1.05rem; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--primary); color: var(--primary-text); }
/* 歌谱框限高，框内可上下滑；歌词才能留在同一屏 */
.sheet { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden auto; max-height: 38vh; -webkit-overflow-scrolling: touch; }
.sheet img { width: 100%; }
.sheet-tip { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }
.song-nav { display: flex; gap: 10px; margin-top: 16px; }
.song-nav button { flex: 1; min-height: 60px; font-size: 1rem; font-weight: 600; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); }

/* 迷你播放条 */
.mini {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 25;
  height: var(--mini-h); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px;
  background: var(--card); border-top: 2px solid var(--primary);
}
body.has-mini { padding-bottom: calc(var(--tab-h) + var(--mini-h) + env(safe-area-inset-bottom)); }
.mini-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; height: 100%; }
.mini-num { flex: 0 0 auto; background: var(--num-bg); color: var(--num-text); font-weight: 800; padding: 4px 10px; border-radius: 10px; }
.mini-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-btn { width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: var(--primary-text); font-size: 1.25rem; display: flex; align-items: center; justify-content: center; }
.mini-btn:last-child { background: var(--num-bg); color: var(--num-text); }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--card); border-top: 2px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.tabbar a .ico { font-size: 1.5rem; line-height: 1; }
.tabbar a.on { color: var(--primary); }

/* 设置页 */
.setting { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.setting h3 { margin: 0 0 8px; font-size: 1.05rem; }
.setting p { margin: 6px 0; color: var(--muted); font-size: 0.9rem; }
.setting ol { padding-left: 1.4em; margin: 6px 0; font-size: 0.95rem; }
.setting li { margin: 6px 0; }
.opts { display: flex; gap: 8px; flex-wrap: wrap; }
.opts .chip { flex: 1; text-align: center; min-height: 52px; }

/* 全屏看图 */
.viewer { position: fixed; inset: 0; z-index: 50; background: #111; color: #fff; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; font-weight: 700; }
.viewer-bar button { min-height: 52px; padding: 0 16px; background: #333; border-radius: 12px; font-size: 1rem; }
.viewer-btns { display: flex; gap: 8px; flex: 0 0 auto; }
.viewer-bar > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer.rotated .viewer-body { display: flex; align-items: center; justify-content: center; overflow: auto; }
.viewer.rotated .viewer-body img { width: auto; height: calc(100vw - 16px); max-width: none; transform: rotate(90deg); transform-origin: center; }
.viewer-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pinch-zoom pan-x pan-y; }
.viewer-body img { width: 100%; background: #fff; }
.viewer-tip { text-align: center; font-size: 0.85rem; color: #bbb; padding: 8px 0 calc(env(safe-area-inset-bottom) + 8px); }

.toast { position: fixed; left: 50%; bottom: 40%; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 14px 22px; border-radius: 14px; font-size: 1.05rem; z-index: 60; max-width: 86vw; text-align: center; }

/* ===================== 滚动歌词（横向走马灯）===================== */
.lyrics { margin-top: 14px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lyrics-head { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.lyrics-head > span:first-child { flex: 0 0 auto; font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.lyr-btn { flex: 0 0 auto; white-space: nowrap; min-height: 42px; padding: 0 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--bg); font-size: 0.85rem; font-weight: 600; }
.lyr-btn[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }

/* 一行高的横向轨道：当前句居中，唱完向左走 */
.lyrics-body {
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  padding: 16px 0; touch-action: pan-x;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.lyrics-body::-webkit-scrollbar { display: none; }
.lyrics-body:not(.manual) { pointer-events: none; }
.lyrics-body:not(.manual) .lyr-line { pointer-events: auto; }
.lyr-track { display: flex; align-items: center; gap: 2.2em; padding: 0 50%; width: max-content; }
.lyr-line {
  flex: 0 0 auto; white-space: nowrap; line-height: 1.4;
  font-size: 1.35rem; font-weight: 700; color: var(--text); opacity: .35;
  transition: opacity .3s, color .3s, transform .3s; transform-origin: center;
}
.lyr-line.done { opacity: .22; }
.lyr-line.on { opacity: 1; color: var(--primary); transform: scale(1.08); }
.lyrics-cal { display: flex; gap: 8px; padding: 0 14px 12px; }
.lyrics-cal button { flex: 1; min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); font-size: 0.82rem; font-weight: 600; }
.lyrics-cal button:active { background: var(--num-bg); }

/* 歌词状态 + 逐句校准 */
.lyr-state { flex: 0 0 auto; margin-left: auto; margin-right: 6px; white-space: nowrap; font-size: 0.7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.lyr-state.ok { color: var(--primary); border-color: var(--primary); }
.lyrics-cal { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 12px; }
.lyrics-cal button { flex: 1 1 28%; min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); font-size: 0.82rem; font-weight: 600; }
.lyrics-cal .cal-main { flex: 1 1 100%; background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-size: 0.95rem; min-height: 50px; }
.lyrics-cal button:active { filter: brightness(1.1); }

.tapbar { padding: 12px 14px 14px; border-top: 1px solid var(--line); background: var(--bg); }
.tap-hint { text-align: center; font-size: 0.8rem; color: var(--muted); }
.tap-next { text-align: center; font-size: 1.3rem; font-weight: 800; color: var(--primary); margin: 8px 0 12px; line-height: 1.4; }
.tap-btn { width: 100%; min-height: 76px; border-radius: 16px; background: var(--primary); color: var(--primary-text); font-size: 1.25rem; font-weight: 800; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.tap-btn:active { transform: scale(.98); }
.tap-btn[disabled] { opacity: .45; }
.tap-ops { display: flex; gap: 8px; margin-top: 10px; }
.tap-ops button { flex: 1; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 0.85rem; font-weight: 600; }
.tap-ops button[disabled] { opacity: .4; }

/* 练唱：变速 / A-B 复读 */
.practice { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.practice .chip { flex: 1 1 45%; text-align: center; }

/* ===================== 投影模式 ===================== */
.proj { position: fixed; inset: 0; z-index: 90; background: #06060a; color: #fff; display: flex; flex-direction: column; --pz: 1; }
.proj-top { flex: 0 0 auto; padding: calc(env(safe-area-inset-top) + 10px) 16px 6px; text-align: center; font-size: 15px; color: #8a8fa3; letter-spacing: 2px; }
.proj-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 24px; cursor: pointer; overflow: hidden; }
.proj-text { width: 100%; text-align: center; }
.proj-cur {
  font-size: clamp(40px, 10vw, 128px); line-height: 1.25; font-weight: 800; color: #fff;
  text-shadow: 0 3px 22px rgba(0,0,0,.85); letter-spacing: 3px; word-break: keep-all;
  transform: scale(var(--pz)); transition: transform .2s;
}
.proj-next { margin-top: clamp(14px, 3vh, 40px); font-size: clamp(22px, 4.6vw, 56px); line-height: 1.3; color: #7e8496; letter-spacing: 2px; transform: scale(var(--pz)); }
.proj-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.proj-bar { flex: 0 0 auto; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 8px 10px calc(env(safe-area-inset-bottom) + 10px); background: rgba(255,255,255,.04); }
.proj-bar button { min-height: 46px; padding: 0 14px; border-radius: 12px; background: #1b1e2b; color: #e6e8f0; font-size: 14px; font-weight: 600; border: 1px solid #2c3145; }
.proj-bar button:active { background: #2a2f44; }
.proj-bar button[aria-pressed="true"] { background: #2a2f44; }
.proj-bar button#projAuto[aria-pressed="true"], .proj-bar button#projPPT[aria-pressed="true"] { background: #2b4a8f; border-color: #3f66c4; color: #fff; }
.proj-bar button#projClose { background: #6b1a22; border-color: #8f2027; }
.proj-tip { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(0,0,0,.72); color: #cfd3e0; font-size: 13px; padding: 8px 16px; border-radius: 999px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
@media (orientation: landscape) and (max-height: 520px) {
  .proj-top { display: none; }
  .proj-bar { padding: 4px 8px; }
  .proj-bar button { min-height: 38px; font-size: 13px; }
}
