/* 膜法语录 —— 语录本气质：宋体引文、纸色底、朱砂只用于强调 */

:root {
  --bg: #f6f3ee;
  --surface: #fffdf9;
  --text: #1f1b16;
  --muted: #6e655a;
  --border: #e6dfd3;
  --accent: #b5371f;
  --accent-ink: #ffffff;
  --mark: #f6dccf;
  --success: #2f7d4f;
  --shadow: 0 1px 2px rgb(31 27 22 / 0.04), 0 4px 16px rgb(31 27 22 / 0.05);

  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --radius: 14px;
  --fast: 120ms; --normal: 180ms; --panel: 240ms;
  --standard: cubic-bezier(0.2, 0, 0, 1);
  --enter: cubic-bezier(0, 0, 0.2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110; --surface: #1b1a18; --text: #ece6dc; --muted: #a39b8f; --border: #2e2b27;
    --accent: #e46a4b; --accent-ink: #1b1a18; --mark: rgb(228 106 75 / 0.24); --success: #5cb07f;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121110; --surface: #1b1a18; --text: #ece6dc; --muted: #a39b8f; --border: #2e2b27;
  --accent: #e46a4b; --accent-ink: #1b1a18; --mark: rgb(228 106 75 / 0.24); --success: #5cb07f;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 顶部：品牌 + 搜索 + 栏目 ---------- */
.brand-row { padding: max(var(--s3), env(safe-area-inset-top)) var(--s4) 0; }
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  padding: var(--s2) var(--s4) 0;
  transition: border-color var(--normal) var(--standard);
}
.top.scrolled { border-bottom-color: var(--border); }
.wrap { max-width: 720px; margin: 0 auto; }

.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  color: var(--text); text-decoration: none;
  font-weight: 600; font-size: 15px; letter-spacing: 0.04em;
  padding: var(--s1) 0;
}
.seal { display: block; flex: none; width: 26px; height: 26px; color: var(--accent); } /* Claude Design A2，路径见 seal.js */

.search { position: relative; }
.search svg {
  position: absolute; left: 14px; top: 50%; translate: 0 -50%;
  width: 20px; height: 20px; color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%; height: 52px;
  padding: 0 48px 0 44px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: 17px var(--sans);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color var(--fast) var(--standard), box-shadow var(--fast) var(--standard);
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); opacity: 0.8; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.clear {
  position: absolute; right: 6px; top: 50%; translate: 0 -50%;
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 22px; line-height: 1;
}
.clear:hover { color: var(--text); }

.tabs {
  display: flex; gap: var(--s1);
  overflow-x: auto; scrollbar-width: none;
  margin: var(--s3) calc(-1 * var(--s4)) 0; padding: 0 var(--s4) var(--s2);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  min-height: 36px; padding: 0 var(--s3);
  border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer;
  transition: background var(--fast) var(--standard), color var(--fast) var(--standard);
}
.tab:hover { color: var(--text); }
.tab[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.tab .n { margin-left: 4px; font-size: 12px; opacity: 0.6; font-variant-numeric: tabular-nums; }
@media (max-width: 479px) { .tab .n { display: none; } .tab { padding: 0 9px; } .tabs { gap: 2px; } }

/* ---------- 结果 ---------- */
main { padding: var(--s3) var(--s4) var(--s12); }
.summary { margin: 0 0 var(--s3); color: var(--muted); font-size: 13px; min-height: 20px; }
.summary b { color: var(--text); font-weight: 600; }

.chips {
  display: flex; align-items: center; gap: var(--s2);
  overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--s4)) var(--s3); padding: 0 var(--s4);
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chips .label { flex: none; color: var(--muted); font-size: 13px; }
.source-chip { flex: none; white-space: nowrap;
  border: 1px dashed var(--border); border-radius: 999px;
  background: transparent; color: var(--muted);
  min-height: 32px; padding: 0 var(--s3); font-size: 13px; cursor: pointer;
}
.source-chip:hover { color: var(--text); border-color: var(--muted); }
.source-chip[aria-pressed="true"] { border-style: solid; border-color: var(--text); color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.group-title {
  margin: var(--s5) 0 var(--s1); padding: 0 var(--s1);
  color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
}
.group-title:first-child { margin-top: 0; }
.group-title.row { display: flex; align-items: baseline; justify-content: space-between; }
.more { border: 0; background: none; color: var(--accent); font-size: 13px; cursor: pointer; padding: var(--s1) 0; min-height: 32px; }

/* ---------- 表情：网格 / 横排 ---------- */
.grid {
  display: grid; gap: var(--s3) var(--s2);
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
.strip {
  display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4) var(--s1);
}
.strip::-webkit-scrollbar { display: none; }
.strip .tile { flex: none; width: 104px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer;
}
.thumb {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 1; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color var(--fast) var(--standard), transform var(--fast) var(--standard);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; } /* 预览裁切填满，完整原图在查看页 */
.tile:hover .thumb { border-color: var(--muted); }
.tile:active .thumb { transform: scale(0.97); }
.badge {
  position: absolute; top: 6px; right: 6px;
  padding: 0 5px; border-radius: 4px; font: 600 10px/16px var(--sans); letter-spacing: 0.04em;
  background: rgb(0 0 0 / 0.55); color: #fff;
}
.cap {
  font-size: 12px; line-height: 1.4; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viewer { display: grid; place-items: center; background: var(--bg); }
.viewer img { display: block; max-width: 100%; max-height: 58vh; object-fit: contain; border-radius: 8px; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s4) var(--s4) var(--s2);
  transition: border-color var(--fast) var(--standard);
}
.card.selected { border-color: var(--accent); }
.card.famous { border-left: 3px solid var(--accent); }

.quote {
  display: block; width: 100%; text-align: left;
  margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  font: 18px/1.75 var(--serif); color: var(--text);
  white-space: pre-line; overflow-wrap: anywhere;
}
.quote .ctx { color: var(--muted); }
.poem-title { margin: 0 0 var(--s2); font: 600 15px/1.5 var(--serif); color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s2);
  margin-top: var(--s2); color: var(--muted); font-size: 13px;
}
.tag {
  display: inline-block; padding: 0 6px; border-radius: 4px;
  border: 1px solid var(--border); font-size: 12px; line-height: 18px;
}
.tag.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.actions { display: flex; gap: var(--s1); margin: var(--s2) calc(-1 * var(--s2)) 0; }
.act {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 var(--s3);
  border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font-size: 14px; cursor: pointer;
  transition: color var(--fast) var(--standard), background var(--fast) var(--standard);
}
.act svg { width: 18px; height: 18px; flex: none; }
.act:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.act.primary { color: var(--accent); }
.act.done { color: var(--success); }

.empty { text-align: center; color: var(--muted); padding: var(--s10) var(--s4); }
.empty p { margin: 0 0 var(--s4); }
.suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); }
.suggest button {
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  min-height: 36px; padding: 0 var(--s3); font: 15px var(--serif); cursor: pointer;
}

footer {
  max-width: 720px; margin: 0 auto; padding: var(--s6) var(--s4) max(var(--s10), env(safe-area-inset-bottom));
  color: var(--muted); font-size: 12px; line-height: 1.8;
  border-top: 1px solid var(--border);
}
footer a { color: inherit; }
footer .row { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); justify-content: space-between; align-items: center; }
.theme { border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); padding: 2px 10px; font-size: 12px; cursor: pointer; min-height: 28px; }
.kbd-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: inline; } }
kbd { font: 11px var(--sans); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }

/* ---------- 对话框：出处 / 分享图 ---------- */
dialog {
  width: min(680px, 100%); max-height: min(88vh, 900px);
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--text);
  box-shadow: 0 -8px 40px rgb(0 0 0 / 0.18);
}
@media (min-width: 720px) {
  dialog { margin: auto; border-radius: 20px; }
}
dialog::backdrop { background: rgb(18 17 16 / 0.42); }
dialog[open] { animation: rise var(--panel) var(--enter); }
dialog[open]::backdrop { animation: fade var(--panel) var(--enter); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes fade { from { opacity: 0; } }

.sheet { display: flex; flex-direction: column; max-height: inherit; }
.sheet:focus { outline: none; }
.sheet-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s3) var(--s3) var(--s5);
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
.sheet-head .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; flex: none;
}
.icon-btn:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.sheet-body { overflow-y: auto; padding: var(--s4) var(--s5); overscroll-behavior: contain; }
.sheet-foot {
  display: flex; flex-wrap: wrap; gap: var(--s2);
  padding: var(--s3) var(--s4) max(var(--s3), env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 var(--s4); flex: 1 1 auto;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 15px; cursor: pointer;
  transition: background var(--fast) var(--standard), border-color var(--fast) var(--standard);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn svg { width: 18px; height: 18px; }

.lead { margin: 0 0 var(--s5); font: 21px/1.75 var(--serif); white-space: pre-line; }
.context { list-style: none; margin: 0; padding: 0; }
.context li {
  padding: var(--s2) var(--s3); margin: 0 calc(-1 * var(--s3));
  border-radius: 10px; font: 16px/1.8 var(--serif); color: var(--muted);
}
.context li.on { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); }
.context .who { font: 600 12px var(--sans); color: var(--muted); margin-right: 6px; }
.context li.r { font-family: var(--sans); font-size: 14px; }
.ctx-title { margin: 0 0 var(--s2); color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }

.preview { display: grid; place-items: center; background: var(--bg); border-radius: 12px; padding: var(--s3); }
.preview img { display: block; max-width: 100%; max-height: 56vh; border-radius: 8px; box-shadow: var(--shadow); }
.preview .busy { color: var(--muted); font-size: 14px; padding: var(--s12) 0; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--bg); margin-bottom: var(--s3); }
.seg button { border: 0; background: transparent; color: var(--muted); border-radius: 8px; min-height: 32px; padding: 0 var(--s3); font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(var(--s6), env(safe-area-inset-bottom));
  translate: -50% 0; z-index: 100;
  padding: 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--normal) var(--standard), transform var(--normal) var(--standard);
}
.toast.show { opacity: 1; transform: none; }

@media (min-width: 720px) {
  .quote { font-size: 19px; }
  main { padding-top: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .toast { transform: none; }
}
