/* =========================================================
   LaTeX Live — 样式
   1. 基础与主题变量
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }

/* 部分组件在 CSS 中设了 display，需显式让 [hidden] 生效 */
[hidden] { display: none !important; }

:root {
  --radius: 10px;
  --radius-sm: 6px;
  --font-ui: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  --topbar-h: 52px;
  --transition: .18s ease;
}

/* ---------- 浅色（默认） ---------- */
html[data-theme="default"] {
  --bg: #f2f4f8;
  --bg-elev: #ffffff;
  --bg-sunken: #f7f8fb;
  --bg-hover: #eef1f7;
  --border: #e2e6ee;
  --border-strong: #ccd3e0;
  --text: #1f2430;
  --text-dim: #6b7488;
  --text-faint: #9aa3b5;
  --accent: #2f6bff;
  --accent-soft: #e8effe;
  --accent-text: #ffffff;
  --sel: rgba(47,107,255,.32);
  --code-bg: #f7f8fb;
  --shadow: 0 1px 2px rgba(24,32,54,.06), 0 8px 24px rgba(24,32,54,.06);
  --shadow-lg: 0 12px 48px rgba(24,32,54,.18);
  --danger: #d9453d;
  --ok: #1f9d63;
}

/* ---------- 深色 ---------- */
html[data-theme="dark"] {
  --bg: #14161c;
  --bg-elev: #1c1f27;
  --bg-sunken: #181b22;
  --bg-hover: #252935;
  --border: #2b303c;
  --border-strong: #3a4150;
  --text: #e6e9f0;
  --text-dim: #99a1b3;
  --text-faint: #6d7688;
  --accent: #5b8cff;
  --accent-soft: #1f2a44;
  --accent-text: #0d1017;
  --sel: rgba(91,140,255,.38);
  --code-bg: #14171e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 56px rgba(0,0,0,.6);
  --danger: #ff6b61;
  --ok: #3ddc97;
}

/* ---------- 蓝色 ---------- */
html[data-theme="blue"] {
  --bg: #e8f1f8;
  --bg-elev: #ffffff;
  --bg-sunken: #f1f7fb;
  --bg-hover: #e2eef7;
  --border: #cfe0ee;
  --border-strong: #aecbdf;
  --text: #17293a;
  --text-dim: #5a7288;
  --text-faint: #8aa0b3;
  --accent: #0f7bbf;
  --accent-soft: #dceefb;
  --accent-text: #ffffff;
  --sel: rgba(15,123,191,.32);
  --code-bg: #f3f9fd;
  --shadow: 0 1px 2px rgba(15,60,90,.07), 0 8px 24px rgba(15,60,90,.07);
  --shadow-lg: 0 12px 48px rgba(15,60,90,.2);
  --danger: #cc4740;
  --ok: #17907a;
}

/* ---------- 粉色 ---------- */
html[data-theme="pink"] {
  --bg: #fdeef4;
  --bg-elev: #fff9fb;
  --bg-sunken: #fbf3f7;
  --bg-hover: #f9e6ee;
  --border: #f0d8e3;
  --border-strong: #dfbacb;
  --text: #33232c;
  --text-dim: #7d6470;
  --text-faint: #ab93a0;
  --accent: #d4568a;
  --accent-soft: #fbe4ee;
  --accent-text: #ffffff;
  --sel: rgba(212,86,138,.32);
  --code-bg: #fdf5f9;
  --shadow: 0 1px 2px rgba(80,30,55,.07), 0 8px 24px rgba(80,30,55,.07);
  --shadow-lg: 0 12px 48px rgba(80,30,55,.2);
  --danger: #c94b5c;
  --ok: #2c9c7a;
}

/* ---------- 黑白 ---------- */
html[data-theme="simple"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-sunken: #f4f4f4;
  --bg-hover: #ececec;
  --border: #dcdcdc;
  --border-strong: #b8b8b8;
  --text: #111111;
  --text-dim: #5c5c5c;
  --text-faint: #8f8f8f;
  --accent: #111111;
  --accent-soft: #e8e8e8;
  --accent-text: #ffffff;
  --sel: rgba(17,17,17,.26);
  --code-bg: #f7f7f7;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.18);
  --danger: #b3261e;
  --ok: #1a7f4b;
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* =========================================================
   2. 顶栏
   ========================================================= */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}

.topbar-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.brand { display: flex; align-items: baseline; text-decoration: none; color: var(--text); }
.brand-mark { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand-name { font-weight: 400; font-size: 17px; color: var(--accent); margin-left: 3px; }
.brand-sub { color: var(--text-faint); font-size: 12.5px; white-space: nowrap; }

/* 首页品牌区（对齐官网 home-brand 结构：LOGO + 竖线 + 「公式编辑器」+ 副标题） */
.home-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  text-decoration: none;
  color: var(--text);
}
.home-brand-titleline { display: flex; align-items: center; gap: 6px; }
.home-brand-logo { display: block; height: 32px; width: auto; }
.home-brand-divider { width: 1px; height: 23px; background: var(--border-strong); flex: none; }
.home-brand-title { font-size: 20px; font-weight: 600; line-height: 24px; color: var(--text); }
.home-brand-sub { font-size: 11px; font-weight: 500; line-height: 13.75px; color: var(--text-dim); white-space: nowrap; }
html[data-theme="dark"] .home-brand-logo { filter: invert(1) hue-rotate(180deg); }

.topbar-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.nav-link {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: var(--transition);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon { width: 15px; height: 15px; flex: none; }

/* 顶栏主题快捷切换（仅浅色 / 深色二态，图标随当前主题切换） */
.nav-icon { display: inline-flex; align-items: center; justify-content: center; padding: 6px 9px; }
.theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: inline-block; }

/* =========================================================
   3. 工作区布局
   ========================================================= */

.workspace {
  height: calc(100vh - var(--topbar-h));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.workspace.is-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
.workspace.is-stacked { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0,1fr) minmax(0,1fr); }

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex: none;
}

.panel-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text); flex: none; }
.panel-title .panel-icon { width: 15px; height: 15px; flex: none; opacity: .85; }

.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.tabs { display: flex; gap: 2px; margin-left: auto; background: var(--bg-sunken); padding: 2px; border-radius: 8px; }

.tab {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: var(--transition);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--bg-elev); color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* 上方工具面板：占输入区约 30% 高度（卡片下方不留大块空白），切换标签不影响下方常驻编辑器 */
.tabpane { display: none; flex-direction: column; min-height: 0; flex: 1 1 30%; overflow-y: auto; }
.tabpane.is-active { display: flex; }

/* =========================================================
   4. 工具栏
   ========================================================= */

.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex: none;
  flex-wrap: wrap;
}

.tool {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  transition: var(--transition);
  white-space: nowrap;
}
.tool:hover { background: var(--bg-hover); color: var(--text); }
.tool.is-on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.toolbar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.toolbar-grow { flex: 1; }

/* =========================================================
   5. 符号面板
   ========================================================= */

.symbols { border-bottom: 1px solid var(--border); background: var(--bg-sunken); flex: none; display: flex; flex-direction: column; max-height: 40%; }

.symbols-cats { display: flex; gap: 2px; overflow-x: auto; padding: 6px 8px; border-bottom: 1px solid var(--border); scrollbar-width: thin; }

.cat {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 4px 10px; border-radius: var(--radius-sm); font-size: 12.5px; white-space: nowrap;
}
.cat:hover { background: var(--bg-hover); color: var(--text); }
.cat.is-active { background: var(--bg-elev); color: var(--accent); font-weight: 600; }

.symbols-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
  min-height: 72px;
  max-height: 190px;
}

.sym {
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  padding: 2px; overflow: hidden;
  transition: var(--transition);
  color: var(--text);
}
.sym:hover { border-color: var(--accent); background: var(--accent-soft); }
.sym mjx-container, .sym svg { max-width: 100%; max-height: 34px; }

.symbols-empty, .symbols-tip { padding: 8px 10px; color: var(--text-faint); font-size: 12px; }
.symbols-tip { border-top: 1px solid var(--border); }

/* =========================================================
   5.1 快捷工具（快捷卡片 + 符号区）
   ========================================================= */

.quick-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
  padding: 10px;
  flex: none;
}

.quick-card { position: relative; border: 1px solid var(--border); background: var(--bg-elev); border-radius: var(--radius-sm);
  padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: var(--transition);
  color: var(--text);
  min-height: 62px;
}
.quick-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick-card.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.quick-card-name { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.quick-card.is-active .quick-card-name { color: var(--accent); font-weight: 600; }
.quick-card-caret { position: absolute; right: 4px; bottom: 2px; font-size: 9px; color: var(--text-faint); line-height: 1; }
.quick-card.is-active .quick-card-caret { color: var(--accent); }

.quick-hint { padding: 6px 10px 12px; font-size: 12px; color: var(--text-faint); text-align: center; }

/* 悬浮符号面板：宽度按官网 Uc()/Kc() 计算（默认 34rem），在卡片正下方弹出，覆盖在编辑器之上 */
.quick-panel { position: fixed; z-index: 80;
  width: min(clamp(18rem, 34rem, 34rem), calc(100vw - 1rem)); max-width: calc(100vw - 1rem);
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: 72vh; overflow: hidden; }
.quick-panel-head { padding: 8px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 8px; flex: none; background: var(--bg-sunken); }
.quick-panel-title { font-size: 13px; font-weight: 600; color: var(--text); }
.quick-panel-en { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.quick-panel-close { margin-left: auto; border: 0; background: transparent; color: var(--text-faint);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 4px; }
.quick-panel-close:hover { color: var(--danger); background: var(--bg-hover); }
.quick-panel-body { overflow-y: auto; padding: 10px; }

/* 分组：整组占满一行（对应官网 divider 容器的 w-full / flex-basis 100%） */
.qp-group { flex: 0 0 100%; width: 100%; }
.qp-group + .qp-group { margin-top: 6px; }
/* 分组标题：官网为「细分隔线 + 灰色小标题 + 细分隔线」（色值 #64748b ≈ --text-dim），非蓝色 */
.qp-group-title {
  margin: 6px 0; padding: 4px 0; font-size: 12px; font-weight: 600;
  color: var(--text-dim); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.qp-group:first-child .qp-group-title { margin-top: 0; border-top: 0; }
/* 符号区：官网用 flex-wrap 自然换行，每个符号宽度由数据里的 size 决定
   （不再用等宽网格，避免宽符号被截断 / 互相重叠） */
.qp-symbols { display: flex; flex-wrap: wrap; align-items: center; }
.qp-symbols .sym {
  flex: none; width: auto; height: auto; overflow: visible;
  margin: 0.2rem; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-sunken);
}
.qp-symbols .sym:hover { border-color: var(--border); background: var(--bg-elev); }
.qp-symbols .sym-img img { max-width: 100%; }

/* =========================================================
   5.2 公式模板
   ========================================================= */

.tpl-count { font-size: 12px; color: var(--text-faint); }

.tpl-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
  align-content: start;
}

.tpl-card {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  text-align: left;
  transition: var(--transition);
  color: var(--text);
  overflow: hidden;
}
.tpl-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.tpl-body {
  min-height: 40px;
  display: flex; align-items: center;
  overflow: hidden;
  color: var(--text);
}
.tpl-body mjx-container, .tpl-body svg { max-width: 100%; max-height: 46px; }
.tpl-name { font-size: 12px; color: var(--text-dim); }

/* =========================================================
   6. 编辑器
   ========================================================= */

.editor { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--code-bg); }

.editor-highlight, .editor-input {
  margin: 0;
  padding: 14px;
  border: 0;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre;
  word-wrap: normal;
  tab-size: 2;
  overflow: auto;
}

.editor-highlight {
  position: absolute; inset: 0;
  pointer-events: none;
  color: var(--text);
  background: var(--code-bg);
}

.editor-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  outline: none;
}
.editor-input::selection { background: var(--sel); color: transparent; }

/* 输入区空状态占位符：对齐官网 home-source-placeholder（浅灰 #d4d7dc，其中「LaTeX」为衬线斜体） */
.editor-placeholder {
  position: absolute; inset: 0;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre;
  color: #d4d7dc;
  pointer-events: none;
  overflow: hidden;
}
.editor-placeholder-latex { font-family: KaTeX_Math, "Times New Roman", serif; font-style: italic; }

/* 输入区域自动换行：两层同时改为 pre-wrap，保持对齐 */
.editor.is-wrap .editor-highlight,
.editor.is-wrap .editor-input,
.editor.is-wrap .editor-placeholder {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.tk-cmd  { color: #a626a4; }
.tk-brace{ color: #4078f2; }
.tk-paren{ color: #986801; }
.tk-num  { color: #b76b01; }
.tk-spec { color: #e45649; }
.tk-op   { color: #0184bc; }
.tk-comment { color: var(--text-faint); font-style: italic; }

html[data-theme="dark"] .tk-cmd  { color: #c678dd; }
html[data-theme="dark"] .tk-brace{ color: #61afef; }
html[data-theme="dark"] .tk-paren{ color: #e5c07b; }
html[data-theme="dark"] .tk-num  { color: #d19a66; }
html[data-theme="dark"] .tk-spec { color: #e06c75; }
html[data-theme="dark"] .tk-op   { color: #56b6c2; }

/* 常驻编辑器区（上方标签页切换不影响它）：占输入区约 70% 高度，比上方工具面板更高 */
.editor-zone {
  flex: 1 1 70%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-strong);
}

/* 底部工具栏（撤销/重做/收藏/复制…）：竖向内边距与右侧输出区底栏一致，使两栏分隔线对齐 */
.editor-toolbar { border-top: 1px solid var(--border); border-bottom: 0; padding: 10px 8px; }
.editor-toolbar .counter { font-size: 12px; color: var(--text-faint); margin-right: 4px; }

/* 可视化模式：输入区渲染只读预览 */
.editor-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: var(--code-bg);
  text-align: center;
}
.editor-view mjx-container, .editor-view svg { max-width: 100%; }
.editor-view-hint { margin-top: 12px; font-size: 12px; color: var(--text-faint); }

/* 底部工具栏：颜色 / 字体 / 字号 / 环境 / 清空 · 源码-可视化 · 字号步进 */
.editor-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex: none;
  flex-wrap: wrap;
}

.bar-menu-item { position: relative; display: inline-flex; }

.bar-btn {
  border: 1px solid transparent;
  background: var(--bg-sunken);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 4px;
  transition: var(--transition);
}
.bar-btn:hover { border-color: var(--border-strong); background: var(--bg-elev); color: var(--text); }
.bar-btn.is-open { border-color: var(--border-strong); background: var(--bg-elev); color: var(--accent); }
.bar-btn .bar-icon { width: 1.2em; height: 1.2em; flex: none; }
.bar-btn .bar-caret { width: .78em; height: .78em; flex: none; opacity: .65; }
.bar-icon .bar-icon-hole { fill: var(--bg-elev); }
.bar-danger { color: var(--danger); }
.bar-danger:hover { border-color: var(--danger); background: var(--bg-elev); color: var(--danger); }

.bar-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 190px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 5px;
}

.menu-title { font-size: 11px; color: var(--text-faint); padding: 4px 8px 2px; }
.menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  border: 0; background: transparent;
  color: var(--text);
  padding: 5px 8px; border-radius: 4px;
  font-size: 12.5px; text-align: left;
}
.menu-item:hover { background: var(--accent-soft); color: var(--accent); }
.menu-item-sample {
  min-width: 108px; height: 32px;
  display: flex; align-items: center; justify-content: flex-start;
  flex: none; overflow: hidden; color: var(--text);
  padding: 0 6px;
  border-radius: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}
.menu-item-sample mjx-container, .menu-item-sample svg { max-height: 24px; }
.menu-item-label { flex: 1; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* 环境菜单：对齐官网——纯文字按钮纵向排列（无缩略图/标题），默认不高亮，悬停才点亮 */
.env-menu { min-width: 130px; padding: 6px; }
.env-menu .menu-item {
  justify-content: center;
  padding: 8px 12px;
  margin-bottom: 5px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
}
.env-menu .menu-item:last-child { margin-bottom: 0; }
.env-menu .menu-item:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.env-menu .menu-item-label { flex: none; }

/* AI 助手：点击开合的下拉面板（与同排悬停菜单互不干扰） */
.ai-wrap[hidden] { display: none; }
.ai-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 31;
  width: 360px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.ai-panel[hidden] { display: none; }

/* 模式切换：整块分段控件，选中项用主题色胶囊（提高优先级，避免被后面的 .mode-switch 覆盖） */
.ai-panel .ai-modes {
  display: flex;
  width: 100%;
  gap: 2px;
  padding: 2px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.ai-panel .ai-modes .mode-btn {
  flex: 1;
  text-align: center;
  border-radius: 6px;
}
.ai-panel .ai-modes .mode-btn.is-active { box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }

.ai-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 64px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  transition: var(--transition);
}
.ai-input::placeholder { color: var(--text-faint); }
.ai-input:focus { outline: none; border-color: var(--accent); background: var(--bg-elev); box-shadow: 0 0 0 3px var(--accent-soft); }

.ai-foot { display: flex; }
.ai-send { flex: 1; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ai-send-icon { width: 15px; height: 15px; flex: none; }
/* 发送按钮常亮：鼠标悬停 / 请求进行中(disabled) 都保持主题蓝，不发生任何颜色变化 */
.btn.ai-send:hover:not(:disabled),
.btn.ai-send:disabled {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  filter: none;
  opacity: 1;
}

/* 结果区：浅底卡片，与输入区形成层次 */
.ai-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ai-result[hidden] { display: none; }
.ai-result-text {
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.55;
}
.ai-result-text.is-error { color: var(--danger); }
.ai-result-actions { display: flex; gap: 6px; }
.ai-result-actions .mini { flex: 1; justify-content: center; }
.ai-result-actions .mini:first-child { color: var(--accent); border-color: var(--accent); }

/* 源码 / 可视化 切换 */
.mode-switch { display: inline-flex; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.mode-btn {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 3px 12px; border-radius: 4px; font-size: 12.5px;
  transition: var(--transition);
}
.mode-btn:hover { color: var(--text); }
.mode-btn.is-active { background: var(--accent); color: #fff; font-weight: 600; }

.size-stepper { display: inline-flex; align-items: center; gap: 2px; }
.step-btn {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.step-btn:hover { border-color: var(--accent); color: var(--accent); }
.step-val { min-width: 28px; text-align: center; font-size: 12.5px; color: var(--text); }

/* =========================================================
   7. 自动补全
   ========================================================= */

.autocomplete {
  position: absolute;
  z-index: 15;
  min-width: 220px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
}

.ac-item { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 4px; cursor: pointer; }
.ac-item.is-sel, .ac-item:hover { background: var(--accent-soft); }
.ac-cmd { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); white-space: nowrap; }
.ac-desc { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =========================================================
   8. 图片 / 文档识别
   ========================================================= */

.dropzone {
  margin: 14px; padding: 30px 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  text-align: center; cursor: pointer;
  transition: var(--transition);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dz-title { margin: 0 0 6px; font-size: 13.5px; color: var(--text); }
.dz-sub { margin: 0; font-size: 12px; color: var(--text-faint); }

.ocr-preview { margin: 0 14px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken); text-align: center; }
.ocr-preview img { max-width: 100%; max-height: 220px; border-radius: var(--radius-sm); background: #fff; }
.ocr-info, .doc-file { margin-top: 8px; font-size: 12px; color: var(--text-dim); word-break: break-all; }

.ocr-actions { display: flex; gap: 8px; padding: 12px 14px 6px; align-items: center; }
.ocr-progress { font-size: 12px; color: var(--text-dim); }

.btn {
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
  padding: 7px 16px; border-radius: var(--radius-sm); font-size: 13px; transition: var(--transition);
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }

.mini {
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-dim);
  padding: 3px 10px; border-radius: 4px; font-size: 12px;
  display: inline-flex; align-items: center; gap: 4px;
}
.mini:hover { color: var(--accent); border-color: var(--accent); }
.mini-icon { width: 13px; height: 13px; flex: none; }

.ocr-result { margin: 8px 14px 14px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; flex: 1; min-height: 140px; }
.ocr-result-head { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.ocr-result-head > span:first-child { font-weight: 600; }
.ocr-result-head .row { margin-left: auto; display: flex; gap: 6px; }
.ocr-result-body { flex: 1; border: 0; outline: none; resize: none; padding: 10px; background: var(--code-bg); font-family: var(--font-mono); font-size: 13px; min-height: 120px; }

.notice { margin: 0 14px 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text-dim); font-size: 12.5px; border: 1px solid var(--border); }
.notice.is-error { background: rgba(217,69,61,.1); color: var(--danger); }

/* =========================================================
   9. 收藏夹
   ========================================================= */

.fav-search {
  flex: 1; max-width: 260px; border: 1px solid var(--border); background: var(--bg-sunken);
  border-radius: var(--radius-sm); padding: 5px 10px; font-size: 12.5px; outline: none;
}
.fav-search:focus { border-color: var(--accent); }

.fav-list { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }

.fav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-sunken); }
.fav-item:hover { border-color: var(--border-strong); }
.fav-body { flex: 1; min-width: 0; }
.fav-tex { font-family: var(--font-mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-time { font-size: 11.5px; color: var(--text-faint); }
.fav-acts { display: flex; gap: 4px; flex: none; }

.empty-hint { padding: 24px 16px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* =========================================================
   10. 输出面板
   ========================================================= */

.zoom { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.zoom-btn {
  width: 22px; height: 22px; border: 1px solid var(--border); background: var(--bg-sunken);
  border-radius: 4px; color: var(--text-dim); line-height: 1; font-size: 14px;
}
.zoom-btn:hover { border-color: var(--accent); color: var(--accent); }
.zoom-range { width: 110px; }
.zoom-val { font-size: 12px; color: var(--text-dim); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

.preview {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
  padding: 20px 16px;
  background: var(--bg-sunken);
  position: relative;
}

.preview-inner { display: flex; align-items: center; justify-content: center; transform-origin: center center; }
.preview-inner.is-linebreak { display: block; width: 100%; }
.preview-inner.is-linebreak mjx-container { max-width: 100%; }
.preview-inner.is-scale { max-width: 100%; }
.preview-inner.is-scale mjx-container { max-width: 100%; }
.preview-inner.is-scroll { white-space: nowrap; }

/* 未输入公式时的空状态：官网同款 LaTeX 水印图（img/empty1.png） */
.preview-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; user-select: none;
}
.preview-empty img { width: min(32rem, 44%); opacity: .38; }

mjx-container[jax="SVG"] { color: var(--text); }
.preview.is-error mjx-container { color: var(--danger); }

.status {
  flex: none; padding: 7px 14px; font-size: 12.5px;
  background: rgba(217,69,61,.1); color: var(--danger);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  max-height: 84px; overflow: auto;
}
.status.is-ok { background: rgba(31,157,99,.1); color: var(--ok); }

.exports { flex: none; border-top: 1px solid var(--border); padding: 9px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* 输出区下拉按钮：按钮本身沿用编辑器工具栏的 .bar-btn，菜单向上展开（按钮在面板底部） */
.out-btn { padding: 6px 12px; }
.out-btn.is-open { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.out-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.out-btn-primary:hover, .out-btn-primary.is-open { background: var(--accent); border-color: var(--accent); color: #fff; filter: brightness(1.06); }
.out-menu { top: auto; bottom: calc(100% + 6px); left: 0; min-width: 190px; }
.exports .bar-menu-item:last-child .out-menu { left: auto; right: 0; }
.out-menu .mi-icon { width: 13px; height: 13px; flex: none; opacity: .8; }
.out-menu .menu-item:disabled { opacity: .45; cursor: not-allowed; }
.out-menu .menu-item:disabled:hover { background: transparent; color: var(--text); }

.head-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* =========================================================
   11. 弹窗 / 抽屉
   ========================================================= */

.modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; }
.modal.is-center { justify-content: center; align-items: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(12,16,28,.42); backdrop-filter: blur(2px); }

.drawer {
  position: relative; z-index: 1;
  width: 420px; max-width: 92vw; height: 100%;
  background: var(--bg-elev); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideIn .22s ease;
}
.dialog {
  position: relative; z-index: 1;
  width: 720px; max-width: 92vw; max-height: 86vh;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}

@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.drawer-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); flex: none; }
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-head .dh-text { min-width: 0; }
.set-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }
.drawer-head .icon-btn { margin-left: auto; }

.icon-btn { border: 0; background: transparent; color: var(--text-dim); font-size: 20px; line-height: 1; width: 28px; height: 28px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.drawer-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); flex: none; }

/* =========================================================
   12. 设置面板内容
   ========================================================= */

.set-block { padding: 14px 0; border-bottom: 1px solid var(--border); }
.set-block:last-child { border-bottom: 0; }
.set-block h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.set-desc { margin: 0 0 10px; font-size: 12px; color: var(--text-faint); }
.set-current { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); }

.set-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.set-row > label { flex: none; width: 110px; font-size: 12.5px; color: var(--text-dim); }
.set-ctrl { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; font-size: 12.5px; color: var(--text-dim); }
.set-ctrl input[type="range"] { width: 150px; }

/* 自定义滑块（输出区域比例 / 输入区域字号，与输出区缩放滑块同款）
   已填充比例由 --p 变量标记，app.js 的 paintRanges() 在每次取值变化时更新 */
.set-ctrl input[type="range"],
.zoom-range {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
.set-ctrl input[type="range"]::-webkit-slider-runnable-track,
.zoom-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(to right,
    var(--accent) 0, var(--accent) var(--p, 50%),
    var(--bg-sunken) var(--p, 50%), var(--bg-sunken) 100%);
}
.set-ctrl input[type="range"]::-webkit-slider-thumb,
.zoom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .12s ease, box-shadow .12s ease;
}
.set-ctrl input[type="range"]:hover::-webkit-slider-thumb,
.zoom-range:hover::-webkit-slider-thumb,
.set-ctrl input[type="range"]:focus-visible::-webkit-slider-thumb,
.zoom-range:focus-visible::-webkit-slider-thumb {
  transform: scale(1.14);
  box-shadow: 0 0 0 5px var(--accent-soft), 0 1px 3px rgba(0,0,0,.28);
}
.set-ctrl input[type="range"]:active::-webkit-slider-thumb,
.zoom-range:active::-webkit-slider-thumb { transform: scale(1.02); }
.set-ctrl input[type="range"]:focus,
.zoom-range:focus { outline: none; }

/* Firefox */
.set-ctrl input[type="range"]::-moz-range-track,
.zoom-range::-moz-range-track {
  height: 6px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-sunken);
}
.set-ctrl input[type="range"]::-moz-range-progress,
.zoom-range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
.set-ctrl input[type="range"]::-moz-range-thumb,
.zoom-range::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--bg-elev); border: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
}
.set-ctrl input[type="range"]:hover::-moz-range-thumb,
.zoom-range:hover::-moz-range-thumb {
  box-shadow: 0 0 0 5px var(--accent-soft), 0 1px 3px rgba(0,0,0,.28);
}
.set-ctrl output { font-variant-numeric: tabular-nums; min-width: 44px; }
.set-ctrl select, .set-ctrl input[type="number"] {
  min-width: 150px; border: 1px solid var(--border); background: var(--bg-sunken);
  border-radius: var(--radius-sm); padding: 5px 8px; font-size: 12.5px; outline: none;
}
.set-ctrl select:focus { border-color: var(--accent); }
.set-ctrl input[type="checkbox"] { accent-color: var(--accent); }
.set-note { color: var(--text-faint); font-size: 11.5px; }

/* 「编辑偏好 / 公式渲染」设置行：左侧标题+说明，右侧控件 */
.set-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.set-item:last-child { border-bottom: 0; }
.set-item .ext-text { flex: 1 1 auto; min-width: 110px; }

/* 分段控件（长公式处理 / 变量样式 / 公式编号） */
.seg { display: inline-flex; flex: none; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: 8px; background: var(--bg-sunken); }
.seg-btn {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 5px 10px; border-radius: var(--radius-sm); font-size: 12px; white-space: nowrap;
  transition: var(--transition);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--bg-elev); color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.theme-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; background: var(--bg-sunken); text-align: center; transition: var(--transition); }
.theme-card:hover { border-color: var(--accent); }
.theme-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.theme-swatch { height: 30px; border-radius: 4px; display: flex; overflow: hidden; margin-bottom: 5px; }
.theme-swatch i { flex: 1; display: block; }
.theme-name { font-size: 11.5px; color: var(--text-dim); }
.theme-desc { display: block; margin-top: 2px; font-size: 10.5px; line-height: 1.35; color: var(--text-faint); }
.theme-card.is-active .theme-name { color: var(--accent); font-weight: 600; }

.ext-grid { display: block; }
.ext-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.ext-item:last-child { border-bottom: 0; }
.ext-text { flex: 1; min-width: 0; }
.ext-text b { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.ext-text em { display: block; font-style: normal; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
/* 开关样式（与官网设置面板一致） */
.ext-item input { flex: none; appearance: none; -webkit-appearance: none; width: 38px; height: 20px; border-radius: 999px; background: var(--border-strong); border: 0; position: relative; margin: 0; cursor: pointer; transition: var(--transition); }
.ext-item input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: var(--transition); }
.ext-item input:checked { background: var(--accent); }
.ext-item input:checked::after { transform: translateX(18px); }
.ext-item.is-on .ext-text b { color: var(--accent); }

/* =========================================================
   13. 文档内容
   ========================================================= */

.doc-body h3 { font-size: 13.5px; margin: 18px 0 6px; color: var(--accent); }
.doc-body h3:first-child { margin-top: 8px; }
.doc-body p { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.doc-body ul { margin: 0 0 8px; padding-left: 20px; font-size: 13px; color: var(--text-dim); line-height: 1.8; }
.doc-body code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: var(--font-mono); font-size: 12.5px; color: var(--text); }
.doc-pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--font-mono); font-size: 12.5px; overflow-x: auto; margin: 0 0 10px; color: var(--text); }

/* =========================================================
   14. Toast
   ========================================================= */

.toast-wrap { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }

.toast {
  background: var(--text); color: var(--bg-elev);
  padding: 8px 16px; border-radius: 999px; font-size: 12.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
  max-width: 80vw;
}
.toast.is-error { background: var(--danger); color: #fff; }
.toast.is-ok { background: var(--ok); color: #fff; }

@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =========================================================
   15. 响应式
   ========================================================= */

@media (max-width: 1024px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .workspace.is-wide { grid-template-columns: minmax(0, 1fr); }
  .brand-sub { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .workspace { padding: 8px; gap: 8px; }
  .tab { padding: 5px 9px; }
  .out-menu { min-width: 160px; }
  .ocr-result { min-height: 100px; }
}

/* =========================================================
   16. 官方资源版（SVG 符号 / 模板缩略图 / 工具栏缩略图）
   ========================================================= */

.quick-card-img { height: 30px; width: auto; max-width: 100%; object-fit: contain; pointer-events: none; }

.qp-matrix { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 12px; color: var(--text-dim); }
.qp-matrix input { width: 54px; padding: 3px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text); font-size: 12px; }

.qp-symbols .sym-img { height: auto; min-height: 30px; }
.qp-symbols .sym-img img { display: block; width: 100%; height: auto; }

.tpl-list { display: block; }
.tpl-sec + .tpl-sec { margin-top: 16px; }
.tpl-cat { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.tpl-cat img { height: 22px; width: auto; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 8px; }
.tpl-card { display: block; padding: 8px; }
.tpl-img { display: block; width: 100%; height: auto; }
.tpl-card[hidden], .tpl-sec[hidden] { display: none !important; }

/* 颜色 / 字体 / 字号 缩略图预览：官方图为"黑字 + 透明底 + 右侧大片留白"，需放大到可辨识并加浅底承托 */
.menu-item-img {
  display: flex; align-items: center; justify-content: flex-start;
  height: 32px; width: 168px; margin-right: 10px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  overflow: hidden;
}
.menu-item-img img { flex: none; height: 24px; width: auto; max-width: none; }
/* 深色主题下黑字缩略图需要浅色承托才看得见 */
html[data-theme="dark"] .menu-item-img { background: #f2f3f7; border-color: #f2f3f7; }

.ac-dot { font-size: 9px; line-height: 1; margin-right: 5px; }

/* =========================================================
   17. 登录态：顶栏账号入口 / 登录引导 / 功能门禁
   ========================================================= */

/* 顶栏账号区：未登录的「登录 / 注册」与已登录的用户名下拉 */
.nav-user-wrap { position: relative; }
.nav-user {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 13px; cursor: pointer; transition: var(--transition);
}
.nav-user:hover { background: var(--bg-hover); color: var(--text); }
.nav-user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 顶栏账号头像：图片头像 / 用户名首字母占位 */
.nav-user-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; display: block; box-shadow: 0 0 0 2px #fff; }
.nav-user-avatar--letter {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 15px; font-weight: 600; line-height: 1;
}
.nav-user-caret { width: 14px; height: 14px; flex: none; transition: transform .15s ease; }
.nav-user.is-open .nav-user-caret { transform: rotate(180deg); }
.nav-user-login { text-decoration: none; }

.nav-user-menu {
  position: absolute; top: calc(100% + 8px); right: -10px; z-index: 120;
  min-width: 140px; padding: 6px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: navMenuIn .16s ease;
}
.nav-user-menu[hidden] { display: none; }
/* 悬停桥：补上菜单与头像之间的空隙，避免鼠标从头像移入菜单时闪断 */
.nav-user-menu::before {
  content: ''; position: absolute; left: 0; right: 0; top: -10px; height: 10px;
}
@keyframes navMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.nav-user-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: transparent; color: var(--text);
  font-size: 13px; border-radius: var(--radius-sm); text-decoration: none;
  cursor: pointer; transition: background var(--transition);
}
.nav-user-item:hover { background: var(--bg-hover); }
.nav-user-ico { width: 16px; height: 16px; flex: none; color: var(--text-dim); transition: color var(--transition); }
.nav-user-item:hover .nav-user-ico { color: var(--text); }
.nav-user-sep { height: 1px; margin: 5px 6px; background: var(--border); }
.nav-user-danger { color: var(--danger); }
.nav-user-danger .nav-user-ico { color: var(--danger); }
.nav-user-danger:hover { background: rgba(217, 69, 61, .1); }

/* 登录引导提示条（未登录时点击受限功能弹出） */
.auth-prompt {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 210; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 16px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow-lg);
  font-size: 12.5px; color: var(--text);
}
.auth-prompt-go {
  border: 0; background: var(--accent); color: var(--accent-text);
  padding: 5px 14px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
}
.auth-prompt-go:hover { filter: brightness(1.08); }
.auth-prompt-close {
  border: 0; background: transparent; color: var(--text-dim);
  font-size: 16px; line-height: 1; padding: 0 4px; cursor: pointer;
}
.auth-prompt-close:hover { color: var(--text); }

/* 功能门禁：未登录时的禁用态 */
.fav-login-btn {
  display: inline-block; margin-left: 8px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--accent);
  padding: 3px 10px; border-radius: 4px; font-size: 12px; cursor: pointer;
}
.fav-login-btn:hover { border-color: var(--accent); }
.tab.is-gated { opacity: .5; cursor: not-allowed; }
.ai-wrap.is-gated { opacity: .5; }


