/* ================= 水墨风 · 文房日课 =================
 * 宣纸为纸，墨为字，朱砂为印。规范见 DESIGN.md
 */
:root {
  --paper: #f7f3ea;
  --card: #fffdf8;
  --ink: #2b2b28;
  --ink-2: #8a8578;
  --line: #e4ddcc;
  --green: #3d5a4c;
  --green-deep: #31473c;
  --cinnabar: #b03a2e;
  --ochre: #a67b4f;
  --radius: 8px;
  --header-h: 56px;
  --tab-h: 60px;
  --font-kai: "LXGW WenKai Screen", "Kaiti SC", "STKaiti", "KaiTi", "FangSong", "SimSun", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191915;
    --card: #23231e;
    --ink: #e9e4d6;
    --ink-2: #7d786c;
    --line: #3a382f;
    --green: #5a7a68;
    --green-deep: #46604f;
    --cinnabar: #c05a4a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: var(--paper);
  /* 宣纸纹理：feTurbulence 分形噪声（透明度 .04） */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .17 0 0 0 0 .17 0 0 0 0 .15 0 0 0 .04 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23p)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
  padding-top: calc(var(--header-h) + 40px);
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

/* ---------- 远山（全局背景层） ---------- */
.ink-mountains {
  position: fixed; top: var(--header-h); left: 0; right: 0;
  z-index: 0; pointer-events: none; overflow: hidden;
}
.ink-mountains svg { display: block; width: 100%; height: auto; }
.ink-mountains .m1 { opacity: .04; filter: blur(1px); }
.ink-mountains .m2 { opacity: .06; }
.ink-mountains .m3 { opacity: .09; }

/* ---------- 门页：空白页 + 口令输入，成功前应用本体不可见 ---------- */
#gateView {
  position: fixed; inset: 0; z-index: 100;
  background: #ffffff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px;
  animation: fadeIn .25s ease;
}
#gateView[hidden] { display: none; }
#gateInput {
  width: min(72vw, 260px); padding: 10px 12px;
  border: 1px solid #d9d9d9; border-radius: 6px;
  background: #fff; color: #2b2b28;
  font-size: 15px; text-align: center; letter-spacing: 2px;
}
#gateInput:focus { outline: none; border-color: #3d5a4c; }
#gateView .btn { min-width: 120px; letter-spacing: 4px; }
.gate-error { font-size: 13px; color: #b03a2e; margin: 0; animation: shake .3s ease; }

/* ---------- 顶栏 ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.app-title { display: flex; align-items: center; gap: 10px; }
.seal-logo {
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--cinnabar);
  box-shadow: inset 0 0 0 1.5px rgba(255,253,248,.4);
  color: #f7f3ea;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-kai); font-size: 19px; font-weight: 700;
}
.app-title h1 { font-family: var(--font-kai); font-size: 21px; margin: 0; font-weight: 700; letter-spacing: 2px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.scroll-ico { color: var(--ink-2); display: inline-flex; }
.scroll-ico svg { stroke: currentColor; }
.book-select {
  appearance: none; -webkit-appearance: none;
  max-width: 36vw; padding: 6px 26px 6px 12px;
  border: none; border-radius: 0;
  background: transparent;
  border-bottom: 1px solid var(--ink-2);
  font-size: 13.5px; font-weight: 600; font-family: var(--font-kai);
  color: var(--ink); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8578' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.icon-btn {
  border: 1px solid var(--line);
  background: transparent; border-radius: 6px;
  width: 34px; height: 34px; font-size: 16px; cursor: pointer;
  color: var(--ink);
  transition: background .2s;
}
.icon-btn:hover { background: rgba(43,43,40,.05); }

/* ---------- 日课条 ---------- */
.stat-strip { max-width: 720px; margin: 10px auto 0; padding: 0 12px; display: flex; gap: 10px; position: relative; z-index: 1; }
.stat-chip {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px 8px 10px;
  font-size: 13.5px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
}
.stat-chip .vlabel {
  writing-mode: vertical-rl;
  font-family: var(--font-kai);
  font-size: 11px; letter-spacing: 2px;
  color: var(--paper); background: var(--green);
  border-radius: 3px; padding: 4px 2px;
  line-height: 1;
}
.stat-chip.hot .vlabel { background: var(--cinnabar); }
.stat-chip .val { font-family: var(--font-kai); font-size: 19px; font-weight: 700; color: var(--cinnabar); margin: 0 2px; }
.stat-chip.hot .val { color: var(--cinnabar); }

/* ---------- 布局 ---------- */
#main { max-width: 720px; margin: 0 auto; padding: 12px; position: relative; z-index: 1; }
.view:not([hidden]) { animation: viewIn .4s ease-out both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(43,43,40,.04);
}
.card-title {
  margin: 0 0 8px; font-family: var(--font-kai); font-size: 16.5px; font-weight: 700; letter-spacing: 2px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
/* 云纹波线：标题两侧（参考站 ～～装饰线） */
.card-title::before, .card-title::after {
  content: ""; flex: none; width: 30px; height: 7px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='7'%3E%3Cpath d='M0 4 Q3.75 .5 7.5 4 T15 4 T22.5 4 T30 4' fill='none' stroke='%23c9c2ae' stroke-width='1.4'/%3E%3C/svg%3E") center/contain no-repeat;
}
@media (prefers-color-scheme: dark) {
  .card-title::before, .card-title::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='7'%3E%3Cpath d='M0 4 Q3.75 .5 7.5 4 T15 4 T22.5 4 T30 4' fill='none' stroke='%234a463a' stroke-width='1.4'/%3E%3C/svg%3E");
  }
}
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.hint { font-size: 13px; margin: 6px 0 10px; }
.empty { text-align: center; padding: 24px 16px 40px; color: var(--ink-2); position: relative; }
.empty .bamboo { margin: 0 auto 4px; display: block; opacity: .8; animation: sway 4s ease-in-out infinite; transform-origin: bottom center; }
@keyframes sway { 0%,100% { transform: rotate(-1.2deg); } 50% { transform: rotate(1.2deg); } }
.empty p { margin: 6px 0; font-family: var(--font-kai); font-weight: 700; font-size: 15.5px; color: var(--ink); }
.empty .vquote {
  position: absolute; right: 18px; top: 18px;
  writing-mode: vertical-rl; font-family: var(--font-kai);
  font-size: 12px; letter-spacing: 4px; color: var(--ink-2); opacity: .7;
}

/* ---------- 按钮 ---------- */
.btn {
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: transparent; color: var(--ink);
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: box-shadow .25s, background .2s, color .2s, transform .08s;
}
.btn:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: 0 0 0 5px rgba(43,43,40,.08); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--green); border-color: var(--green); color: #f7f3ea; }
.btn.primary:hover { background: var(--green-deep); border-color: var(--green-deep); box-shadow: 0 0 0 5px rgba(61,90,76,.14); }
.btn.danger { background: var(--cinnabar); border-color: var(--cinnabar); color: #f7f3ea; }
.btn.danger:hover { box-shadow: 0 0 0 5px rgba(176,58,46,.14); filter: brightness(.95); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.small-btn { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.gen-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.sel-badge {
  border: 1px solid var(--cinnabar);
  color: var(--cinnabar);
  border-radius: 4px; padding: 2px 10px;
  font-size: 13px; font-weight: 700; font-family: var(--font-kai);
  animation: fadeUp .25s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 单词本 ---------- */
.search-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.search-row input {
  flex: 1; padding: 9px 13px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 14px;
}
.search-row input:focus { outline: none; border-color: var(--green); }
.entry-list { display: flex; flex-direction: column; gap: 10px; }
.entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 0 rgba(43,43,40,.04);
  display: flex; gap: 10px; align-items: flex-start;
  animation: cardIn .3s ease both;
  transition: border-color .2s;
}
.entry:hover { border-color: var(--ink-2); }
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.entry:nth-child(1) { animation-delay: .02s; } .entry:nth-child(2) { animation-delay: .05s; }
.entry:nth-child(3) { animation-delay: .08s; } .entry:nth-child(4) { animation-delay: .11s; }
.entry:nth-child(5) { animation-delay: .14s; } .entry:nth-child(n+6) { animation-delay: .16s; }
.entry-main { flex: 1; min-width: 0; }
.entry-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.entry-word { font-family: var(--font-kai); font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.entry-word.hf { color: var(--cinnabar); }
.entry-word.hf::after {
  content: "高频"; font-family: var(--font-kai);
  font-size: 10.5px; color: #f7f3ea;
  background: var(--cinnabar);
  border-radius: 3px; padding: 1px 5px; margin-left: 7px;
  vertical-align: 2px; letter-spacing: 1px;
}
.entry-phon { color: var(--ink-2); font-size: 12.5px; }
.tag {
  font-size: 10.5px; font-weight: 600; color: var(--green);
  border: 1px solid var(--green);
  border-radius: 3px; padding: 0 5px;
}
.tag.o { color: var(--ochre); border-color: var(--ochre); }
.tag.dimt { color: var(--ink-2); border-color: var(--line); }
.tag.cin { color: var(--cinnabar); border-color: var(--cinnabar); }
.sense-line { font-size: 13.5px; margin-top: 3px; color: var(--text); color: var(--ink); }
.sense-line .pos { color: var(--ink-2); font-style: italic; margin-right: 4px; font-size: 12.5px; }
.sense-line.dim { color: var(--ink-2); font-size: 12.5px; }
.sense-line .star { color: var(--cinnabar); margin-right: 2px; }
.entry-note { font-size: 12.5px; color: var(--ochre); margin-top: 3px; }
.entry-note::before { content: "批"; font-family: var(--font-kai); font-size: 10px; color: #f7f3ea; background: var(--ochre); border-radius: 2px; padding: 0 3px; margin-right: 5px; vertical-align: 1px; }
.entry-del {
  border: none; background: none; color: var(--ink-2); font-size: 15px;
  cursor: pointer; padding: 2px 5px; align-self: flex-start; border-radius: 4px;
}
.entry-del:hover { color: var(--cinnabar); }
.entry input[type="checkbox"] { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--green); cursor: pointer; }

/* ---------- 选择器 ---------- */
.picker-list {
  max-height: 46vh; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 8px; margin: 10px 0; background: var(--card);
}
.picker-row {
  display: flex; gap: 8px; align-items: center; padding: 8px 10px;
  border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer;
}
.picker-row:hover { background: rgba(61,90,76,.05); }
.picker-row:last-child { border-bottom: none; }
.picker-row .prev { color: var(--ink-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-row input { accent-color: var(--green); width: 16px; height: 16px; }
.picker-filters { display: flex; gap: 8px; }
.picker-filters #pickerSearch { width: auto; flex: 1; }
.picker-date {
  width: 44%; flex: none; padding: 9px 6px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
  font-size: 13px; font-weight: 600;
}
.picker-row b.hf { color: var(--cinnabar); }
#pickerSearch, #newBookName, #synCustomSense {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 14px;
}
#pickerSearch:focus, #newBookName:focus, #synCustomSense:focus { outline: none; border-color: var(--green); }
#synCustomSense { margin-top: 8px; }

/* ---------- 选词填空 ---------- */
.passage-title { margin: 10px 0 6px; font-family: var(--font-kai); font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 5px; margin: 8px 0; }
.legend .opt { font-size: 13px; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--line); background: var(--card); }
.legend .opt b { color: var(--ink-2); margin-right: 4px; font-family: var(--font-kai); }
.legend .opt.ok { border-color: var(--green); background: rgba(61,90,76,.09); }
.legend .opt.ok b, .legend .opt.ok { color: var(--green); }
.legend .opt.bad { border-color: var(--cinnabar); background: rgba(176,58,46,.07); }
.legend .opt.bad b, .legend .opt.bad { color: var(--cinnabar); }
.passage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 0 rgba(43,43,40,.04);
  font-size: 15px; line-height: 2.2;
  position: relative;
}
.stamp {
  position: absolute; top: 10px; right: 12px;
  width: 54px; height: 54px;
  border: 3px solid var(--cinnabar);
  border-radius: 8px;
  color: var(--cinnabar);
  font-family: var(--font-kai); font-size: 32px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1.5px rgba(176,58,46,.35);
  background: rgba(176,58,46,.05);
  transform: rotate(-8deg);
  animation: stampIn .35s cubic-bezier(.2,1.4,.4,1) both;
  pointer-events: none;
}
@keyframes stampIn {
  from { opacity: 0; transform: rotate(-14deg) scale(1.8); }
  to { opacity: 1; transform: rotate(-8deg) scale(1); }
}
.blank { display: inline-flex; align-items: center; gap: 2px; }
.blank .no { font-size: 11px; color: var(--paper); background: var(--ink); border-radius: 2px; padding: 0 5px; font-family: var(--font-kai); margin-right: 2px; }
.blank select {
  border: none; border-bottom: 2px solid var(--ink); background: transparent;
  color: var(--ink); font-weight: 700; font-size: 14px; padding: 0 2px; min-width: 52px;
  cursor: pointer; border-radius: 0;
}
.blank select.right { border-bottom: 2.5px solid var(--green); color: var(--green); }
.blank select.wrong { border-bottom: 2.5px solid var(--cinnabar); color: var(--cinnabar); animation: shake .3s ease; }
.blank.done .surface { font-weight: 700; color: var(--green); }
.blank.miss .surface { font-weight: 700; color: var(--cinnabar); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.score { font-family: var(--font-kai); font-weight: 700; font-size: 16px; margin: 10px 0; letter-spacing: 1px; }
.score .good { color: var(--green); }
.score .poor { color: var(--cinnabar); }
.analysis { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.analysis h4 {
  margin: 0 0 8px; font-family: var(--font-kai); font-weight: 700; letter-spacing: 2px; font-size: 15.5px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.analysis h4::before, .analysis h4::after {
  content: ""; flex: none; width: 26px; height: 7px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='7'%3E%3Cpath d='M0 4 Q3.75 .5 7.5 4 T15 4 T22.5 4 T30 4' fill='none' stroke='%23c9c2ae' stroke-width='1.4'/%3E%3C/svg%3E") center/contain no-repeat;
}
@media (prefers-color-scheme: dark) {
  .analysis h4::before, .analysis h4::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='7'%3E%3Cpath d='M0 4 Q3.75 .5 7.5 4 T15 4 T22.5 4 T30 4' fill='none' stroke='%234a463a' stroke-width='1.4'/%3E%3C/svg%3E");
  }
}
.analysis ol { margin: 0; padding-left: 20px; }
.analysis li { margin-bottom: 9px; font-size: 13.5px; }
.analysis li .aw { font-weight: 700; color: var(--green); }
.analysis li.wrong-blank .aw { color: var(--cinnabar); }
.analysis li .tag { margin: 0 2px; }
.translation { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; font-size: 13.5px; color: var(--ink-2); }

/* ---------- 记忆短文 ---------- */
.mem-passage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(43,43,40,.04);
  position: relative; overflow: hidden;
}
.mem-passage::before {
  content: "记"; position: absolute; top: 10px; right: 12px;
  writing-mode: vertical-rl;
  font-family: var(--font-kai); font-size: 11px; letter-spacing: 3px;
  color: var(--ink-2); opacity: .65;
}
.mem-passage::after {
  content: "墨"; position: absolute; right: -6px; bottom: -22px;
  font-family: var(--font-kai); font-size: 92px; line-height: 1;
  color: var(--ink); opacity: .05; pointer-events: none;
}
.mem-passage .passage-en { font-size: 15px; line-height: 2; }
.mem-passage .passage-en .tw {
  color: var(--green);
  font-weight: 700;
  border-bottom: 1.5px solid var(--green);
  padding: 0 1px;
}
.mem-bar { display: flex; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }
.passage-cn { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 10px; font-size: 14px; line-height: 2; }
.sense-reveal {
  background: rgba(166,123,79,.16);
  border-radius: 3px; padding: 0 4px; cursor: pointer;
  border-bottom: 1.5px dashed var(--ochre); font-weight: 600;
  transition: background .15s;
}
.sense-reveal:hover { background: rgba(166,123,79,.28); }
.sense-reveal.revealed { background: rgba(61,90,76,.1); color: var(--green); border-bottom: 1.5px solid var(--green); animation: fadeUp .2s ease; }

/* ---------- 同义词 / 相似词 ---------- */
.word-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px; margin: 9px 0;
  display: flex; gap: 10px; align-items: flex-start;
  animation: cardIn .3s ease both;
}
.word-card .wc-main { flex: 1; min-width: 0; }
.wc-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.wc-word { font-family: var(--font-kai); font-size: 16.5px; font-weight: 700; }
.wc-word.hf { color: var(--cinnabar); }
.wc-word.hf::after {
  content: "高频"; font-size: 10.5px; color: #f7f3ea; background: var(--cinnabar);
  border-radius: 3px; padding: 1px 5px; margin-left: 7px; letter-spacing: 1px;
}
.wc-pos { color: var(--ink-2); font-style: italic; font-size: 12.5px; }
.wc-hidden { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.wc-def { font-size: 13.5px; margin-top: 3px; }
.wc-def .diff { color: var(--ink-2); display: block; margin-top: 3px; }
.wc-actions { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.add-book-btn { border: 1px solid var(--green); background: transparent; color: var(--green); font-size: 12px; cursor: pointer; padding: 2px 9px; border-radius: 4px; }
.add-book-btn:hover { background: rgba(61,90,76,.08); }
.reveal-btn { white-space: nowrap; }
.sense-radios { display: flex; flex-direction: column; gap: 5px; margin: 6px 0 2px; }
.sense-radios label { font-size: 13.5px; display: flex; gap: 6px; align-items: baseline; }
.sense-radios input { accent-color: var(--green); }
.sense-radios .pos { color: var(--ink-2); font-style: italic; font-size: 12px; }
.sense-radios .star { color: var(--cinnabar); }

/* ---------- 弹层：卷轴装裱 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(43,43,40,.4); z-index: 50; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(92vw, 560px); max-height: 84vh; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 4px; padding: 18px;
  box-shadow: 0 12px 40px rgba(30,30,26,.25);
  animation: scrollOpen .3s ease-out both;
}
.modal::before {
  content: ""; position: absolute; inset: 4px;
  border: 1px solid var(--line); border-radius: 2px;
  pointer-events: none;
}
@keyframes scrollOpen { from { clip-path: inset(0 50% 0 50%); opacity: .5; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
.modal h3 { margin: 0 0 8px; font-family: var(--font-kai); font-size: 18px; font-weight: 700; letter-spacing: 2px; display: flex; align-items: center; gap: 8px; }
.modal h3 .vdeco {
  writing-mode: vertical-rl;
  font-size: 10.5px; letter-spacing: 2px; font-weight: 400;
  color: #f7f3ea; background: var(--green);
  border-radius: 2px; padding: 3px 1.5px;
  line-height: 1.1; max-height: 34px;
}
.modal textarea {
  width: 100%; border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 14px; padding: 10px; resize: vertical;
}
.paste-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.paste-row .btn.small-btn { border: 1.5px dashed var(--ink-2); box-shadow: none; color: var(--ink-2); }
.modal textarea:focus { outline: none; border-color: var(--green); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 12px; }
.import-preview { background: var(--paper); border: 1px dashed var(--line); border-radius: 6px; padding: 8px 10px; margin-top: 8px; max-height: 30vh; overflow-y: auto; }
.books-list { display: flex; flex-direction: column; gap: 7px; margin: 8px 0; }
.book-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
}
.book-row .bname { flex: 1; font-family: var(--font-kai); font-weight: 700; letter-spacing: 1px; }
.book-row .bcount { color: var(--ink-2); font-size: 12.5px; }
.book-row.active { border-color: var(--green); background: rgba(61,90,76,.07); }
.book-row button { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--ink-2); padding: 2px 5px; border-radius: 4px; }
.book-row button.del:hover { color: var(--cinnabar); }
.book-row button.use { color: var(--green); font-weight: 700; }
.book-row input.rename { flex: 1; border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; background: var(--paper); color: var(--ink); font-size: 13.5px; }
.new-book-row { display: flex; gap: 8px; margin: 10px 0; }
.new-book-row input { flex: 1; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.data-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- toast / loading ---------- */
.toast {
  position: fixed; z-index: 70; left: 50%; bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  border-radius: 4px; padding: 9px 16px; font-size: 13.5px; max-width: 86vw;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.err { background: var(--cinnabar); color: #f7f3ea; }
.gen-loading {
  position: fixed; z-index: 65; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: rgba(247,243,234,.85); color: var(--ink);
  font-family: var(--font-kai); font-size: 15px; letter-spacing: 3px;
  backdrop-filter: blur(1.5px);
}
@media (prefers-color-scheme: dark) { .gen-loading { background: rgba(25,25,21,.88); } }
.gen-loading[hidden] { display: none; }
.spinner {
  width: 26px; height: 34px;
  background: radial-gradient(ellipse 50% 42% at 50% 40%, var(--ink) 60%, transparent 62%);
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  animation: inkDrop 1.6s ease-in-out infinite;
}
@keyframes inkDrop { 0%,100% { transform: scale(.82); opacity: .55; } 50% { transform: scale(1.12); opacity: 1; } }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--paper); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: none; background: none; color: var(--ink-2);
  font-size: 11.5px; font-family: var(--font-kai); letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; cursor: pointer; position: relative;
  padding-top: 4px;
}
.tab .tab-ico { height: 24px; display: flex; align-items: center; transition: transform .2s; }
.tab .tab-ico svg { stroke: currentColor; }
.tab.active { color: var(--ink); font-weight: 700; }
.tab.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; background: var(--cinnabar); border-radius: 0 0 3px 3px;
}
.tab .sel-dot {
  position: absolute; top: 5px; right: calc(50% - 20px);
  background: var(--cinnabar); color: #f7f3ea; border-radius: 999px;
  font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px;
}

@media (min-width: 720px) {
  body { font-size: 15.5px; }
  .app-header { padding-left: calc((100vw - 720px)/2 + 14px); padding-right: calc((100vw - 720px)/2 + 14px); }
  .tabbar { padding-left: calc((100vw - 720px)/2); padding-right: calc((100vw - 720px)/2); }
}
