/* ============================================================
   中国教科书图书馆 · 首页样式（v3：沉浸式图书馆主题）
   ============================================================ */

/* ============== 开场动画 · 折叠屏展开 ============== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
  user-select: none;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.splash.is-hide { opacity: 0; pointer-events: none; }
.splash.is-closing { opacity: 1 !important; }

.splash-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(200,155,92,.06) 0%, transparent 50%);
}

.splash-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ===== 书本动画由 splash-animate.css 定义 ===== */

.splash-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255,200,120,.6);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 15;
  pointer-events: none;
  animation: ringExpand 1.8s ease-out forwards;
}
.splash-ring-1 { animation-delay: 0.8s; border-color: rgba(200,155,92,.5); }
.splash-ring-2 { animation-delay: 1.0s; border-color: rgba(180,130,70,.35); }
.splash-ring-3 { animation-delay: 1.2s; border-color: rgba(160,110,55,.2); }
@keyframes ringExpand {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  40%  { opacity: .6; }
  100% { transform: translate(-50%, -50%) scale(28); opacity: 0; }
}

.splash-symbols {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 720px;
  height: 500px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 30;
  overflow: visible;
}
.splash-sym {
  position: absolute;
  font-size: clamp(20px, 3.5vw, 40px);
  font-weight: 900;
  opacity: 0;
  left: 50%;
  top: 70%;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translate3d(-50%, 0, 0) scale(0);
}
/* 不同符号颜色变化 */
.splash-sym:nth-child(6n+1) { color: #c0392b; --sym-glow: rgba(192,57,43,.7); text-shadow: 0 0 14px rgba(192,57,43,.7), 0 0 30px rgba(192,57,43,.35); }
.splash-sym:nth-child(6n+2) { color: #2980b9; --sym-glow: rgba(41,128,185,.7); text-shadow: 0 0 14px rgba(41,128,185,.7), 0 0 30px rgba(41,128,185,.35); }
.splash-sym:nth-child(6n+3) { color: #27ae60; --sym-glow: rgba(39,174,96,.7); text-shadow: 0 0 14px rgba(39,174,96,.7), 0 0 30px rgba(39,174,96,.35); }
.splash-sym:nth-child(6n+4) { color: #e67e22; --sym-glow: rgba(230,126,34,.7); text-shadow: 0 0 14px rgba(230,126,34,.7), 0 0 30px rgba(230,126,34,.35); }
.splash-sym:nth-child(6n+5) { color: #8e44ad; --sym-glow: rgba(142,68,173,.7); text-shadow: 0 0 14px rgba(142,68,173,.7), 0 0 30px rgba(142,68,173,.35); }
.splash-sym:nth-child(6n+6) { color: #d35400; --sym-glow: rgba(211,84,0,.7); text-shadow: 0 0 14px rgba(211,84,0,.7), 0 0 30px rgba(211,84,0,.35); }

.splash-quote {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 50;
  width: 680px;
  height: 470px;
  overflow: hidden;
}
.splash-quote-item {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: quoteShow 6s ease infinite;
  animation-delay: calc(1s + var(--qi) * 1s);
}
@keyframes quoteShow {
  0%    { opacity: 0; transform: translateY(12px) scale(.97); }
  5%    { opacity: 1; transform: translateY(0) scale(1); }
  18%   { opacity: 1; transform: translateY(0) scale(1); }
  26%   { opacity: 0; transform: translateY(-40px) scale(.95); }
  100%  { opacity: 0; transform: translateY(-40px) scale(.95); }
}
.splash-quote-text {
  font-size: clamp(22px, 3.5vw, 38px);
  font-weight: 700;
  letter-spacing: 4px;
  margin: 0 0 14px;
  color: #5a3a1a;
  text-shadow:
    0 0 20px rgba(255,230,160,.8),
    0 0 40px rgba(255,210,120,.4),
    0 2px 6px rgba(0,0,0,.5);
}
.splash-quote-author {
  font-size: 15px;
  letter-spacing: 6px;
  color: #8a6a3a;
  margin: 0;
  text-shadow: 0 0 12px rgba(255,230,160,.5), 0 1px 3px rgba(0,0,0,.4);
  align-self: flex-end;
  margin-right: 20%;
}

.splash-skip {
  position: absolute;
  top: 28px;
  right: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(30,18,8,.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(200,155,92,.25);
  color: #f7e3bf;
  font-size: 14px;
  letter-spacing: 3px;
  cursor: pointer;
  z-index: 200;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  user-select: none;
  opacity: 0;
  animation: skipFadeIn .5s ease forwards;
  box-shadow: 0 2px 12px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.06);
}
.splash-skip:hover {
  background: rgba(200,155,92,.18);
  border-color: rgba(200,155,92,.65);
  transform: translateX(-2px);
  box-shadow: 0 4px 20px rgba(200,155,92,.15), inset 0 1px 0 rgba(255,255,255,.08);
  color: #fff3dc;
}
.splash-skip:active {
  transform: translateX(-2px) scale(.96);
  transition-duration: .1s;
}
@keyframes skipFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.splash-progress {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  width: min(420px, 65vw);
  height: 3px;
  background: rgba(255,255,255,.05);
  border-radius: 2px;
  overflow: hidden;
  z-index: 200;
}
.splash-progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #c89b5c 0%, #f7e3bf 50%, #c89b5c 100%);
  box-shadow: 0 0 16px rgba(255,200,120,.5);
  animation: progressFill 5s linear forwards;
}
@keyframes progressFill { to { width: 100%; } }

/* 主内容在动画期间隐藏，动画结束后淡入 */
body:not(.splash-done) .lib-header,
body:not(.splash-done) .stage-tabs,
body:not(.splash-done) .lib-breadcrumb,
body:not(.splash-done) .publisher-bar,
body:not(.splash-done) .library,
body:not(.splash-done) .lib-footer { opacity: 0; }
body.splash-done .lib-header,
body.splash-done .stage-tabs,
body.splash-done .lib-breadcrumb,
body.splash-done .publisher-bar,
body.splash-done .library,
body.splash-done .lib-footer { opacity: 1; transition: opacity .9s ease .15s; }

@media (max-width: 768px) {
  .splash-symbols { width: 420px; height: 300px; }
  .splash-sym { font-size: clamp(16px, 5vw, 28px); }
  .splash-quote { width: 380px; height: 270px; }
  .splash-quote-text { font-size: 18px; }
  .splash-skip { top: 16px; right: 16px; font-size: 13px; padding: 10px 16px; }
  .splash-progress { bottom: 24px; width: 80vw; }
}

*, *::before, *::after { box-sizing: border-box; }

:root {
  --wood-1: #6b3f1d;
  --wood-2: #8a5430;
  --wood-3: #4a2a12;
  --wood-dark: #2a160a;
  --wood-shadow: rgba(0, 0, 0, .55);
  --shelf-edge: #3d1f0b;
  --paper: #f6efe0;
  --paper-dim: #e8dcc3;
  --ink: #2b2118;
  --accent: #c89b5c;
  --accent-light: #e8c680;
  --accent-glow: rgba(200, 155, 92, .25);
  --bg-deep: #1a120b;
  --bg-surface: rgba(26, 18, 11, .78);
  --glass: rgba(26, 18, 11, .72);
  --text-main: #f7e3bf;
  --text-dim: #c9b48d;
  --text-muted: #a8916b;
  --success: #4caf50;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --shadow-md: 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.45);
  --transition: all .25s cubic-bezier(.4, 0, .2, 1);
}

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background:
    /* 顶层：暖光晕 */
    radial-gradient(ellipse at 20% 0%, rgba(200, 155, 92, .10) 0%, transparent 45%),
    radial-gradient(ellipse at 80% 0%, rgba(200, 155, 92, .08) 0%, transparent 40%),
    /* 中层：书架竖线纹理 */
    repeating-linear-gradient(90deg,
      rgba(0,0,0,.18) 0 2px,
      transparent 2px 36px,
      rgba(255,255,255,.03) 36px 38px,
      transparent 38px 72px
    ),
    /* 底层：深木色 */
    linear-gradient(180deg, #24180f 0%, #1a120b 40%, #0f0905 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ===== 顶部品牌区 ===== */
.lib-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 40px;
  border-bottom: 1px solid rgba(200, 155, 92, .22);
  background:
    linear-gradient(180deg, rgba(20,13,7,.92), rgba(20,13,7,.78)),
    repeating-linear-gradient(90deg, rgba(0,0,0,.2) 0 2px, transparent 2px 48px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.lib-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.lib-logo {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(200,155,92,.18), rgba(200,155,92,.05));
  border: 1px solid rgba(200, 155, 92, .35);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    0 4px 12px rgba(0,0,0,.3);
  overflow: hidden;
}
.lib-logo img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.lib-titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-main);
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}

.lib-sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: .5px;
}

.lib-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.lib-search::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: .7;
  pointer-events: none;
}
.lib-search input {
  width: 100%;
  padding: 11px 16px 11px 38px;
  border: 1px solid rgba(200, 155, 92, .35);
  border-radius: 26px;
  background: rgba(0,0,0,.22);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  box-shadow: inset 0 1px 4px rgba(0,0,0,.2);
}
.lib-search input::placeholder { color: var(--text-muted); }
.lib-search input:focus {
  border-color: var(--accent);
  background: rgba(0,0,0,.32);
  box-shadow:
    inset 0 1px 4px rgba(0,0,0,.25),
    0 0 0 3px var(--accent-glow);
}

/* ===== 多选下载按钮 ===== */
.lib-select-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(200, 155, 92, .35);
  border-radius: 24px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.lib-select-btn::before {
  content: '☐';
  font-size: 14px;
}
.lib-select-btn:hover {
  background: rgba(200, 155, 92, .12);
  color: var(--text-main);
  border-color: var(--accent);
}

.lib-fullscreen-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(200, 155, 92, .35);
  border-radius: 20px;
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.lib-fullscreen-btn:hover {
  background: rgba(200, 155, 92, .12);
  color: var(--text-main);
  border-color: var(--accent);
}
.lib-fullscreen-btn .icon-exit { display: none; }
.lib-fullscreen-btn.in-fullscreen .icon-enter { display: none; }
.lib-fullscreen-btn.in-fullscreen .icon-exit { display: block; }

body.select-mode .lib-select-btn {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(200, 155, 92, .35);
}
body.select-mode .lib-select-btn::before { content: '✓'; }

/* ===== 选择操作栏 ===== */
.select-bar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 40px;
  background: rgba(20, 13, 7, .88);
  border-bottom: 1px solid rgba(200, 155, 92, .22);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.select-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: .5px;
}

/* ===== 出版社筛选条（独立于多选按钮） ===== */
.publisher-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 40px;
  background: linear-gradient(180deg, rgba(20,13,7,.45), transparent);
  border-bottom: 1px solid rgba(200, 155, 92, .12);
  flex-wrap: wrap;
}
.publisher-bar-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: .5px;
  flex: 0 0 auto;
}
.publisher-bar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.publisher-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(200, 155, 92, .22);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.publisher-tag:hover {
  color: var(--text-main);
  background: rgba(200, 155, 92, .12);
  border-color: rgba(200, 155, 92, .4);
}
.publisher-tag.active {
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(200, 155, 92, .25);
  font-weight: 600;
}
.select-count .select-size {
  color: var(--accent-light);
  font-weight: 700;
}
.select-bar-actions { display: flex; gap: 10px; }
.select-download-btn, .select-cancel-btn, .select-all-btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid rgba(200, 155, 92, .4);
  cursor: pointer;
  transition: var(--transition);
}
.select-download-btn {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(200, 155, 92, .25);
}
.select-download-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.select-download-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  filter: none;
  transform: none;
}
.select-cancel-btn {
  background: rgba(255,255,255,.05);
  color: var(--text-dim);
}
.select-cancel-btn:hover { background: rgba(255,255,255,.12); color: var(--text-main); }
.select-all-btn {
  background: rgba(200, 155, 92, .12);
  color: var(--text-dim);
}
.select-all-btn:hover { background: rgba(200, 155, 92, .22); color: var(--text-main); }

/* ===== 面包屑 ===== */
.lib-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 40px;
  font-size: 13px;
  color: var(--text-dim);
  background: linear-gradient(180deg, rgba(20,13,7,.55), transparent);
}
.crumb {
  color: var(--text-dim);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 16px;
  background: rgba(0,0,0,.12);
  border: 1px solid rgba(200, 155, 92, .12);
  transition: var(--transition);
}
.crumb:hover {
  background: rgba(200, 155, 92, .12);
  color: var(--text-main);
  border-color: rgba(200, 155, 92, .3);
}
.crumb.active {
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  font-weight: 700;
  cursor: default;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(200, 155, 92, .25);
}
.crumb-sep {
  color: var(--text-muted);
  user-select: none;
  font-size: 11px;
}

/* ===== 学段 Tab ===== */
.stage-tabs {
  display: none;
  align-items: stretch;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 40px 18px;
  background: linear-gradient(180deg, rgba(20,13,7,.55), transparent);
}

@media (max-width: 1100px) {
  .stage-tabs {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(200,155,92,.3) transparent;
  }
  .stage-tabs::-webkit-scrollbar { height: 4px; }
  .stage-tabs::-webkit-scrollbar-thumb { background: rgba(200,155,92,.3); border-radius: 2px; }
}

.stage-tab-card {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 200px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-main);
  background:
    linear-gradient(135deg, rgba(255,255,255,.06), rgba(0,0,0,.18)),
    linear-gradient(135deg, var(--tab-accent, #c89b5c) 0%, rgba(0,0,0,0) 55%);
  border: 1px solid rgba(200, 155, 92, .2);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stage-tab-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--tab-accent, var(--accent));
}
.stage-tab-card:hover {
  transform: translateY(-3px);
  border-color: rgba(200, 155, 92, .4);
  box-shadow: var(--shadow-md);
}
.stage-tab-card.active {
  background:
    linear-gradient(135deg, rgba(255,255,255,.12), rgba(0,0,0,.1)),
    linear-gradient(135deg, var(--tab-accent, #c89b5c) 0%, rgba(0,0,0,0) 70%);
  border-color: var(--tab-accent, var(--accent));
  box-shadow:
    0 0 0 3px var(--tab-accent, var(--accent)),
    0 16px 34px -10px rgba(0,0,0,.6),
    0 0 32px rgba(200, 155, 92, .35);
  transform: translateY(-4px) scale(1.02);
}
.stage-tab-card.active::before {
  width: 5px;
  box-shadow: 0 0 16px var(--tab-accent, var(--accent));
}
.stage-tab-card.active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 12px solid var(--tab-accent, var(--accent));
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
  z-index: 2;
}
.stage-tab-card.active .stage-tab-card-icon {
  background: rgba(0,0,0,.35);
  border-color: rgba(255,255,255,.2);
}
.stage-tab-card-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  flex-shrink: 0;
}
.stage-tab-card-body { flex: 1; min-width: 0; }
.stage-tab-card-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-tab-card-tag {
  font-size: 10px;
  font-weight: 600;
  opacity: .75;
  margin-left: 2px;
  white-space: nowrap;
}
.stage-tab-card-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ===== 主区 ===== */
.library {
  padding: 28px 40px 100px;
  min-height: calc(100vh - 140px);
}
.library-loading {
  text-align: center;
  color: var(--text-dim);
  padding: 100px 20px;
  font-size: 15px;
}
.empty {
  padding: 100px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.8;
}

/* ===== 学科卡片 ===== */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  animation: fadeUp .45s ease both;
}
.subject-card {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 120px;
  text-decoration: none;
  color: var(--text-main);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.18));
  border-radius: var(--radius-sm);
  border: 1px solid rgba(200, 155, 92, .18);
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.subject-card:hover {
  transform: translateY(-4px) rotateY(-2deg);
  border-color: var(--subject-color, var(--accent));
  box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
}
.subject-card-spine {
  width: 16px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.35), transparent 40%, transparent 60%, rgba(255,255,255,.1)),
    var(--subject-color, var(--accent));
  box-shadow:
    inset -2px 0 0 rgba(0,0,0,.25),
    inset 2px 0 0 rgba(255,255,255,.15);
}
.subject-card-body {
  flex: 1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.subject-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 2px;
}
.subject-card-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== 书架包裹 ===== */
.subject-shelf-wrap {
  display: flex;
  flex-direction: column;
  gap: 26px;
  animation: fadeUp .45s ease both;
}
.subject-shelf-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 3px;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.subject-color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255,255,255,.06), 0 0 12px currentColor;
}

/* 版本组 */
.edition-group {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(200, 155, 92, .1);
}
.edition-group:last-child { border-bottom: none; }
.edition-label {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: 6px 0 10px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  border-radius: 12px;
  letter-spacing: .5px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(200, 155, 92, .25);
}
.edition-meta { color: rgba(26,18,11,.6); font-weight: 600; }

.group-label {
  display: block;
  margin: 20px 0 10px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(200, 155, 92, .25);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  letter-spacing: 2px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}
.shelf-more {
  margin-top: 10px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  background: rgba(0,0,0,.12);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(200, 155, 92, .15);
}

/* === 书封网格 === */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 18px;
  padding: 6px 0 22px;
  position: relative;
}
/* 书架层板 */
.book-grid::after {
  content: '';
  position: absolute;
  left: -12px; right: -12px; bottom: 0;
  height: 10px;
  background:
    linear-gradient(180deg, #5c3618, #3d1f0b 60%, #1a0d04);
  border-radius: 0 0 8px 8px;
  box-shadow:
    0 6px 14px rgba(0,0,0,.55),
    inset 0 2px 0 rgba(255,255,255,.08);
  pointer-events: none;
}

/* 单本书封 */
.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  transition: var(--transition);
  transform-style: preserve-3d;
  perspective: 800px;
}
.book-card:hover {
  transform: translateY(-8px);
  z-index: 2;
}
.book-card-cover {
  position: relative;
  flex: none;
  aspect-ratio: 1 / 1.414;
  display: flex;
  flex-direction: column;
  padding: 10px;
  border-radius: 4px 10px 0 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 38%, rgba(0,0,0,.2) 100%),
    linear-gradient(180deg, var(--book-color, #6c7a89), var(--book-color-deep, #3a4248));
  box-shadow:
    inset 7px 0 0 rgba(0,0,0,.22),
    inset 10px 0 18px rgba(0,0,0,.18),
    0 14px 24px -10px rgba(0,0,0,.75);
  overflow: hidden;
  transition: var(--transition);
}
.book-card:hover .book-card-cover {
  box-shadow:
    inset 7px 0 0 rgba(0,0,0,.22),
    inset 10px 0 18px rgba(0,0,0,.18),
    0 26px 40px -12px rgba(0,0,0,.8),
    0 0 0 2px rgba(200, 155, 92, .5);
}
/* 书脊（左侧深色一道） */
.book-card-stripe {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 7px;
  background: linear-gradient(180deg, rgba(0,0,0,.4), rgba(0,0,0,.15));
  box-shadow: inset -1px 0 0 rgba(255,255,255,.2);
  z-index: 4;
}

/* PDF 首页缩略图（懒加载后填充 src） */
.book-card-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
  opacity: 0;
  transition: opacity .45s ease;
  z-index: 1;
}
.book-card.has-cover .book-card-thumb {
  opacity: 1;
}
.book-card.has-cover .book-card-fallback,
.book-card.has-cover .book-card-loading {
  opacity: 0;
  pointer-events: none;
}

/* 封面加载中动画 */
.book-card-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  z-index: 3;
  background: rgba(0,0,0,.12);
  transition: opacity .3s;
}
.book-card-loading .loading-text {
  font-size: 11px;
  color: rgba(255,255,255,.85);
  letter-spacing: 2px;
}
.book-card-loading .loading-dots {
  font-size: 18px;
  color: rgba(255,255,255,.8);
  animation: dotsBlink 1.5s infinite;
}
@keyframes dotsBlink {
  0%, 50% { opacity: .3; }
  25%, 75% { opacity: 1; }
}

/* 文字回退层（默认显示，渲染前的占位）*/
.book-card-fallback {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px 2px 0;
  transition: opacity .25s;
}
.book-card-fallback .book-card-title { padding-top: 0; }
.book-card-fallback .book-card-foot { margin-top: auto; padding-bottom: 4px; }

/* 封面下方信息区域 */
.book-card-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 10px 6px 7px;
  gap: 5px;
  background: linear-gradient(180deg, rgba(30,20,12,.95), rgba(20,13,7,.95));
  border-radius: 0 0 5px 5px;
  border-top: 1px solid rgba(200, 155, 92, .18);
  flex-shrink: 0;
  overflow: visible;
  box-shadow: 0 6px 14px rgba(0,0,0,.35);
}
.book-card-grade {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text-main);
  text-align: center;
  background: rgba(0,0,0,.4);
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid rgba(200, 155, 92, .25);
}
.book-card-grade:empty { display: none; }
.book-card-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.book-card-row:empty { display: none; }
.book-card-size {
  display: none;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  background: rgba(0,0,0,.3);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(200, 155, 92, .12);
}
body.select-mode .book-card-size { display: block; }
/* 书封顶部反光 */
.book-card-cover::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(255,255,255,.2), transparent);
  pointer-events: none;
}
/* 书封纸张纹理 */
.book-card-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 2px, transparent 2px 4px);
  pointer-events: none;
  opacity: .5;
}

/* 大徽章：「一上」「三下」「七年级」等 */
.book-card-badge {
  position: relative;
  z-index: 2;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1.1;
  text-align: center;
  margin-top: 8px;
  margin-bottom: 10px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
  padding: 8px 4px;
  border-top: 1px solid rgba(255,255,255,.4);
  border-bottom: 1px solid rgba(255,255,255,.4);
}
.book-card-badge:empty { display: none; }

/* 中段：书名（去前缀） */
.book-card-title {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  max-height: calc(14px * 1.5 * 3); /* 3行限制 */
  letter-spacing: .5px;
  text-align: center;
  padding: 4px 2px 0;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
  mask-image: linear-gradient(to bottom, black calc(100% - 1.2em), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 1.2em), transparent 100%);
}

/* 底部 meta（版本 / 学科） */
.book-card-foot {
  position: relative;
  z-index: 2;
  text-align: center;
  margin-top: 6px;
}
.book-card-meta {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .5px;
  color: rgba(255,255,255,.9);
  background: rgba(0,0,0,.32);
  padding: 3px 8px;
  border-radius: 8px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 阅读进度 */
.book-card-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  width: calc(100% - 8px);
}
.book-card-progress > span {
  display: inline-block;
  background: rgba(0,0,0,.4);
  padding: 3px 10px;
  border-radius: 10px;
  letter-spacing: .5px;
}
.book-card-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(0,0,0,.4);
  border-radius: 2px;
  overflow: hidden;
}
.book-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd28a, #ffb454);
  box-shadow: 0 0 8px rgba(255, 180, 84, .4);
}

/* 底部书页厚度 */
.book-card-base {
  flex-shrink: 0;
  height: 8px;
  margin: -3px 5px 0;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.6));
  border-radius: 0 0 5px 5px;
  box-shadow: 0 5px 10px rgba(0,0,0,.45);
}

/* ===== 书卡复选框（多选下载模式） ===== */
.book-card-checkbox {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 10;
  width: 30px;
  height: 30px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(0, 0, 0, .5);
  border: 2px solid rgba(255, 255, 255, .7);
  border-radius: 50%;
  outline: none;
  transition: var(--transition);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
}
.book-card-checkbox:hover {
  border-color: #fff;
  background: rgba(0, 0, 0, .6);
  transform: scale(1.12);
}
.book-card-checkbox:checked {
  background: var(--success);
  border-color: #fff;
  box-shadow: 0 3px 12px rgba(76, 175, 80, .55);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 12 10 16 18 8'/%3E%3C/svg%3E");
  background-size: 17px;
  background-position: center;
  background-repeat: no-repeat;
}
body.select-mode .book-card-checkbox { display: block; }
body.select-mode .book-card.selected .book-card-cover {
  box-shadow:
    inset 7px 0 0 rgba(0,0,0,.22),
    inset 10px 0 18px rgba(0,0,0,.18),
    0 0 0 3px var(--success),
    0 0 20px rgba(76, 175, 80, .25);
}
body.select-mode .book-card.selected .book-card-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(76, 175, 80, .1);
  border-radius: inherit;
  pointer-events: none;
}
body.select-mode .book-card { cursor: pointer; }

/* ===== 底部 ===== */
.lib-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 32px;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(13, 8, 5, .92);
  border-top: 1px solid rgba(200, 155, 92, .18);
  backdrop-filter: blur(6px);
  z-index: 40;
}
.lib-footer-center {
  font-size: 11px;
  color: var(--text-muted);
  opacity: .6;
}
.lib-footer code {
  color: var(--text-dim);
  background: rgba(255,255,255,.06);
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 600;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 自定义确认弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.modal-box {
  width: min(92vw, 420px);
  padding: 32px 28px 24px;
  background:
    linear-gradient(180deg, rgba(42,30,18,.95), rgba(20,13,7,.98));
  border: 1px solid rgba(200, 155, 92, .4);
  border-radius: var(--radius-md);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, .75),
    inset 0 1px 0 rgba(255,255,255,.06);
  text-align: center;
  transform: scale(.9) translateY(10px);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.modal-overlay.show .modal-box {
  transform: scale(1) translateY(0);
}
.modal-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--text-main);
  background: linear-gradient(135deg, rgba(200,155,92,.18), rgba(200,155,92,.05));
  border: 1px solid rgba(200, 155, 92, .3);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(200, 155, 92, .15);
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 14px;
  letter-spacing: 1px;
}
.modal-body {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-dim);
  margin: 0 0 26px;
  white-space: pre-line;
}
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
}
.modal-btn {
  padding: 10px 26px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 24px;
  border: 1px solid rgba(200, 155, 92, .35);
  cursor: pointer;
  transition: var(--transition);
  min-width: 110px;
}
.modal-btn:active { transform: scale(.96); }
.modal-cancel {
  color: var(--text-dim);
  background: rgba(255, 255, 255, .06);
}
.modal-cancel:hover { background: rgba(255, 255, 255, .14); color: var(--text-main); }
.modal-confirm {
  color: var(--ink);
  background: linear-gradient(180deg, var(--accent-light), var(--accent));
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(200, 155, 92, .3);
}
.modal-confirm:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .lib-header {
    flex-wrap: wrap;
    padding: 14px 18px;
    gap: 12px;
  }
  .lib-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .lib-select-btn {
    order: 2;
    padding: 7px 14px;
    font-size: 12px;
  }
  .lib-fullscreen-btn {
    order: 1;
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 720px) {
  .lib-brand { gap: 10px; }
  .lib-logo { width: 38px; height: 38px; }
  .lib-logo img { width: 24px; height: 24px; }
  .lib-titles h1 { font-size: 16px; }
  .lib-sub { font-size: 11px; }

  .select-bar { padding: 10px 18px; }
  .select-bar-actions { gap: 8px; }
  .select-download-btn, .select-cancel-btn, .select-all-btn { padding: 7px 12px; font-size: 12px; }
  .publisher-bar { padding: 10px 18px; }
  .publisher-tag { padding: 4px 10px; font-size: 11px; }

  .lib-breadcrumb, .library, .stage-tabs { padding-left: 18px; padding-right: 18px; }

  .stage-tabs {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 16px 18px 20px;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(200,155,92,.3) transparent;
  }
  .stage-tabs::-webkit-scrollbar { height: 4px; }
  .stage-tabs::-webkit-scrollbar-thumb { background: rgba(200,155,92,.3); border-radius: 2px; }
  .stage-tab-card { flex: 0 0 auto; width: 160px; padding: 12px 14px; gap: 10px; }
  .stage-tab-card-icon { width: 32px; height: 32px; font-size: 18px; flex-shrink: 0; }
  .stage-tab-card-title { font-size: 14px; }
  .stage-tab-card-tag { font-size: 10px; }
  .stage-tab-card-meta { font-size: 10px; }

  .subject-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .subject-card { height: 100px; }
  .subject-card-title { font-size: 15px; letter-spacing: 1px; }
  .subject-card-meta { font-size: 11px; }

  .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px 12px; }
  .book-card-title { font-size: 12px; }
  .book-card-grade { font-size: 11px; }

  .lib-footer {
    flex-direction: column;
    gap: 4px;
    padding: 8px 18px;
    font-size: 11px;
    text-align: center;
  }
  .modal-box { padding: 26px 22px 20px; }
  .modal-actions { gap: 10px; }
  .modal-btn { padding: 9px 18px; min-width: 90px; }
}

@media (max-width: 400px) {
  .lib-sub { display: none; }
  .lib-titles h1 { font-size: 14px; }
  .lib-select-btn { padding: 6px 12px; font-size: 11px; }
}

@media (min-width: 721px) and (max-width: 1100px) {
  .lib-header { padding: 16px 28px; }
  .library { padding-left: 28px; padding-right: 28px; }
  .subject-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (min-width: 1440px) {
  .library { padding-left: 60px; padding-right: 60px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
