/* ==========================================================================
   栩良图书馆 - 统一样式表 v2
   ==========================================================================
   设计目标：
   - 移动优先 (Mobile First)
   - 完美适配：手机/平板/桌面/超宽屏
   - 触摸优化：点击区域 ≥ 44px
   - 性能：纯 CSS，零运行时
   - 排版：中文优先，雅致易读

   断点：
   - sm:  < 600px   手机竖屏
   - md:  600-1024  手机横屏 / 平板
   - lg:  1024-1280 桌面
   - xl:  ≥ 1280   超宽屏
   ========================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
  /* 颜色 */
  --c-bg:        #f7f3ec;
  --c-bg-soft:   #fdfaf5;
  --c-ink:       #1a1714;
  --c-ink-soft:  #4a4540;
  --c-muted:     #7a7066;
  --c-line:      #e0d5c5;
  --c-line-soft: #ede4d4;
  --c-accent:    #b8412b;
  --c-accent-soft: #d4a99a;
  --c-gold:      #c69b54;
  --c-success:   #2d6a3a;
  --c-error:     #b8412b;
  --c-warn:      #8a5a1c;

  /* 字体 */
  --font-serif: "Noto Serif SC", "Source Han Serif SC", -apple-system, "PingFang SC", "Microsoft YaHei", serif;
  --font-sans:  -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono:  "SF Mono", "JetBrains Mono", Consolas, monospace;

  /* 尺寸 */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.12);

  /* 动效 */
  --t-fast: 0.15s ease;
  --t-base: 0.25s ease;
  --t-slow: 0.4s ease;

  /* 布局 */
  --container: 1200px;
  --gap: 1rem;
}

/* ---------- 2. 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* 防止移动端字号过小 */
@media (max-width: 600px) {
  body { font-size: 15px; }
}

a { color: var(--c-accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: #8c2f1f; }

img, video { max-width: 100%; height: auto; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-weight: 700; line-height: 1.4; color: var(--c-ink);
  margin: 1.5em 0 0.5em;
}
h1 { font-size: 1.8em; }
h2 { font-size: 1.4em; }
h3 { font-size: 1.15em; }

/* ---------- 3. 布局容器 ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.25rem;
}

@media (min-width: 600px) {
  .container { padding: 0 2rem; }
}

.row { display: flex; flex-wrap: wrap; gap: var(--gap); }
.col { flex: 1 1 0%; min-width: 0; }

/* 移动端默认单列 */
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- 4. 顶部导航 ---------- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-line);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1.25rem; max-width: var(--container);
  margin: 0 auto; gap: 1rem;
}

.logo {
  font-size: 1.125rem; font-weight: 700;
  letter-spacing: 0.05em; color: var(--c-ink);
  display: flex; align-items: center; gap: 0.5rem;
  white-space: nowrap; flex-shrink: 0;
}
.logo small { font-size: 0.6em; color: var(--c-muted); font-weight: 400; display: none; }

@media (min-width: 600px) {
  .header-inner { padding: 1rem 2rem; }
  .logo { font-size: 1.25rem; }
  .logo small { display: inline; }
}

.nav-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: none; background: transparent;
  cursor: pointer; color: var(--c-ink); border-radius: var(--r-sm);
}
.nav-toggle:hover { background: var(--c-line-soft); }
.nav-toggle svg { width: 24px; height: 24px; }

@media (min-width: 1024px) {
  .nav-toggle { display: none; }
}

.nav-links {
  display: none; list-style: none;
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border-bottom: 1px solid var(--c-line);
  padding: 0.5rem 0; box-shadow: var(--shadow-md);
}
.nav-links.open { display: block; }
.nav-links li { display: block; }
.nav-links a {
  display: block; padding: 0.875rem 1.5rem;
  color: var(--c-ink); font-size: 1rem;
  border-left: 3px solid transparent; transition: all var(--t-fast);
}
.nav-links a:hover, .nav-links a.active {
  color: var(--c-accent);
  background: var(--c-bg-soft);
  border-left-color: var(--c-accent);
  text-decoration: none;
}

@media (min-width: 1024px) {
  .nav-links {
    display: flex !important; position: static;
    background: transparent; border: none; box-shadow: none;
    padding: 0; gap: 0.25rem; flex-wrap: wrap;
  }
  .nav-links li { display: inline-flex; }
  .nav-links a {
    padding: 0.5rem 1rem; font-size: 0.95rem;
    border-left: none; border-bottom: 2px solid transparent;
    border-radius: var(--r-sm);
  }
  .nav-links a:hover, .nav-links a.active {
    background: var(--c-bg-soft);
    border-bottom-color: var(--c-accent);
  }
}

/* ---------- 5. Hero ---------- */
.hero {
  text-align: center;
  padding: 3rem 1.25rem 2rem;
}
@media (min-width: 600px) { .hero { padding: 4rem 2rem 3rem; } }
@media (min-width: 1024px) { .hero { padding: 5rem 2rem 3rem; } }

.hero h1 {
  font-size: 1.75rem; margin: 0 0 0.75rem; letter-spacing: 0.05em;
}
@media (min-width: 600px) { .hero h1 { font-size: 2.25rem; } }
@media (min-width: 1024px) { .hero h1 { font-size: 2.75rem; } }

.hero p { color: var(--c-muted); font-size: 1rem; max-width: 600px; margin: 0 auto; }
@media (min-width: 600px) { .hero p { font-size: 1.1rem; } }

.hero .stats {
  display: flex; gap: 1.5rem; justify-content: center;
  margin-top: 1.5rem; flex-wrap: wrap;
}
.hero .stat strong { display: block; font-size: 1.75rem; color: var(--c-accent); }
.hero .stat span { font-size: 0.85rem; color: var(--c-muted); }
@media (min-width: 600px) {
  .hero .stats { gap: 2.5rem; }
  .hero .stat strong { font-size: 2.25rem; }
}

/* ---------- 6. 卡片 ---------- */
.card {
  background: #fff; border: 1px solid var(--c-line);
  border-radius: var(--r-md); padding: 1rem;
  transition: all var(--t-base);
}
@media (min-width: 600px) { .card { padding: 1.5rem; } }

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-gold);
}

.card-cover { font-size: 2.5rem; margin-bottom: 0.5rem; }
@media (min-width: 600px) { .card-cover { font-size: 3rem; } }

.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.25rem; }
@media (min-width: 600px) { .card-title { font-size: 1.15rem; } }

.card-meta { font-size: 0.8rem; color: var(--c-muted); margin-bottom: 0.5rem; }
.card-desc {
  font-size: 0.875rem; color: var(--c-ink-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 7. 徽章 / 标签 ---------- */
.badge {
  display: inline-block;
  padding: 0.2em 0.625em; border-radius: var(--r-pill);
  font-size: 0.7rem; background: var(--c-bg-soft); color: var(--c-accent);
  border: 1px solid var(--c-line-soft);
  white-space: nowrap;
}
.badge.level { background: #eef5ee; color: var(--c-success); border-color: #c2dec5; }
.badge.cat   { background: #fff5e0; color: var(--c-warn); border-color: #e5d2a6; }
.badge.tag   { background: #f3f4f6; color: var(--c-muted); }

/* ---------- 8. 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.625rem 1.5rem;
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: #fff; color: var(--c-ink); cursor: pointer;
  font-size: 0.95rem; font-weight: 500; text-decoration: none;
  transition: all var(--t-fast); user-select: none;
  gap: 0.5rem; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--c-accent); color: #fff; }
.btn.primary:hover { background: #8c2f1f; color: #fff; }
.btn.outline { border-color: var(--c-accent); color: var(--c-accent); }
.btn.outline:hover { background: var(--c-accent); color: #fff; }
.btn.danger  { background: #dc2626; color: #fff; }
.btn.danger:hover  { background: #b91c1c; }
.btn.sm      { min-height: 36px; padding: 0.375rem 0.875rem; font-size: 0.85rem; }
.btn.full    { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- 9. 表单 ---------- */
label {
  display: block; margin: 0.75rem 0 0.375rem;
  color: var(--c-ink-soft); font-size: 0.875rem; font-weight: 500;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="url"],
input[type="file"], select, textarea {
  width: 100%; min-height: 44px; padding: 0.625rem 0.875rem;
  border: 1px solid var(--c-line); border-radius: var(--r-sm);
  background: #fff; color: var(--c-ink); font-size: 1rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(184, 65, 43, 0.1);
}
textarea { min-height: 100px; resize: vertical; }
input[type="checkbox"] { min-height: auto; width: 1.125rem; height: 1.125rem; }

/* ---------- 10. 提示框 ---------- */
.flash {
  margin: 1rem auto; max-width: var(--container);
  padding: 0.75rem 1rem; border-radius: var(--r-sm);
  font-size: 0.9rem; border: 1px solid;
}
.flash.success { background: #d1fae5; color: #065f46; border-color: #a7e3c1; }
.flash.error   { background: #fde7e2; color: var(--c-error); border-color: #f0c0b3; }
.flash.warning { background: #fff5e0; color: var(--c-warn); border-color: #e5d2a6; }
.flash.info    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* ---------- 11. 分类筛选 ---------- */
.filter {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  padding: 1rem 0; margin: 1.5rem 0;
  border-top: 1px solid var(--c-line);
  border-bottom: 1px solid var(--c-line);
}
.filter button {
  background: #fff; border: 1px solid var(--c-line); color: var(--c-ink);
  padding: 0.5rem 1rem; min-height: 36px;
  border-radius: var(--r-pill); cursor: pointer; font-size: 0.875rem;
  transition: all var(--t-fast);
}
.filter button:hover, .filter button.active {
  background: var(--c-accent); color: #fff; border-color: var(--c-accent);
}

/* ---------- 12. 表格（响应式） ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td {
  padding: 0.625rem 0.75rem; text-align: left;
  border-bottom: 1px solid var(--c-line); font-size: 0.875rem;
}
th { background: var(--c-bg-soft); color: var(--c-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:hover { background: var(--c-bg-soft); }

/* 移动端表格折叠 */
@media (max-width: 600px) {
  table.responsive thead { display: none; }
  table.responsive tr {
    display: block; margin-bottom: 0.5rem; padding: 0.75rem;
    background: #fff; border: 1px solid var(--c-line); border-radius: var(--r-sm);
  }
  table.responsive td {
    display: flex; justify-content: space-between; padding: 0.375rem 0;
    border: none; font-size: 0.9rem;
  }
  table.responsive td::before {
    content: attr(data-label); font-weight: 600; color: var(--c-muted);
    margin-right: 1rem; font-size: 0.8rem;
  }
  table.responsive td:last-child { padding-top: 0.5rem; border-top: 1px solid var(--c-line-soft); margin-top: 0.5rem; }
}

/* ---------- 13. 分页 ---------- */
.pagination {
  display: flex; gap: 0.25rem; justify-content: center;
  margin-top: 1.5rem; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: 40px; padding: 0 0.75rem;
  border: 1px solid var(--c-line); border-radius: var(--r-sm);
  color: var(--c-ink-soft); text-decoration: none; font-size: 0.9rem;
  transition: all var(--t-fast);
}
.pagination a:hover { background: var(--c-bg-soft); }
.pagination .current { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }

/* ---------- 14. 详情页 ---------- */
.detail-hero {
  display: flex; flex-direction: column; gap: 1rem;
  background: #fff; border: 1px solid var(--c-line);
  border-radius: var(--r-md); padding: 1.25rem; margin-bottom: 1.5rem;
}
@media (min-width: 600px) {
  .detail-hero { flex-direction: row; gap: 1.5rem; padding: 1.75rem; }
}
.detail-cover { font-size: 4rem; text-align: center; flex-shrink: 0; }
@media (min-width: 600px) { .detail-cover { font-size: 5rem; } }
.detail-info { flex: 1; min-width: 0; }
.detail-info h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
@media (min-width: 600px) { .detail-info h1 { font-size: 1.75rem; } }
.detail-info .meta { color: var(--c-muted); font-size: 0.875rem; margin-bottom: 0.75rem; }

/* ---------- 15. AI 预测页 ---------- */
.predict-card {
  max-width: 480px; margin: 1.5rem auto; padding: 1.5rem 1.25rem;
  text-align: center; background: #fff; border: 2px dashed var(--c-gold);
  border-radius: var(--r-lg);
}
@media (min-width: 600px) { .predict-card { padding: 2.5rem 2rem; } }
.predict-seal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; margin-bottom: 1rem;
  background: var(--c-gold); color: var(--c-ink);
  font-size: 1.5rem; font-weight: 700; border-radius: 50%;
  letter-spacing: 0.1em;
}
@media (min-width: 600px) { .predict-seal { width: 80px; height: 80px; font-size: 1.75rem; } }
.predict-card h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
@media (min-width: 600px) { .predict-card h1 { font-size: 1.75rem; } }
.predict-card ul { list-style: none; text-align: left; margin: 1.25rem 0; padding: 1rem; background: var(--c-bg-soft); border-radius: var(--r-md); }
.predict-card li { padding: 0.4rem 0; font-size: 0.95rem; color: var(--c-ink-soft); }

/* ---------- 16. 底部 ---------- */
footer {
  border-top: 1px solid var(--c-line); padding: 1.5rem 1.25rem;
  text-align: center; color: var(--c-muted); font-size: 0.85rem;
  margin-top: 2rem; line-height: 1.8;
}

/* ---------- 17. 后台布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; background: #1f2937; color: #d1d5db;
  padding: 1.5rem 0; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
@media (max-width: 1023px) {
  .sidebar { width: 64px; }
  .sidebar .logo small, .sidebar .user, .sidebar nav a span { display: none; }
  .sidebar nav a { padding: 0.875rem 1rem; text-align: center; font-size: 1.125rem; }
}
@media (max-width: 600px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; padding: 0.5rem 0; display: flex; align-items: center; gap: 0.5rem; overflow-x: auto; }
  .sidebar .logo { display: none; }
  .sidebar nav { display: flex; gap: 0.25rem; }
  .sidebar nav a { padding: 0.5rem 0.75rem; font-size: 0.8rem; white-space: nowrap; }
  .sidebar .user { display: none; }
  .main { padding: 1rem !important; }
}

.sidebar .logo { padding: 0 1.5rem 1.5rem; border-bottom: 1px solid #374151; margin-bottom: 1rem; }
.sidebar .logo a { color: #fff; font-size: 1.1rem; font-weight: 700; text-decoration: none; display: block; }
.sidebar .logo small { display: block; font-size: 0.7em; color: #9ca3af; margin-top: 0.25rem; font-weight: 400; }

.sidebar nav a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 1.5rem; color: #d1d5db; text-decoration: none;
  font-size: 0.95rem; border-left: 3px solid transparent; transition: all var(--t-fast);
}
.sidebar nav a:hover, .sidebar nav a.active { background: #111827; color: #fff; border-left-color: var(--c-gold); }

.sidebar .user { padding: 1rem 1.5rem; border-top: 1px solid #374151; margin-top: 1rem; font-size: 0.85em; color: #9ca3af; }

.main { flex: 1; padding: 1.5rem 1rem; min-width: 0; }
@media (min-width: 1024px) { .main { padding: 2rem 2.5rem; } }

/* ---------- 18. 统计卡片 ---------- */
.stats { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .stats { gap: 1rem; grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .stats { grid-template-columns: repeat(6, 1fr); } }
.stat {
  background: #fff; padding: 1rem; border-radius: var(--r-md);
  border-left: 4px solid var(--c-gold);
}
@media (min-width: 600px) { .stat { padding: 1.25rem; } }
.stat .v { font-size: 1.5rem; font-weight: 700; color: #1f2937; }
@media (min-width: 600px) { .stat .v { font-size: 1.75rem; } }
.stat .l { font-size: 0.8rem; color: #6b7280; margin-top: 0.25rem; }

/* ---------- 19. 工具类 ---------- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--c-muted); }
.text-accent { color: var(--c-accent); }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.code { font-family: var(--font-mono); font-size: 0.85em; padding: 0.125em 0.375em; background: var(--c-bg-soft); border-radius: 3px; }

/* ---------- 20. 动画 ---------- */
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fade-in 0.3s ease; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulse { animation: pulse 2s ease infinite; }

/* ---------- 21. 减少动效（无障碍） ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- 22. 打印样式 ---------- */
@media print {
  .header, .sidebar, footer, .nav-toggle { display: none; }
  .main { padding: 0; }
  body { background: #fff; color: #000; }
}

/* ---------- 23. 暗色模式（v2 准备） ---------- */
@media (prefers-color-scheme: dark) {
  /* 留空，等用户启用 */
}
