:root {
  --ink: #1c1b18;
  --ink-soft: #4a463f;
  --paper: #f5f1e8;
  --paper-2: #ece5d6;
  --accent: #9c2b2b;
  --accent-soft: #c2533f;
  --gold: #b8860b;
  --line: #d8cfbb;
  --shadow: rgba(40, 30, 15, 0.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Serif SC", serif;
  color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(circle at 20% 10%, #faf6ec 0%, var(--paper) 60%);
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* 顶部 */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(245, 241, 232, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-size: 22px; font-weight: 700; color: var(--accent); letter-spacing: 2px; white-space: nowrap; }
.brand small { font-size: 12px; color: var(--ink-soft); font-weight: 400; margin-left: 8px; letter-spacing: 0; }
.search-box { flex: 1; min-width: 200px; display: flex; gap: 8px; }
.search-box input {
  flex: 1; padding: 9px 14px; border: 1px solid var(--line);
  border-radius: 22px; background: #fff; font-size: 15px; outline: none;
}
.search-box input:focus { border-color: var(--accent-soft); }
.nav-links { display: flex; gap: 6px; }
.nav-links button {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 8px 14px; border-radius: 20px; font-size: 14px;
}
.nav-links button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.container { max-width: 960px; margin: 0 auto; padding: 24px 18px 60px; }

/* 统计卡片 */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.stat {
  flex: 1; min-width: 120px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; text-align: center; box-shadow: 0 2px 8px var(--shadow);
}
.stat .num { font-size: 30px; font-weight: 700; color: var(--accent); }
.stat .label { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

/* 筛选 */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filters button {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 6px 14px; border-radius: 16px; font-size: 13px;
}
.filters button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* 诗词卡片 */
.poem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.poem-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; box-shadow: 0 2px 8px var(--shadow); transition: transform .15s, box-shadow .15s;
  cursor: pointer;
}
.poem-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px var(--shadow); border-color: var(--accent-soft); }
.poem-card h3 { font-size: 18px; color: var(--ink); }
.poem-card .meta { font-size: 12px; color: var(--ink-soft); margin: 4px 0 8px; }
.poem-card .excerpt {
  font-size: 14px; color: var(--ink-soft); white-space: pre-line;
  max-height: 4.2em; overflow: hidden;
  border-left: 3px solid var(--gold); padding-left: 10px;
}
.tag { display: inline-block; font-size: 11px; color: var(--accent); background: #fbeeea; padding: 1px 8px; border-radius: 10px; margin: 6px 4px 0 0; }

/* 详情 */
.detail-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.detail-head h1 { font-size: 28px; color: var(--accent); }
.detail-head .by { color: var(--ink-soft); font-size: 15px; }
.back { display: inline-block; margin-bottom: 14px; color: var(--ink-soft); font-size: 14px; }
.section { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; box-shadow: 0 2px 8px var(--shadow); }
.section h2 { font-size: 16px; color: var(--accent); margin-bottom: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.content-text { white-space: pre-line; font-size: 17px; line-height: 2; letter-spacing: .5px; }
.hide-lines .line { color: transparent; background: #e9e2d2; border-radius: 4px; user-select: none; }
.notes-list { list-style: none; }
.notes-list li { padding: 5px 0; border-bottom: 1px dotted var(--line); }
.notes-list b { color: var(--accent-soft); margin-right: 8px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar button {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 6px 14px; border-radius: 16px; font-size: 13px;
}
.toolbar button:hover { border-color: var(--accent-soft); color: var(--accent); }

/* 默写 */
.dictation-line { margin-bottom: 14px; }
.dictation-line .q { font-size: 15px; color: var(--ink-soft); }
.dictation-line input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 16px; margin-top: 4px; font-family: inherit;
}
.dictation-line.correct input { border-color: #2e7d32; background: #eef7ee; }
.dictation-line.wrong input { border-color: var(--accent); background: #fbeeea; }

/* 飞花令 */
.fh-input { display: flex; gap: 8px; margin-bottom: 14px; }
.fh-input input { padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; width: 80px; text-align: center; }
.fh-result { font-size: 16px; white-space: pre-line; }
.fh-result .row { padding: 8px 10px; border-left: 3px solid var(--gold); margin-bottom: 8px; background: #faf6ec; border-radius: 0 8px 8px 0; }
.fh-result .row small { color: var(--ink-soft); }

/* 聊天 */
.chat-box { background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; max-height: 320px; overflow-y: auto; margin-bottom: 10px; }
.chat-msg { margin-bottom: 10px; }
.chat-msg.user { text-align: right; }
.chat-msg .bubble { display: inline-block; padding: 8px 14px; border-radius: 14px; max-width: 80%; white-space: pre-line; font-size: 15px; }
.chat-msg.user .bubble { background: var(--accent); color: #fff; }
.chat-msg.bot .bubble { background: #fff; border: 1px solid var(--line); }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; padding: 9px 14px; border: 1px solid var(--line); border-radius: 20px; font-size: 15px; outline: none; }
.chat-input button { background: var(--accent); color: #fff; border: none; padding: 9px 20px; border-radius: 20px; }

.empty { text-align: center; color: var(--ink-soft); padding: 40px; }
.badge { font-size: 12px; color: #fff; background: var(--gold); padding: 1px 8px; border-radius: 10px; margin-left: 6px; }
footer { text-align: center; color: var(--ink-soft); font-size: 13px; padding: 24px; border-top: 1px solid var(--line); }

/* 通用 */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 18px; box-shadow: 0 2px 8px var(--shadow); }
.catalog-tip { font-size: 14px; color: var(--ink-soft); }
.catalog-tip code { background: var(--paper-2); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--ink-soft); font-size: 14px; }
.sub { font-size: 14px; color: var(--accent); margin: 16px 0 8px; border-left: 3px solid var(--gold); padding-left: 8px; }
.mood-box { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; font-size: 14px; line-height: 1.8; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: #fff; color: var(--ink-soft); padding: 7px 13px; border-radius: 16px; font-size: 13px; }
.tabs button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* 意象 */
.img-list { margin-top: 8px; }
.img-row { padding: 10px 0; border-bottom: 1px dotted var(--line); }
.img-idx { display: inline-block; font-size: 12px; color: var(--gold); margin-right: 8px; }
.img-hint { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

/* 节奏 */
.rhythm-list { margin-top: 8px; }
.rhythm-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dotted var(--line); font-size: 16px; }
.beat { font-size: 12px; color: var(--gold); white-space: nowrap; }

/* 钩子 */
.hook-box { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 20px; letter-spacing: 2px; line-height: 2.2; word-break: break-all; }
.hook-char { color: var(--accent); font-weight: 700; }
.blank-line { font-size: 17px; padding: 6px 0; letter-spacing: 2px; }

/* 情境 */
.scene-item { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; font-size: 14px; }
.scene-item:hover { border-color: var(--accent-soft); background: var(--paper-2); }
#feynmanInput, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 15px; resize: vertical; }

/* 复习计划 */
.plan-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.plan-btn { border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 12px; padding: 4px 10px; font-size: 12px; }
.plan-btn.done { background: #2e7d32; color: #fff; border-color: #2e7d32; }

/* 作者链接 */
.author-link:hover { opacity: .8; }

@media (max-width: 560px) {
  .brand { font-size: 18px; }
  .poem-grid { grid-template-columns: 1fr; }
  .hook-box { font-size: 16px; }
}
