/* 文库 3.0 与设置对话框：书房级的静谧展陈，每一本笔记都是可以拿在手里的精装书。
   目录：外壳 · 侧栏 · 顶栏 · 分组标题 · 继续书写 · 封面网格 · 列表 · 搜索结果 · 回收站与空状态 · 多选操作条 · 拖放 · 设置 · 窄屏 */

/* ── 外壳 ─────────────────────────────────────────── */
.library-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--grain), var(--surface-0);
}

.lib-scrim { display: none; }

.lib-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.lib-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: var(--space-5);
}

.lib-content {
  max-width: 1360px;
  padding: var(--space-2) 44px 120px;
}

/* ── 侧栏 ─────────────────────────────────────────── */
.lib-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 14px max(14px, env(safe-area-inset-bottom, 0px));
  border-right: 1px solid var(--line);
  background: var(--surface-1);
}

.lib-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 22px;
  font: 500 18px/1 var(--font-serif);
  letter-spacing: .04em;
  color: var(--ink-1);
}
.lib-brand .brand-mark {
  display: block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgb(42 32 20 / .12));
}

.lib-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -4px;
  padding: 0 4px;
}

.side-row { position: relative; border-radius: var(--radius-s); }
.side-row + .side-row { margin-top: 2px; }

.side-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  border-radius: var(--radius-s);
  color: var(--ink-2);
  font-size: var(--text-m);
  text-align: left;
  transition: background var(--fast), color var(--fast);
}
.side-item .icon { width: 18px; height: 18px; color: var(--ink-3); transition: color var(--fast); }
.side-item > span { flex: 1; }
.side-item small {
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}
@media (hover: hover) {
  .side-item:hover { background: color-mix(in oklab, var(--surface-3) 76%, transparent); color: var(--ink-1); }
  .side-item:hover .icon { color: var(--ink-2); }
}
.side-item[aria-current='page'] {
  background: var(--surface-2);
  color: var(--ink-1);
  font-weight: 600;
  box-shadow: var(--shadow-1), 0 0 0 1px color-mix(in srgb, var(--line) 85%, transparent);
}
.side-item[aria-current='page']::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.side-item[aria-current='page'] .icon { color: var(--accent-ink); }
.side-item[aria-current='page'] small { color: var(--ink-2); }

.side-more {
  position: absolute;
  top: 5px;
  right: 4px;
  opacity: 0;
  pointer-events: none;
}
.side-row:hover .side-more, .side-more:focus-visible, .side-more[aria-expanded='true'] { opacity: 1; pointer-events: auto; }
.side-row:hover .side-item small, .side-row:has(.side-more:focus-visible) .side-item small { visibility: hidden; }

.side-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 4px;
  padding: 0 4px 0 11px;
}
.side-folders .side-item { font-size: var(--text-m); }
.side-sep { height: 1px; margin: 14px 10px; background: var(--line); }

.lib-side-foot {
  display: grid;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.is-dragging-book [data-drop-folder] .side-item,
.is-dragging-book [data-drop-star] .side-item,
.is-dragging-book [data-drop-trash] .side-item { outline: 1px dashed var(--line-strong); outline-offset: -1px; }
.side-row.drop-target .side-item {
  background: var(--accent-soft);
  color: var(--accent-ink);
  outline: 1.5px solid var(--accent);
}

/* ── 顶栏 ─────────────────────────────────────────── */
.lib-head {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-5);
  max-width: 1360px;
  padding: 28px 44px 16px;
}

.lib-title { flex: 1 1 260px; min-width: 0; }
.lib-title h1 {
  font-size: var(--text-2xl);
  line-height: 1.18;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-hello {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .06em;
}
.lib-hello::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .85;
}
.lib-sub { margin-top: 5px; color: var(--ink-3); font-size: var(--text-s); font-variant-numeric: tabular-nums; }

.lib-tools { display: flex; align-items: center; gap: 8px; }
.lib-search { width: 252px; transition: width var(--slow) var(--ease); }
@media (min-width: 1121px) {
  .lib-search:focus-within { width: 304px; }
}
.lib-search .input { min-height: var(--control); }
.lib-search .input::-webkit-search-cancel-button { appearance: none; }
.lib-search .input:focus + kbd, .lib-search .input:not(:placeholder-shown) + kbd { display: none; }
.lib-layout { height: var(--control); align-items: center; }
.lib-layout > button { display: grid; place-items: center; min-width: 34px; min-height: 28px; padding: 0 6px; color: var(--ink-3); }
.lib-layout > button[aria-pressed='true'] { color: var(--ink-1); }
.lib-layout .icon { width: 17px; height: 17px; }

.lib-sort-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: 0 1px 1.5px rgb(42 34 22 / .04);
}
@media (hover: hover) {
  .lib-sort-btn:hover { border-color: var(--line-strong); }
}

.lib-select-btn {
  min-height: var(--control);
  padding: 0 13px;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.lib-select-btn[aria-pressed='true'] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.lib-new {
  min-height: var(--control);
  padding: 0 16px;
  margin-left: 2px;
  border-radius: var(--radius-s);
}
.lib-drawer-btn { display: none; }

/* ── 分组标题 ─────────────────────────────────────── */
.lib-section + .lib-section { margin-top: 34px; }
.lib-h2 {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 4px 0 16px;
  font-size: 17px;
  color: var(--ink-1);
}
.lib-count { color: var(--ink-3); font: var(--text-s) var(--font-ui); }

/* ── 继续书写 ─────────────────────────────────────── */
.resume-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
}

.resume-card {
  display: grid;
  gap: 9px;
  min-width: 0;
  text-align: left;
  border-radius: var(--radius-m);
}
.resume-paper {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
  overflow: hidden;
  transition: transform var(--normal) var(--ease), box-shadow var(--normal) var(--ease), border-color var(--fast);
}
:root[data-theme='dark'][data-night-paper='on'] .resume-paper {
  background: var(--paper-night);
}
/* 左上角精致书签丝带色标，克制地提示归属哪一本 */
.resume-paper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  z-index: 2;
  width: 10px;
  height: 16px;
  border-radius: 0 0 3px 3px;
  background: var(--cover-tint);
  box-shadow: 0 2px 4px rgb(0 0 0 / .16);
}
/* 右下角微微纸角折影 */
.resume-paper::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .35);
  pointer-events: none;
}
:root[data-theme='dark'] .resume-paper::after {
  box-shadow: inset 0 0 0 1px rgb(255 250 240 / .08);
}
.resume-paper canvas, .resume-paper .cover-print { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.resume-paper.is-fallback { background: var(--cover-tint); }
@media (hover: hover) {
  .resume-card:hover .resume-paper { transform: translateY(-3px); box-shadow: var(--shadow-2), 0 0 0 1px var(--line-strong); }
}
.resume-card:focus-visible .resume-paper { transform: translateY(-2px); box-shadow: var(--shadow-2), 0 0 0 1px var(--accent); }
.resume-card:focus-visible { outline-offset: 4px; }

.resume-text { display: grid; gap: 2px; min-width: 0; padding: 0 2px; }
.resume-text strong { font-size: var(--text-s); font-weight: 600; color: var(--ink-1); transition: color var(--fast); }
@media (hover: hover) {
  .resume-card:hover .resume-text strong { color: var(--accent-ink); }
}
.resume-text small { color: var(--ink-3); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }

/* 速记卡：与继续书写浑然一体的点阵灵感卡片 */
.quick-paper {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  border: 1.5px dashed var(--line-strong);
  background:
    radial-gradient(circle, color-mix(in oklab, var(--ink-3) 34%, transparent) 1px, transparent 1.35px) 0 0 / 16px 16px,
    var(--surface-2);
  box-shadow: var(--shadow-1);
  color: var(--ink-2);
  font-size: var(--text-s);
  font-weight: 500;
}
.quick-paper::before, .quick-paper::after { content: none; }
.quick-paper .icon {
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  transition: transform var(--normal) var(--ease), background var(--fast), color var(--fast);
}
.quick-paper > span {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-1);
  font-weight: 500;
}
@media (hover: hover) {
  .resume-quick:hover .quick-paper {
    border-color: var(--accent-line);
    box-shadow: var(--shadow-2);
    color: var(--accent-ink);
  }
  .resume-quick:hover .quick-paper .icon {
    background: var(--accent);
    color: var(--on-accent);
    transform: scale(1.06);
  }
}

/* ── 封面网格（精装书籍展陈） ─────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 32px 28px;
}

.book-card { position: relative; min-width: 0; }

.book-cover {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 3px 11px 11px 3px;
}
.book-cover .cover {
  box-shadow: var(--shadow-book);
  transition: transform 240ms var(--ease), box-shadow 240ms var(--ease);
}
/* 书架网格里：插画封面完全展现画面呼吸感，不叠加重复标题胶囊；极简书脊/线框封面保留压纹题签 */
.book-grid .book-cover .cover:not([data-plate]) .title { display: none; }

@media (hover: hover) {
  .book-cover:hover .cover {
    transform: translateY(-5px) perspective(900px) rotateY(-4deg);
    box-shadow: var(--shadow-book-hover);
  }
}
.book-cover:focus-visible .cover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-book-hover);
}
.book-cover:focus-visible { outline-offset: 5px; }

/* 星标浮钮 */
.book-star {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass-strong);
  color: var(--ink-2);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity var(--fast), transform 240ms var(--ease), color var(--fast);
}
.book-star .icon { width: 15px; height: 15px; }
.book-star[aria-pressed='true'] { opacity: 1; color: #c98a1b; }
:root[data-theme='dark'] .book-star[aria-pressed='true'] { color: #e8ae42; }
.book-star[aria-pressed='true'] .icon { fill: currentColor; }
@media (hover: hover) {
  .book-card:hover .book-star { opacity: 1; transform: translateY(-5px); }
  .book-star:hover { color: #c98a1b; }
  :root[data-theme='dark'] .book-star:hover { color: #e8ae42; }
}
.book-star:focus-visible { opacity: 1; }

.book-meta {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  margin-top: 13px;
  padding: 0 2px;
}
.book-text { display: grid; flex: 1; min-width: 0; gap: 2px; }
.book-text strong { font-size: var(--text-m); font-weight: 600; line-height: 1.38; color: var(--ink-1); transition: color var(--fast); }
@media (hover: hover) {
  .book-card:hover .book-text strong { color: var(--accent-ink); }
}
.book-text small { color: var(--ink-3); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.book-more { margin: -2px -6px 0 0; opacity: 0; transition: opacity var(--fast), background var(--fast); }
.book-card:hover .book-more, .book-more:focus-visible, .book-more[aria-expanded='true'] { opacity: 1; }

/* 多选勾选圈 */
.book-check {
  position: absolute;
  top: 9px;
  left: 14px;
  z-index: 4;
  display: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--scrim);
  color: transparent;
  box-shadow: var(--shadow-1);
}
.book-check .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.is-selecting .book-check { display: grid; }
.is-selecting .book-star, .is-selecting .book-card .book-more { display: none; }
.is-selecting .book-cover:hover .cover { transform: none; }
.book-card.is-selected .book-check { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.book-card.is-selected .cover { outline: 2.5px solid var(--accent); outline-offset: 3px; }

[draggable='false'] .cover { filter: saturate(.65); opacity: .82; }

.lib-more { height: 1px; }
.lib-more-note { margin-top: var(--space-3); color: var(--ink-3); font-size: var(--text-s); }

/* ── 列表 ─────────────────────────────────────────── */
.book-list { display: grid; }
.book-list-head, .book-row-main {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) minmax(0, 160px) 68px 112px;
  align-items: center;
  gap: var(--space-4);
}
.book-list-head {
  padding: 0 46px 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: 600;
}
.book-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-right: 6px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-s);
  transition: background var(--fast);
}
@media (hover: hover) {
  .book-row:hover { background: var(--surface-2); box-shadow: var(--shadow-1); border-bottom-color: transparent; }
}
.book-row-main {
  flex: 1;
  min-width: 0;
  min-height: 62px;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  text-align: left;
}
.row-cover .cover { width: 36px; border-radius: 2px 5px 5px 2px; box-shadow: var(--shadow-1); }
.row-cover .cover .title { display: none; }
.row-cover .cover::after { width: 4px; border-left-width: 2px; }
.row-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
.row-star .icon { width: 14px; height: 14px; fill: currentColor; color: var(--accent); }
.row-folder, .row-pages, .row-time { color: var(--ink-3); font-size: var(--text-s); }
.row-check {
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  color: transparent;
}
.row-check .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.is-selecting .book-row-main, .is-selecting .book-list-head { grid-template-columns: 22px 36px minmax(0, 1fr) minmax(0, 160px) 68px 112px; }
.head-check { display: none; }
.is-selecting .head-check { display: block; }
.is-selecting .row-check { display: grid; }
.book-row.is-selected { background: var(--accent-soft); }
.book-row.is-selected .row-check { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.book-row .book-more { margin: 0; opacity: .6; }
.book-row:hover .book-more { opacity: 1; }
.is-selecting .book-row .book-more { visibility: hidden; }

/* ── 搜索结果 ─────────────────────────────────────── */
.hit-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--space-2) var(--space-5); }
.page-hit {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  text-align: left;
  transition: background var(--fast), border-color var(--fast);
}
@media (hover: hover) {
  .page-hit:hover { background: var(--surface-2); border-color: var(--line); }
}
.hit-thumb { width: 64px; flex: none; aspect-ratio: 794 / 1123; }
.hit-thumb canvas, .hit-thumb .cover-print { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.hit-thumb.is-fallback { background: var(--cover-tint); }
.hit-body { display: grid; gap: 4px; min-width: 0; }
.hit-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--ink-1);
  font-size: var(--text-m);
  line-height: 1.55;
}
.hit-text mark { padding: 0 3px; border-radius: 3px; background: var(--accent-soft); color: var(--accent-ink); }
.hit-body small { color: var(--ink-3); font-size: var(--text-xs); }

/* ── 回收站与空状态 ───────────────────────────────── */
.trash-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 var(--space-5);
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-1);
  color: var(--ink-2);
  font-size: var(--text-s);
}
.lib-empty {
  min-height: 54dvh;
  align-content: center;
  gap: 10px;
  animation: lib-empty-in 480ms var(--ease-out) both;
}
@keyframes lib-empty-in { from { opacity: 0; transform: translateY(8px); } }
.empty-art {
  width: 140px;
  height: 104px;
  margin-bottom: 6px;
  overflow: visible;
  filter: drop-shadow(0 8px 18px rgb(42 32 20 / .08));
}
.empty-art .empty-book-l,
.empty-art .empty-book-r,
.empty-art .empty-book-c {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform var(--slow) var(--ease-spring);
}
@media (hover: hover) {
  .lib-empty:hover .empty-book-l { transform: translate(-6px, 2px) rotate(-5deg); }
  .lib-empty:hover .empty-book-r { transform: translate(6px, 2px) rotate(5deg); }
  .lib-empty:hover .empty-book-c { transform: translateY(-4px); }
}
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}
.empty-actions .btn { margin-top: 0; min-height: 40px; padding: 0 18px; }

/* ── 多选操作条 ───────────────────────────────────── */
.lib-bar {
  position: fixed;
  left: calc(var(--sidebar) + (100vw - var(--sidebar)) / 2);
  bottom: 24px;
  z-index: 30;
  max-width: calc(100vw - var(--sidebar) - 32px);
  padding: 6px 8px;
  border-radius: var(--radius-pill);
  transform: translateX(-50%);
  overflow-x: auto;
  animation: lib-bar-in var(--normal) var(--ease);
}
.lib-bar .btn { border-radius: var(--radius-pill); }
.lib-bar .btn.small .icon { width: 16px; height: 16px; }
.lib-bar .label { color: var(--ink-1); font-weight: 600; white-space: nowrap; }
.lib-bar .v-divider { margin: 0 4px; }
.lib-bar-done { border-color: transparent; background: var(--ink-1); color: var(--surface-2); }
.lib-bar-done:hover:not(:disabled) { background: var(--ink-2); }
@keyframes lib-bar-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ── 拖入文件 ─────────────────────────────────────── */
.lib-drop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.lib-drop[hidden] { display: none; }
.lib-drop-card {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  width: min(440px, 100%);
  padding: 44px 32px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-l);
  background: var(--surface-2);
  box-shadow: var(--shadow-3);
  text-align: center;
}
.lib-drop-card .icon { width: 32px; height: 32px; color: var(--accent); animation: drop-bob 1.4s ease-in-out infinite; }
@keyframes drop-bob { 50% { transform: translateY(4px); } }
.lib-drop-card strong { font: 500 var(--text-xl) var(--font-serif); }
.lib-drop-card p { color: var(--ink-3); font-size: var(--text-s); }

/* ── 设置对话框（高质感实底，零透视干扰） ─────────── */
dialog.settings-dialog {
  height: min(620px, 86dvh);
  background: var(--surface-2);
}
.settings-dialog .dialog-head { padding-bottom: 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.settings-dialog .dialog-body { display: flex; padding: 0; overflow: hidden; background: var(--surface-2); }
.settings { display: grid; grid-template-columns: 184px minmax(0, 1fr); flex: 1; min-height: 0; }

.settings-nav {
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: var(--surface-1);
}
.settings-nav button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 11px;
  border-radius: var(--radius-s);
  color: var(--ink-2);
  text-align: left;
  transition: background var(--fast), color var(--fast);
}
.settings-nav .icon { width: 18px; height: 18px; color: var(--ink-3); }
@media (hover: hover) {
  .settings-nav button:hover { background: color-mix(in oklab, var(--surface-3) 76%, transparent); color: var(--ink-1); }
}
.settings-nav button[aria-selected='true'] {
  background: var(--surface-2);
  color: var(--ink-1);
  font-weight: 600;
  box-shadow: var(--shadow-1), 0 0 0 1px color-mix(in srgb, var(--line) 85%, transparent);
}
.settings-nav button[aria-selected='true']::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.settings-nav button[aria-selected='true'] .icon { color: var(--accent-ink); }

.settings-pane { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px 30px 30px; background: var(--surface-2); }
.settings-pane > * { animation: settings-pane-in 120ms var(--ease-out) both; }
@keyframes settings-pane-in { from { opacity: .72; } }
.settings-title { margin-bottom: var(--space-2); font-size: var(--text-xl); font-weight: 500; }
.settings-pane .setting-row { padding: 14px 0; }
.settings-pane .setting-row p { margin-top: 3px; line-height: 1.55; }
.settings-pane label.setting-row { cursor: pointer; }
.settings-pane .segment > button { padding: 0 11px; }
.settings-foot-note { margin-top: var(--space-4); color: var(--ink-3); font-size: var(--text-s); }
.offline-phase { color: var(--ink-2); font-weight: 500; }
.offline-phase[data-phase='ready'] { color: var(--green); }
.offline-phase[data-phase='error'] { color: var(--danger); }

.settings-pet {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-2) 0 var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-1);
}
.settings-pet strong { display: block; font: 500 var(--text-l) var(--font-serif); }
.settings-pet p { margin-top: 2px; color: var(--ink-3); font-size: var(--text-s); }
.settings-pet-art { position: relative; display: block; width: 72px; height: 72px; flex: none; }
.settings-pet-art .pet-art, .settings-pet-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.settings-pet-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.settings-pet-art .pet-rest, .settings-pet-art .pet-growth { display: none; }

.settings-about-head { display: flex; align-items: center; gap: var(--space-4); margin: var(--space-2) 0 var(--space-5); }
.settings-logo .brand-mark { width: 50px; height: 50px; filter: drop-shadow(0 3px 8px rgb(42 32 20 / .14)); }
.settings-about-head strong { display: block; font-size: var(--text-xl); font-weight: 500; }
.settings-about-head p { color: var(--ink-3); font-size: var(--text-s); }
.settings-h3 { margin: var(--space-5) 0 var(--space-2); color: var(--ink-1); font-size: var(--text-s); font-weight: 600; }
.settings-tips { display: grid; gap: 10px; margin: 0; }
.settings-tips > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--space-3); }
.settings-tips dt { color: var(--ink-1); font-size: var(--text-s); font-weight: 500; }
.settings-tips dd { margin: 0; color: var(--ink-2); font-size: var(--text-s); line-height: 1.6; }
.settings-text { color: var(--ink-2); font-size: var(--text-s); line-height: 1.7; }

/* ── 中等宽度 ─────────────────────────────────────── */
@media (max-width: 1120px) {
  .lib-head { padding: 24px 28px 14px; }
  .lib-content { padding: var(--space-2) 28px 120px; }
  .lib-tools { flex: 1 1 100%; }
  .lib-search { flex: 1; width: auto; max-width: 360px; }
  .lib-new { margin-left: auto; }
  .resume-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .resume-row > :nth-child(n + 4):not(.resume-quick) { display: none; }
}

/* ── 窄屏：侧栏抽屉 + 两列网格 ────────────────────── */
@media (max-width: 759px) {
  .library-shell { grid-template-columns: minmax(0, 1fr); }
  .lib-side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(280px, 84vw);
    box-shadow: var(--shadow-3);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform var(--normal) var(--ease), visibility 0s var(--normal);
  }
  .drawer-open .lib-side { transform: none; visibility: visible; transition: transform var(--normal) var(--ease); }
  .lib-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: var(--scrim);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--normal);
  }
  .drawer-open .lib-scrim { opacity: 1; pointer-events: auto; }
  .lib-drawer-btn { display: inline-grid; margin: 0 -4px 0 -8px; align-self: center; }
  .lib-head { align-items: center; gap: var(--space-3); padding: 14px 16px 12px; }
  .lib-title { flex-basis: 0; }
  .lib-title h1 { font-size: var(--text-xl); }
  .lib-hello { display: none; }
  .lib-sub { margin-top: 2px; font-size: var(--text-xs); }
  .lib-tools { flex-wrap: wrap; gap: 6px; }
  .lib-search { flex: 1 1 100%; max-width: none; order: 5; }
  .lib-search kbd { display: none; }
  .lib-new { margin-left: auto; }
  .lib-content { padding: 4px 16px 120px; }
  .resume-row {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 48%;
    gap: var(--space-3);
    margin: 0 -16px;
    padding: 0 16px 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 16px;
    scrollbar-width: none;
  }
  .resume-row > * { scroll-snap-align: start; }
  .resume-row > :nth-child(n + 4):not(.resume-quick) { display: grid; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 16px; }
  .book-list-head { display: none; }
  .book-row-main, .is-selecting .book-row-main { grid-template-columns: 36px minmax(0, 1fr) auto; gap: var(--space-3); }
  .is-selecting .book-row-main { grid-template-columns: 22px 36px minmax(0, 1fr) auto; }
  .row-folder, .row-pages { display: none; }
  .hit-list { grid-template-columns: minmax(0, 1fr); }
  .lib-bar { left: 50%; max-width: calc(100vw - 16px); bottom: 12px; }
  .lib-bar .btn.small { padding: 0 8px; }
  .lib-bar .bar-text { display: none; }
  .trash-note { flex-direction: column; align-items: flex-start; }
  .settings { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    padding: 8px 12px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .settings-nav button { flex: 0 1 auto; min-height: 32px; padding: 0 10px; font-size: var(--text-xs); }
  .settings-nav button[aria-selected='true']::before { display: none; }
  .settings-nav .icon { display: none; }
  .settings-pane { padding: 16px 18px 24px; }
  .settings-pane .setting-row { flex-wrap: wrap; }
  .settings-tips > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (hover: none) and (pointer: coarse) {
  .book-more { opacity: 1; }
  .side-more { opacity: 1; pointer-events: auto; }
  .side-row .side-item small { visibility: hidden; }
}
