/* ============================================================
   Plume Studio — design system
   Warm paper surfaces, quiet chrome, content first.
   ============================================================ */

:root {
  --bg: #faf9f6;
  --bg-side: #f3f1ea;
  --bg-inset: #f1eee7;
  --paper-inset: #f1eee7;
  --bg-hover: rgba(60, 52, 38, 0.055);
  --bg-active: rgba(60, 52, 38, 0.09);
  --text: #2b2823;
  --text-2: #6f695e;
  --text-3: #8a857c;
  --border: #e7e3da;
  --border-2: #d9d4c8;
  --accent: #44695b;         /* muted ink green */
  --accent-soft: rgba(68, 105, 91, 0.12);
  --accent-text: #3b5f52;
  --danger: #9c4038;
  --danger-soft: rgba(156, 64, 56, 0.1);
  --shadow-pop: 0 8px 28px rgba(35, 30, 22, 0.14), 0 2px 8px rgba(35, 30, 22, 0.08);
  --shadow-modal: 0 24px 64px rgba(35, 30, 22, 0.22);
  --radius: 8px;
  --radius-sm: 6px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", STSong, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #211f1c;
  --bg-side: #1b1a17;
  --bg-inset: #2a2723;
  --paper-inset: #2a2723;
  --bg-hover: rgba(240, 232, 214, 0.06);
  --bg-active: rgba(240, 232, 214, 0.1);
  --text: #e8e4da;
  --text-2: #a8a294;
  --text-3: #8a857a;
  --border: #37342e;
  --border-2: #45413a;
  --accent: #7fa895;
  --accent-soft: rgba(127, 168, 149, 0.14);
  --accent-text: #93b7a6;
  --danger: #c96f66;
  --danger-soft: rgba(201, 111, 102, 0.14);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
/* the hidden attribute must always win — author display rules (e.g. the
   format toolbar's display:flex) would otherwise silently override it */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
b { font-weight: 600; }
kbd {
  font-family: var(--font-ui); font-size: 11px; color: var(--text-3);
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.hint { color: var(--text-3); font-size: 12.5px; line-height: 1.6; }
.icon { flex: none; display: block; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout ---------- */

#app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 248px; flex: none; background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
  padding: 14px 10px 10px;
}
.main { flex: 1; min-width: 0; overflow-y: auto; position: relative; }
body.route-editor .main { overflow: hidden; }

/* ---------- buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 7px 14px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
:root[data-theme="dark"] .btn-primary { color: #14201b; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: var(--border-2); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 5px; }
.btn-block { width: 100%; justify-content: flex-start; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex: none;
  border: none; background: transparent; color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer; padding: 0;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.active { color: var(--accent-text); background: var(--accent-soft); }

.input {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 7px 10px; width: 100%;
}
.input:focus { outline: none; border-color: var(--accent); }
.input-sm { padding: 5px 8px; font-size: 13px; width: auto; }
textarea.input { resize: vertical; line-height: 1.6; }
select.input, select.input-sm { cursor: pointer; }

.form-col { display: flex; flex-direction: column; gap: 8px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; }
.form-label { font-size: 12px; color: var(--text-3); font-weight: 500; margin-top: 6px; }
.check-row { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check-row input { accent-color: var(--accent); }

/* ---------- color system ---------- */

.c-gray   { --c-bg: rgba(120,113,100,.13); --c-fg: #6f695e; }
.c-stone  { --c-bg: rgba(140,125,105,.16); --c-fg: #7d7261; }
.c-red    { --c-bg: rgba(156,64,56,.12);   --c-fg: #9c4038; }
.c-amber  { --c-bg: rgba(168,124,40,.14);  --c-fg: #96702a; }
.c-green  { --c-bg: rgba(68,105,91,.13);   --c-fg: #44695b; }
.c-teal   { --c-bg: rgba(52,110,120,.12);  --c-fg: #35707a; }
.c-blue   { --c-bg: rgba(62,92,130,.12);   --c-fg: #3e5c82; }
.c-violet { --c-bg: rgba(104,84,140,.12);  --c-fg: #68548c; }
.c-pink   { --c-bg: rgba(160,80,110,.12);  --c-fg: #a0506e; }
:root[data-theme="dark"] .c-gray   { --c-fg: #a8a294; }
:root[data-theme="dark"] .c-stone  { --c-fg: #b0a490; }
:root[data-theme="dark"] .c-red    { --c-fg: #c98079; }
:root[data-theme="dark"] .c-amber  { --c-fg: #c4a065; }
:root[data-theme="dark"] .c-green  { --c-fg: #8fb3a3; }
:root[data-theme="dark"] .c-teal   { --c-fg: #7fb0b8; }
:root[data-theme="dark"] .c-blue   { --c-fg: #8ba7c9; }
:root[data-theme="dark"] .c-violet { --c-fg: #a795c4; }
:root[data-theme="dark"] .c-pink   { --c-fg: #c489a0; }

.c-gray-text { color: #6f695e; } .c-red-text { color: #9c4038; } .c-amber-text { color: #96702a; }
.c-green-text { color: #44695b; } .c-teal-text { color: #35707a; } .c-blue-text { color: #3e5c82; }
.c-violet-text { color: #68548c; } .c-pink-text { color: #a0506e; } .c-stone-text { color: #7d7261; }

.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--c-fg, var(--text-2));
  background: var(--c-bg, var(--bg-inset));
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.tag-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; color: var(--c-fg, var(--text-2));
  background: var(--c-bg, var(--bg-inset));
  padding: 1.5px 8px; border-radius: 5px; white-space: nowrap;
}
.tag-remove {
  border: none; background: none; color: inherit; cursor: pointer;
  font-size: 13px; padding: 0 0 0 2px; opacity: .6;
}
.tag-remove:hover { opacity: 1; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background: var(--c-bg, var(--bg-inset));
  position: relative;
}
.color-swatch::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--c-fg, var(--text-3)); }
.color-swatch.c-none::after { background: var(--border-2); }
.color-swatch.active { border-color: var(--accent); }

.status-row-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.status-opt {
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--c-fg); background: var(--c-bg);
  border: 1px solid transparent; border-radius: 20px; padding: 3px 10px;
  opacity: .65;
}
.status-opt:hover { opacity: .9; }
.status-opt.active { opacity: 1; border-color: var(--c-fg); }

/* ---------- tag editor ---------- */

.tag-editor { position: relative; display: flex; flex-direction: column; gap: 6px; }
.tag-editor-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-editor-chips:empty { display: none; }
.tag-editor-input {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 5px 8px;
}
.tag-editor-input:focus { outline: none; border-color: var(--accent); }
.tag-suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); overflow: hidden; margin-top: 2px;
}
.tag-suggest-item {
  display: flex; justify-content: space-between; width: 100%;
  font: inherit; font-size: 13px; color: var(--text);
  background: none; border: none; cursor: pointer; padding: 6px 10px;
}
.tag-suggest-item span { color: var(--text-3); font-size: 11.5px; }
.tag-suggest-item:hover { background: var(--bg-hover); }

/* ---------- menu ---------- */

.menu {
  position: fixed; z-index: 300; padding: 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  max-height: 70vh; overflow-y: auto;
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font: inherit; font-size: 13px; color: var(--text); text-align: left;
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 6px 9px; cursor: pointer; white-space: pre;
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item.danger { color: var(--danger); }
.menu-item.disabled { color: var(--text-3); cursor: default; }
.menu-item.disabled:hover { background: none; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.menu-hint { color: var(--text-3); font-size: 11px; margin-left: 12px; }
.menu-check { width: 16px; color: var(--accent-text); display: inline-flex; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-header { font-size: 11px; color: var(--text-3); padding: 5px 9px 3px; }

.icon-grid { display: grid; grid-template-columns: repeat(7, 32px); gap: 2px; }
.icon-cell {
  width: 32px; height: 32px; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-2);
}
.icon-cell:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(30, 26, 20, 0.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 20px 20px; overflow-y: auto;
  opacity: 0; transition: opacity .15s;
}
.modal-overlay.show { opacity: 1; }
.modal {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-modal);
  transform: translateY(8px); transition: transform .15s;
  display: flex; flex-direction: column; max-height: 84vh;
}
.modal-overlay.show .modal { transform: none; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 0;
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 0 18px 16px; flex-wrap: wrap;
}
.confirm-text { margin: 0; line-height: 1.7; color: var(--text-2); }
.modal-search .modal-body { padding: 0; }

/* ---------- toast ---------- */

#toastRoot { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg);
  font-size: 13px; padding: 9px 16px; border-radius: 8px;
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(8px); transition: all .25s;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { background: var(--accent); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast-success { color: #14201b; }

/* ---------- sidebar ---------- */

.side-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 8px 12px; font-size: 14.5px;
}
.side-brand b { letter-spacing: .01em; }
.side-brand .side-ver { flex: 1; font-size: 10px; color: var(--text-3); align-self: flex-end; padding-bottom: 2px; }
.side-search {
  display: flex; align-items: center; gap: 8px;
  font: inherit; font-size: 13px; color: var(--text-3);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px; cursor: pointer;
  margin: 0 2px 8px;
}
.side-search:hover { border-color: var(--border-2); }
.side-search span { flex: 1; text-align: left; }
.side-new { margin: 0 2px 14px; }

.side-nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--text-2);
  padding: 6px 9px; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; user-select: none;
}
.nav-item:hover { background: var(--bg-hover); text-decoration: none; }
.nav-item.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.nav-item span:not(.nav-count):not(.cat-node-icon) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 11px; color: var(--text-3); }

.side-sec { margin-top: 18px; }
.side-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-3); font-weight: 500;
  padding: 0 9px 4px; letter-spacing: .04em;
}
.side-sec-acts { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.side-sec:hover .side-sec-acts { opacity: 1; }
.side-sec-acts .icon-btn { width: 22px; height: 22px; }
.side-empty { font-size: 12px; color: var(--text-3); padding: 4px 9px; }

.cat-node { --depth: 0; }
.cat-nav { padding-left: calc(6px + var(--depth) * 14px); }
.cat-caret {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex: none;
  border: none; background: none; color: var(--text-3); cursor: pointer;
  border-radius: 4px; padding: 0; transition: transform .12s;
}
.cat-caret:hover { background: var(--bg-active); }
.cat-caret.open { transform: rotate(90deg); }
.cat-caret.empty { visibility: hidden; }
.nav-item .cat-node-icon { display: inline-flex; width: 18px; justify-content: center; font-size: 13px; flex: none; }
.cat-node-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view-item { position: relative; }
.view-del { width: 20px; height: 20px; opacity: 0; }
.view-item:hover .view-del { opacity: 1; }

.side-foot { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 1px; }

/* ---------- cloud sync ---------- */

.side-sync {
  margin-top: 8px; padding: 7px 9px; display: flex; align-items: center; gap: 7px;
  background: none; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  color: var(--text-2); font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.side-sync:hover { border-color: var(--accent); color: var(--text); }
.side-sync-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-2); flex: none; }
[data-state='idle'] .sync-dot, [data-state='idle'].sync-state-box .sync-dot { background: var(--accent); }
[data-state='pending'] .sync-dot, [data-state='pending'].sync-state-box .sync-dot { background: #c8912f; }
[data-state='error'] .sync-dot, [data-state='error'].sync-state-box .sync-dot { background: var(--danger); }
[data-state='syncing'] .sync-dot, [data-state='syncing'].sync-state-box .sync-dot { background: var(--accent); animation: sync-pulse 1.1s infinite; }
[data-state='error'].side-sync { border-color: var(--danger); color: var(--danger); }

@keyframes sync-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.sync-state-box {
  display: flex; align-items: center; gap: 8px; margin: 10px 0 14px;
  padding: 9px 12px; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--bg-inset); font-size: 13px; color: var(--text-2);
}

.sync-history { max-height: 380px; overflow-y: auto; }
.sync-history-row {
  display: flex; align-items: baseline; gap: 10px; padding: 8px 2px;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.sync-history-row:last-child { border-bottom: none; }
.sync-history-row code { color: var(--accent-text); flex: none; }
.sync-history-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-history-row time { color: var(--text-2); font-size: 12px; flex: none; }

/* ---------- page scaffolding ---------- */

.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 26px 32px 12px; flex-wrap: wrap;
}
.page-head-l { display: flex; align-items: baseline; gap: 10px; }
.page-head-l h2 { margin: 0; font-size: 19px; }
.page-count { font-size: 12.5px; color: var(--text-3); }
.page-head-r { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-hint { margin: 0 32px 14px; max-width: 640px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-3); text-align: center; padding: 70px 20px; line-height: 1.8;
}
.empty-state.small { padding: 26px 16px; font-size: 13px; }

.filter-bar, .batch-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 32px 10px; font-size: 12.5px;
}
.batch-bar {
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 8px 12px; color: var(--accent-text);
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; color: var(--text-2);
}
.filter-chip button { border: none; background: none; cursor: pointer; color: var(--text-3); font-size: 13px; padding: 0; }

/* ---------- article list ---------- */

.art-list { padding: 4px 32px 40px; display: flex; flex-direction: column; }
.art-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 13px 12px; margin: 0; border-radius: var(--radius);
  border-bottom: 1px solid var(--border);
  cursor: pointer; position: relative;
}
.art-row:hover { background: var(--bg-hover); }
.art-row.selected { background: var(--accent-soft); }
.art-check { display: flex; align-items: center; padding-top: 14px; }
.art-check input { accent-color: var(--accent); }

.cover-thumb {
  width: 74px; height: 54px; flex: none; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-inset); border: 1px solid var(--border);
}
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-blank { display: flex; align-items: center; justify-content: center; }
.cover-blank span { font-family: var(--font-serif); font-size: 20px; color: var(--text-3); opacity: .7; }

.art-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.art-title { font-size: 14.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art-excerpt { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-3);
}
.meta-cat { color: var(--text-2); }
.meta-flag { display: inline-flex; color: var(--text-3); }
.meta-flag.fav { color: #b08a3e; }
.meta-due { display: inline-flex; align-items: center; gap: 3px; }
.art-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.art-more { opacity: 0; align-self: center; }
.art-row:hover .art-more, .art-card:hover .art-more { opacity: 1; }

.art-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px; padding: 8px 32px 40px;
}
.art-card {
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; cursor: pointer; position: relative;
  transition: border-color .15s, transform .15s;
}
.art-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.art-card .card-cover { width: 100%; height: 130px; border: none; border-radius: 0; border-bottom: 1px solid var(--border); }
.art-card .cover-blank span { font-size: 30px; }
.art-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.art-card .art-title { white-space: normal; }
.art-card .art-more { position: absolute; top: 8px; right: 8px; background: var(--bg); border: 1px solid var(--border); }

.progress { height: 4px; background: var(--bg-inset); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }

/* ---------- dashboard ---------- */

.dash { max-width: 980px; margin: 0 auto; padding: 44px 36px 60px; }
.dash-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.dash-head p { margin: 0; }
.dash-quick { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 8px; }
.quick-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13.5px; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 15px; cursor: pointer; transition: border-color .12s, background .12s;
}
.quick-btn:hover { border-color: var(--border-2); background: var(--bg-hover); }
.quick-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .quick-btn.primary { color: #14201b; }

.dash-sec { margin-top: 30px; }
.dash-sec h3 {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 0 12px; font-size: 13px; color: var(--text-3); font-weight: 500; letter-spacing: .04em;
}
.continue-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.continue-card {
  display: flex; flex-direction: column; gap: 7px; text-align: left;
  font: inherit; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; cursor: pointer; transition: border-color .15s, transform .15s;
}
.continue-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.continue-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }

.dash-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 28px; align-items: start; }
.recent-list { display: flex; flex-direction: column; }
.recent-row {
  display: flex; align-items: center; gap: 12px;
  font: inherit; text-align: left; background: none; color: var(--text);
  border: none; border-bottom: 1px solid var(--border);
  padding: 9px 4px; cursor: pointer; border-radius: 4px;
}
.recent-row:hover { background: var(--bg-hover); }
.recent-row .art-title { flex: 1; font-weight: 450; }
.recent-time { flex: none; }

.stat-list { display: flex; flex-direction: column; gap: 2px; }
.stat {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 8px 4px; border-bottom: 1px solid var(--border);
}
.stat b { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--text-3); }

/* ---------- categories page ---------- */

.cat-tree { padding: 6px 32px 40px; max-width: 760px; }
.cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px calc(10px + var(--depth) * 26px);
  border-radius: var(--radius-sm); border-bottom: 1px solid var(--border);
}
.cat-row:hover { background: var(--bg-hover); }
.cat-drag { color: var(--text-3); cursor: grab; display: inline-flex; opacity: 0; }
.cat-row:hover .cat-drag, .col-item:hover .cat-drag { opacity: .7; }
.cat-icon {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-2);
}
.cat-icon:hover { background: var(--bg-active); }
.cat-name {
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text);
  background: none; border: none; cursor: pointer; padding: 2px 4px;
}
.cat-name:hover { text-decoration: underline; }
.cat-desc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.cat-row .icon-btn { opacity: 0; }
.cat-row:hover .icon-btn { opacity: 1; }

/* ---------- tags page ---------- */

.tag-table { padding: 6px 32px 40px; max-width: 680px; }
.tag-trow {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 10px; border-bottom: 1px solid var(--border); border-radius: var(--radius-sm);
}
.tag-trow:hover { background: var(--bg-hover); }
.tag-trow .tag-chip { font-size: 13px; padding: 3px 11px; cursor: pointer; border: none; }
.tag-tools { margin-left: auto; display: inline-flex; gap: 2px; opacity: 0; }
.tag-trow:hover .tag-tools { opacity: 1; }
.tag-search { width: 180px; }

/* ---------- collections ---------- */

.col-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px; padding: 8px 32px 40px;
}
.col-card {
  display: flex; flex-direction: column; text-align: left; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; cursor: pointer; padding: 0; transition: border-color .15s, transform .15s;
}
.col-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.col-cover {
  height: 110px; background: var(--bg-inset); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.col-cover img { width: 100%; height: 100%; object-fit: cover; }
.col-cover span { font-family: var(--font-serif); font-size: 30px; color: var(--text-3); opacity: .6; }
.col-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }

.col-head { display: flex; gap: 18px; padding: 30px 32px 16px; align-items: flex-start; flex-wrap: wrap; }
.col-head-cover {
  width: 120px; height: 86px; flex: none; border-radius: var(--radius);
  background: var(--bg-inset); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-3);
  cursor: pointer; overflow: hidden; padding: 0;
}
.col-head-cover img { width: 100%; height: 100%; object-fit: cover; }
.col-head-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 7px; }
.col-head-main h2 { margin: 0; font-size: 20px; }
.col-intro { margin: 0; cursor: pointer; }
.col-intro:hover { color: var(--text-2); }
.col-chapters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 32px 10px; }
.col-items { padding: 4px 32px 40px; max-width: 860px; }
.col-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; border-bottom: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer;
}
.col-item:hover { background: var(--bg-hover); }
.col-item-num { font-size: 12px; color: var(--text-3); width: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.col-item .icon-btn { opacity: 0; }
.col-item:hover .icon-btn { opacity: 1; }
.col-chapter { max-width: 130px; }

/* ---------- image library ---------- */

.lib-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 32px 16px; }
.lib-toolbar .input { width: 200px; }
.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; padding: 0 32px 40px;
}
.lib-cell {
  position: relative; padding: 0; border: 1px solid var(--border);
  background: var(--bg-inset); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; aspect-ratio: 4/3;
}
.lib-cell:hover { border-color: var(--border-2); }
.lib-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-cell-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 11px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(20,16,10,.75));
  padding: 14px 8px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: 0; transition: opacity .15s;
}
.lib-cell:hover .lib-cell-meta { opacity: 1; }

.img-detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.img-detail-preview {
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; min-height: 240px; overflow: hidden;
}
.img-detail-preview img { max-width: 100%; max-height: 380px; object-fit: contain; }
.img-usage { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

.lib-picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lib-picker-cell {
  padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer; aspect-ratio: 4/3; background: var(--bg-inset);
}
.lib-picker-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-picker-cell:hover { border-color: var(--border-2); }
.lib-picker-cell.picked { border-color: var(--accent); }

/* ---------- templates ---------- */

.tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; padding: 8px 32px 40px;
}
.tpl-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; transition: border-color .15s;
}
.tpl-card:hover { border-color: var(--border-2); }
.tpl-icon { display: inline-flex; color: var(--text-2); }
.tpl-acts { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.tpl-icon-btn { width: 42px; padding: 8px 6px; color: var(--text-2); }
.tpl-md { font-family: var(--font-mono); font-size: 12.5px; }

/* ---------- trash / settings ---------- */

.trash-row { cursor: default; }
.trash-row .btn { align-self: center; flex: none; }

.settings { padding: 4px 32px 60px; max-width: 640px; }
.settings section { margin-bottom: 30px; }
.settings h3 { font-size: 13px; color: var(--text-3); font-weight: 500; letter-spacing: .04em; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 7px 0; font-size: 13.5px;
}
.set-row label { color: var(--text-2); }
.set-row label .hint { display: block; margin-top: 2px; font-size: 12px; }
.sync-section .set-row label { flex: 0 0 240px; }
.sync-section .set-row .input { flex: 1; min-width: 0; }
.set-row .input-sm { width: 170px; }
.set-row input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.set-links { display: flex; gap: 8px; flex-wrap: wrap; }
.set-links .btn { text-decoration: none; }
.custom-status-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- global search ---------- */

.gsearch-input {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--text-3);
}
.gsearch-input input {
  flex: 1; font: inherit; font-size: 15px; color: var(--text);
  background: none; border: none; outline: none;
}
.gsearch-results { max-height: 55vh; overflow-y: auto; padding: 8px; }
.gs-head { font-size: 11px; color: var(--text-3); padding: 8px 10px 4px; letter-spacing: .04em; }
.gs-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  font: inherit; font-size: 13.5px; color: var(--text); text-align: left;
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 7px 10px; cursor: pointer;
}
.gs-row:hover { background: var(--bg-hover); }
.gs-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-imgs { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 10px 8px; }
.gs-img { padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; width: 64px; height: 48px; background: var(--bg-inset); }
.gs-img img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- export / import dialogs ---------- */

.export-formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.export-format {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; font-size: 13px;
}
.export-format:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.export-format input { display: none; }
.export-format span { font-size: 11px; color: var(--text-3); }
.export-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px 14px; }

.import-drop {
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%;
  font: inherit; color: var(--text-2); text-align: center;
  background: var(--bg-inset); border: 1.5px dashed var(--border-2); border-radius: 10px;
  padding: 28px 18px; cursor: pointer;
}
.import-drop:hover, .import-drop.over { border-color: var(--accent); color: var(--accent-text); }

/* ============================================================
   EDITOR
   ============================================================ */

.editor-shell { display: flex; flex-direction: column; height: 100%; }
.editor-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg); flex: none; gap: 10px;
  transition: opacity .3s;
}
.etb-left, .etb-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.etb-crumb { font-size: 12.5px; color: var(--text-3); margin-left: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etb-save { font-size: 12px; color: var(--text-3); margin-right: 8px; white-space: nowrap; }
.etb-save.save-failed, .etb-save.save-offline { color: var(--danger); }

.editor-main { display: flex; flex: 1; min-height: 0; position: relative; }
.editor-scroll { flex: 1; overflow-y: auto; min-width: 0; }
.editor-page { margin: 0 auto; padding: 44px 56px 30vh; }

.editor-cover { position: relative; margin-bottom: 22px; }
.editor-cover img { width: 100%; max-height: 300px; object-fit: cover; border-radius: 10px; display: block; }
.cover-remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(20,16,10,.5); color: #fff; opacity: 0;
}
.editor-cover:hover .cover-remove { opacity: 1; }

.editor-title {
  font-size: 30px; font-weight: 650; line-height: 1.35;
  outline: none; margin-bottom: 6px; word-break: break-word;
  font-family: var(--font-serif);
}
.editor-title:empty::before { content: attr(data-ph); color: var(--text-3); opacity: .5; }

.editor-metaline {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 4px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.meta-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 12px; color: var(--text-2);
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 4px 8px; cursor: pointer;
}
.meta-chip:hover { background: var(--bg-hover); }
.meta-chip.meta-add { color: var(--text-3); }
.meta-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }

.editor-footbar {
  flex: none; padding: 6px 16px;
  border-top: 1px solid var(--border); background: var(--bg);
  transition: opacity .3s;
  display: flex; align-items: center; gap: 10px;
}
.efb-stats { font-size: 11.5px; color: var(--text-3); flex: 1; min-width: 0; }
.efb-voice-status {
  font-size: 11.5px; color: var(--accent-text); max-width: 45%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.efb-mic { flex: none; position: relative; }
.efb-mic.recording { color: var(--danger); }
.efb-mic.recording::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--danger); animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(1.5); } }

.editor-tail { min-height: 120px; cursor: text; }

/* ----- info panel ----- */

.editor-panel {
  width: 300px; flex: none; border-left: 1px solid var(--border);
  background: var(--bg-side); display: flex; flex-direction: column;
}
.editor-panel[hidden] { display: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px;
}
.panel-head h3 { margin: 0; font-size: 13.5px; }
.panel-scroll { overflow-y: auto; padding: 0 16px 20px; }
.editor-panel section { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.panel-digest { font-size: 13px; }
.panel-cover {
  height: 90px; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg-inset); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.panel-cover img { width: 100%; height: 100%; object-fit: cover; }
.panel-cover-empty { font-size: 12px; color: var(--text-3); }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.panel-grid > div { display: flex; flex-direction: column; gap: 4px; }
.panel-grid .input-sm { width: 100%; }
.panel-switches { flex-direction: row !important; gap: 18px !important; }
.extra-cats { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.panel-collections { display: flex; flex-direction: column; gap: 6px; }

/* ----- blocks ----- */

.editor-blocks { font-size: 17px; line-height: 1.8; }
.editor-blocks.font-serif .eb-text { font-family: var(--font-serif); }

.eb { position: relative; display: flex; padding: 1px 0; }
.eb-body { flex: 1; min-width: 0; }
.eb-gutter {
  position: absolute; left: -52px; top: 2px;
  display: flex; gap: 0; opacity: 0; transition: opacity .12s;
}
.eb:hover .eb-gutter { opacity: 1; }
.eb-add, .eb-drag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: none; background: none;
  color: var(--text-3); border-radius: var(--radius-sm); cursor: pointer; padding: 0;
}
.eb-add:hover, .eb-drag:hover { background: var(--bg-hover); color: var(--text-2); }
.eb-drag { cursor: grab; }
.eb.dragging { opacity: .4; }
.eb.drop-before::before, .eb.drop-after::after {
  content: ''; position: absolute; left: 0; right: 0; height: 2px;
  background: var(--accent); border-radius: 2px; z-index: 5;
}
.eb.drop-before::before { top: -2px; }
.eb.drop-after::after { bottom: -2px; }
.cat-row.drop-after, .col-item.drop-after { box-shadow: 0 2px 0 var(--accent); }

.eb-text { outline: none; word-break: break-word; white-space: pre-wrap; min-height: 1.5em; position: relative; }
.eb-text:empty::before {
  content: attr(data-ph); color: var(--text-3); opacity: 0;
  position: absolute; pointer-events: none;
}
.eb-text:focus:empty::before { opacity: .45; }
.eb-text a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.eb-text mark { background: rgba(200, 165, 60, .3); color: inherit; border-radius: 2px; padding: 0 1px; }
.eb-text code {
  font-family: var(--font-mono); font-size: .85em;
  background: var(--bg-inset); border-radius: 4px; padding: 1px 5px;
}

.ebt-p .eb-body { padding: 3px 0; }
.eb-heading { font-weight: 650; font-family: var(--font-serif); }
.ebt-h1 .eb-body { padding: 18px 0 4px; }
.ebt-h2 .eb-body { padding: 14px 0 3px; }
.ebt-h3 .eb-body { padding: 10px 0 2px; }
.eb-heading.h1 { font-size: 1.55em; line-height: 1.4; }
.eb-heading.h2 { font-size: 1.3em; line-height: 1.45; }
.eb-heading.h3 { font-size: 1.12em; line-height: 1.5; }

.ebt-quote .eb-body {
  border-left: 3px solid var(--border-2); padding: 3px 0 3px 16px;
  color: var(--text-2); margin: 4px 0;
}

.ebt-ul .eb-body, .ebt-ol .eb-body, .ebt-todo .eb-body {
  display: flex; gap: 10px; padding: 2px 0; align-items: baseline;
}
.eb-bullet { flex: none; color: var(--text-2); user-select: none; width: 18px; text-align: center; }
.eb-num { font-variant-numeric: tabular-nums; font-size: .92em; }
.eb-li { flex: 1; min-width: 0; }
.eb-todo-box {
  flex: none; width: 17px; height: 17px; align-self: center;
  border: 1.5px solid var(--border-2); border-radius: 5px; background: none;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; padding: 0; transform: translateY(2px);
}
.eb-todo-box.done { background: var(--accent); border-color: var(--accent); }
.eb-done { color: var(--text-3); text-decoration: line-through; }

.eb-callout {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin: 6px 0;
}
.eb-callout.c-warning { background: rgba(168,124,40,.08); border-color: rgba(168,124,40,.25); }
.eb-callout.c-danger { background: var(--danger-soft); border-color: rgba(156,64,56,.3); }
.eb-callout.c-tip { background: var(--accent-soft); border-color: rgba(68,105,91,.3); }
.eb-callout-icon {
  flex: none; display: inline-flex; background: none; border: none; cursor: pointer;
  padding: 0; margin-top: 5px; color: var(--text-2); border-radius: 4px;
}
.eb-callout-icon:hover { color: var(--text); }
.eb-callout.c-tip .eb-callout-icon { color: var(--accent-text); }
.eb-callout.c-warning .eb-callout-icon { color: #96702a; }
.eb-callout.c-danger .eb-callout-icon { color: var(--danger); }
.eb-callout-text { flex: 1; min-width: 0; font-size: .94em; }

.eb-toggle { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin: 6px 0; flex: 1; }
.eb-toggle-head { display: flex; gap: 6px; align-items: center; }
.eb-toggle-arrow {
  flex: none; display: inline-flex; border: none; background: none; color: var(--text-3);
  cursor: pointer; padding: 2px; border-radius: 4px; transition: transform .15s;
}
.eb-toggle.open .eb-toggle-arrow { transform: rotate(90deg); }
.eb-toggle-summary { flex: 1; font-weight: 550; }
.eb-toggle-body { display: none; padding: 8px 0 2px 24px; font-size: .95em; }
.eb-toggle.open .eb-toggle-body { display: block; }

.eb-hr { border: none; border-top: 1px solid var(--border-2); margin: 18px 0; width: 100%; }
.ebt-divider .eb-body { cursor: default; }

.eb-code {
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin: 6px 0; position: relative;
}
.eb-code-lang {
  position: absolute; top: 6px; right: 8px; width: 76px;
  font: inherit; font-size: 11px; color: var(--text-3); text-align: right;
  background: none; border: none; outline: none;
}
.eb-code-text {
  display: block; width: 100%; resize: none; overflow: hidden;
  font-family: var(--font-mono); font-size: .82em; line-height: 1.6;
  color: var(--text); background: none; border: none; outline: none; padding: 0;
}

.eb-math { margin: 6px 0; flex: 1; }
.eb-math-text {
  display: block; width: 100%; resize: none; overflow: hidden;
  font-family: var(--font-mono); font-size: .8em; color: var(--text-2);
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; outline: none;
}
.eb-math-preview {
  text-align: center; font-family: Georgia, serif; font-style: italic;
  font-size: 1.05em; padding: 10px 0 2px; white-space: pre-wrap; color: var(--text);
}
.eb-math-preview.empty { display: none; }

.eb-table { margin: 8px 0; overflow-x: auto; }
.eb-table table { border-collapse: collapse; width: 100%; font-size: .9em; }
.eb-table td, .eb-table th {
  border: 1px solid var(--border-2); padding: 7px 11px; min-width: 70px;
  text-align: left; outline: none;
}
.eb-table th { background: var(--bg-inset); font-weight: 600; }
.eb-table-tools { display: flex; gap: 6px; padding-top: 6px; opacity: 0; transition: opacity .12s; }
.eb-table:hover .eb-table-tools { opacity: 1; }
.eb-table-tools button {
  font: inherit; font-size: 11.5px; color: var(--text-3);
  background: none; border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 8px; cursor: pointer;
}
.eb-table-tools button:hover { color: var(--text); background: var(--bg-hover); }

.eb-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 6px 0; }
.eb-col {
  border: 1px dashed transparent; border-radius: var(--radius-sm);
  padding: 4px 6px; min-height: 2em;
}
.eb-col:hover, .eb-col:focus { border-color: var(--border); }

/* images */
.eb-image { margin: 10px auto; position: relative; text-align: center; }
.eb-image img { max-width: 100%; display: block; margin: 0 auto; }
.eb-image.layout-left { float: left; width: 44%; margin: 4px 22px 8px 0; }
.eb-image.layout-right { float: right; width: 44%; margin: 4px 0 8px 22px; }
.eb-image.layout-wide { width: calc(100% + 80px) !important; margin-left: -40px; max-width: none; }
.eb-image.layout-full { width: calc(100% + 112px) !important; margin-left: -56px; max-width: none; }
.eb-image figcaption { display: flex; flex-direction: column; gap: 1px; margin-top: 7px; }
.eb-cap-title, .eb-cap-text {
  font: inherit; text-align: center; background: none; border: none; outline: none;
  color: var(--text-2); width: 100%;
}
.eb-cap-title { font-size: .78em; font-weight: 600; }
.eb-cap-text { font-size: .76em; color: var(--text-3); }
.eb-cap-title::placeholder, .eb-cap-text::placeholder { color: var(--text-3); opacity: 0; transition: opacity .15s; }
.eb-image:hover .eb-cap-title::placeholder, .eb-image:hover .eb-cap-text::placeholder { opacity: .55; }

.eb-image-empty {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  background: var(--bg-inset); border: 1.5px dashed var(--border-2);
  border-radius: var(--radius); padding: 26px 16px;
}
.eb-image-empty button {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 7px 13px; cursor: pointer;
}
.eb-image-empty button:hover { color: var(--text); border-color: var(--text-3); }

.eb-image-bar {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 2px;
  background: rgba(28, 24, 18, 0.72); border-radius: 7px; padding: 3px;
  opacity: 0; transition: opacity .15s;
}
.eb-image:hover .eb-image-bar { opacity: 1; }
.eb-image-bar button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border: none; background: none; color: #eee;
  border-radius: 5px; cursor: pointer; padding: 0;
}
.eb-image-bar button:hover { background: rgba(255,255,255,.16); }

/* gallery */
.eb-gallery { display: grid; gap: 10px; margin: 10px 0 4px; }
.eb-gallery.gallery-grid2, .eb-gallery.gallery-compare { grid-template-columns: 1fr 1fr; }
.eb-gallery.gallery-grid3 { grid-template-columns: 1fr 1fr 1fr; }
.eb-gallery.gallery-grid { grid-template-columns: repeat(3, 1fr); }
.eb-gallery.gallery-row { display: flex; }
.eb-gallery.gallery-row .eb-gallery-item { flex: 1; min-width: 0; }
.eb-gallery.gallery-masonry { display: block; column-count: 2; column-gap: 10px; }
.eb-gallery.gallery-masonry .eb-gallery-item { break-inside: avoid; margin: 0 0 10px; }
.eb-gallery.gallery-carousel {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; padding-bottom: 6px;
}
.eb-gallery.gallery-carousel .eb-gallery-item { flex: 0 0 78%; scroll-snap-align: center; }
.eb-gallery-item { margin: 0; position: relative; }
.eb-gallery-item img {
  width: 100%; border-radius: var(--radius-sm); display: block; cursor: pointer;
  object-fit: cover;
}
.eb-gallery.gallery-grid2 .eb-gallery-item img, .eb-gallery.gallery-grid3 .eb-gallery-item img,
.eb-gallery.gallery-grid .eb-gallery-item img, .eb-gallery.gallery-compare .eb-gallery-item img { aspect-ratio: 4/3; }
.eb-gallery-item figcaption input {
  font: inherit; font-size: .74em; color: var(--text-3); text-align: center;
  width: 100%; background: none; border: none; outline: none; margin-top: 4px;
}
.compare-tag {
  position: absolute; top: 8px; left: 8px;
  font-size: 11px; color: #fff; background: rgba(28,24,18,.7);
  border-radius: 4px; padding: 2px 8px;
}
.eb-gallery-tools { display: flex; gap: 6px; padding: 6px 0 2px; opacity: 0; transition: opacity .12s; }
.eb-body:hover .eb-gallery-tools { opacity: 1; }
.eb-gallery-tools button {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 12px; color: var(--text-3);
  background: none; border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 9px; cursor: pointer;
}
.eb-gallery-tools button:hover { color: var(--text); background: var(--bg-hover); }

/* floating format toolbar */
.fmtbar {
  position: fixed; z-index: 350; display: flex; gap: 1px; padding: 3px;
  background: #2b2823; border-radius: 8px; box-shadow: var(--shadow-pop);
}
:root[data-theme="dark"] .fmtbar { background: #35322c; }
.fmtbar button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; font: inherit; font-size: 13px;
  color: #f0ece2; background: none; border: none; border-radius: 5px;
  cursor: pointer; padding: 0 6px;
}
.fmtbar button:hover { background: rgba(255,255,255,.15); }

/* image editor modal */
.img-editor-stage {
  position: relative; display: flex; justify-content: center;
  background: var(--bg-inset); border-radius: var(--radius); padding: 12px; min-height: 300px;
  overflow: hidden;
}
.img-editor-stage canvas { max-width: 100%; }
.crop-box {
  position: absolute; border: 1.5px solid #fff;
  outline: 9999px solid rgba(20, 16, 10, 0.45); cursor: move;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4); touch-action: none;
}
.crop-handle {
  position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
  background: #fff; border-radius: 50%; cursor: nwse-resize;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.img-editor-tools { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.img-editor-tools button {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px; color: var(--text-2);
  background: none; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 6px 12px; cursor: pointer;
}

/* version history */
.history-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.history-info { display: flex; flex-direction: column; gap: 2px; }
.history-acts { display: flex; gap: 6px; }
.diff-view {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
  background: var(--bg-inset); border-radius: var(--radius); padding: 12px;
  max-height: 56vh; overflow: auto; white-space: pre-wrap;
}
.diff-line.diff-add { background: rgba(68,105,91,.14); color: var(--accent-text); }
.diff-line.diff-del { background: rgba(156,64,56,.12); color: var(--danger); text-decoration: line-through; }

/* focus mode */
body.focus-mode .sidebar { display: none; }
.editor-shell.focus .editor-panel { display: none; }
.editor-shell.focus .editor-page { padding-top: 9vh; }
.editor-shell.chrome-hidden .editor-topbar,
.editor-shell.chrome-hidden .editor-footbar { opacity: 0; pointer-events: none; }
.editor-shell.focus .eb-gutter { opacity: 0; }
.editor-shell.focus .eb:hover .eb-gutter { opacity: .6; }

/* ----- wiki links ----- */

.wiki-suggest {
  position: fixed; z-index: 360; min-width: 240px; max-width: 320px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); padding: 4px; overflow: hidden;
}
.wiki-suggest-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%;
  font: inherit; font-size: 13px; color: var(--text); text-align: left;
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 6px 9px; cursor: pointer;
}
.wiki-suggest-item span { color: var(--text-3); font-size: 11px; flex: none; }
.wiki-suggest-item:hover, .wiki-suggest-item.active { background: var(--bg-hover); }
.wikilink { color: var(--r-accent, var(--accent-text)); text-decoration: none !important; border-bottom: 1px dashed currentColor; }
.wikilink-missing { color: var(--text-3); border-bottom: 1px dashed var(--border-2); }

/* ----- editor panel: relations ----- */

.plink-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.plink-label { font-size: 11px; color: var(--text-3); letter-spacing: .03em; }
.plink-list { display: flex; flex-direction: column; gap: 2px; }
.plink-item, .plink-row a {
  font-size: 12.5px; color: var(--text); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plink-item:hover, .plink-row a:hover { color: var(--accent-text); }
.plink-row { display: flex; align-items: center; gap: 7px; }
.plink-row a { flex: 1; min-width: 0; }
.plink-row .icon-btn { width: 20px; height: 20px; opacity: 0; }
.plink-row:hover .icon-btn { opacity: 1; }
.plink-type { font-size: 10.5px; color: var(--text-3); background: var(--bg-inset); border-radius: 4px; padding: 1px 6px; flex: none; }
.plink-suggest a { color: var(--text-2); }

/* ============================================================
   KNOWLEDGE GRAPH
   ============================================================ */

.graph-shell { position: relative; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.graph-shell.mode-dark { background: #0e1016; }
.graph-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg);
  flex-wrap: wrap; z-index: 5;
}
.mode-dark .graph-toolbar { background: #1b1a1f; border-color: #2b2a30; }
.mode-dark .graph-toolbar .btn, .mode-dark .graph-toolbar .input {
  background: #232228; border-color: #37343d; color: #ddd8cc;
}
.mode-dark .graph-toolbar .icon-btn { color: #a8a294; }
.mode-dark .graph-toolbar .gt-title { color: #e6e2d8; }
.gt-left, .gt-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gt-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; margin-right: 6px; }
.gt-search { width: 190px; }

.graph-canvas { flex: 1; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.graph-canvas:active { cursor: grabbing; }

.graph-legend {
  position: absolute; left: 14px; bottom: 34px; display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-3); pointer-events: none;
}
.mode-dark .graph-legend { color: #77737c; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-line { width: 18px; border-top: 1.5px solid currentColor; }
.legend-line.dashed { border-top-style: dashed; }

.graph-hint {
  position: absolute; left: 14px; bottom: 12px; font-size: 11px; color: var(--text-3);
  opacity: .8; pointer-events: none;
}
.mode-dark .graph-hint { color: #77737c; }

.graph-panel {
  position: absolute; right: 0; top: 49px; bottom: 0; width: 300px;
  background: var(--bg-side); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 6;
}
.graph-panel[hidden] { display: none; }
.mode-dark .graph-panel { background: #1c1b20; border-color: #2b2a30; color: #ddd8cc; }
.mode-dark .graph-panel .hint, .mode-dark .graph-panel .plink-label { color: #77737c; }
.mode-dark .graph-panel .plink-item, .mode-dark .graph-panel .plink-row a { color: #c9c4b8; }
.mode-dark .graph-panel .btn { background: #232228; border-color: #37343d; color: #ddd8cc; }
.mode-dark .graph-panel .icon-btn { color: #a8a294; }
.mode-dark .graph-panel .plink-type { background: #2a2830; color: #a8a294; }
.gp-title { font-size: 16px; margin: 0 0 6px; line-height: 1.5; font-family: var(--font-serif); }
.gp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.gp-depth { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-bottom: 14px; }

.graph-pathbar, .graph-multibar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 18px;
  display: flex; align-items: center; gap: 10px; z-index: 7;
  background: var(--bg); border: 1px solid var(--border); border-radius: 24px;
  padding: 7px 16px; box-shadow: var(--shadow-pop); font-size: 13px;
  max-width: 86%; flex-wrap: wrap; justify-content: center;
}
.graph-pathbar[hidden], .graph-multibar[hidden] { display: none; }
.mode-dark .graph-pathbar, .mode-dark .graph-multibar {
  background: #232228; border-color: #37343d; color: #ddd8cc;
}
.mode-dark .graph-pathbar .btn, .mode-dark .graph-multibar .btn { background: #2a2830; border-color: #403d47; color: #ddd8cc; }
.mode-dark .graph-pathbar .icon-btn { color: #a8a294; }
.pathbar-pos { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pathbar-current { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.mode-dark .pathbar-current, .mode-dark .pathbar-pos { color: #a8a294; }

.pe-items { display: flex; flex-direction: column; gap: 2px; }
.pe-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); font-size: 13px;
}
.pe-num { font-size: 11px; color: var(--text-3); width: 16px; text-align: right; }
.pe-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-item .icon-btn { width: 20px; height: 20px; }

@media (max-width: 900px) {
  .graph-panel { width: min(280px, 80vw); }
  .gt-search { width: 130px; }
  .graph-hint { display: none; }
}

/* ============================================================
   READER
   ============================================================ */

.reader-shell {
  display: flex; flex-direction: column; height: 100%;
  background: var(--r-bg, var(--bg)); color: var(--r-text, var(--text));
}
.reader-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg); color: var(--text); flex: none; gap: 10px;
}
.reader-layout { display: flex; flex: 1; min-height: 0; }
.reader-toc {
  width: 220px; flex: none; overflow-y: auto;
  padding: 30px 10px 30px 22px;
  border-right: 1px solid var(--r-border, var(--border));
  font-size: 12.5px;
}
.toc-title { color: var(--r-text3, var(--text-3)); font-size: 11px; letter-spacing: .05em; margin-bottom: 8px; }
.reader-toc a {
  display: block; color: var(--r-text2, var(--text-2)); text-decoration: none;
  padding: 3.5px 8px; border-radius: 5px; border-left: 2px solid transparent;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reader-toc a:hover { background: var(--bg-hover); }
.reader-toc a.active { color: var(--r-accent, var(--accent-text)); border-left-color: var(--r-accent, var(--accent)); }
.reader-toc .toc-l2 { padding-left: 20px; }
.reader-toc .toc-l3 { padding-left: 34px; }
.reader-scroll { flex: 1; overflow-y: auto; min-width: 0; }

.reader-article {
  max-width: var(--r-width, 700px); margin: 0 auto;
  padding: 52px 40px 40px;
  font-family: var(--r-font, var(--font-ui));
  font-size: var(--r-size, 17px);
  line-height: var(--r-lh, 1.85);
}
.reader-cover img { width: 100%; max-height: 380px; object-fit: cover; border-radius: var(--r-img-radius, 8px); }
.reader-cover { margin-bottom: 30px; }
.reader-head { margin-bottom: 2.2em; }
.reader-title {
  font-family: var(--r-font-head, var(--font-serif));
  font-size: var(--r-title-size, 2em); font-weight: var(--r-title-weight, 650);
  line-height: 1.35; margin: 0 0 .5em;
  text-align: var(--r-title-align, left);
}
.reader-digest { color: var(--r-text2, var(--text-2)); font-style: italic; margin: 0 0 .8em; text-align: var(--r-title-align, left); }
.reader-meta { font-size: .78em; color: var(--r-text3, var(--text-3)); text-align: var(--r-title-align, left); }

.reader-body p { margin: var(--r-para-gap, 1.15em) 0; text-indent: var(--r-indent, 0); }
.reader-body h1, .reader-body h2, .reader-body h3 {
  font-family: var(--r-font-head, var(--font-serif));
  font-weight: var(--r-head-weight, 650); line-height: 1.45;
  margin: 1.9em 0 .7em; text-indent: 0;
}
.reader-body h1 { font-size: 1.5em; }
.reader-body h2 { font-size: 1.28em; }
.reader-body h2::before { content: var(--r-h2-deco, none); color: var(--r-accent, var(--accent)); margin-right: 10px; }
.reader-body h3 { font-size: 1.1em; }
.reader-body blockquote {
  margin: 1.4em 0; padding: var(--r-quote-pad, 2px 0 2px 18px);
  border-left: var(--r-quote-border, 3px solid var(--border-2));
  background: var(--r-quote-bg, none); border-radius: var(--r-quote-radius, 0);
  color: var(--r-text2, var(--text-2)); font-style: var(--r-quote-style, normal);
  text-indent: 0;
}
.reader-body ul, .reader-body ol { margin: var(--r-para-gap, 1.15em) 0; padding-left: 1.6em; text-indent: 0; }
.reader-body li { margin: .35em 0; }
.reader-body a { color: var(--r-accent, var(--accent-text)); text-decoration: underline; text-underline-offset: 3px; }
.reader-body mark { background: rgba(200,165,60,.28); color: inherit; padding: 0 2px; border-radius: 2px; }
.reader-body code { font-family: var(--font-mono); font-size: .84em; background: var(--r-inset, var(--bg-inset)); border-radius: 4px; padding: 1px 5px; }
.reader-body hr {
  border: none; margin: 2.6em auto; width: var(--r-hr-width, 100%);
  border-top: var(--r-hr, 1px solid var(--border-2));
  text-align: center;
}
.reader-code {
  background: var(--r-inset, var(--bg-inset)); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-size: .82em; line-height: 1.65;
  margin: 1.5em 0;
}
.reader-code code { background: none; padding: 0; font-size: inherit; }
.reader-math {
  text-align: center; font-family: Georgia, serif; font-style: italic;
  margin: 1.8em 0; white-space: pre-wrap; text-indent: 0;
}
.reader-table-wrap { overflow-x: auto; margin: 1.5em 0; }
.reader-table-wrap table { border-collapse: collapse; width: 100%; font-size: .9em; }
.reader-table-wrap td, .reader-table-wrap th { border: 1px solid var(--r-border, var(--border-2)); padding: 8px 12px; text-align: left; }
.reader-table-wrap th { background: var(--r-inset, var(--bg-inset)); }
.callout {
  display: flex; gap: 10px; margin: 1.5em 0;
  background: var(--r-inset, var(--bg-inset)); border: 1px solid var(--r-border, var(--border));
  border-radius: 8px; padding: 14px 16px; font-size: .93em; text-indent: 0;
}
.callout-icon { flex: none; display: inline-flex; color: var(--text-2); padding-top: 3px; }
.callout-tip .callout-icon { color: var(--accent-text); }
.callout-warning .callout-icon { color: #96702a; }
.callout-danger .callout-icon { color: var(--danger); }
.callout-body { flex: 1; min-width: 0; }
.reader-toggle { border: 1px solid var(--r-border, var(--border)); border-radius: 8px; padding: 10px 16px; margin: 1.5em 0; }
.reader-toggle summary { cursor: pointer; font-weight: 600; }
.reader-toggle > div { padding-top: 8px; font-size: .95em; }
.todo-list { list-style: none; padding-left: .3em !important; }
.todo-item { display: flex; gap: 9px; align-items: baseline; }
.todo-box {
  flex: none; width: 1em; height: 1em; border: 1.5px solid var(--r-text3, var(--border-2));
  border-radius: 4px; font-size: .72em; line-height: 1.2em; text-align: center;
  transform: translateY(2px); color: #fff;
}
.todo-item.done .todo-box { background: var(--r-accent, var(--accent)); border-color: var(--r-accent, var(--accent)); }
.todo-item.done > span:last-child { color: var(--r-text3, var(--text-3)); text-decoration: line-through; }

.reader-figure { margin: var(--r-img-gap, 2em) auto; text-align: center; text-indent: 0; }
.reader-figure img { max-width: 100%; border-radius: var(--r-img-radius, 8px); }
.reader-figure.layout-wide, .reader-figure.layout-full { width: calc(100% + 80px); margin-left: -40px; max-width: none; }
.reader-figure.layout-left { float: left; width: 44%; margin: 6px 24px 10px 0; }
.reader-figure.layout-right { float: right; width: 44%; margin: 6px 0 10px 24px; }
.reader-figure figcaption, .reader-gallery figcaption {
  font-size: .76em; color: var(--r-text3, var(--text-3)); margin-top: 9px; line-height: 1.6;
  text-indent: 0;
}
.figcap-title { font-weight: 600; color: var(--r-text2, var(--text-2)); }
.figcap-meta { font-size: .95em; opacity: .85; }

.reader-gallery { display: grid; gap: 10px; margin: var(--r-img-gap, 2em) 0; }
.reader-gallery figure { margin: 0; text-align: center; }
.reader-gallery img { width: 100%; border-radius: var(--r-img-radius, 8px); object-fit: cover; display: block; }
.reader-gallery.gallery-grid2, .reader-gallery.gallery-compare { grid-template-columns: 1fr 1fr; }
.reader-gallery.gallery-grid3, .reader-gallery.gallery-grid { grid-template-columns: repeat(3, 1fr); }
.reader-gallery.gallery-grid2 img, .reader-gallery.gallery-grid3 img,
.reader-gallery.gallery-grid img, .reader-gallery.gallery-compare img { aspect-ratio: 4/3; }
.reader-gallery.gallery-row { display: flex; }
.reader-gallery.gallery-row figure { flex: 1; min-width: 0; }
.reader-gallery.gallery-masonry { display: block; column-count: 2; column-gap: 10px; }
.reader-gallery.gallery-masonry figure { break-inside: avoid; margin-bottom: 10px; }
.reader-gallery.gallery-carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; }
.reader-gallery.gallery-carousel figure { flex: 0 0 80%; scroll-snap-align: center; }
.reader-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin: 1.5em 0; text-indent: 0; }

.reader-foot {
  max-width: var(--r-width, 700px); margin: 0 auto; padding: 0 40px 60px;
  display: flex; flex-direction: column; gap: 14px;
}
.reader-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.reader-cols a { color: var(--r-accent, var(--accent-text)); }
.reader-nav {
  display: flex; justify-content: space-between; gap: 14px;
  border-top: 1px solid var(--r-border, var(--border)); padding-top: 18px; margin-top: 8px;
}
.reader-nav-item {
  display: flex; flex-direction: column; gap: 3px; max-width: 46%;
  text-decoration: none; color: var(--r-text, var(--text));
}
.reader-nav-item .hint { color: var(--r-text3, var(--text-3)); }
.reader-nav-item:hover { text-decoration: none; }
.reader-nav-item:hover b { color: var(--r-accent, var(--accent-text)); }
.reader-nav-item.next { text-align: right; margin-left: auto; }

/* ---------- reading themes ---------- */

.rt-minimal { --r-width: 680px; }

.rt-magazine {
  --r-font-head: var(--font-ui);
  --r-title-size: 2.5em; --r-title-weight: 800; --r-head-weight: 750;
  --r-width: 740px; --r-accent: #9c4038; --r-img-radius: 2px;
  --r-h2-deco: '/'; --r-hr: 2px solid currentColor; --r-hr-width: 60px;
}
.rt-magazine .reader-title { letter-spacing: -0.015em; }

.rt-academic {
  --r-font: var(--font-serif); --r-font-head: var(--font-serif);
  --r-size: 16.5px; --r-lh: 1.9; --r-width: 720px;
  --r-title-align: center; --r-title-size: 1.7em; --r-title-weight: 700;
  --r-accent: #3e5c82; --r-img-radius: 0; --r-quote-style: italic;
}

.rt-essay {
  --r-font: var(--font-serif); --r-font-head: var(--font-serif);
  --r-size: 17.5px; --r-lh: 2.0; --r-para-gap: 1.5em; --r-width: 640px;
  --r-accent: #8c5a3f; --r-img-radius: 6px; --r-img-gap: 2.6em;
  --r-quote-border: none; --r-quote-pad: 14px 26px; --r-quote-bg: var(--bg-inset);
  --r-quote-radius: 8px; --r-quote-style: italic; --r-hr-width: 15%;
}

.rt-photo {
  --r-width: 860px; --r-size: 15.5px;
  --r-title-align: center; --r-title-size: 1.6em; --r-title-weight: 500;
  --r-img-radius: 3px; --r-img-gap: 2.8em; --r-head-weight: 500;
  --r-hr: none;
}
.rt-photo .reader-figure figcaption { letter-spacing: .05em; }

.rt-news {
  --r-size: 16px; --r-lh: 1.75; --r-para-gap: 1em; --r-width: 680px;
  --r-font-head: var(--font-ui); --r-title-size: 1.75em; --r-title-weight: 750;
  --r-accent: #9c4038; --r-img-radius: 3px;
  --r-quote-border: 3px solid #9c4038;
}

.rt-dark {
  --r-bg: #232120; --r-text: #ddd8cc; --r-text2: #a29c8e; --r-text3: #7f7a6e;
  --r-border: #3a3733; --r-inset: #2c2a27; --r-accent: #a3c2b3;
  --r-width: 690px; --r-lh: 1.9;
}

.rt-book {
  --r-font: var(--font-serif); --r-font-head: var(--font-serif);
  --r-size: 17.5px; --r-lh: 2.0; --r-width: 620px;
  --r-indent: 2em; --r-para-gap: 0.4em;
  --r-title-align: center; --r-title-size: 1.65em;
  --r-accent: #44695b; --r-img-radius: 2px;
  --r-hr: none;
}
.rt-book .reader-body hr::before { content: '· · ·'; color: var(--r-text3, var(--text-3)); letter-spacing: .3em; }

.rt-blog {
  --r-size: 16.5px; --r-width: 700px;
  --r-font-head: var(--font-ui); --r-title-weight: 700;
  --r-accent: #35707a; --r-img-radius: 10px;
  --r-quote-border: 3px solid #35707a;
}

/* ============================================================
   responsive & print
   ============================================================ */

@media (max-width: 1180px) {
  .reader-toc { display: none; }
  .eb-image.layout-full, .eb-image.layout-wide {
    width: 100% !important; margin-left: 0 !important;
  }
  .reader-figure.layout-full, .reader-figure.layout-wide {
    width: 100%; margin-left: 0;
  }
}

@media (max-width: 1024px) {
  .sidebar { width: 216px; }
  .editor-page { padding: 36px 40px 30vh; }
  .eb-gutter { left: -40px; }
  .dash-cols { grid-template-columns: 1fr; }
  .editor-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 60; box-shadow: var(--shadow-pop); }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: var(--shadow-pop); width: 260px;
  }
  body.side-open .sidebar { transform: none; }
  .mobile-nav-btn {
    position: fixed; left: 12px; bottom: 16px; z-index: 210;
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--text); color: var(--bg); border: none;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-pop); cursor: pointer;
  }
  .page-head, .page-hint { padding-left: 18px; padding-right: 18px; }
  .page-hint, .filter-bar, .batch-bar, .lib-toolbar, .col-chapters { margin-left: 18px; margin-right: 18px; }
  .art-list, .art-grid, .cat-tree, .tag-table, .col-grid, .col-items, .lib-grid, .tpl-grid, .settings { padding-left: 18px; padding-right: 18px; }
  .col-head { padding-left: 18px; padding-right: 18px; }
  .dash { padding: 28px 20px 50px; }
  .editor-page { padding: 26px 22px 30vh; }
  .eb-gutter { left: -30px; }
  .eb-add { display: none; }
  .editor-title { font-size: 24px; }
  .reader-article, .reader-foot { padding-left: 22px; padding-right: 22px; }
  .cover-thumb { width: 56px; height: 44px; }
  .export-formats { grid-template-columns: 1fr 1fr; }
  .img-detail { grid-template-columns: 1fr; }
  .eb-columns, .reader-columns { grid-template-columns: 1fr; }
  .editor-panel { width: min(300px, 88vw); }
}
@media (min-width: 821px) {
  .mobile-nav-btn { display: none !important; }
}

@media print {
  .sidebar, .reader-topbar, .reader-toc, .reader-nav, .editor-topbar,
  .editor-footbar, .mobile-nav-btn, #toastRoot, .fmtbar { display: none !important; }
  #app, .main, .reader-shell, .reader-scroll, .reader-layout { display: block; height: auto; overflow: visible; }
  body { background: #fff; }
  .reader-article { max-width: 100%; padding: 0; }
  .reader-figure, .reader-gallery, .eb-image { break-inside: avoid; }
}
