/* BookDistiller — 现代主义极简（Swiss / editorial）
   原则：中性灰阶、1px 细线、无阴影、单一强调色、严格栅格、字重对比 */

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --ink: #101012;
  --muted: #63636a;
  --faint: #9a9aa1;
  --line: #e7e7e3;
  --line-strong: #d5d5d0;
  --accent: #d93f2a;
  --accent-soft: #fbece8;
  --ok: #2f7a52;
  --warn: #96661c;
  --err: #c0392b;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --font-read: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", Georgia, serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0d;
    --surface: #141416;
    --surface-2: #1c1c1f;
    --ink: #f3f3f1;
    --muted: #a0a0a6;
    --faint: #6e6e74;
    --line: #26262a;
    --line-strong: #36363b;
    --accent: #ff6b4a;
    --accent-soft: #2a1712;
    --ok: #58b183;
    --warn: #d0a04e;
    --err: #e0685c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: var(--accent); }

::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ 布局 */

.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
}

.main { overflow-y: auto; }

.page {
  max-width: 1020px;
  margin: 0 auto;
  padding: 56px 56px 96px;
}

/* ------------------------------------------------------------------ 品牌 */

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 26px 22px 22px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--font-read);
  font-size: 15px;
  line-height: 1;
  flex: none;
}

.brand-name {
  font-size: 13.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ------------------------------------------------------------------ 侧栏 */

.sidebar-actions { display: flex; padding: 0 22px 18px; }
.sidebar-actions .btn { width: 100%; }

.nav-links {
  display: flex;
  gap: 18px;
  padding: 0 22px 18px;
  border-bottom: 1px solid var(--line);
}

.nav-links .btn-ghost {
  padding: 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.nav-links .btn-ghost:hover { color: var(--ink); background: transparent; }

.book-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.book-item {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  padding: 9px 10px 9px 12px;
  transition: background 0.12s var(--ease);
}
.book-item:hover { background: var(--surface-2); }
.book-item.active { background: var(--surface-2); }
.book-item.active::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 11px;
  bottom: 11px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.book-item .t {
  display: block;
  font-size: 13px;
  font-weight: 520;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.book-item .m {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.dot.ok { background: var(--ok); }
.dot.run { background: var(--warn); }
.dot.err { background: var(--err); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.health { display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: nowrap;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease),
    color 0.12s var(--ease);
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  font-weight: 560;
}
.btn-primary:hover { background: #000; border-color: #000; }
@media (prefers-color-scheme: dark) {
  .btn-primary:hover { background: #fff; border-color: #fff; }
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: transparent; color: var(--ink); border-color: transparent; }

.btn-danger { color: var(--err); border-color: transparent; background: transparent; }
.btn-danger:hover { border-color: var(--err); }

.btn-sm { height: 28px; padding: 0 11px; font-size: 11.5px; }

/* ------------------------------------------------------------------ 分段选择 */

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.seg button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--ink); color: var(--bg); }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ------------------------------------------------------------------ 页面头 */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.24;
  font-weight: 600;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0 0 14px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: none;
}

.sub {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.005em;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }

.chip-genre { color: var(--accent); border-color: rgba(217, 63, 42, 0.35); }

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: transparent;
}
.chip.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.chip.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }

/* ------------------------------------------------------------------ 卡片 */

.card {
  margin-top: 32px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.start-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

select.scope,
input.scope {
  flex: 1;
  min-width: 180px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink);
  transition: border-color 0.12s var(--ease);
}
select.scope:hover, input.scope:hover { border-color: var(--muted); }
select.scope:focus, input.scope:focus { border-color: var(--ink); outline: none; }

.hint {
  margin-top: 12px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--faint);
}

/* ------------------------------------------------------------------ 进度 */

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.progress-stage {
  font-size: 13px;
  font-weight: 560;
  letter-spacing: -0.005em;
}

.progress-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 2px;
  margin: 14px 0 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.45s var(--ease);
}

.log {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  max-height: 180px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.85;
  color: var(--muted);
}
.log div { display: flex; gap: 10px; }
.log .st { flex: none; min-width: 60px; color: var(--faint); }
.log .err { color: var(--err); }
.log .warn { color: var(--warn); }

/* ------------------------------------------------------------------ 标签页 */

.tabs {
  display: flex;
  gap: 22px;
  margin: 40px 0 0;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  border: 0;
  background: transparent;
  padding: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
  transition: color 0.12s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 560; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--ink);
}
.tab:disabled { opacity: 0.3; cursor: default; }

.panel { padding-top: 28px; }

/* ------------------------------------------------------------------ 大纲 */

.tree { font-size: 13px; }

.tree .vol { margin-bottom: 28px; }

.tree .vol-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tree .ch {
  margin-top: 4px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.tree .ch-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  color: var(--ink);
}

.tree .sec {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0 3px 14px;
  font-size: 12px;
  color: var(--muted);
}

.tree .n {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.tree .row:hover { background: var(--surface-2); border-radius: 4px; }

/* ------------------------------------------------------------------ 阅读区 */

.reader-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 18px;
}

.reader {
  max-width: 680px;
  font-family: var(--font-read);
  font-size: 16.5px;
  line-height: 1.95;
  letter-spacing: 0.005em;
  white-space: pre-wrap;
  color: var(--ink);
}

.note-box {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  word-break: break-all;
  color: var(--muted);
}

audio { width: 100%; margin-top: 16px; }

/* ------------------------------------------------------------------ 空状态 */

.empty {
  padding: 64px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--muted);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.empty.hot { border-color: var(--accent); background: var(--accent-soft); }
.empty h3 {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.empty p { margin: 0; font-size: 12px; line-height: 1.8; }

/* ------------------------------------------------------------------ 队列 */

.job-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.job-row:last-child { border-bottom: 0; }
.job-main { flex: 1; min-width: 0; }
.job-title {
  font-size: 13px;
  font-weight: 520;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-meta {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
}
.job-actions { display: flex; gap: 6px; flex: none; }

/* ------------------------------------------------------------------ 提示条 */

.banner-warn {
  margin-top: 24px;
  border-color: rgba(217, 63, 42, 0.45);
  background: rgba(217, 63, 42, 0.06);
}

/* ------------------------------------------------------------------ 主视觉 */

.hero {
  position: relative;
  overflow: hidden;
  margin-top: 30px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.hero-bg {
  position: absolute;
  inset: -30%;
  background-image: var(--cover);
  background-size: cover;
  background-position: center;
  filter: blur(48px) saturate(1.15);
  opacity: 0.28;
  transform: scale(1.1);
}

.hero-content {
  position: relative;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 30px;
}

.cover-hero {
  width: 116px;
  flex: none;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.hero-text { min-width: 0; }

.hero-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.hero-title {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 620;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hero-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ 书架 */

.search-row { margin: 28px 0 0; }
.search-row input { width: 100%; }

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 28px 20px;
  margin-top: 24px;
}

.shelf-item {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s var(--ease);
}
.shelf-item:hover { transform: translateY(-2px); }

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.shelf-item:hover .cover {
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.26);
  transform: translateY(-2px);
}
.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-read);
  font-size: 34px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

.shelf-title {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 560;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.shelf-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shelf-flag { margin-top: 7px; }

.book-hero { display: flex; gap: 22px; align-items: flex-start; }
.cover-sm { width: 92px; flex: none; }
@media (max-width: 900px) { .cover-sm { width: 72px; } .book-hero { gap: 14px; } }

/* ------------------------------------------------------------------ 书架交互 */

.cover-wrap { position: relative; }
.cover-play {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(16, 16, 18, 0.72);
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.shelf-item:hover .cover-play { opacity: 1; }
@media (hover: none) { .cover-play { opacity: 1; } }
.cover-play svg { width: 13px; height: 13px; margin-left: 2px; }

.filters { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.filter {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
}
.filter:hover { border-color: var(--muted); color: var(--ink); }
.filter.active { border-color: var(--ink); color: var(--ink); }

.audio-hero { display: flex; align-items: center; gap: 16px; margin: 18px 0 14px; }
.play-big {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  flex: none;
}
.play-big svg { width: 20px; height: 20px; margin-left: 3px; }

/* ------------------------------------------------------------------ 迷你播放器 */

.miniplayer {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  width: min(420px, calc(100vw - 40px));
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  z-index: 70;
  opacity: 0;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.miniplayer.on { display: flex; opacity: 1; transform: translate(-50%, 0); }

.mp-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  flex: none;
}
.mp-btn svg { width: 13px; height: 13px; }
.mp-body { flex: 1; min-width: 0; }
.mp-title {
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-bar {
  display: flex;
  align-items: center;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  touch-action: none;
}
.mp-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.mp-track > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
}
.mp-track > b {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%) scale(0);
  transition: transform 0.12s var(--ease);
  pointer-events: none;
}
.mp-bar:hover .mp-track > b,
.mp-bar:active .mp-track > b { transform: translateY(-50%) scale(1); }
.mp-times {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: none;
  min-width: 56px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--faint);
}
.mp-remaining { color: var(--muted); }
.mp-speed { flex: none; display: flex; align-items: center; gap: 8px; }
.mp-speed input[type='range'] {
  width: 62px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.mp-speed span {
  min-width: 36px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.mp-close { border: 0; background: transparent; color: var(--faint); font-size: 13px; padding: 4px 6px; }

/* ------------------------------------------------------------------ 弹窗 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.45);
}
.modal {
  width: min(440px, 100%);
  padding: 24px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.modal h2 { margin-bottom: 16px; font-size: 15px; color: var(--ink); letter-spacing: 0; }
.modal textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
}
.stars { display: flex; gap: 4px; margin-bottom: 14px; }
.star {
  border: 0;
  background: transparent;
  padding: 0 2px;
  font-size: 24px;
  line-height: 1;
  color: var(--line-strong);
}
.star.on { color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ------------------------------------------------------------------ 图书管理员 */

.assistant-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease);
}
.assistant-fab:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.assistant-fab-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}

.assistant {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 390px;
  display: none;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.25);
  z-index: 80;
}
.assistant.on { display: flex; }

.assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.assistant-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.assistant-sub { margin-top: 4px; font-size: 11px; color: var(--faint); }
.assistant-close { border: 0; background: transparent; color: var(--faint); font-size: 13px; padding: 4px; }

.assistant-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.assistant-empty { color: var(--muted); font-size: 12.5px; line-height: 1.8; }
.assistant-empty ul { margin: 8px 0 14px; padding-left: 18px; }
.assistant-suggests { display: flex; flex-direction: column; gap: 6px; }
.assistant-suggest {
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.assistant-suggest:hover { border-color: var(--line-strong); color: var(--ink); }

.assistant-msg {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.75;
  word-break: break-word;
}
.assistant-msg.user { align-self: flex-end; background: var(--ink); color: var(--bg); }
.assistant-msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.assistant-msg.typing { color: var(--faint); font-size: 12px; }

.assistant-books { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.assistant-book {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: inherit;
}
.assistant-book:hover { border-color: var(--line-strong); }
.assistant-cover { width: 34px; flex: none; margin: 0; border-radius: 3px; }
.assistant-book b { display: block; font-size: 12px; font-weight: 550; }
.assistant-book em { display: block; margin-top: 3px; font-style: normal; font-size: 11px; color: var(--faint); }

.assistant-acts { display: flex; gap: 8px; margin-top: 10px; }
.assistant-act {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}
.assistant-act:hover { border-color: var(--accent); color: var(--accent); }

.assistant-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 16px;
  border-top: 1px solid var(--line);
}
.assistant-form input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ 表格 */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--faint);
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.table tr:last-child td { border-bottom: 0; }
.table td:first-child { font-weight: 520; }
.table a { text-decoration: none; }
.table a:hover { color: var(--accent); }
.table tbody tr { transition: background 0.12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------ 设置 */

.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px 20px;
  font-size: 12px;
}
.kv .k { color: var(--faint); letter-spacing: 0.01em; }
.kv .v {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  word-break: break-all;
}

/* ------------------------------------------------------------------ Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 8px);
  z-index: 99;
  max-width: min(520px, 84vw);
  padding: 11px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); }

/* ------------------------------------------------------------------ 响应式 */

/* 手机：底部导航 + 全屏内容 */

.mobilenav { display: none; }
.back-link { display: none; }

@media (max-width: 900px) {
  html, body { height: auto; overflow-x: hidden; overflow-y: auto; }

  .app { display: block; height: auto; }
  .sidebar { display: none; }
  .main { overflow: visible; padding-bottom: calc(58px + env(safe-area-inset-bottom)); }

  .page { padding: 20px 18px 32px; }
  h1 { font-size: 24px; }
  .page-head { gap: 12px; }
  .card { padding: 18px; margin-top: 20px; }

  .connect-grid { flex-direction: column; align-items: stretch !important; gap: 14px !important; }
  .connect-info { min-width: 0 !important; width: 100%; }
  .connect-qr { align-self: center; }
  .seg { display: flex; width: 100%; }
  .seg button {
    flex: 1;
    height: auto;
    min-height: 30px;
    padding: 5px 8px;
    white-space: normal;
    line-height: 1.35;
  }
  .hint code { word-break: break-all; }

  .tabs { gap: 18px; overflow-x: auto; }
  .tab { padding-bottom: 11px; white-space: nowrap; }

  .reader { font-size: 16px; line-height: 1.9; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv .k { margin-top: 12px; }

  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    padding: 0;
    margin-bottom: 14px;
  }

  .mobilenav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
    bottom: 0;
    z-index: 60;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 54px;
    border: 0;
    background: transparent;
    color: var(--faint);
    font-size: 10px;
    letter-spacing: 0.02em;
  }
  .mnav-item.active { color: var(--ink); }
  .mnav-item svg { width: 19px; height: 19px; }

  .toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .miniplayer { bottom: calc(64px + env(safe-area-inset-bottom)); width: calc(100vw - 24px); }
  .assistant { width: 100%; }
  .assistant-fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }

  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; }
  .cover-fallback { font-size: 30px; }
}
