/* =========================================================
   古诗文库 · 设计系统（参考 陕西华腾汇动科技 官网）
   主色 #2563eb / 强调 #06b6d4 / 中性 n-50~n-900
   大圆角 + 弹簧缓动 + 双字体（UI sans / 诗词 serif）
   ========================================================= */
:root {
  --primary: #2563eb;
  --primary-sub: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #06b6d4;
  --accent-light: #cffafe;
  --n-50: #f8fafc;
  --n-100: #f1f5f9;
  --n-200: #e2e8f0;
  --n-300: #cbd5e1;
  --n-400: #94a3b8;
  --n-500: #64748b;
  --n-600: #475569;
  --n-700: #334155;
  --n-800: #1e293b;
  --n-900: #0f172a;
  --font-display: 'Outfit', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-body: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-serif: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-primary: 0 8px 28px rgba(37, 99, 235, 0.28);
  --surface: #ffffff;
  --bg: var(--n-50);
  --text: var(--n-800);
  --text-soft: var(--n-500);
  --line: var(--n-200);
}

/* 昼夜模式：夜读（深蓝，参考 n-900 色板） */
[data-theme="ink"] {
  --surface: #16223b;
  --bg: #0f172a;
  --text: #e2e8f0;
  --text-soft: #94a3b8;
  --line: #2a3a5c;
  --primary-light: rgba(37, 99, 235, 0.22);
  --n-100: #16223b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* 背景：网格 + 光晕，呼应公司主页 hero */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.035) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 90% 70% at 80% 0%, #000 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 80% 0%, #000 10%, transparent 75%);
}
.bg-blob {
  position: fixed; top: -10%; right: -5%; width: 42vw; height: 42vw; max-width: 640px; max-height: 640px;
  border-radius: 50%; z-index: 0; pointer-events: none;
  background: radial-gradient(circle at 30% 30%, rgba(37, 99, 235, 0.10) 0%, rgba(6, 182, 212, 0.06) 40%, transparent 70%);
  filter: blur(60px);
  animation: blobFloat 9s var(--ease-spring) infinite alternate;
}
@keyframes blobFloat {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.15) rotate(8deg); }
}

/* ===================== 顶部导航 ===================== */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1400px; margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 22px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--shadow-primary);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-family: var(--font-display); font-size: 19px; font-weight: 800; letter-spacing: -0.01em; color: var(--n-900); }
[data-theme="ink"] .brand-text b { color: #fff; }
.brand-text i { font-style: normal; font-size: 12px; color: var(--text-soft); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-pill {
  font-size: 13px; color: var(--primary); background: var(--primary-light);
  padding: 6px 14px; border-radius: 999px; font-weight: 500; white-space: nowrap;
}
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 18px;
  display: grid; place-items: center; transition: all 0.3s var(--ease-out);
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }
.nav-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
  color: var(--primary); background: var(--primary-light);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  transition: all 0.25s var(--ease-out);
}
.nav-link:hover { background: var(--primary); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); }

/* ===================== 布局：左检索 + 右结果 ===================== */
.layout {
  position: relative; z-index: 1;
  max-width: 1400px; margin: 0 auto; padding: 28px;
  display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: start;
}

/* ---------- 左侧检索栏 ---------- */
.sidebar {
  position: sticky; top: 92px;
  display: flex; flex-direction: column; gap: 22px;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 8px 8px 8px 14px; box-shadow: var(--shadow-sm); transition: border-color 0.3s var(--ease-out);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.sb-icon { width: 18px; height: 18px; color: var(--n-400); flex-shrink: 0; }
.search-box input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: var(--font-body); font-size: 14px; color: var(--text);
}
.sb-go { padding: 9px 18px; font-size: 13px; }

.side-section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.side-title {
  font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--n-700);
  margin-bottom: 14px; padding-left: 10px; position: relative;
}
[data-theme="ink"] .side-title { color: #cbd5e1; }
.side-title::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 14px; border-radius: 2px; background: linear-gradient(var(--primary), var(--accent));
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: var(--text-soft); }
.field select, .field input, .fh input {
  width: 100%; padding: 10px 12px; font-family: var(--font-body); font-size: 14px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); outline: none; transition: border-color 0.25s var(--ease-out);
}
.field select:focus, .field input:focus, .fh input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.side-actions { display: flex; gap: 10px; margin-top: 4px; }
.side-actions .btn-primary { flex: 1; }
.side-actions .btn-ghost { flex: 1; }
.full { width: 100%; margin-bottom: 10px; }
.fh { display: flex; flex-direction: column; gap: 10px; }
.fh input { margin-bottom: 0; }

/* ---------- 按钮（对齐公司主页） ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; font-family: var(--font-body); font-size: 14px; font-weight: 600;
  color: #fff; background: var(--primary); border: none; border-radius: 999px;
  cursor: pointer; text-decoration: none; transition: all 0.3s var(--ease-out);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover { background: var(--primary-sub); transform: translateY(-2px); box-shadow: var(--shadow-primary); }
.btn-primary:active { transform: scale(0.97); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; font-family: var(--font-body); font-size: 14px; font-weight: 500;
  color: var(--n-600); background: transparent; border: 1px solid var(--n-200);
  border-radius: 999px; cursor: pointer; transition: all 0.3s var(--ease-out); text-decoration: none;
}
[data-theme="ink"] .btn-ghost { color: #cbd5e1; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-ghost:active { transform: scale(0.97); }

/* ---------- 右侧结果区 ---------- */
.content { min-width: 0; }
.content-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
#result-title {
  font-family: var(--font-display); font-size: clamp(20px, 3vw, 26px); font-weight: 800;
  letter-spacing: -0.01em; color: var(--n-900);
}
[data-theme="ink"] #result-title { color: #fff; }
.result-count { font-size: 13px; color: var(--text-soft); white-space: nowrap; }
.result-count b { color: var(--primary); font-weight: 700; }

/* 诗词卡片网格 */
.poem-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 18px 18px 18px 20px; cursor: pointer; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.35s var(--ease-out);
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(var(--primary), var(--accent)); opacity: 0; transition: opacity 0.35s var(--ease-out);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--n-300); }
.card:hover::before { opacity: 1; }
.card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.card-title { font-family: var(--font-serif); font-size: 18px; font-weight: 700; color: var(--n-900); margin-bottom: 8px; letter-spacing: 0.5px; }
[data-theme="ink"] .card-title { color: #f1f5f9; }
.card-meta { font-size: 12.5px; color: var(--primary); margin-bottom: 10px; }
.card-snippet { font-family: var(--font-serif); font-size: 13.5px; color: var(--n-600); line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
[data-theme="ink"] .card-snippet { color: #94a3b8; }

/* 骨架屏 */
.skeleton {
  height: 116px; border-radius: var(--radius-md); border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--n-100) 30%, var(--n-200) 50%, var(--n-100) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
[data-theme="ink"] .skeleton { background: linear-gradient(100deg, #16223b 30%, #233252 50%, #16223b 70%); background-size: 200% 100%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* 空/错状态 */
.empty, .error, .loading {
  grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-soft); font-size: 15px;
}
.error { color: #dc2626; }

/* ---------- 分页 ---------- */
.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 26px;
}
.page-btn, .page-num {
  min-width: 38px; height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: 14px; cursor: pointer; transition: all 0.25s var(--ease-out);
}
.page-num[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; cursor: default; }
.page-btn:hover:not(:disabled), .page-num:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { color: var(--n-400); padding: 0 4px; }
.page-jump { font-size: 13px; color: var(--text-soft); margin-left: 8px; display: inline-flex; align-items: center; gap: 6px; }
.page-jump input { width: 58px; padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-align: center; font-family: var(--font-body); background: var(--bg); color: var(--text); outline: none; }
.page-jump input:focus { border-color: var(--primary); }

/* ---------- 随机 / 飞花令 展示卡 ---------- */
.feature { margin-bottom: 24px; }
.feature:empty { display: none; }
.poem-show {
  background: linear-gradient(160deg, var(--surface), var(--n-50));
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: clamp(26px, 5vw, 44px); box-shadow: var(--shadow-md);
}
[data-theme="ink"] .poem-show { background: linear-gradient(160deg, #16223b, #111c33); }
.fh-tag {
  display: inline-block; margin-bottom: 18px; padding: 5px 16px;
  background: var(--primary); color: #fff; border-radius: 999px; font-size: 13px; letter-spacing: 1px;
}

/* ===================== 详情弹窗 ===================== */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(6px);
  opacity: 1; transition: opacity 0.3s var(--ease-out);
}
.modal.hidden { opacity: 0; pointer-events: none; }
.modal-card {
  position: relative; width: min(640px, 96vw); max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: clamp(28px, 5vw, 48px); box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  transform: translateY(0) scale(1); transition: transform 0.35s var(--ease-spring);
}
.modal.hidden .modal-card { transform: translateY(16px) scale(0.97); }
.modal-close {
  position: absolute; top: 14px; right: 16px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--text-soft); font-size: 20px; line-height: 1; cursor: pointer; transition: all 0.25s var(--ease-out);
}
.modal-close:hover { color: #dc2626; border-color: #dc2626; }
.modal-tools { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.chip {
  padding: 6px 16px; font-size: 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); transition: all 0.25s var(--ease-out);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

.detail-title { font-family: var(--font-serif); text-align: center; margin: 0 0 10px; font-size: clamp(24px, 4vw, 32px); letter-spacing: 3px; color: var(--n-900); }
[data-theme="ink"] .detail-title { color: #fff; }
.detail-meta { text-align: center; color: var(--primary); font-size: 14px; margin-bottom: 28px; letter-spacing: 1px; }
.detail-content {
  font-family: var(--font-serif);
  line-height: 2.1; font-size: clamp(16px, 2.4vw, 19px); color: var(--n-800); text-align: center;
}
[data-theme="ink"] .detail-content { color: #e2e8f0; }
.detail-content .verse-line { margin: 0 0 14px; text-indent: 0; }
.detail-content .verse-line:last-child { margin-bottom: 0; }
.detail-content.vertical {
  writing-mode: vertical-rl; text-orientation: upright;
  max-height: 60vh; margin: 0 auto; text-align: start;
  letter-spacing: 5px; line-height: 2.4; overflow: auto; padding: 4px 10px;
}
.detail-content.vertical .verse-line { margin: 0 14px 0 0; }

/* ===================== 页脚 / Toast ===================== */
.site-foot { position: relative; z-index: 1; text-align: center; padding: 28px; font-size: 13px; color: var(--text-soft); }
.site-foot a { color: var(--primary); text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  z-index: 60; padding: 12px 22px; border-radius: 999px; font-size: 14px; color: #fff;
  background: var(--n-800); box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: all 0.35s var(--ease-out);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #dc2626; }

/* ===================== 响应式 ===================== */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; padding: 18px; }
  .sidebar { position: static; }
  .nav-inner { padding: 12px 18px; }
  .brand-text i { display: none; }
  .nav-pill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
