/* EasyRead · 共用的设计变量与基础组件（文献库页和阅读页都用） */
[hidden] { display: none !important; }  /* 元素设了 hidden 就一定藏起来，别被自己的 display 盖掉 */
:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #fbfaf6;
  --surface-2: #efebe2;
  --ink: #23211d;
  --ink-2: #5a554c;
  --ink-3: #8c8579;
  --rule: #e2dcd0;
  --rule-2: #d3cbbb;
  --accent: #2d6173;
  --accent-soft: rgba(45, 97, 115, .08);
  --accent-soft-2: rgba(45, 97, 115, .14);
  --mine: #9c5f1c;
  --mine-soft: rgba(156, 95, 28, .09);
  --danger: #b0472f;
  --ok: #4f7f52;
  --hl: rgba(236, 196, 92, .38);
  --hl-yellow: rgba(236, 196, 92, .40);
  --hl-green: rgba(126, 181, 118, .34);
  --hl-blue: rgba(110, 160, 214, .32);
  --hl-pink: rgba(226, 92, 92, .26);
  --ul-yellow: #d9a42a; --ul-green: #5b9a52; --ul-blue: #4a82c3; --ul-pink: #d0473f;
  --hl-q: rgba(45, 97, 115, .16);
  --focus: rgba(45, 97, 115, .05);
  --shadow: 0 1px 2px rgba(35, 33, 29, .05), 0 8px 28px rgba(35, 33, 29, .10);
  --shadow-lg: 0 2px 6px rgba(35, 33, 29, .06), 0 24px 60px rgba(35, 33, 29, .18);

  --serif-zh: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "Songti SC", "STSong", serif;
  --sans-zh: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --serif-en: "Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, "Noto Serif SC", serif;
  --ui: "Noto Sans SC", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --bar-h: 50px;
}
/* 英文界面：西文字体排前面，否则中文字体会把弯引号、撇号画成全角 */
html[lang="en"] {
  --ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  --serif-zh: "Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, serif;
  --sans-zh: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", sans-serif;
}
/* 译文不是中文时换正文字体（变量名沿用 -zh，指“译文”） */
html[lang="zh-Hant"] { --ui: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei UI", "Microsoft JhengHei", system-ui, sans-serif; }
html[data-target="zh-Hant"] { --serif-zh: "Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, "Noto Serif TC", "Source Han Serif TC", "Songti TC", PMingLiU, serif; --sans-zh: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei UI", sans-serif; }
html[data-target="ja"] { --serif-zh: "Noto Serif JP", "Source Han Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; --sans-zh: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif; }
html[data-target="ko"] { --serif-zh: "Noto Serif KR", "Source Han Serif KR", AppleMyungjo, Batang, serif; --sans-zh: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
html[data-target="en"], html[data-target="es"], html[data-target="fr"], html[data-target="de"], html[data-target="it"] { --serif-zh: "Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, serif; --sans-zh: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1917;
  --surface: #22211e;
  --surface-2: #2a2825;
  --ink: #ddd7cb;
  --ink-2: #b2aa9c;
  --ink-3: #7d766b;
  --rule: #33312d;
  --rule-2: #45423c;
  --accent: #86b8c9;
  --accent-soft: rgba(134, 184, 201, .09);
  --accent-soft-2: rgba(134, 184, 201, .16);
  --mine: #d8a35c;
  --mine-soft: rgba(216, 163, 92, .10);
  --danger: #e08a72;
  --ok: #8fbf8f;
  --hl: rgba(216, 163, 92, .28);
  --hl-yellow: rgba(216, 163, 92, .30);
  --hl-green: rgba(126, 181, 118, .26);
  --hl-blue: rgba(110, 160, 214, .26);
  --hl-pink: rgba(232, 108, 104, .26);
  --ul-yellow: #d8a652; --ul-green: #8fbf84; --ul-blue: #86ade0; --ul-pink: #e8837c;
  --hl-q: rgba(134, 184, 201, .16);
  --focus: rgba(134, 184, 201, .05);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 24px 60px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.6 var(--ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(236, 196, 92, .45); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 15px; height: 15px; }

/* 顶栏：常驻 */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h); z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.topbar .grow { flex: 1; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 9px; font: 650 17px/1 var(--ui); letter-spacing: -.01em; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand .mark { width: 26px; height: 26px; flex: none; display: block; }
.brand b { font-weight: 700; color: var(--accent); }
.brand-back { gap: 3px; padding: 0 8px 0 4px; color: var(--ink-3); }
.brand-back .mark { width: 24px; height: 24px; }
.brand small { font: 400 12.5px/1 var(--ui); color: var(--ink-3); letter-spacing: .02em; margin-left: 2px; }

/* 按钮 */
.btn {
  height: 32px; padding: 0 12px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--ink-2); white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--accent-soft); color: var(--ink); }
.btn.on { background: var(--accent-soft-2); color: var(--accent); }
.btn.line { box-shadow: inset 0 0 0 1px var(--rule-2); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { opacity: .9; background: var(--ink); color: var(--bg); }
.btn.accent { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.accent { color: #10201f; }
.btn.accent:hover { opacity: .9; background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: color-mix(in srgb, var(--rule) 60%, transparent); }
.seg button { height: 26px; padding: 0 11px; border-radius: 7px; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink-3); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; border: 0; outline: 0;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule-2); color: var(--ink);
}
select.input:not([multiple]):not([size]) {
  appearance: none; padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1.5 1.5 4.5 4.5 4.5-4.5' fill='none' stroke='%2389847d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
@media (forced-colors: active) {
  select.input:not([multiple]):not([size]) { appearance: auto; background-image: none; }
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.7; }
.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.hint { font-size: 12px; color: var(--ink-3); line-height: 1.6; }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.chip button { color: var(--ink-3); font-size: 13px; line-height: 1; }
.chip button:hover { color: var(--danger); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 11.5px; white-space: nowrap; }
.pill.unread { color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--rule-2); }
.pill.reading { color: var(--accent); background: var(--accent-soft); }
.pill.done { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.spin { width: 11px; height: 11px; border-radius: 50%; border: 1.6px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 浮层 */
.menu, .popover {  /* 菜单要能盖住设置对话框（.dialog-backdrop 是 90） */
  position: fixed; z-index: 100; background: var(--surface); color: var(--ink);
  box-shadow: 0 0 0 1px var(--rule), var(--shadow); border-radius: 10px;
  opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity .14s, transform .14s;
}
.menu.open, .popover.open { opacity: 1; pointer-events: auto; transform: none; }
.menu-list { padding: 5px; min-width: 190px; }
/* 页面内确认框（js/common/confirm.js） */
.confirm { position: fixed; inset: 0; margin: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); max-height: calc(100dvh - 24px); overflow: auto; width: min(320px, calc(100vw - 16px)); padding: 14px 14px 12px; box-sizing: border-box; }
.confirm::backdrop { background: rgba(20, 18, 15, .32); }
.confirm .cf-title { font-size: 14px; font-weight: 600; line-height: 1.45; }
.confirm .cf-body { margin-top: 5px; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.confirm .cf-input { width: 100%; margin-top: 10px; box-sizing: border-box; }
.confirm .cf-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn.danger-fill:hover { background: var(--danger); opacity: .9; }
.menu-list button, .menu-list a { display: flex; align-items: center; gap: 9px; width: 100%; height: 32px; padding: 0 10px; border-radius: 7px; font-size: 13.5px; color: var(--ink-2); text-align: left; text-decoration: none; }
.menu-list button:hover, .menu-list a:hover, .menu-list .kb-on { background: var(--accent-soft); color: var(--ink); }
.menu-list .kbd { margin-left: auto; font: 11px var(--mono); color: var(--ink-3); }
.menu-list hr { border: 0; border-top: 1px solid var(--rule); margin: 5px 4px; }

.dialog-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(20, 18, 15, .28); display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .18s; }
.dialog-backdrop.open { opacity: 1; pointer-events: auto; }
.dialog { width: min(560px, 94vw); max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 22px 24px; transform: translateY(8px); transition: transform .18s; }
.dialog-backdrop.open .dialog { transform: none; }
.dialog h2 { font: 600 18px/1.4 var(--serif-zh); margin: 0 0 16px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 95; transform: translate(-50%, 12px);
  padding: 9px 14px; border-radius: 10px; background: var(--ink); color: var(--bg);
  font-size: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .2s;
  display: flex; gap: 12px; align-items: center; max-width: 92vw;
}
#toast.open { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: inherit; text-decoration: underline; text-underline-offset: 3px; opacity: .85; }

kbd { font: 11px var(--mono); padding: 1px 5px; border-radius: 4px; box-shadow: inset 0 -1px 0 var(--rule-2), inset 0 0 0 1px var(--rule); color: var(--ink-2); }
input[type=range] { accent-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.btn.icon.lang-btn { font: 600 12.5px/1 var(--ui); letter-spacing: .02em; }  /* 顶栏的 中 / EN */
