/* ==========================================================================
   Lexi · 应用外壳与新增交互
   --------------------------------------------------------------------------
   在 tokens.css / app.css 之上补这一层，只做三件事：
   ① 把方案里的「画面」变成可运行的整页应用（视口、抽屉、搜索、弹窗）
   ② 补齐 app.css 里没有的组件：原生 dialog、菜单、统计条、空状态、编辑表单
   ③ 响应式：900 以下侧栏变抽屉；375 下手不横向滚动
   配色、字体族、圆角阶梯全部沿用 tokens.css，不新增任何颜色令牌。
   ========================================================================== */

/* ── 1 · 整页外壳 ───────────────────────────────────────────── */
html, body { height: 100%; }
body { overflow: hidden; }

.app-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: var(--fs-md);
  line-height: var(--lh-ui);
  letter-spacing: var(--ls-ui);
}

.app-shell .workspace { flex: 1; min-height: 0; }

.brand {
  border: 0; background: transparent; text-align: left;
  font-family: inherit;
}
.brand-mark {
  width: 30px; height: 30px; flex: none;
  display: block;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }

.only-mobile { display: none; }

/* 搜索组合：有内容时右侧让出清除按钮 */
.combo-search.has-value input { padding-right: 30px; }
.search-clear {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-2); background: transparent;
  color: var(--text-3); cursor: pointer;
}
.search-clear:hover { background: var(--hover); color: var(--text); }
.search-clear .ic { position: static; transform: none; width: 13px; height: 13px; }

/* ── 2 · 侧栏补充 ──────────────────────────────────────────── */
.side-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 6px var(--sb-text);
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .05em; color: var(--text-3);
}
.side-head .spacer { flex: 1; }
.side-add {
  width: 24px; height: 24px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-2); background: transparent;
  color: var(--text-3); cursor: pointer;
}
.side-add:hover { background: var(--hover); color: var(--accent); }
.side-add .ic { width: 14px; height: 14px; }

.art-folder-body { display: none; }
.art-folder.open .art-folder-body { display: block; }
.art-folder-head .fcaret {
  left: 43px; display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px;
  transition: transform var(--dur) var(--ease);
}
.art-folder.open .art-folder-head .fcaret { transform: rotate(90deg); }
.art-folder-head .fcaret .ic { width: 12px; height: 12px; }

.art-add {
  display: flex; align-items: center; gap: 6px;
  width: calc(100% - 16px); margin: 2px 8px 4px;
  padding: 7px 10px 7px var(--sb-text);
  border: 0; border-radius: var(--r-2); background: transparent;
  color: var(--text-3); font-family: inherit; font-size: var(--fs-xs);
  cursor: pointer; text-align: left;
}
.art-add:hover { background: var(--hover); color: var(--text); }
.art-add .ic { width: 13px; height: 13px; }

.side-keys { margin-top: 8px; opacity: .75; line-height: 1.6; }

.sidebar-scrim {
  position: fixed; inset: var(--topbar-h) 0 0 0;
  background: rgb(22 21 15 / .38);
  z-index: 55;
  border: 0; padding: 0;
}

/* ── 3 · 主内容区通用 ──────────────────────────────────────── */
.pane-inner { width: 100%; }

.view-in { animation: viewIn .22s var(--ease-out-quint) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.pane-inner.pane-anim { animation: viewIn .22s var(--ease-out-quint) both; }

.section-title {
  font-size: var(--fs-xl); font-weight: 650; letter-spacing: var(--ls-ui);
  margin: 0 0 var(--s-3);
}

.eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-3);
}

/* ── 4 · 词条详情（编辑器 / 语言空态） ─────────────────────── */
.composer { margin-bottom: var(--s-5); }
.detail-title { white-space: normal; overflow: visible; text-overflow: clip; }
.lang-btn:disabled { opacity: .42; cursor: not-allowed; }
.lang-btn:disabled:hover { color: var(--text-3); background: transparent; }

/* 词条详情的中 / EN：只保留语言代码，尽量轻 */
.term-lang-switch { padding: 2px; gap: 1px; }
.term-lang-switch .lang-btn {
  min-width: 30px; padding: 2px 7px;
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: .02em; line-height: 1.6;
}

.field-empty {
  display: inline-block; color: var(--text-3); font-size: var(--fs-sm);
  font-style: normal; line-height: 1.7;
}
.detail .field-body { font-size: calc(var(--read-lg) * var(--read-scale, 1)); overflow-wrap: anywhere; }
.detail .detail-title { font-size: calc(var(--read-h1) * var(--read-scale, 1)); }

.detail-toolrow {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  margin: var(--s-4) 0 var(--s-3);
}
.detail-source {
  font-size: var(--fs-xs); color: var(--text-3);
  background: var(--bg-sunken); border-radius: var(--r-full);
  padding: 4px 10px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.detail-meta span + span::before { content: '·'; margin-right: 14px; color: var(--ink-faint); }

.field-body .term-link,
.plain .term-link {
  display: inline; padding: 0 1px; border: 0; background: transparent;
  color: var(--accent); font: inherit; cursor: pointer;
  border-bottom: 1px dashed var(--accent-soft-2); border-radius: var(--r-1);
}
.field-body .term-link:hover { background: var(--accent-soft); border-bottom-color: var(--accent); }

.lang-empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3);
  margin: var(--s-5) 0 var(--s-4); padding: var(--s-6);
  border: 1px dashed var(--line-strong); border-radius: var(--r-4);
  background: var(--bg-elev); max-width: var(--measure-read);
}
.lang-empty b { font-size: var(--fs-lg); color: var(--text); }
.lang-empty p { margin: 0; font-size: var(--fs-sm); color: var(--text-3); line-height: 1.7; }

.edit-form { margin-top: var(--s-6); }
.edit-form .edit-field { margin-bottom: var(--s-5); max-width: var(--measure-read); }
.edit-form label {
  display: block; margin-bottom: 6px;
  font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
}
.edit-form .input, .edit-form .textarea { background: var(--bg-elev); }
.edit-form .textarea {
  min-height: 96px; font-family: var(--font-sans);
  font-size: var(--fs-md); line-height: 1.7;
}
.edit-note { font-size: var(--fs-xs); color: var(--text-3); margin: 0 0 var(--s-5); max-width: var(--measure-read); }
.err-text { color: var(--err); font-size: var(--fs-xs); margin: 6px 0 0; }

.detail-toolbar {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  margin-top: var(--s-6); padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

/* ── 5 · 搜索视图 ──────────────────────────────────────────── */
.search-view { padding-top: var(--s-2); }
.sv-head { margin-bottom: var(--s-5); }
.sv-title {
  font-size: var(--fs-2xl); font-weight: 650; letter-spacing: var(--ls-title);
  margin: 6px 0 0; line-height: 1.3;
}
.sv-sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 6px; }
.sv-list { display: grid; gap: var(--s-2); }
.sv-item {
  display: block; width: 100%; text-align: left;
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line); border-radius: var(--r-3);
  background: var(--bg-elev); cursor: pointer; font-family: inherit;
  transition: border-color var(--dur), background var(--dur), transform var(--dur);
}
.sv-item:hover { border-color: var(--line-strong); background: var(--hover); }
.sv-item:active { transform: scale(.997); }
.sv-top { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.sv-name { font-size: var(--fs-lg); font-weight: 650; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.sv-cat {
  font-size: var(--fs-2xs); color: var(--text-3);
  background: var(--bg-sunken); border-radius: var(--r-full); padding: 2px 8px;
}
.sv-snip {
  margin-top: 5px; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.65;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
mark { background: var(--accent-soft-2); color: inherit; border-radius: 2px; padding: 0 1px; }

.sv-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s-2); padding: var(--s-20) var(--s-5) var(--s-12);
}
.sv-empty .empty-ic {
  width: 44px; height: 44px; color: var(--text-3); opacity: .45; margin-bottom: var(--s-1);
}
.sv-empty > .ic { width: 44px; height: 44px; color: var(--text-3); opacity: .4; margin-bottom: var(--s-1); }
.sv-empty h2 { margin: 0; font-size: var(--fs-xl); font-weight: 650; }
.sv-empty p { margin: 0; font-size: var(--fs-sm); color: var(--text-3); line-height: 1.7; max-width: 420px; }
.sv-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; margin-top: var(--s-3); }

/* ── 6 · 文章工作台补充 ────────────────────────────────────── */
.explain-def, .explain-plain { overflow-wrap: anywhere; }
.reader-nav .reader-title {
  position: static; transform: none; flex: 1; min-width: 0; margin: 0;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-nav .reader-cat { margin-left: 0; }
.reader-input .reader-text { min-height: 300px; }
.reader-bar { border-top: 1px solid var(--line); margin-top: var(--s-3); }
.reader-bar .spacer { flex: 1; }
.reader-leadrow .usage-chip { border: 0; cursor: pointer; font-family: inherit; }
.reader-leadrow .usage-chip:hover { background: var(--hover); color: var(--text); }
.reader-colhead .n { margin-left: auto; font-weight: 500; }
.pick-text { display: flex; flex-direction: column; gap: 2px; }
.pick-term, .pick-gloss { display: block; }
.pick-gloss { margin-top: 0; }
.pick.exists .pick-gloss { color: var(--text-3); }
.pick input:disabled { opacity: .45; cursor: default; }
.reader-foot .btn[disabled] { opacity: .45; }
.reader-empty { padding: var(--s-8) var(--s-4); text-align: center; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.7; }

/* ── 7 · 原生 dialog / 弹窗 ────────────────────────────────── */
.row-label { display: block; font-size: var(--fs-sm); font-weight: 550; color: var(--text-2); margin-bottom: 5px; }
dialog.modal-dialog {
  position: fixed; inset: 0;
  width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh;
  margin: 0; padding: 9vh 20px 40px;
  border: 0; background: transparent; color: var(--text);
  overflow-y: auto; overscroll-behavior: contain;
  font-family: var(--font-sans);
}
dialog.modal-dialog::backdrop {
  background: rgb(22 21 15 / .44);
  backdrop-filter: blur(2px);
}
dialog.modal-dialog[open] .modal { animation: modalIn .22s var(--ease-out-quint) both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.modal { margin: 0 auto; max-width: 100%; }
.modal .modal-head { padding-inline: 56px; }
.modal-body { max-height: min(58vh, 560px); overflow-y: auto; }
.modal--wide { width: min(720px, 94vw); }
.modal--wide .modal-body { max-height: min(62vh, 620px); }
.modal--settings { width: min(880px, 94vw); }
.modal--settings .modal-body { max-height: min(60vh, 600px); }
.modal--confirm { width: min(460px, 94vw); }

.modal-x {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-2); background: transparent;
  color: var(--text-3); cursor: pointer; font-size: 19px; line-height: 1;
}
.modal-x:hover { background: var(--hover); color: var(--text); }
.modal-x .ic { width: 16px; height: 16px; }

.modal-foot .spacer { flex: 1; }
.modal-foot .danger-left { margin-right: auto; }
.section { margin-bottom: var(--s-6); }
.modal .hint { line-height: 1.6; }
.modal .textarea {
  min-height: 108px; font-family: var(--font-sans);
  font-size: var(--fs-lg); line-height: 1.6;
}
.modal .chips { padding: 2px 0 0; }
.modal .chips .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal .section:last-child { margin-bottom: 0; }
.modal .row:last-child { margin-bottom: 0; }
.modal .kv { font-size: var(--fs-sm); }
.modal .modal-sub { font-size: var(--fs-sm); color: var(--text-3); margin: -4px 0 0; }

.field-inline-err { color: var(--err); font-size: var(--fs-xs); margin-top: 6px; }

.range-row { display: flex; align-items: center; gap: var(--s-3); }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-value {
  min-width: 46px; text-align: right; font-family: var(--font-mono);
  font-size: var(--fs-xs); color: var(--text-2);
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-2) 0;
}
.switch-row label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; margin: 0; }
.switch-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.test-note { font-size: var(--fs-xs); margin-top: 6px; }
.test-note.ok { color: var(--ok); }
.test-note.err { color: var(--err); }

/* ── 8 · 菜单 ──────────────────────────────────────────────── */
.menu { max-height: min(70vh, 460px); overflow-y: auto; }
.menu button { display: flex; align-items: center; gap: 9px; }
.menu button .ic { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.menu button:hover .ic { color: var(--text); }
.menu-hint { margin-left: auto; font-size: var(--fs-2xs); color: var(--text-3); }
.menu button[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.menu button[aria-checked="true"] .ic { color: var(--accent); }

/* ── 9 · 统计弹窗 ──────────────────────────────────────────── */
.stat-cards {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--r-3);
  overflow: hidden; margin-bottom: var(--s-5);
}
.stat-cell { padding: var(--s-4); background: var(--bg-elev); border-right: 1px solid var(--line); }
.stat-cell:last-child { border-right: 0; }
.stat-cell .v { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-cell .v.accent { color: var(--accent); }
.stat-cell .l { margin-top: 4px; font-size: var(--fs-2xs); color: var(--text-3); }

.bar-list { display: grid; gap: 10px; margin: 0 0 var(--s-5); }
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 34px; gap: 10px; align-items: center; }
.bar-name { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: var(--r-full); background: var(--bg-sunken); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); background: var(--accent); }
.bar-num { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }

/* ── 10 · 空状态 / 状态提示 ────────────────────────────────── */
.state-note {
  display: flex; align-items: flex-start; gap: 9px;
  margin: var(--s-4) 0; padding: 11px 14px;
  border-radius: var(--r-3); background: var(--bg-sunken);
  color: var(--text-2); font-size: var(--fs-sm); line-height: 1.65;
}
.state-note .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--text-3); }
.state-note.warn { background: var(--warn-soft); color: var(--text); }
.state-note.err { background: var(--err-soft); color: var(--text); }
.state-note.ok { background: var(--ok-soft); color: var(--text); }

/* ── 11 · 减少动效（设置项） ──────────────────────────────── */
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}

body.resizing { cursor: col-resize; user-select: none; }
.home-quote .mark-end { margin-left: auto; align-self: flex-end; }
.explain-act:disabled { opacity: .45; cursor: default; }
.explain-x { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; }
.explain-x .ic { width: 14px; height: 14px; }

/* 暗色主题：橙色实心控件改用深色字，保证 4.5:1 以上对比 */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-danger-solid,
html[data-theme="dark"] .combo-new,
html[data-theme="dark"] .home-cta,
html[data-theme="dark"] .tabs button.on { color: #171008; }
html[data-theme="dark"] .btn-danger-solid:hover:not(:disabled) {
  background: color-mix(in srgb, var(--err) 82%, #fff);
  color: #171008;
}

.reader-field-label {
  display: block; margin: 0 0 8px;
  font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── 12 · 响应式 ──────────────────────────────────────────── */
@media (max-width: 1080px) {
  .topbar { grid-template-columns: minmax(120px, auto) minmax(0, 1fr) auto; gap: var(--s-3); }
  .brand .slogan { display: none; }
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-cell:nth-child(2) { border-right: 0; }
  .stat-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .only-mobile { display: grid; }
  .topbar { padding: 0 var(--s-3); gap: var(--s-2); }
  .topbar-center { max-width: 560px; }
  .topbar-actions { gap: 0; }
  .combo-cat { padding: 0 8px; }
  .combo-cat-name { display: none; }
  .combo-swatch { width: 8px; height: 8px; }
  .search-combo { height: 36px; }
  .combo-new { width: 32px; height: 32px; }

  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 60;
    width: min(290px, 86vw);
    transform: translateX(-102%);
    transition: transform .24s var(--ease-out-quint);
    box-shadow: var(--shadow-2);
  }
  .app-shell.sidebar-open .sidebar { transform: none; }
  .resizer { display: none; }

  .pane-inner { padding: var(--s-6) var(--s-4) var(--s-16); }
  .pane-inner.reader-open { display: block; flex: none; padding: var(--s-3) var(--s-4) var(--s-6); }
  .pane-scroll.reader-open { display: block; overflow-y: auto; }
  .reader { display: block; }
  .reader-split { flex-direction: column; gap: var(--s-4); }
  .reader-src-body { max-height: 290px; flex: none; }
  .reader-list { max-height: 400px; flex: none; }

  .detail-head-top { flex-wrap: wrap; gap: var(--s-3); }
  .detail-title { font-size: clamp(26px, 8vw, 34px); }
  .detail .detail-title { font-size: clamp(26px, 8vw, 34px); }
  .detail-actions .btn-danger { margin-left: 0; }

  .home-hero { gap: var(--s-4); margin-bottom: var(--s-6); }
  .home-nest { width: 116px; height: 104px; }
  .home-big b { font-size: 42px; }
  .home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-stat { padding: var(--s-3) var(--s-3) var(--s-3) 0; }
  .home-stat:not(:first-child) { padding-left: var(--s-3); }
  .home-stat:nth-child(3) { padding-left: 0; }
  .home-stat:nth-child(2) { border-right: 0; }
  .home-stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .home-bars { gap: var(--s-2); }
  .home-quote { padding: var(--s-4); }
  .home-quote .qtext { font-size: var(--fs-lg); }

  dialog.modal-dialog { padding: 5vh 12px 24px; }
  .modal--settings { width: 100%; }
  .modal-body { max-height: 66vh; }
  .modal--wide .modal-body, .modal--settings .modal-body { max-height: 66vh; }

  .reader-nav { flex-wrap: wrap; row-gap: var(--s-2); }
  .reader-nav .reader-title {
    flex: 1 1 100%; order: 5;
    text-align: left; white-space: normal; overflow: visible; text-overflow: clip;
    overflow-wrap: anywhere; font-size: var(--fs-lg); margin-top: 2px;
  }
  .reader-leadrow { flex-direction: column; gap: var(--s-2); }
}

@media (max-width: 560px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .brand-mark { width: 30px; height: 30px; }
  .topbar-actions .icon-btn { width: 32px; }
  .combo-cat { display: none; }
  .combo-search input { padding-left: 30px; font-size: var(--fs-sm); }
  .combo-search .ic { left: 9px; }

  .home-hero { align-items: flex-start; }
  .home-nest { width: 88px; height: 80px; }
  .home-big b { font-size: 38px; }
  .home-sub { font-size: var(--fs-sm); }

  .detail-stats { gap: 6px; }
  .stat { height: 30px; padding: 0 10px; }

  .modal-head { font-size: var(--fs-xl); }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 78px minmax(0, 1fr) 28px; }
  .sv-actions .btn { flex: 1 1 auto; }

  .reader-back, .reader-del, .reader-cat { height: 32px; padding: 0 10px; font-size: var(--fs-sm); }
  .reader-add-row { flex-wrap: wrap; }
  .reader-add-input { flex-basis: 100%; }
}

/* ══════════════════════════════════════════════════════════════
   18 · 顶栏加号 FAB 与引导动画（按源码恢复）
   ══════════════════════════════════════════════════════════════ */
.topbar-center { gap: 10px; }
.topbar-center .search-combo { flex: 1; min-width: 0; width: auto; }

.fab {
  width: 38px; height: 38px; flex: none; position: relative;
  border: 0; border-radius: var(--r-full); cursor: pointer;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--sh-fab);
  transition: transform var(--dur) var(--spring), background var(--dur), box-shadow var(--dur);
}
.fab:hover { background: var(--accent-hover); transform: scale(1.07); }
.fab:active { transform: scale(.93); }
.fab .ic { width: 19px; height: 19px; }
.fab::after {
  content: ''; position: absolute; inset: 0; border-radius: var(--r-full);
  pointer-events: none; opacity: 0; transform: scale(1);
  box-shadow: 0 0 0 0 var(--accent-soft-2), 0 0 14px 3px var(--accent-ring);
}
html[data-theme="dark"] .fab { color: #171008; }

.guide { position: absolute; top: 0; height: 100%; z-index: 7; }
.guide[hidden] { display: none !important; }
.guide-stage { position: absolute; inset: 0; pointer-events: none; }
.gd { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gd-stem {
  fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round;
  stroke-dasharray: 260; stroke-dashoffset: 260; animation: gdDraw 4.6s ease-in-out infinite;
}
.gd-leaf {
  fill: var(--accent); opacity: 0; transform-origin: center;
  animation: gdLeaf 4.6s ease-in-out infinite;
}
@keyframes gdDraw {
  0% { stroke-dashoffset: 260 } 34% { stroke-dashoffset: 0 }
  80% { stroke-dashoffset: 0; opacity: 1 } 94% { opacity: 0 }
  100% { stroke-dashoffset: 260; opacity: 0 }
}
@keyframes gdLeaf {
  0%, 18% { opacity: 0; transform: scale(.2) } 38% { opacity: .9; transform: scale(1) }
  80% { opacity: .9; transform: scale(1) } 94%, 100% { opacity: 0 }
}
.gd-ink {
  fill: none; stroke: var(--text-3); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 300; stroke-dashoffset: 300; animation: gdDraw2 4.4s ease-in-out infinite;
}
@keyframes gdDraw2 {
  0% { stroke-dashoffset: 300 } 38% { stroke-dashoffset: 0 }
  82% { stroke-dashoffset: 0; opacity: .85 } 96% { opacity: 0 }
  100% { stroke-dashoffset: 300; opacity: 0 }
}
.gd-streak {
  position: absolute; top: 50%; left: 0; width: 0; height: 2.5px; margin-top: -1.25px;
  border-radius: 3px; opacity: 0;
  background: linear-gradient(90deg, transparent 0%, var(--accent-soft-2) 58%, var(--accent) 100%);
  animation: gdStreak 3.4s cubic-bezier(.5,0,.4,1) infinite;
}
@keyframes gdStreak {
  0%, 12% { width: 0; opacity: 0 } 15% { opacity: .9 }
  60% { width: calc(100% - 4px); opacity: .55 }
  74% { width: calc(100% - 4px); opacity: 0 } 100% { width: 0; opacity: 0 }
}
.gd-dot {
  position: absolute; top: 50%; left: 0; width: 8px; height: 8px; margin-top: -4px;
  border-radius: var(--r-full); background: var(--accent);
  box-shadow: 0 0 12px 2px var(--accent-ring);
  animation: gdFly 3.4s cubic-bezier(.5,0,.4,1) infinite;
}
@keyframes gdFly {
  0% { left: 0; transform: scale(.6); opacity: 0 }
  12% { left: 0; transform: scale(1); opacity: 1 }
  60% { left: calc(100% - 8px); transform: scale(1); opacity: 1 }
  70% { left: calc(100% - 8px); transform: scale(1.6); opacity: 0 }
  100% { left: calc(100% - 8px); transform: scale(.6); opacity: 0 }
}
.gd-card {
  position: absolute; top: 50%; left: 0; width: 30px; height: 22px; margin-top: -11px;
  border-radius: 5px; background: var(--text);
  box-shadow: 0 4px 12px rgb(0 0 0 / .2);
  animation: gdCard 4s ease-in-out infinite;
}
@keyframes gdCard {
  0% { left: 0; transform: translateY(6px) rotate(-9deg) scale(.8); opacity: 0 }
  10% { opacity: 1 }
  58% { left: calc(100% - 30px); transform: translateY(-2px) rotate(4deg) scale(1); opacity: 1 }
  68% { left: calc(100% - 30px); transform: scale(.35); opacity: 0 }
  100% { left: calc(100% - 30px); transform: scale(.35); opacity: 0 }
}
.fab.gd-glow-branch::after { animation: gdGlowBranch 4.6s ease-out infinite; }
.fab.gd-glow-sketch::after { animation: gdGlowSketch 4.4s ease-out infinite; }
.fab.gd-glow-dot::after    { animation: gdGlowDot    3.4s ease-out infinite; }
.fab.gd-glow-card::after   { animation: gdGlowCard   4s ease-out infinite; }
@keyframes gdGlowBranch {
  0%, 30% { opacity: 0; transform: scale(1) } 36% { opacity: 1; transform: scale(1.05) }
  58% { opacity: 0; transform: scale(1.65) } 100% { opacity: 0; transform: scale(1) }
}
@keyframes gdGlowSketch {
  0%, 34% { opacity: 0; transform: scale(1) } 40% { opacity: 1; transform: scale(1.05) }
  62% { opacity: 0; transform: scale(1.65) } 100% { opacity: 0; transform: scale(1) }
}
@keyframes gdGlowDot {
  0%, 56% { opacity: 0; transform: scale(1) } 62% { opacity: 1; transform: scale(1.06) }
  84% { opacity: 0; transform: scale(1.7) } 100% { opacity: 0; transform: scale(1) }
}
@keyframes gdGlowCard {
  0%, 54% { opacity: 0; transform: scale(1) } 60% { opacity: 1; transform: scale(1.06) }
  82% { opacity: 0; transform: scale(1.7) } 100% { opacity: 0; transform: scale(1) }
}
.guide-close {
  position: absolute; top: 2px; right: 0; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: var(--r-full); cursor: pointer;
  background: var(--hover); color: var(--text-3);
  line-height: 1; display: grid; place-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur), background var(--dur), color var(--dur);
}
.guide:hover .guide-close { opacity: 1; pointer-events: auto; }
.guide-close:hover { background: var(--active); color: var(--text); }
@media (max-width: 1080px) { .guide { display: none !important; } }

/* ══════════════════════════════════════════════════════════════
   19 · 侧栏右键菜单 / 未归类
   ══════════════════════════════════════════════════════════════ */
.menu button.menu-danger { color: var(--err); }
.menu button.menu-danger .ic { color: var(--err); }
.menu button.menu-danger:hover { background: var(--err-soft); }
.menu .menu-heading { letter-spacing: .04em; }
.art-sublabel { padding: 8px 10px 4px var(--sb-text); font-size: var(--fs-2xs); font-weight: 650; color: var(--text-3); }

/* ══════════════════════════════════════════════════════════════
   20 · 文章输入 / 阅读 / 框选
   ══════════════════════════════════════════════════════════════ */
.reader-rag {
  height: 30px; padding: 0 10px; font-size: var(--fs-xs); white-space: nowrap;
  background: var(--rag-bg); border-color: var(--rag-line); color: var(--rag-ink);
}
.reader-rag:hover:not(:disabled) { background: var(--rag-bg-hover); border-color: var(--rag-line); color: var(--rag-ink); }
.reader-close { width: 32px; height: 32px; flex: none; }
.reader-close .ic { width: 16px; height: 16px; }
.reader-del { flex: none; }
.reader-del .ic { width: 16px; height: 16px; }
.reader-nav .reader-title { min-width: 0; }
.reader-filerow { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.reader-filehint { font-size: var(--fs-xs); color: var(--text-3); }
.reader-input .reader-text { min-height: 220px; flex: 1; }
.reader-input .reader-bar { flex-wrap: wrap; row-gap: 8px; }
.reader-input .reader-max { margin-left: 0; }
.reader-input .reader-bar .spacer { flex: 1; min-width: 8px; }
.reader-max select { height: 30px; }
.reader-phase {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-2xs); color: var(--text-3); letter-spacing: .04em;
}
.reader-selectall { display: flex; gap: 10px; margin-left: auto; }
.reader-colhead .reader-cost { color: var(--text-3); font-weight: 500; }
.reader-rag.done { color: var(--ok); border-color: var(--ok); background: var(--rag-bg); }
.reader-empty-read { padding: 54px 20px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.8; }

.read-wrap { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.read-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.read-hint { flex: 1; min-width: 180px; font-size: var(--fs-xs); color: var(--text-3); }
.read-font { display: inline-flex; gap: 2px; }
.read-font-btn {
  height: 28px; min-width: 32px; padding: 0 7px; border: 1px solid var(--line);
  border-radius: var(--r-2); background: var(--bg-elev); color: var(--text-2);
  font-family: var(--font-mono); font-size: 11px; cursor: pointer;
}
.read-font-btn:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.read-font-btn:disabled { opacity: .35; cursor: default; }
.read-body {
  flex: 1; min-height: 0; overflow: auto; padding: 22px 24px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-4);
  font-size: calc(var(--read-lg) * var(--read-scale, 1)); line-height: 1.9; color: var(--text);
  user-select: text; -webkit-user-select: text;
}
.read-para { margin: 0 0 15px; }
.read-para:last-child { margin-bottom: 0; }
.read-term {
  display: inline; padding: 0 2px; border: 0; border-radius: var(--r-1);
  background: var(--accent-soft); color: inherit; font: inherit; cursor: pointer;
  border-bottom: 1px dashed var(--accent-soft-2);
}
.read-term:hover { background: var(--accent-soft-2); }
.read-pill-wrap {
  position: fixed; z-index: 320; display: flex; align-items: center; gap: 6px;
}
.read-pill {
  height: 32px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: var(--r-2); background: var(--bg-elev); color: var(--text);
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--shadow-1); cursor: pointer;
}
.read-pill:hover { border-color: var(--line-strong); background: var(--bg-sunken); }
.read-pill.add { color: var(--accent); }

.collect-bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 190; width: min(780px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: var(--r-3);
  box-shadow: var(--shadow-2);
}
.cb-chips { display: flex; align-items: center; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; }
.cb-chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  max-width: 210px; padding: 4px 8px; border-radius: var(--r-2);
  background: var(--bg-sunken); font-size: var(--fs-2xs); color: var(--text-2);
}
.cb-chip b { color: var(--accent); font-variant-numeric: tabular-nums; }
.cb-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-x { border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 0 1px; font-size: 13px; }
.cb-x:hover { color: var(--err); }
.cb-acts { display: flex; gap: 6px; flex: none; }
.cb-act {
  height: 30px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: var(--r-2); background: var(--bg); color: var(--text-2);
  font-family: inherit; font-size: var(--fs-2xs); cursor: pointer; white-space: nowrap;
}
.cb-act:hover { background: var(--hover); color: var(--text); }
.cb-act.pri { background: var(--accent); border-color: transparent; color: #fff; }
.cb-act.pri:hover { background: var(--accent-hover); color: #fff; }
html[data-theme="dark"] .cb-act.pri { color: #171008; }

/* 阅读态放宽内容列 */
.pane-inner.reading-open { max-width: var(--pane-w-read); }
.reading-open .read-bar,
.reading-open .read-para { width: 100%; max-width: var(--measure-read); margin-left: auto; margin-right: auto; }
.reading-open .read-body { padding: 30px 56px; flex: 0 1 auto; max-height: 100%; }
@media (max-width: 1240px) { .reading-open .read-body { padding: 20px 22px; } }
@media (max-width: 900px) {
  .reading-open .read-body { padding: 18px 16px; }
  .reader-rag { height: 28px; padding: 0 8px; }
  .read-bar { gap: 8px; }
  .collect-bar { bottom: 12px; padding: 6px 8px; }
}

/* ══════════════════════════════════════════════════════════════
   21 · 设置页新增组件
   ══════════════════════════════════════════════════════════════ */
.plan-tag {
  font-size: var(--fs-2xs); font-weight: 650; padding: 2px 8px;
  border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent);
}
.qbar { height: 7px; border-radius: var(--r-full); background: var(--bg-sunken); overflow: hidden; }
.qbar i { display: block; height: 100%; border-radius: var(--r-full); background: var(--accent); }
.qrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 9px 0 5px; font-size: var(--fs-xs); color: var(--text-3); }
.qnum { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-2); font-variant-numeric: tabular-nums; }
.quota-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.license-state { font-size: var(--fs-xs); margin-top: 6px; }
.license-state.ok { color: var(--ok); }
.license-state.err { color: var(--err); }
.device-id { display: inline-block; margin-left: 4px; font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-2); }
.provider-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--line-strong); background: var(--hover); color: var(--text); }
button.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.settings-note { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.65; margin: 6px 0 0; }
.sync-code {
  font-family: var(--font-mono); font-size: var(--fs-sm); letter-spacing: .08em;
  background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--r-2);
  padding: 8px 10px; color: var(--text); white-space: nowrap; overflow-x: auto;
}
.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin: 8px 0; }
@media (max-width: 640px) { .sync-grid { grid-template-columns: 1fr; } }
.cat-manager { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.cat-manager .input { flex: 1; }
.modal--settings .section > h3 { scroll-margin-top: 12px; }
.modal--settings .modal-body { padding-bottom: 8px; }
.settings-index { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.settings-index button {
  height: 26px; padding: 0 9px; border: 1px solid var(--line);
  border-radius: var(--r-2); background: transparent; color: var(--text-3);
  font-family: inherit; font-size: var(--fs-2xs); cursor: pointer;
}
.settings-index button:hover { color: var(--text); border-color: var(--line-strong); }

/* ── 设置：左侧功能区块 + 右侧面板 ───────────────────────── */
.modal--settings .modal-body {
  padding: 0;
  max-height: none;
  overflow: visible;
}
.settings-shell {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  height: min(60vh, 600px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.settings-nav {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  background: var(--bg-sunken);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}
.settings-nav-item {
  width: 100%;
  min-height: 40px;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  cursor: pointer;
  transition: color var(--dur), background var(--dur), box-shadow var(--dur);
}
.settings-nav-item:hover { color: var(--text); background: var(--hover); }
.settings-nav-item.on {
  color: var(--accent);
  background: var(--bg-elev);
  font-weight: 650;
  box-shadow: var(--sh-1);
}
.settings-nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.settings-panels {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 24px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.settings-panel { display: none; }
.settings-panel.on { display: block; animation: settingsPanelIn .18s var(--ease-out-quint) both; }
@keyframes settingsPanelIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.settings-panel .section { margin-bottom: 28px; }
.settings-panel .section:last-child { margin-bottom: 0; }
.settings-panel .section + .section { padding-top: 22px; border-top: 1px solid var(--line); }
html.reduce-motion .settings-panel.on { animation: none; }

@media (max-width: 760px) {
  .settings-shell { grid-template-columns: clamp(112px, 25vw, 144px) minmax(0, 1fr); height: min(66vh, 620px); }
  .settings-nav { padding: 10px 6px; gap: 8px; }
  .settings-nav-item { min-height: 40px; padding: 10px 8px; font-size: var(--fs-md); }
  .settings-panels { padding: 16px 14px 18px; }
  .settings-panel .section { margin-bottom: 22px; }
  .settings-panel .section + .section { padding-top: 18px; }
}
@media (max-width: 560px) {
  .settings-nav { padding: 8px 4px; gap: 8px; }
  .settings-nav-item { min-height: 40px; padding: 10px 8px; font-size: var(--fs-md); letter-spacing: -.01em; }
  .settings-panels { padding: 14px 12px 16px; }
}

@media (max-width: 1080px) {
  .guide { display: none !important; }
}
@media (max-width: 560px) {
  .fab { width: 36px; height: 36px; }
  .fab .ic { width: 18px; height: 18px; }
  .reader-rag { font-size: 11px; padding: 0 7px; }
  .cb-chip { max-width: 130px; }
  .cb-acts .cb-act:first-child { padding: 0 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .gd-stem, .gd-ink { animation: none; stroke-dashoffset: 0; }
  .gd-leaf { animation: none; opacity: .9; }
  .gd-dot { animation: none; left: calc(50% - 4px); opacity: .85; }
  .gd-streak { animation: none; width: calc(50% - 4px); opacity: .5; }
  .gd-card { animation: none; left: calc(50% - 15px); opacity: .85; }
  .fab::after { animation: none !important; opacity: 0; }
}
html.reduce-motion .gd-stem,
html.reduce-motion .gd-ink,
html.reduce-motion .gd-leaf,
html.reduce-motion .gd-dot,
html.reduce-motion .gd-streak,
html.reduce-motion .gd-card,
html.reduce-motion .fab::after { animation: none !important; }
.reader-del { width: 34px; padding: 0; background: transparent; border-color: transparent; }
.reader-del:hover { background: var(--err-soft); color: var(--err); border-color: transparent; }
mark.read-term { cursor: default; border-bottom: 0; }
.explain-collect-list { display: grid; gap: 8px; max-height: 300px; overflow-y: auto; }
.explain-collect-item {
  display: flex; gap: 9px; padding: 9px 11px; border-radius: var(--r-2);
  background: var(--bg-sunken); font-size: var(--fs-sm); line-height: 1.7; color: var(--text-2);
}
.explain-collect-item b {
  flex: none; color: var(--accent); font-family: var(--font-mono);
  font-size: var(--fs-2xs); padding-top: 2px;
}
.explain-collect-item span { min-width: 0; overflow-wrap: anywhere; }
::highlight(lexi-picked) { background-color: var(--accent-soft-2); color: inherit; }
@media (max-width: 900px) { .reader-del { width: 32px; } }
/* 加号本体的呼吸光：即使窗口不够画引导线，红色圆点加号也不是静止的 */
.fab.gd-glow-branch,
.fab.gd-glow-sketch,
.fab.gd-glow-dot,
.fab.gd-glow-card { animation: fabBreath 3.6s ease-in-out infinite; }
@keyframes fabBreath {
  0%, 100% { box-shadow: var(--sh-fab), 0 0 0 0 var(--accent-soft-2); }
  50% { box-shadow: var(--sh-fab), 0 0 0 7px var(--accent-soft); }
}
@media (prefers-reduced-motion: reduce) { .fab { animation: none !important; } }
html.reduce-motion .fab { animation: none !important; }
