:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --fg: #16181d;
  --muted: #6b7280;
  --line: #e3e5e9;
  --accent: #2563eb;
  --ok: #16a34a;
  --off: #9ca3af;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --card: #191c23;
    --fg: #e8eaee;
    --muted: #9aa1ad;
    --line: #2a2e38;
    --accent: #4f83ff;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  padding: 12px 12px 32px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.full { width: 100%; }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; color: var(--muted); }

/* 登录 */
.login-card { max-width: 420px; margin: 8vh auto; }
label { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
input[type=email], input[type=password], input[type=text], input[type=number], select {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.captcha-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.captcha-row input { margin-top: 0; flex: 1; }
/* 验证码：按原始比例显示，绝不能裁切（object-fit:cover 会切掉数字） */
#captcha-img {
  height: 46px; width: auto; max-width: 52%;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  cursor: pointer; flex: 0 0 auto;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; }

/* 通用 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.row { display: flex; gap: 10px; margin-top: 16px; }
.row > * { flex: 1; }
button {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 10px; padding: 11px 14px; font-size: 15px; cursor: pointer;
}
button:active { transform: scale(0.985); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.small { padding: 7px 10px; font-size: 13px; }
.switch-line { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
button.link {
  border: none; background: none; padding: 0 0 0 4px;
  color: var(--accent); font-size: 13px; text-decoration: underline; cursor: pointer;
}
button.link:active { transform: none; }
.msg { min-height: 18px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.msg.err { color: #dc2626; }
.msg.ok { color: var(--ok); }

/* 顶栏 */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.device-pick { display: flex; align-items: center; gap: 8px; flex: 1; }
.device-pick select { margin-top: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: 0 0 auto; }
.dot.on { background: var(--ok); }

/* 正在播放 */
.now { margin-bottom: 12px; }
.now-title { font-size: 15px; font-weight: 600; }
.now-chapter { font-size: 13px; color: var(--muted); word-break: break-all; }
.range { width: 100%; margin: 6px 0; accent-color: var(--accent); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.controls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 14px 0 10px; }
.ctrl { padding: 12px 4px; font-size: 13px; line-height: 1.3; }
.ctrl b { font-weight: 600; }
.ctrl.play { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 15px; }

.jump { display: flex; gap: 8px; }
.jump input { margin-top: 0; }
.sliders { margin-top: 12px; }
.slider { margin: 10px 0 0; }
.slider > span { display: flex; justify-content: space-between; }

/* 设置 */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.inline { display: flex; align-items: center; gap: 6px; }
.num { width: 68px; margin-top: 0; text-align: center; }
.setting select { width: auto; min-width: 104px; margin-top: 0; }
.switch { display: inline-flex; align-items: center; margin: 0; }
.switch input { display: none; }
.switch i { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; display: block; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

/* 书库 */
.lib-head { display: flex; align-items: center; justify-content: space-between; }
.lib-head h2 { margin-bottom: 0; }
#sel-book { margin: 10px 0; }
.chapters { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; }
.chapters li {
  padding: 11px 10px; border-top: 1px solid var(--line);
  font-size: 14px; word-break: break-all; cursor: pointer; display: flex; gap: 8px; justify-content: space-between;
}
.chapters li:first-child { border-top: 0; }
.chapters li.active { color: var(--accent); font-weight: 600; }
.chapters li span.d { color: var(--muted); font-size: 12px; flex: 0 0 auto; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(20,22,28,.94); color: #fff; padding: 10px 16px;
  border-radius: 999px; font-size: 13px; max-width: 86vw; text-align: center; z-index: 50;
}
