/* ═══════════════════════════════════════════════════════════════════════
   书斋 Web 书架 · /bookshelf
   ---------------------------------------------------------------------------
   布局参考 Readest：左侧固定导航、右侧工具条 + 封面网格、点开右滑详情。
   配色不另起一套 —— 全部吃 css/tokens.css 的令牌，深浅色只跟随系统。
   封面不是图：没有封面时用纸色 + 竖排书名生成一张，看起来仍然像"一本书"。
   ═══════════════════════════════════════════════════════════════════════ */

.sh-body { overflow-x: hidden; }

/* hidden 属性必须压得住 author 样式：.grid 有 display:grid，不加 !important 就藏不住 */
[hidden] { display: none !important; }

.sh {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── 左侧栏 ─────────────────────────────────────────────────────── */
.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
}

.rail__brand {
  display: flex; align-items: center; gap: 9px;
  padding: 2px 10px 22px;
  color: var(--accent); text-decoration: none;
}
.rail__brand span {
  font-family: var(--font-display); font-size: 20px;
  letter-spacing: .04em; color: var(--ink);
}
.rail__brand em {
  font-style: normal; font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--line-2); border-radius: 99px;
  padding: 1px 7px; margin-top: 3px;
}
.rail__brand:hover { text-decoration: none; }
.rail__brand:hover span { color: var(--accent); }

.rail__nav { display: flex; flex-direction: column; gap: 2px; }
.rail__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--ink-2); font-size: 14px; text-decoration: none;
  transition: background var(--dur-1) var(--ease-soft), color var(--dur-1) var(--ease-soft);
}
.rail__item svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: .8; }
.rail__item:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.rail__item.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rail__item.is-on svg { opacity: 1; }
.rail__item--soft { color: var(--ink-3); font-size: 13px; }
.rail__n {
  margin-left: auto; font-size: 11.5px; font-weight: 500;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.rail__item.is-on .rail__n { color: var(--accent); }

.rail__hr { height: 1px; background: var(--line); margin: 12px 10px; }
.rail__sp { flex: 1 1 auto; }

.rail__acct {
  border-top: 1px solid var(--line);
  padding: 14px 8px 4px;
  display: flex; flex-direction: column; gap: 6px;
}
.rail__signin {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.rail__signin:hover { filter: brightness(1.04); text-decoration: none; }
.rail__alt { text-align: center; font-size: 12px; color: var(--ink-3); }
.rail__alt:hover { color: var(--accent); }

.rail__user { display: flex; align-items: center; gap: 10px; }
.rail__av {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; overflow: hidden;
  border: 1px solid var(--line);
}
.rail__av img { width: 100%; height: 100%; object-fit: cover; }
.rail__who { min-width: 0; flex: 1 1 auto; }
.rail__nick {
  display: block; font-size: 13px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail__out {
  font-size: 11.5px; color: var(--ink-3); padding: 0;
  text-decoration: underline; text-underline-offset: 3px;
  background: none; border: 0; cursor: pointer;
}
.rail__out:hover { color: var(--danger); }

.rail__foot {
  margin: 12px 8px 0; font-size: 11px; color: var(--ink-3);
  letter-spacing: .02em;
}

/* ── 主区 ───────────────────────────────────────────────────────── */
.main {
  min-width: 0;
  padding: 30px clamp(20px, 3.6vw, 46px) 96px;
}

.head {
  display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.head__t { flex: 1 1 auto; min-width: 180px; }
.head h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 2.4vw, 34px);
  font-weight: 600; letter-spacing: .01em;
}
.head__sub { margin-top: 5px; font-size: 13px; color: var(--ink-3); }

.head__tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search {
  display: flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink-3);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search input {
  width: 168px; border: 0; background: none; color: var(--ink);
  font: inherit; font-size: 13.5px; outline: none;
}
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { display: none; }

.sel { position: relative; }
.sel select {
  height: 36px; padding: 0 30px 0 12px;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: 13px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.sel::after {
  content: ''; position: absolute; right: 12px; top: 50%;
  width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg); pointer-events: none;
}
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.seg {
  display: flex; padding: 3px; gap: 2px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 9px;
}
.seg button {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 28px; border-radius: 6px;
  color: var(--ink-3);
}
.seg button.is-on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(20, 40, 28, .08); }

.head__tools .btn { height: 36px; padding: 0 15px; font-size: 13px; }

/* 未登录时不摆筛选：点了也没书可筛，只会让人以为坏了 */
.sh[data-state="guest"] .chips { display: none; }
.sh[data-state="guest"] .rail__item[data-filter] { opacity: .45; pointer-events: none; }

/* 窄屏筛选条（宽屏隐藏，看左侧栏） */
.chips { display: none; gap: 6px; margin: 0 0 18px; flex-wrap: wrap; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 12.5px;
}
.chip.is-on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.demo-tag {
  display: inline-block; margin: 0 0 16px;
  font-size: 11.5px; color: var(--ink-3);
  border: 1px dashed var(--line-2); border-radius: 99px; padding: 3px 10px;
}

/* ── 书架网格 ───────────────────────────────────────────────────── */
.grid {
  display: grid;
  /* ⭐ [2026-11-10 鱼干「太大了」] 病根不是列宽，是 **1fr**：
     只有 2 本书时 auto-fill 会算出 3 列（每列 245px），`1fr` 又把整列宽都摊给这 2 本
     ⇒ 单本封面被撑到 245px，看着巨大。
     改成「固定范围 146~158px + justify-content:start」：每本尺寸稳定、书少时不拉伸、
     书多时自动排满。比例仍由 .bk__cover 的 aspect-ratio:2/3 撑，不会变形。 */
  grid-template-columns: repeat(auto-fill, minmax(146px, 158px));
  gap: 28px 20px;
  justify-content: start;
}

.bk {
  position: relative;
  display: flex; flex-direction: column;
  text-align: left; cursor: pointer;
  animation: bk-in var(--dur-3) var(--ease-out) both;
}
@keyframes bk-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bk { animation: none; }
}

.bk__cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 6px 9px 9px 6px;
  /* 学鸿蒙端：纯色底（按 id 散列到的 12 色之一）+ 书脊处一道压痕。
     旧版在纸色上叠了一层白色高光，那是给浅色纸用的；底色变深以后高光会糊成一块光斑。 */
  background:
    linear-gradient(100deg, rgba(0, 0, 0, .1) 0 5px, transparent 5px),
    var(--cv, var(--cv-1));
  border: 1px solid var(--line);
  box-shadow: 0 1px 1px rgba(20, 40, 28, .05), 0 6px 18px rgba(20, 40, 28, .07);
  overflow: hidden;
  transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.bk:hover .bk__cover,
.bk:focus-visible .bk__cover {
  transform: translateY(-3px);
  box-shadow: 0 2px 3px rgba(20, 40, 28, .06), 0 16px 34px rgba(20, 40, 28, .14);
}

/* 文字封面：居中白字衬线体，最多两行（字号由 bookshelf.js 的 fitCoverTitle 定） */
.bk__cvt {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 8px;
}
.bk__cvt span {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 17px; line-height: 1.35;
  color: #FFFFFF; text-align: center;
  word-break: normal;            /* 英文单词绝不从中间断（放不下靠缩字号 / 截断） */
  overflow-wrap: normal;
}

/* 真封面叠在文字封面上面：加载失败由 is-nocover 摘掉，露回文字封面 */
.bk__cover img,
.dt__cover img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.bk__cover.is-nocover img,
.dt__cover.is-nocover img { display: none; }

.bk__prog {
  position: absolute; left: 0; right: 0; bottom: 0;
  /* 封面底色现在一律是深色（或一张图），黑色轨道会消失，改白色低透明度 */
  height: 3px; background: rgba(255, 255, 255, .18);
}
.bk__prog i {
  display: block; height: 100%; background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.bk__badge {
  position: absolute; right: 8px; bottom: 10px;
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--glass); color: var(--ink-2);
  border: 1px solid var(--line);
  backdrop-filter: blur(4px);
}
.bk__badge--done { color: var(--accent); border-color: var(--accent-ring); }

.bk__t {
  margin: 10px 2px 0;
  font-family: var(--font-display);
  font-size: 14.5px; font-weight: 600; line-height: 1.4;
  color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.bk__a { margin: 3px 2px 0; font-size: 12px; color: var(--ink-3); }

/* 列表视图 */
.grid.is-list { grid-template-columns: 1fr; gap: 2px; }
.grid.is-list .bk {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  grid-template-areas: "cover title meta" "cover author meta";
  align-items: center; gap: 0 16px;
  padding: 10px 12px; border-radius: 10px;
}
.grid.is-list .bk:hover { background: var(--bg-1); }
.grid.is-list .bk__cover {
  grid-area: cover; width: 46px; aspect-ratio: 2 / 3;
  border-radius: 3px 4px 4px 3px;
  box-shadow: 0 1px 4px rgba(20, 40, 28, .14);
}
.grid.is-list .bk__cvt { display: none; }
.grid.is-list .bk__badge { display: none; }
.grid.is-list .bk:hover .bk__cover { transform: none; }
.grid.is-list .bk__t {
  grid-area: title; margin: 0; font-size: 14px;
  -webkit-line-clamp: 1;
}
.grid.is-list .bk__a { grid-area: author; margin: 1px 0 0; }
.grid.is-list .bk__meta {
  grid-area: meta; font-size: 12px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
}
.bk__meta { display: none; }

/* ── 空态 / 登录门 ─────────────────────────────────────────────── */
.state {
  max-width: 560px; margin: clamp(28px, 7vh, 90px) auto 0;
  text-align: center; padding: 0 8px;
}
.state__art {
  position: relative; width: 108px; height: 76px; margin: 0 auto 26px;
}
.state__art i {
  position: absolute; bottom: 0; width: 26px; height: 68px;
  border: 1px solid var(--line-2); border-radius: 3px;
  background: var(--bg-1);
}
.state__art i:nth-child(1) { left: 26px; height: 60px; transform: rotate(-7deg); background: var(--cv-2); }
.state__art i:nth-child(2) { left: 42px; height: 71px; background: var(--cv-1); z-index: 2; }
.state__art i:nth-child(3) { left: 58px; height: 55px; transform: rotate(8deg); background: var(--cv-3); }
.state__art--key { display: flex; align-items: center; justify-content: center; color: var(--accent); }
.state__art--key svg { width: 62px; height: 62px; opacity: .7; }

.state h2 {
  font-family: var(--font-display);
  font-size: clamp(21px, 2.2vw, 26px); margin-bottom: 10px;
}
.state p {
  font-size: 14px; color: var(--ink-2); line-height: 1.85;
  max-width: 46ch; margin: 0 auto;
}
.state__acts {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin: 22px 0 0;
}
.state__mini { margin-top: 16px !important; font-size: 12px !important; color: var(--ink-3) !important; }

/* ── 详情抽屉 ───────────────────────────────────────────────────── */
.detail {
  position: fixed; top: 0; right: 0; z-index: 80;
  width: min(382px, 100vw); height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  transform: translateX(102%);
  transition: transform var(--dur-2) var(--ease-out);
  overflow-y: auto;
}
.detail.is-open { transform: none; }
.detail__x {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); background: var(--glass);
}
.detail__x:hover { color: var(--ink); background: var(--bg-1); }
.detail__in { padding: 30px 26px 40px; }

.dt__cover {
  position: relative;
  width: 156px; aspect-ratio: 2 / 3; margin: 0 auto 22px;
  border-radius: 5px 8px 8px 5px;
  background:
    linear-gradient(100deg, rgba(0, 0, 0, .1) 0 5px, transparent 5px),
    var(--cv, var(--cv-1));
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(20, 40, 28, .16);
  overflow: hidden;
}
/* 抽屉里的封面宽 156px，字可以比网格里大一号 */
.dt__cover .bk__cvt span { font-size: 20px; }

.dt__t {
  font-family: var(--font-display);
  font-size: 22px; line-height: 1.35; text-align: center;
  margin: 0 0 6px;
}
.dt__a { text-align: center; font-size: 13px; color: var(--ink-3); margin-bottom: 22px; }

.dt__rows { border-top: 1px solid var(--line); }
.dt__row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.dt__row span { color: var(--ink-3); }
.dt__row b { font-weight: 500; color: var(--ink); text-align: right; }

.dt__bar {
  height: 6px; border-radius: 99px; background: var(--bg-2);
  margin: 18px 0 8px; overflow: hidden;
}
.dt__bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.dt__pt { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }

.dt__acts { margin-top: 24px; display: flex; flex-direction: column; gap: 8px; }
.dt__acts .btn { width: 100%; height: 42px; justify-content: center; }
.dt__hint { font-size: 11.5px; color: var(--ink-3); text-align: center; margin-top: 4px; }

.scrim {
  position: fixed; inset: 0; z-index: 70;
  background: var(--scrim); opacity: 0;
  transition: opacity var(--dur-2);
}
.scrim.is-on { opacity: 1; }

/* ── 导入说明弹层 ───────────────────────────────────────────────── */
.sh-modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 20px; }
.sh-modal[hidden] { display: none; }
.sh-modal__scrim { position: absolute; inset: 0; background: var(--scrim); }
.sh-modal__box {
  position: relative; width: min(430px, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 28px 26px 22px;
  box-shadow: var(--shadow-2);
}
.sh-modal__box h2 { font-family: var(--font-display); font-size: 20px; margin-bottom: 10px; }
.sh-modal__box p { font-size: 13.5px; color: var(--ink-2); line-height: 1.8; }
.sh-modal__note { margin-top: 10px; font-size: 12.5px !important; color: var(--ink-3) !important; }
.sh-modal__x { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%; color: var(--ink-3); }
.sh-modal__x:hover { background: var(--bg-1); color: var(--ink); }
.sh-modal__acts { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.sh-modal__acts .btn { height: 38px; padding: 0 16px; font-size: 13px; }

/* ── 轻提示 ─────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 140;
  transform: translate(-50%, 14px);
  background: var(--ink); color: var(--bg);
  font-size: 13px; padding: 9px 16px; border-radius: 99px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2), transform var(--dur-2);
  box-shadow: var(--shadow-1);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── 窄屏 ───────────────────────────────────────────────────────── */
@media (max-width: 899px) {
  .sh { display: block; }
  .rail {
    position: sticky; top: 0; z-index: 60;
    height: auto; flex-direction: row; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-right: 0; border-bottom: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: saturate(1.4) blur(14px);
  }
  .rail__brand { padding: 0; }
  .rail__brand em { display: none; }
  .rail__nav { display: none; }
  .rail__sp { flex: 1 1 auto; }
  .rail__acct {
    flex-direction: row; align-items: center; padding: 0; border: 0;
    margin-left: auto;
  }
  .rail__signin { height: 32px; padding: 0 12px; font-size: 12.5px; }
  .rail__signin svg { display: none; }
  .rail__alt { display: none; }
  .rail__foot { display: none; }

  .main { padding: 18px 16px 90px; }
  .head { align-items: flex-start; margin-bottom: 14px; }
  .head h1 { font-size: 25px; }
  .head__tools { width: 100%; }
  .search { flex: 1 1 160px; }
  .search input { width: 100%; }
  .head__tools .btn { flex: 0 0 auto; }
  .chips { display: flex; }
  .grid { grid-template-columns: repeat(auto-fill, 132px); gap: 22px 14px; justify-content: start; }
  .detail { width: 100%; }
}

/* ⭐ [2026-11-04] 拖拽上传时的整页提示（对应 bookshelf.js 里 html.dropping） */
html.dropping #app::after {
  content: "松手就上传";
  position: fixed; inset: 14px; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(6px);
  color: var(--accent); font-family: var(--font-display); font-size: 1.4rem; letter-spacing: .08em;
  pointer-events: none;
}

/* ⭐ [2026-11-09] 空间配额提示条：快满 = 强调色，已满 = 危险色。
   只占一行，不挡任何操作；文案由 applyQuotaLine() 决定。 */
.quota-note {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: var(--r-m, 10px);
  font-size: 12.5px; line-height: 1.65;
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.quota-note.is-full {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.quota-note b { font-weight: 600; }

/* ⭐ [2026-11-10 鱼干要的批量删除] ───────────────────────────── */
.bk__chk {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .9);
  background: rgba(0, 0, 0, .28);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  pointer-events: none;                 /* 点卡片本身就行，别拦事件 */
}
.bk.is-sel .bk__chk {
  background: var(--danger, #c0392b);
  border-color: var(--danger, #c0392b);
}
.bk.is-sel .bk__chk::after {
  content: ""; position: absolute; left: 5px; top: 2px;
  width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.bk.is-sel {
  outline: 2px solid var(--danger, #c0392b);
  outline-offset: 2px; border-radius: 12px;
}

.bulkbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 999px;
  background: #1d1a17; color: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3);
  z-index: 70;
}
.bulkbar[hidden] { display: none; }
.bulkbar__n { font-size: 13px; opacity: .85; padding: 0 4px; }
.bulkbar .btn { padding: 6px 14px; font-size: 13px; }
