/* ============================================================
 * style.css — 知识导图全局样式（亮 / 暗双主题）
 * ============================================================ */

/* ---------- 主题变量 ---------- */
:root, body[data-theme="light"] {
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-soft: cubic-bezier(.2, .65, .3, 1);
  --motion-fast: 160ms;
  --motion-normal: 280ms;
  --surface-glass: rgba(255, 255, 255, .84);
  --bg: #f3f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f4f9;
  --bg-inset: #eef1f6;
  --text: #1f2430;
  --text-2: #5b6472;
  --text-3: #9aa3b2;
  --border: #e3e7ee;
  --border-2: #d4dae4;
  --accent: #3e63dd;
  --accent-soft: rgba(62, 99, 221, .12);
  --danger: #e5484d;
  --ok: #2f9e63;
  --warn: #e8a33d;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .16);
  --mm-node-bg: #ffffff;
  --mm-edge-bg: #f8fafc;
  --mask-bg: #c3cad6;
}
body[data-theme="dark"] {
  color-scheme: dark;
  --surface-glass: rgba(33, 38, 47, .9);
  --bg: #14171d;
  --bg-sidebar: #1b1f27;
  --bg-card: #21262f;
  --bg-hover: #262c37;
  --bg-inset: #1a1f28;
  --text: #e8ebf1;
  --text-2: #a7b0bf;
  --text-3: #6b7484;
  --border: #2c333f;
  --border-2: #3a4250;
  --accent: #6c8cff;
  --accent-soft: rgba(108, 140, 255, .16);
  --danger: #ff6b6e;
  --ok: #4ac47f;
  --warn: #f0b25a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  --mm-node-bg: #2a303b;
  --mm-edge-bg: #14171d;
  --mask-bg: #4a5262;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background-color var(--motion-normal) var(--ease-soft), color var(--motion-normal) var(--ease-soft);
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- 启动画面 ---------- */
#boot-loading {
  position: fixed; inset: 0; z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; color: var(--text-2); background: var(--bg);
}
.boot-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 整体布局 ---------- */
#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- 侧边栏 ---------- */
#sidebar {
  width: 240px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  transition: background-color var(--motion-normal) var(--ease-soft), border-color var(--motion-normal) var(--ease-soft);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px 12px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-icon { font-size: 20px; }
.brand-name { white-space: nowrap; }
.icon-btn {
  border: none; background: transparent; font-size: 17px; line-height: 1;
  padding: 6px; border-radius: 8px; color: var(--text-2);
}
.icon-btn:hover { background: var(--bg-hover); }

.side-search { padding: 0 12px 10px; }
.side-search input {
  width: 100%; padding: 8px 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 8px; outline: none;
  background: var(--bg-inset); color: var(--text);
}
.side-search input:focus { border-color: var(--accent); }

.category-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.cat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; margin-bottom: 2px; border-radius: 10px;
  cursor: pointer; user-select: none; border: 1px solid transparent;
  transition: background-color var(--motion-fast) var(--ease-soft), border-color var(--motion-fast) var(--ease-soft), transform var(--motion-fast) var(--ease-out);
}
.cat-item:hover { background: var(--bg-hover); }
.cat-item.active { background: var(--accent-soft); border-color: var(--accent); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-icon { font-size: 16px; flex-shrink: 0; width: 22px; text-align: center; }
.cat-name { flex: 1; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-count {
  font-size: 11px; color: var(--text-3); background: var(--bg-inset);
  padding: 1px 7px; border-radius: 20px;
}
.cat-empty { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 24px 8px; }

.new-category {
  margin: 8px 12px 14px; padding: 10px; font-size: 13.5px;
  border: 1.5px dashed var(--border-2); border-radius: 10px;
  background: transparent; color: var(--text-2);
}
.new-category:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- 主区域 ---------- */
#main { flex: 1; min-width: 0; overflow-y: auto; position: relative; }

/* ---------- 欢迎页 ---------- */
.welcome {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 40px 20px; text-align: center;
}
.welcome .w-icon { font-size: 64px; margin-bottom: 8px; }
.welcome h1 { font-size: 26px; margin-bottom: 6px; }
.welcome p { color: var(--text-2); max-width: 460px; line-height: 1.7; font-size: 14px; }
.welcome .w-feats {
  display: flex; gap: 14px; margin: 22px 0 8px; flex-wrap: wrap; justify-content: center;
}
.welcome .w-feat {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 18px; width: 180px; box-shadow: var(--shadow); text-align: left;
}
.welcome .w-feat .fi { font-size: 22px; margin-bottom: 6px; }
.welcome .w-feat b { font-size: 13.5px; display: block; margin-bottom: 3px; }
.welcome .w-feat span { font-size: 12px; color: var(--text-2); line-height: 1.5; display: block; }
.welcome .w-btns { display: flex; gap: 12px; margin-top: 18px; }

/* ---------- 通用按钮 ---------- */
.btn {
  padding: 9px 18px; border-radius: 10px; font-size: 13.5px; border: 1px solid var(--border-2);
  background: var(--bg-card); color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 90%, white); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: rgba(229, 72, 77, .08); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 分类库（library） ---------- */
.library { padding: 26px 30px 40px; max-width: 1200px; margin: 0 auto; }
.lib-banner {
  --cat-color: #3e63dd;
  display: flex; align-items: center; gap: 16px;
  border-radius: 16px; padding: 20px 24px; margin-bottom: 22px;
  background: var(--cat-color);
  background: linear-gradient(135deg, var(--cat-color), color-mix(in srgb, var(--cat-color) 55%, #000 0%) 140%);
  color: #fff; box-shadow: var(--shadow);
}
.lib-icon {
  width: 62px; height: 62px; border-radius: 16px; background: rgba(255, 255, 255, .22);
  display: flex; align-items: center; justify-content: center; font-size: 34px; flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.lib-titles { flex: 1; min-width: 0; }
.lib-titles h1 { font-size: 22px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-titles p { font-size: 12.5px; opacity: .85; }
.lib-actions { display: flex; gap: 8px; flex-shrink: 0; }
.lib-actions .btn {
  background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); color: #fff;
  backdrop-filter: blur(4px);
}
.lib-actions .btn:hover { background: rgba(255, 255, 255, .3); color: #fff; }

.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px;
}
.map-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 16px 12px; position: relative; overflow: hidden;
  cursor: pointer;
  transition: transform var(--motion-normal) var(--ease-out), box-shadow var(--motion-normal) var(--ease-soft), border-color var(--motion-fast) var(--ease-soft), background-color var(--motion-normal) var(--ease-soft);
  display: flex; flex-direction: column; gap: 6px;
}
.map-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-2); }
.map-card-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.map-card h3 { font-size: 15px; margin-top: 4px; word-break: break-all; }
.map-meta { font-size: 12px; color: var(--text-2); word-break: break-all; }
.map-date { font-size: 11.5px; color: var(--text-3); }
.map-card-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.map-card-actions .btn { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

/* ---------- 上传卡片 ---------- */
.upload-card {
  border: 2px dashed var(--border-2); border-radius: 14px; min-height: 170px;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--motion-normal) var(--ease-out), border-color var(--motion-fast) var(--ease-soft), background-color var(--motion-normal) var(--ease-soft); background: var(--bg-card);
}
.upload-card.dragover { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.upload-inner { text-align: center; padding: 20px; user-select: none; }
.upload-inner .ui { font-size: 34px; margin-bottom: 8px; }
.upload-inner h3 { font-size: 15px; margin-bottom: 4px; }
.upload-inner p { font-size: 12px; color: var(--text-3); }
.upload-status {
  position: absolute; inset: auto 0 0 0; padding: 8px 14px; font-size: 12px;
  color: var(--accent); background: var(--accent-soft); display: none;
}
.upload-card { position: relative; }
.upload-card.has-status .upload-status { display: block; }

/* ---------- 编辑器 ---------- */
.editor { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ed-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--bg-sidebar); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.ed-toolbar .btn { padding: 6px 12px; font-size: 12.5px; }
#map-title {
  flex: 1; min-width: 120px; max-width: 340px; font-size: 15px; font-weight: 600;
  border: 1px solid transparent; background: transparent; color: var(--text);
  padding: 6px 10px; border-radius: 8px; outline: none;
}
#map-title:hover, #map-title:focus { border-color: var(--border-2); background: var(--bg-inset); }
.ed-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.spacer { flex: 1; }

#mm-container { flex: 1; min-height: 0; position: relative; overflow: hidden; background: var(--mm-edge-bg); contain: layout paint; }
.mm-wrap { position: absolute; inset: 0; }
.mm-svg { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; touch-action: none; }
.mm-svg.panning { cursor: grabbing; }
.mm-svg text { user-select: none; }
.mm-node { cursor: pointer; }
.mm-node.selected > rect:first-child { stroke: var(--accent); stroke-width: 2.5; }
.mm-node.editing { opacity: .25; }
.mm-badge { cursor: pointer; }
.mm-edit-fo textarea {
  width: 100%; height: 100%; resize: none;
  border: 2px solid var(--accent); border-radius: 8px;
  background: var(--bg-card); color: var(--text);
  padding: 5px 10px; font-size: 13px; line-height: 1.45;
  outline: none; box-shadow: var(--shadow-lg); overflow: hidden;
}
.mm-edit-fo > div { height: 100%; }

/* 画布右下角缩放控件 */
.mm-zoomctrl {
  position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 4px;
}
.mm-zoomctrl button {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); font-size: 16px; box-shadow: var(--shadow);
}
.mm-zoomctrl button:hover { border-color: var(--accent); color: var(--accent); }

/* 操作提示条 */
.mm-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font-size: 11.5px; color: var(--text-3); background: var(--bg-card);
  border: 1px solid var(--border); padding: 5px 14px; border-radius: 20px;
  box-shadow: var(--shadow); white-space: nowrap; pointer-events: none;
}

/* 节点浮动工具条 */
.mm-node-toolbar {
  position: absolute; display: none; gap: 4px; padding: 4px;
  left: 0; top: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 20;
}
.mm-node-toolbar.show { display: flex; }
.mm-node-toolbar button {
  border: none; background: transparent; font-size: 12px; padding: 5px 8px;
  border-radius: 7px; color: var(--text-2); white-space: nowrap;
}
.mm-node-toolbar button:hover { background: var(--bg-hover); color: var(--accent); }
.mm-node-toolbar button.danger:hover { color: var(--danger); }

/* 复习模式底部栏 */
.review-bar {
  position: absolute; left: 50%; bottom: 48px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 18px; box-shadow: var(--shadow-lg); z-index: 30; flex-wrap: wrap; max-width: 92%;
}
.review-bar .rv-title { font-size: 13px; font-weight: 700; color: var(--accent); }
.review-bar .rv-progress { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.rv-bar-track {
  width: 150px; height: 6px; border-radius: 6px; background: var(--bg-inset); overflow: hidden;
}
.rv-bar-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .25s; }

/* Review assessments and source reading use the same surfaces as the editor. */
.review-bar { width: 650px; display: block; max-height: 42%; overflow-y: auto; }
.rv-top, .rv-controls, .rv-ratings { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-top .rv-bar-track { flex: 1; min-width: 60px; }
.rv-question { font-size: 14px; line-height: 1.6; margin: 12px 0; overflow-wrap: anywhere; }
.rv-feedback { font-size: 12px; color: var(--text-2); line-height: 1.6; margin-top: 8px; }
.due-entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 14px; margin-top: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-card); color: var(--text); text-align: left; }
.due-entry:hover { border-color: var(--accent); background: var(--accent-soft); }
.due-entry b, .due-entry small { display: block; overflow-wrap: anywhere; }
.due-entry small { margin-top: 5px; color: var(--text-2); }
.due-entry > span:last-child { flex-shrink: 0; color: var(--accent); }
.empty-study { padding: 24px 4px; font-size: 14px; line-height: 1.7; color: var(--text-2); }
.modal.source-modal { width: min(960px, 94vw); }
.modal.refine-modal { width: min(620px, 94vw); }
.source-nav { display: flex; gap: 10px; align-items: center; margin: 14px 0; }
.source-nav label { flex-shrink: 0; font-size: 13px; }
.source-nav select, .refine-options select { min-width: 0; width: 100%; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-inset); color: var(--text); font: inherit; font-size: 13px; }
.source-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); gap: 18px; }
.source-columns section { min-width: 0; }
.source-body h4 { font-size: 13px; margin: 12px 0 8px; }
.source-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 14px;
  line-height: 1.8; background: var(--bg-inset); padding: 16px; border-radius: 10px;
  max-height: 46vh; overflow-y: auto; color: var(--text); }
.source-body details { margin: 12px 0; }
.source-body summary { font-size: 13px; color: var(--accent); cursor: pointer; margin-bottom: 8px; }
#source-frame { width: 100%; height: 46vh; border: 1px solid var(--border); border-radius: 10px; background: white; }
.refine-range { display: flex; gap: 12px; margin-top: 14px; }
.refine-range label { flex: 1; font-size: 13px; }
.refine-options p.f-label { display: block; margin: 14px 0 8px; font-size: 13px; color: var(--text-2); }
.refine-range input { display: block; margin-top: 6px; width: 100%; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-inset); color: var(--text); font: inherit; }
.refine-chapters { border: 1px solid var(--border); border-radius: 10px; max-height: 180px; overflow-y: auto; padding: 4px 10px; }
.refine-chapters label { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; cursor: pointer; }
.refine-chapters input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--accent); }
.refine-chapters span { overflow-wrap: anywhere; }
.refine-chapters small { display: block; color: var(--text-2); font-size: 11px; margin-top: 3px; }
#refine-estimate { margin: 12px 0; }
.mm-node-toolbar { max-width: calc(100% - 12px); flex-wrap: wrap; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 20, 30, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(6px); animation: fadeIn var(--motion-normal) var(--ease-out) both;
}
.modal {
  background: var(--bg-card); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(480px, 92vw); max-height: 86vh; display: flex; flex-direction: column;
  animation: popIn 320ms var(--ease-out) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.97) translateY(12px); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 22px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16.5px; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--text-3); padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border);
}
.modal-body p.desc { color: var(--text-2); font-size: 13.5px; line-height: 1.7; margin-bottom: 8px; }
.modal-body label.f-label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 14px 0 7px;
}
.modal-body input[type="text"] {
  width: 100%; padding: 9px 12px; font-size: 14px; border: 1px solid var(--border-2);
  border-radius: 9px; background: var(--bg-inset); color: var(--text); outline: none;
}
.modal-body input[type="text"]:focus { border-color: var(--accent); }
.modal-body input[type="password"] {
  width: 100%; padding: 9px 12px; font-size: 14px; border: 1px solid var(--border-2);
  border-radius: 9px; background: var(--bg-inset); color: var(--text); outline: none;
}
.modal-body input[type="password"]:focus { border-color: var(--accent); }

/* ---------- AI 相关样式 ---------- */
.ai-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-2); margin-top: 10px;
  cursor: pointer; user-select: none;
}
.ai-toggle:hover { color: var(--accent); }
.ai-toggle input { accent-color: var(--accent); cursor: pointer; }
.provider-list .review-opt { margin-bottom: 8px; padding: 10px 12px; }
.modal-spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 0 auto 12px;
}
.ai-loading-box { text-align: center; padding: 22px 0; color: var(--text-2); font-size: 13.5px; line-height: 1.7; }
.ai-preview {
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 12px; line-height: 1.7; max-height: 260px; overflow: auto;
  white-space: pre; font-family: Consolas, "Courier New", monospace; color: var(--text-2);
}
.ai-err { color: var(--danger); }

/* 颜色选择网格 */
.color-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.color-swatch {
  aspect-ratio: 1; border-radius: 10px; cursor: pointer; border: 3px solid transparent;
  outline: 1px solid rgba(0, 0, 0, .08); transition: transform var(--motion-fast) var(--ease-out);
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.sel { border-color: var(--bg-card); outline: 2.5px solid var(--text); }
.color-custom-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.color-custom-row input[type="color"] {
  width: 42px; height: 32px; border: 1px solid var(--border-2); border-radius: 8px;
  background: none; padding: 2px; cursor: pointer;
}
.color-custom-row span { font-size: 12.5px; color: var(--text-3); }

/* 图标选择网格 */
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon-swatch {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 19px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--bg-inset);
}
.icon-swatch:hover { border-color: var(--accent); transform: scale(1.1); }
.icon-swatch.sel { border-color: var(--accent); background: var(--accent-soft); }

/* 复习模式选项 */
.review-opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; margin-bottom: 10px;
  transition: border-color var(--motion-fast) var(--ease-soft), background-color var(--motion-fast) var(--ease-soft);
}
.review-opt:hover { border-color: var(--accent); }
.review-opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.review-opt .rd { margin-top: 3px; }
.review-opt b { font-size: 13.5px; display: block; }
.review-opt span { font-size: 12px; color: var(--text-2); }
.review-stats { display: flex; gap: 12px; justify-content: center; margin: 10px 0; }
.review-stat {
  flex: 1; text-align: center; background: var(--bg-inset); border-radius: 12px; padding: 14px 8px;
}
.review-stat b { display: block; font-size: 22px; }
.review-stat span { font-size: 11.5px; color: var(--text-2); }
.rs-total b { color: var(--accent); }
.rs-done b { color: var(--ok); }
.rs-fuzzy b { color: var(--danger); }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 18px;
  font-size: 13px; box-shadow: var(--shadow-lg); animation: toastIn var(--motion-normal) var(--ease-out) both; max-width: 80vw;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* A restrained motion system: direct manipulation stays immediate; surfaces settle softly. */
.btn, .icon-btn, .new-category, .modal-close, .mm-zoomctrl button,
.mm-node-toolbar button, .icon-swatch {
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-soft),
    border-color var(--motion-fast) var(--ease-soft), color var(--motion-fast) var(--ease-soft), opacity var(--motion-fast) var(--ease-soft);
}
button:not(:disabled):active, .icon-swatch:active, .color-swatch:active { transform: scale(.96); }
.cat-item:active { transform: scale(.985); }
.map-card:active { transform: translateY(0) scale(.992); }
button:focus-visible, .cat-item:focus-visible, .map-card:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent-soft); outline-offset: 3px;
}
.side-search input, .modal-body input, #map-title {
  transition: border-color var(--motion-fast) var(--ease-soft), background-color var(--motion-normal) var(--ease-soft);
}
.welcome, .library { animation: viewIn 320ms var(--ease-out) both; }
.editor { animation: fadeIn var(--motion-normal) var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.w-feat { transition: transform var(--motion-normal) var(--ease-out), border-color var(--motion-fast) var(--ease-soft); }
@media (hover: hover) and (pointer: fine) { .w-feat:hover { transform: translateY(-2px); border-color: var(--border-2); } }
.modal, .toast, .mm-node-toolbar, .mm-zoomctrl button, .review-bar {
  background: var(--surface-glass);
}
/* Limit backdrop blur to small floating controls to keep the canvas inexpensive to paint. */
.mm-node-toolbar, .review-bar { backdrop-filter: blur(12px); }
.modal-mask.closing { pointer-events: none; animation: fadeOut 160ms var(--ease-soft) both; }
.modal-mask.closing .modal { animation: popOut 160ms var(--ease-soft) both; }
.toast.leaving { animation: toastOut 160ms var(--ease-soft) both; }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes popOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes toastOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-6px); } }
#toast-root { pointer-events: none; }
#main, .category-list, .modal-body, .ai-preview {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .boot-spinner, .modal-spinner { animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 窄屏适配 ---------- */
@media (max-width: 760px) {
  #sidebar { width: 200px; }
  .library { padding: 16px; }
  .lib-banner { flex-wrap: wrap; }
  .mm-hint { display: none; }
  .brand { font-size: 15px; gap: 6px; }
}
@media (max-width: 600px) {
  #sidebar { width: 72px; }
  .side-head { flex-direction: column; gap: 12px; padding: 16px 8px 12px; }
  .brand-name, .side-search, .cat-dot, .cat-name, .cat-count { display: none; }
  .cat-item { justify-content: center; padding: 10px 6px; }
  .cat-icon { width: auto; font-size: 22px; }
  .new-category { margin: 8px 10px 14px; min-height: 42px; font-size: 0; }
  .new-category::after { content: '＋'; font-size: 22px; }
  #btn-due-review::after { content: '🎯'; }
  .review-bar { padding: 12px; bottom: 62px; max-width: 94%; max-height: 48%; }
  .rv-top .rv-bar-track { display: none; }
  .rv-controls .btn, .rv-ratings .btn { padding: 7px 8px; font-size: 12px; }
  .lib-grid { grid-template-columns: minmax(0, 1fr); }
  .lib-banner { padding: 16px; gap: 12px; }
  .lib-actions { flex-wrap: wrap; }
  .ed-toolbar { gap: 6px; padding: 8px; }
  .ed-toolbar .btn { padding: 6px 8px; }
  .ed-meta { display: none; }
  #map-title { min-width: 80px; }
  .mm-zoomctrl button { width: 42px; height: 42px; }
  .mm-node-toolbar { gap: 0; padding: 2px; }
  .mm-node-toolbar button { padding: 7px 5px; }
  .rv-bar-track { width: 100px; }
}
