:root {
  --paper: #f5f7fb;
  --paper-light: #ffffff;
  --paper-card: #ffffff;
  --ink: #172238;
  --muted: #6d7d94;
  --line: #e2e9f1;
  --accent: #315cf4;
  --accent-dark: #2447c7;
  --accent-soft: #e9eeff;
  --shadow: 0 12px 32px rgba(32, 58, 92, 0.1);
  --reader-font-size: 1.12rem;
  --reader-line-height: 2.05;
}

/* 柔和米白主题 */
body.theme-cream {
  --paper: #f7f4ed;
  --paper-light: #ffffff;
  --paper-card: #ffffff;
  --ink: #222320;
  --muted: #726e64;
  --line: rgba(80, 70, 55, 0.16);
  --accent: #315cf4;
  --accent-soft: #e9eeff;
}

/* 夜读暗色主题 */
body.theme-night {
  --paper: #1c1c19;
  --paper-light: #252522;
  --paper-card: #2a2a26;
  --ink: #e3dfd5;
  --muted: #9e9a90;
  --line: rgba(230, 220, 200, 0.14);
  --accent: #8da7ff;
  --accent-dark: #b6c5ff;
  --accent-soft: rgba(141, 167, 255, 0.16);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* 对话框通用层叠重置：未打开时强制隐藏，确保在 Safari/Chrome/iOS/Android/Mac 均不流入页面 */
dialog:not([open]),
.reader:not([open]),
.doc-drawer:not([open]),
.guide-dialog:not([open]) {
  display: none !important;
}

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  transition: background 200ms ease, color 200ms ease;
}

body.theme-night {
  background: var(--paper);
}

button, input { font: inherit; }

.app-header, main {
  width: min(920px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 0 14px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup, .header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark { width: 42px; height: 42px; border-radius: 10px; box-shadow: 0 4px 12px rgba(32, 58, 92, 0.16); }
.brand-lockup h1 { font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; letter-spacing: 0.02em; }
.brand-lockup p { margin: 1px 0 0; color: var(--muted); font-size: 0.78rem; }
.header-actions { gap: 8px; }
.header-button { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--paper-light); cursor: pointer; font-size: 0.85rem; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: 0.03em; }
h2 { font-size: clamp(1.4rem, 5vw, 1.9rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 0.95rem; color: var(--muted); }

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper-card);
  font-size: 1.55rem;
  cursor: pointer;
  transition: transform 120ms ease, background 160ms ease;
}

.icon-button:active { transform: scale(0.94); }

.import-card {
  position: relative;
  overflow: hidden;
  max-width: 660px;
  margin: min(8vh, 56px) auto 0;
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-card);
  box-shadow: var(--shadow);
}


.import-card > p:not(.section-kicker) { max-width: 36rem; color: var(--muted); line-height: 1.8; }

.primary-action, .secondary-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  padding: 0 24px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-weight: 600;
  transition: background 150ms ease, transform 120ms ease;
}

.primary-action:hover { background: var(--accent-dark); }
.primary-action:active { transform: scale(0.97); }
.primary-action.full-width { width: 100%; }

.status-line { min-height: 1.4rem; margin-top: 16px; color: var(--muted); font-size: 0.9rem; }
.status-line.error { color: var(--accent); font-weight: 600; }

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(75, 65, 49, 0.12);
}

.progress-fill { width: 0; height: 100%; background: var(--accent); transition: width 160ms ease; }

.library-shell { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }

.library-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px 18px;
  border-top: 1px solid var(--line);
}

.library-meta span, .library-meta strong { display: block; }
.library-meta span { color: var(--muted); font-size: 0.8rem; }
.library-meta strong { margin-top: 3px; font-size: 1.08rem; }

.text-button { border: 0; padding: 4px 8px; color: var(--accent); background: transparent; cursor: pointer; font-size: 0.9rem; }

/* 视图分段选择器 */
.view-tabs {
  display: flex;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #edf1f6;
}

.view-tab {
  flex: 1;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 160ms ease;
}

.view-tab.active {
  color: var(--accent-dark);
  background: var(--paper-light);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

/* 分类胶囊滚动条 */
.facet-bar { margin-bottom: 14px; }

.facet-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.facet-scroller::-webkit-scrollbar { display: none; }

.facet-pill {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--paper-card);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 140ms ease;
}

.facet-pill.active {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 600;
}

.panel-summary { padding: 4px 2px 14px; color: var(--muted); font-size: 0.88rem; }

/* 书架网格与卡片 */
.shelf-grid {
  display: grid;
  gap: 14px;
}

.shelf-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  color: inherit;
  background: var(--paper-card);
  box-shadow: 0 5px 18px rgba(32, 58, 92, 0.05);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.shelf-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.shelf-card:active { transform: scale(0.985); }

.shelf-card h3 {
  font-size: 1.08rem;
  line-height: 1.45;
  margin-bottom: 6px;
}

.shelf-card .book-meta {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

.shelf-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: auto;
}

.badge-tag {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-soft);
}

.badge-pages {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
}

/* 检索框与结果 */
.search-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 7px 7px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-light);
  box-shadow: 0 7px 22px rgba(32, 58, 92, 0.07);
}

.search-box > span { color: var(--accent); font-size: 1.45rem; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 1rem; color: var(--ink); }
.search-box button { padding: 9px 18px; border: 0; border-radius: 12px; color: white; background: var(--accent); cursor: pointer; font-weight: 600; }

.shelf-search-box {
  margin-bottom: 12px;
}

.shelf-search-box .shelf-clear-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
}

.shelf-search-box .shelf-clear-btn:active,
.shelf-search-box .shelf-clear-btn:hover {
  color: var(--accent);
  background: rgba(0, 0, 0, 0.05);
}

.shelf-container {
  position: relative;
  min-height: 320px;
}

.shelf-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-family: "Songti SC", "SimSun", "STSong", Georgia, -apple-system, serif;
  font-style: normal;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  font-weight: 500;
  letter-spacing: 0.22em;
  padding-left: 0.22em;
  color: var(--ink);
  opacity: 0.18;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 0;
}

.shelf-grid {
  position: relative;
  z-index: 1;
}

.empty-shelf-notice {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-shelf-notice.has-box {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(4px);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.shelf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
}
.shelf-toolbar .panel-summary {
  margin: 0;
}
.shelf-options {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}
.shelf-options select {
  min-height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-light);
  font-size: 0.84rem;
}

.search-options { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 10px 2px 2px; color: var(--muted); font-size: 0.84rem; }
.search-options select { min-height: 34px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper-light); }

.result-list { display: grid; gap: 14px; }

/* 全库检索聚合卡片 */
.search-group-card {
  width: 100%;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  color: inherit;
  background: var(--paper-card);
  box-shadow: 0 4px 16px rgba(32, 58, 92, 0.05);
  box-sizing: border-box;
}

.search-group-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.search-group-info {
  min-width: 0;
  flex: 1;
}

.search-group-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-group-title {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  cursor: pointer;
}

.search-group-title:hover {
  color: var(--accent);
}

.search-group-cat {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(32, 58, 92, 0.08);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.search-group-meta {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.search-group-count {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(184, 51, 42, 0.08);
  border: 1px solid rgba(184, 51, 42, 0.18);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 文献内部命中条目 */
.search-group-matches {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.search-match-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--paper-light);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
  color: inherit;
  box-sizing: border-box;
}

.search-match-item:active {
  transform: scale(0.99);
  background: rgba(0, 0, 0, 0.03);
}

.search-match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.search-match-arrow {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: normal;
}

.search-match-snippet {
  margin: 0;
  color: var(--ink);
  opacity: 0.9;
  line-height: 1.62;
  font-size: 0.88rem;
}

.search-remaining-container {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.search-remaining-container[hidden] {
  display: none;
}

.search-expand-button {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 150ms ease;
}

.search-expand-button:active,
.search-expand-button:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(184, 51, 42, 0.04);
}

.result-card {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  color: inherit;
  background: var(--paper-card);
  box-shadow: 0 5px 18px rgba(32, 58, 92, 0.05);
  cursor: pointer;
  transition: transform 120ms ease;
}

.result-card:active { transform: scale(0.99); }
.result-card h3 { margin: 0; font-size: 1.05rem; }
.result-meta { margin: 5px 0 8px; color: var(--accent); font-size: 0.8rem; font-weight: 600; }
.result-card p { margin: 0; color: var(--ink); opacity: 0.9; line-height: 1.68; font-size: 0.93rem; }
mark { padding: 0 0.12em; color: inherit; background: #f6d177; border-radius: 2px; }

.secondary-action { width: 100%; margin-top: 16px; color: var(--ink); background: transparent; border: 1px solid var(--line); }

/* 单书详情抽屉 */
.doc-drawer {
  display: none;
}

.doc-drawer[open] {
  width: min(620px, 100%);
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper-light);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}

.doc-drawer::backdrop { background: rgba(20, 18, 14, 0.45); backdrop-filter: blur(4px); }

.drawer-header {
  position: sticky;
  top: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-light);
  z-index: 10;
}

.drawer-heading { min-width: 0; }
.drawer-heading h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.15rem; }
.drawer-heading span { color: var(--muted); font-size: 0.8rem; margin-top: 2px; display: block; }

.drawer-content {
  padding: 20px 20px calc(40px + env(safe-area-inset-bottom));
}

.meta-block {
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-card);
  font-size: 0.88rem;
  line-height: 1.8;
}

.meta-item { display: flex; margin-bottom: 4px; }
.meta-label { width: 5.5rem; color: var(--muted); flex-shrink: 0; }
.meta-val { color: var(--ink); font-weight: 500; }

.catalog-section { margin-top: 24px; }
.catalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.catalog-header h4 { margin: 0; }
.page-jump-form {
  display: flex;
  align-items: center;
  gap: 6px;
}
.page-jump-form input {
  width: 68px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-card);
  color: var(--ink);
  font-size: 0.84rem;
  text-align: center;
  -moz-appearance: textfield;
}
.page-jump-form input::-webkit-outer-spin-button,
.page-jump-form input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.page-jump-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(184, 51, 42, 0.15);
}
.page-jump-form button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.12s ease;
}
.page-jump-form button:hover {
  opacity: 0.92;
}
.page-jump-form button:active {
  transform: scale(0.96);
}

.document-search-section { margin-top: 24px; }
.document-search-section h4 { margin-bottom: 10px; }
.document-search-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.document-search-box input { min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--paper-card); }
.document-search-box button { padding: 0 16px; border: 0; border-radius: 10px; color: #fff; background: var(--accent); font-weight: 600; }
.document-search-summary { min-height: 1.3rem; margin-top: 9px; color: var(--muted); font-size: 0.82rem; }
.document-result-list { display: grid; gap: 8px; }
.document-result { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--paper-card); text-align: left; cursor: pointer; }
.document-result strong { display: block; margin-bottom: 4px; color: var(--accent-dark); font-size: 0.82rem; }
.document-result span { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 0.85rem; line-height: 1.55; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.page-pill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 8px;
}

.page-btn {
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-card);
  font-size: 0.83rem;
  cursor: pointer;
  text-align: center;
  transition: all 120ms ease;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn:active { transform: scale(0.95); }

/* 沉浸式阅读器 */
.reader {
  display: none;
}

.reader[open] {
  width: min(880px, 100%);
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper-light);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

.reader::backdrop { background: rgba(20, 18, 14, 0.5); backdrop-filter: blur(4px); }

.reader-toolbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-light);
  z-index: 10;
}

.reader-toolbar-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.reader-heading { min-width: 0; }
.reader-heading strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem; }
.reader-heading span { display: block; margin-top: 2px; color: var(--accent); font-size: 0.78rem; font-weight: 600; }

.icon-button.quiet { flex: 0 0 auto; border: 0; background: transparent; width: 38px; height: 38px; }

.reader-tools { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.tool-btn {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-card);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-btn:active { background: var(--accent-soft); }

.reader-article {
  flex: 1;
  overflow-y: auto;
  max-width: 48rem;
  margin: 0 auto;
  padding: 24px 22px 30px;
  white-space: pre-wrap;
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  letter-spacing: 0.02em;
  font-family: "Noto Serif CJK SC", "Songti SC", STSong, Georgia, serif;
}

/* 阅读器底部导航栏 */
.reader-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper-light);
}

.nav-arrow-btn {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper-card);
  font-size: 0.88rem;
  cursor: pointer;
}

.nav-arrow-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-indicator {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* 浮动 Toast 提示 */
.toast {
  position: fixed;
  bottom: max(32px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: 999px;
  color: white;
  background: rgba(30, 28, 24, 0.92);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-size: 0.88rem;
  pointer-events: none;
  z-index: 1000;
  animation: fadeInOut 2s ease forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

@media (min-width: 680px) {
  .shelf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader[open], .doc-drawer[open] { height: calc(100% - 32px); margin-top: 16px; border-radius: 24px 0 0 24px; }
}

@media (min-width: 960px) {
  .shelf-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 顶部添加到主屏幕指引条 */
.install-prompt-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #f0f4ff;
  border-bottom: 1px solid #dbe4ff;
  color: var(--ink);
  font-size: 0.84rem;
  position: relative;
  z-index: 20;
}
.install-prompt-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.install-prompt-content img { border-radius: 8px; flex-shrink: 0; }
.install-prompt-content strong { color: var(--accent); display: block; font-size: 0.86rem; }
.install-prompt-content p { margin: 2px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.install-guide-btn { margin-left: auto; padding: 7px 10px; border: 1px solid #b9c8f8; border-radius: 8px; color: var(--accent-dark); background: #fff; font-size: 0.8rem; font-weight: 600; white-space: nowrap; cursor: pointer; }
.install-dismiss-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.guide-dialog { display: none; }
.guide-dialog[open] { display: block; width: min(680px, calc(100% - 24px)); max-height: min(88vh, 820px); margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--paper-light); box-shadow: 0 24px 70px rgba(23, 34, 56, 0.26); }
.guide-dialog::backdrop { background: rgba(23, 34, 56, 0.42); backdrop-filter: blur(3px); }
.guide-header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; border-bottom: 1px solid var(--line); background: var(--paper-light); z-index: 2; }
.guide-header p { margin: 0 0 2px; color: var(--accent); font-size: 0.76rem; font-weight: 700; }
.guide-header h2 { font-size: 1.3rem; }
.guide-content { display: grid; gap: 12px; padding: 16px 18px 22px; }
.guide-section { padding: 15px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.recommended-guide { border-color: #cbd7ff; background: #f5f7ff; }
.guide-badge { display: inline-block; margin-bottom: 7px; padding: 3px 7px; border-radius: 6px; color: var(--accent-dark); background: var(--accent-soft); font-size: 0.72rem; font-weight: 700; }
.guide-section h3 { font-size: 1rem; }
.guide-section summary { cursor: pointer; font-weight: 700; }
.guide-section ol { margin: 10px 0 0; padding-left: 1.35rem; color: #33445b; line-height: 1.7; font-size: 0.92rem; }
.guide-section li + li { margin-top: 5px; }
.import-guide p { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; line-height: 1.55; }

@media (max-width: 520px) {
  .app-header, main { width: min(100% - 24px, 920px); }
  .header-button { padding: 0 9px; }
  .install-prompt-banner { align-items: flex-start; padding-inline: 12px; }
  .install-prompt-content img { display: none; }
  .install-guide-btn { margin-top: 1px; }
  .reader-toolbar { align-items: flex-start; gap: 8px; }
  .reader-tools { gap: 4px; }
  .tool-btn { padding: 6px 8px; }
}
