/* ============================================================
   陈昌文 · 文案库 — 中式印刷纸感
   宣纸米白 / 墨黑 / 印章朱砂红
   ============================================================ */
:root {
  --paper: #f6f1e7;
  --paper-deep: #efe8d8;
  --ink: #1c1a17;
  --ink-soft: #58534a;
  --ink-faint: #8d8678;
  --seal-red: #c3272b;
  --seal-red-deep: #9e1f23;
  --line: #ddd2bd;
  --card: #fffdf8;
  --shadow: 0 1px 2px rgba(60, 48, 24, .06), 0 6px 24px -8px rgba(60, 48, 24, .12);
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --font-body: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

/* 纸张噪点纹理 */
.paper-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------- 头部 ---------------- */
.hero {
  position: relative; z-index: 1;
  border-bottom: 3px double var(--line);
  background: linear-gradient(180deg, var(--paper-deep), var(--paper));
}
.hero-inner {
  max-width: 860px; margin: 0 auto;
  padding: 34px 20px 26px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.seal {
  width: 64px; height: 64px; flex: none;
  background: var(--seal-red);
  color: #fff7ee;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; line-height: 1.18;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(255, 247, 238, .35), 0 4px 14px -4px rgba(195, 39, 43, .55);
  transform: rotate(-3deg);
  animation: seal-in .6s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes seal-in {
  from { transform: rotate(-3deg) scale(1.6); opacity: 0; }
  to   { transform: rotate(-3deg) scale(1); opacity: 1; }
}
.hero-text { flex: 1; min-width: 200px; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 6vw, 38px);
  font-weight: 900; letter-spacing: .06em;
}
.hero h1 .dot { color: var(--seal-red); margin: 0 .1em; }
.hero-sub { color: var(--ink-soft); font-size: 13px; letter-spacing: .12em; margin-top: 2px; }
.hero-sub .sep { color: var(--seal-red); margin: 0 4px; }
.hero-stats { display: flex; gap: 22px; }
.stat { text-align: center; }
.stat b {
  display: block; font-family: var(--font-display);
  font-size: 22px; color: var(--seal-red); font-weight: 800;
}
.stat span { font-size: 11px; color: var(--ink-faint); letter-spacing: .15em; }

/* ---------------- 工具栏 ---------------- */
.container { max-width: 860px; margin: 0 auto; padding: 18px 16px 90px; position: relative; z-index: 1; }
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
  padding: 12px 0 10px;
  background: linear-gradient(180deg, var(--paper) 80%, transparent);
}
.search-wrap {
  flex: 1; min-width: 200px; position: relative; display: flex; align-items: center;
}
.search-icon { position: absolute; left: 12px; color: var(--ink-faint); }
#search {
  width: 100%; padding: 11px 38px 11px 38px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font-size: 15px; font-family: var(--font-body);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
#search:focus { border-color: var(--seal-red); box-shadow: 0 0 0 3px rgba(195, 39, 43, .12); }
.search-clear {
  position: absolute; right: 8px; width: 26px; height: 26px;
  border: none; border-radius: 50%; cursor: pointer;
  background: var(--paper-deep); color: var(--ink-soft); font-size: 12px;
}
.toolbar-actions { display: flex; gap: 8px; }

.btn {
  border: none; cursor: pointer; border-radius: 12px;
  padding: 11px 16px; font-size: 14px; font-weight: 600;
  font-family: var(--font-body);
  transition: transform .12s, box-shadow .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: var(--ink); color: var(--paper);
  box-shadow: 0 4px 14px -6px rgba(28, 26, 23, .6);
}
.btn-primary:hover { background: #000; }
.btn-ghost {
  background: transparent; color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn-ghost.on { background: var(--seal-red); border-color: var(--seal-red); color: #fff; }

/* 下拉菜单 */
.export-all-wrap, .export-sel-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; min-width: 150px;
  animation: menu-in .15s ease both;
}
.menu-up { top: auto; bottom: calc(100% + 6px); }
@keyframes menu-in { from { opacity: 0; transform: translateY(4px); } }
.menu button {
  display: block; width: 100%; text-align: left;
  padding: 12px 16px; border: none; background: none; cursor: pointer;
  font-size: 14px; color: var(--ink); font-family: var(--font-body);
}
.menu button:hover { background: var(--paper-deep); }
.menu button + button { border-top: 1px solid var(--line); }

.result-hint { color: var(--ink-faint); font-size: 13px; padding: 4px 2px 0; }

/* 排序 chips */
.sort-bar { display: flex; align-items: center; gap: 8px; padding: 8px 0 0; flex-wrap: wrap; }
.sort-label { font-size: 12px; color: var(--ink-faint); letter-spacing: .1em; }
.sort-chip {
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink-soft);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: var(--font-body);
  transition: all .15s; -webkit-tap-highlight-color: transparent;
}
.sort-chip:hover { border-color: var(--ink-soft); }
.sort-chip.on { background: var(--seal-red); border-color: var(--seal-red); color: #fff; }

/* 导出菜单（带时间范围） */
.menu-export { min-width: 220px; padding: 6px 0; }
.menu-label {
  font-size: 11px; color: var(--ink-faint); letter-spacing: .15em;
  padding: 8px 16px 4px;
}
.range-opts { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 14px 8px; }
.range-opts button {
  width: auto; border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink-soft);
  padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: var(--font-body);
}
.range-opts button.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.menu-export .menu-act { border-top: 1px solid var(--line); }

.meta-stats { color: var(--seal-red); font-weight: 600; }

/* ---------------- 卡片列表 ---------------- */
.list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.card {
  position: relative; display: flex;
  background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: card-in .45s ease both;
  transition: border-color .2s, transform .2s;
}
@keyframes card-in { from { opacity: 0; transform: translateY(14px); } }
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--seal-red), var(--seal-red-deep));
  opacity: 0; transition: opacity .2s;
}
.card:hover { border-color: #cbbfa4; }
.card:hover::before { opacity: 1; }
.card.selected { border-color: var(--seal-red); background: #fffaf3; }
.card.selected::before { opacity: 1; }

/* 选择框：选择模式才显示 */
.card-check { display: none; align-items: flex-start; padding: 18px 0 0 14px; cursor: pointer; }
body.select-mode .card-check { display: flex; }
.card-check input { display: none; }
.checkmark {
  width: 22px; height: 22px; border-radius: 7px;
  border: 2px solid var(--line); background: var(--paper);
  display: inline-block; position: relative; transition: all .15s;
}
.card-check input:checked + .checkmark { background: var(--seal-red); border-color: var(--seal-red); }
.card-check input:checked + .checkmark::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
body.select-mode .card { cursor: pointer; }

.card-body { flex: 1; padding: 16px 18px 12px; min-width: 0; }
.card-title {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 800; line-height: 1.5;
  letter-spacing: .02em;
  word-break: break-all;
}
.card-meta { display: flex; gap: 12px; margin: 4px 0 8px; font-size: 12px; color: var(--ink-faint); }
.meta-duration:not(:empty)::before { content: "⏱ "; }
.card-text {
  font-size: 15px; color: var(--ink-soft);
  white-space: pre-wrap; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.card.expanded .card-text { display: block; -webkit-line-clamp: unset; overflow: visible; }

.card-actions {
  display: flex; gap: 6px; margin-top: 10px;
  border-top: 1px dashed var(--line); padding-top: 8px;
}
.act {
  border: none; background: none; cursor: pointer;
  padding: 7px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  text-decoration: none; font-family: var(--font-body);
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.act:hover { background: var(--paper-deep); color: var(--ink); }
.act-copy { color: var(--seal-red); }
.act-copy:hover { background: rgba(195, 39, 43, .08); color: var(--seal-red-deep); }
.act-copy.copied { color: #2a7d2e; }

/* ---------------- 加载 / 空态 ---------------- */
.loading { display: flex; justify-content: center; gap: 8px; padding: 28px 0; }
.ink-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--ink-faint);
  animation: ink-bounce 1s infinite ease-in-out;
}
.ink-dot:nth-child(2) { animation-delay: .15s; background: var(--seal-red); }
.ink-dot:nth-child(3) { animation-delay: .3s; }
@keyframes ink-bounce { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-7px); opacity: 1; } }

.empty { text-align: center; padding: 56px 0; color: var(--ink-faint); }
.empty-seal {
  width: 72px; height: 72px; margin: 0 auto 14px;
  border: 2.5px solid var(--line); border-radius: 14px;
  font-family: var(--font-display); font-size: 34px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  color: var(--line); transform: rotate(-4deg);
}

.btn-more {
  display: block; margin: 22px auto 0; padding: 12px 36px;
  background: transparent; border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--ink-soft); font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: var(--font-body);
}
.btn-more:hover { border-color: var(--seal-red); color: var(--seal-red); }

/* ---------------- 底部批量操作栏 ---------------- */
.select-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  animation: bar-up .25s cubic-bezier(.2, 1, .3, 1) both;
}
@keyframes bar-up { from { transform: translateY(100%); } }
.select-bar-inner {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(28, 26, 23, .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-radius: 16px; padding: 10px 14px;
  box-shadow: 0 8px 30px -8px rgba(28, 26, 23, .5);
}
.select-info { color: var(--paper); font-size: 14px; white-space: nowrap; }
.select-info b { color: #ff9d9f; font-size: 17px; font-family: var(--font-display); }
.select-actions { display: flex; gap: 8px; align-items: center; }
.btn-ghost-light {
  background: transparent; color: var(--paper);
  border: 1.5px solid rgba(246, 241, 231, .35);
}
.btn-light { background: var(--paper); color: var(--ink); }
.btn-red {
  background: var(--seal-red); color: #fff;
  box-shadow: 0 4px 12px -4px rgba(195, 39, 43, .7);
}
.select-cancel {
  width: 32px; height: 32px; border: none; border-radius: 50%; cursor: pointer;
  background: rgba(246, 241, 231, .15); color: var(--paper); font-size: 13px;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  z-index: 50; background: var(--ink); color: var(--paper);
  padding: 11px 22px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 8px 24px -6px rgba(28, 26, 23, .5);
  animation: toast-in .25s ease both; max-width: 86vw; text-align: center;
}
.toast.ok::before { content: "✓ "; color: #7fd884; font-weight: 700; }
.toast.err::before { content: "✕ "; color: #ff9d9f; font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

.footer {
  text-align: center; padding: 26px 0 40px;
  color: var(--ink-faint); font-size: 12px; letter-spacing: .2em;
  position: relative; z-index: 1;
}

/* ---------------- 桌面适配 ---------------- */
@media (min-width: 720px) {
  .hero-inner { padding: 44px 24px 34px; }
  .card-title { font-size: 19px; }
  .card-text { font-size: 15.5px; }
}
/* ---------------- 手机适配 ---------------- */
@media (max-width: 540px) {
  .hero-inner { gap: 14px; padding: 24px 16px 20px; }
  .hero-stats { width: 100%; justify-content: flex-start; gap: 28px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .export-all-wrap { flex: 1; display: flex; }
  .export-all-wrap .btn { width: 100%; }
  .select-bar-inner { flex-wrap: wrap; }
  .select-actions { flex: 1; justify-content: flex-end; }
  .btn { padding: 10px 12px; font-size: 13px; }
}
