:root {
  --bg: #14181f; --card: #1e242e; --card2: #262d39; --text: #e9edf3; --muted: #8e99a8; --line: #313a48;
  --main: #f59e0b; --main-soft: #3a2d10; --left: #60a5fa; --right: #f59e0b; --danger: #ef6b5b; --ok: #34d399;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif; }
body { touch-action: manipulation; overscroll-behavior: none; }
#view { height: 100%; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select { font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 100%; min-width: 0; }
select { appearance: none; }
a { color: var(--main); }
h3 { margin: 18px 4px 6px; font-size: 14px; color: var(--muted); font-weight: 600; }

.page { max-width: 560px; width: 100%; margin: 0 auto; padding: 0 12px calc(24px + env(safe-area-inset-bottom)); flex: 1; overflow: auto; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 50px; padding: 4px 0; }
.bar h1 { font-size: 18px; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.bar .back { color: var(--main); text-decoration: none; font-weight: 600; padding: 8px 6px 8px 0; font-size: 17px; flex: none; }
.ibtn { font-size: 20px; padding: 6px 8px; border-radius: 10px; }
.ibtn:active, .ibtn.on { background: var(--card2); }
.btn { padding: 9px 14px; border-radius: 10px; background: var(--card2); font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--main); color: #14181f; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; height: 50px; font-size: 17px; margin-top: 8px; }
.btn:disabled { opacity: .4; }

.login { padding: 40px 0; display: flex; flex-direction: column; gap: 10px; }
.login h2 { margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 6px; }

.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #000c; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 90vw; }
dialog { border: 0; border-radius: 16px; background: var(--card); color: var(--text); padding: 18px; width: min(92vw, 420px); max-height: 85vh; overflow: auto; }
dialog::backdrop { background: #0008; }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog .form { display: flex; flex-direction: column; gap: 10px; }
dialog .row { display: flex; gap: 8px; }
dialog .row .btn { flex: 1; }
label.f { display: block; font-size: 13px; color: var(--muted); }
label.f input, label.f select { margin-top: 4px; }

/* 譜庫 */
.week { display: flex; gap: 4px; align-items: flex-end; height: 56px; padding: 0 2px; }
.week div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.week i { display: block; width: 100%; background: var(--main); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.week div.today span { color: var(--text); font-weight: 600; }
.jobs { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.job { font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--main-soft); color: var(--main); }
.job.fail { background: #3a1d1d; color: var(--danger); }
.bar a.btn { text-decoration: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; }
.chips button { padding: 6px 12px; border-radius: 999px; background: var(--card); font-size: 14px; white-space: nowrap; color: var(--muted); }
.chips button.on { background: var(--main-soft); color: var(--main); font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list .kind { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; background: var(--card2); color: var(--muted); }
.list .kind.xml { background: #3a2d10; color: var(--main); }
.list .kind.pdf { background: #2a1d1d; color: #f87171; }
.list .mid { flex: 1; min-width: 0; }
.list .mid div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.list .mid small { color: var(--muted); display: block; margin-top: 2px; }
.list.wrap .mid div, .list.wrap .mid small { white-space: normal; }
.menu a.btn { text-decoration: none; display: block; }
.list .more { font-size: 20px; color: var(--muted); padding: 6px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 14px; line-height: 1.7; }
.progress { height: 6px; background: var(--card2); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--main); width: 0; transition: width .2s; }

/* 譜頁共用 */
.sheetpage { height: 100%; display: flex; flex-direction: column; }
.sheetpage .bar { padding: 0 8px; min-height: 44px; flex: none; }
.tools { display: flex; gap: 4px; align-items: center; padding: 4px 8px; overflow-x: auto; flex: none; background: var(--card); scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.tools button, .tools select { flex: none; padding: 7px 10px; border-radius: 9px; background: var(--card2); font-size: 14px; font-weight: 600; width: auto; border: 0; min-height: 36px; }
.tools button.on { background: var(--main); color: #14181f; }
.tools button.L.on { background: var(--left); }
.tools button.R.on { background: var(--right); }
.tools .sep { width: 1px; height: 24px; background: var(--line); flex: none; margin: 0 2px; }
.tools .play { font-size: 18px; min-width: 46px; }
.tools .pos { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding: 0 4px; white-space: nowrap; }

/* 圖譜 */
.pdfwrap { flex: 1; overflow: auto; position: relative; background: #2b2f36; }
.pdfpage { position: relative; margin: 8px auto; background: #fff; box-shadow: 0 2px 10px #0006; }
.pdfpage canvas { display: block; }
.pdfpage canvas.ink { position: absolute; inset: 0; touch-action: none; }
.pdfpage .pn { position: absolute; right: 6px; bottom: 4px; font-size: 11px; color: #0008; }
.pdfwrap img { display: block; margin: 8px auto; max-width: 100%; }

/* 數位譜 */
.split { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* 手機橫放：譜在左、瀑布流在右 */
@media (orientation: landscape) and (max-height: 540px) {
  .split { flex-direction: row; }
  .osmdwrap { flex-basis: 56%; }
  .fallwrap { flex-basis: 44%; }
  .bar { min-height: 38px; }
}
.osmdwrap { position: relative; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; background: #fff; color: #000; flex: 1 1 50%; min-height: 0; }
.osmdwrap .labels { position: absolute; left: 0; top: 0; pointer-events: none; }
.osmdwrap .labels span { position: absolute; transform: translate(-50%, -100%); font-size: 10px; font-weight: 700; color: #b45309; background: #fffc; padding: 0 2px; border-radius: 3px; line-height: 1.2; white-space: nowrap; }
.osmdwrap .labels span.L { color: #1d4ed8; }
.osmdwrap .labels span.ledger { color: #b91c1c; }
.osmdwrap .loading { padding: 30px; color: #555; text-align: center; }
.fallwrap { position: relative; flex: 1 1 50%; min-height: 0; background: #0b0d12; }
.fallwrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.split.only-sheet .fallwrap, .split.only-fall .osmdwrap { display: none; }
.split.only-sheet .osmdwrap, .split.only-fall .fallwrap { flex-basis: 100%; }
.seek { display: flex; align-items: center; gap: 8px; padding: 2px 10px; flex: none; background: var(--card); }
.seek input[type=range] { flex: 1; padding: 0; border: 0; background: none; accent-color: var(--main); }
.seek .mnum { width: 64px; padding: 5px 6px; text-align: center; font-size: 14px; }

.menu { display: flex; flex-direction: column; gap: 6px; }
.menu button { text-align: left; padding: 12px; border-radius: 10px; background: var(--card2); font-size: 16px; }
.menu button.danger { color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; }
