/* 新麦AI 前端样式（Phase 2：三栏 + 暗黑主题）。
   主题由 theme.js 在 <html> 上盖 data-theme，两套变量集中在此。 */

:root {
  --bg: #f6f7f9; --panel: #ffffff; --border: #e3e6ea; --text: #1f2937;
  --muted: #6b7280; --accent: #2563eb; --accent-soft: #eff4ff;
  --user-bubble: #2563eb; --ai-bubble: #ffffff; --danger: #dc2626;
  --hover: #f0f2f5; --code-bg: #f3f4f6; --mark: #fef08a; --shadow: rgba(0,0,0,.05);
  /* 表格增强（批次一）：明暗双主题各自定义，正文样式禁止写死颜色 */
  --table-stripe: #f4f6f9; --table-border: #e3e6ea; --table-head-bg: #eef1f5;
  --table-hover-bg: #e9f1ff; --table-scroll-fade: rgba(0,0,0,.12);
}
:root[data-theme="dark"] {
  --bg: #101418; --panel: #171c22; --border: #2a323c; --text: #e5e7eb;
  --muted: #94a0ae; --accent: #4c8dff; --accent-soft: #1c2940;
  --user-bubble: #2563eb; --ai-bubble: #1c222a; --danger: #f87171;
  --hover: #1f2630; --code-bg: #232a33; --mark: #715e10; --shadow: rgba(0,0,0,.35);
  --table-stripe: #1a212a; --table-border: #2a323c; --table-head-bg: #212933;
  --table-hover-bg: #223047; --table-scroll-fade: rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font: 15px/1.65 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
       background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- 登录 / 改密 ---------- */
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
             padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 8px 30px var(--shadow); }
.auth-logo { width: 46px; height: 46px; display: block; margin-bottom: 14px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
#view-login h1 { margin-bottom: 22px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
               border-radius: 8px; background: var(--panel); }
.field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
/* 上面那条 width:100% 是给文本框的；复选框吃到它会被撑成整行、把标签文字挤到下一行
   （v1.8.84 账号管理表单里第一次出现「.field 内的复选框」这种组合才暴露） */
.field input[type="checkbox"] { width: auto; }
.btn-primary { width: 100%; padding: 11px; background: var(--accent); color: #fff;
               border-radius: 8px; font-weight: 600; margin-top: 6px; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ---------- 三栏主布局（宽度可拖拽自定义，layout.js 持久化） ---------- */
.app { display: flex; height: 100dvh; overflow: hidden;
       --sidebar-w: 280px; --report-w: 400px; }

.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
           display: flex; flex-direction: column; transition: transform .25s; z-index: 30; }

.col-resizer { width: 5px; flex-shrink: 0; cursor: col-resize; background: transparent;
               margin: 0 -2px; z-index: 20; touch-action: none; }
.col-resizer:hover, .app.resizing .col-resizer { background: var(--accent-soft); }
.app:not(.report-open) #rz-report { display: none; }
.app.resizing { user-select: none; }
.app.resizing .report-panel { transition: none; }
.side-head { padding: 16px 16px 10px; display: flex; align-items: center; justify-content: space-between; }
.side-head .logo { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.side-head .logo img { width: 22px; height: 22px; }
.side-head .logo span { color: var(--accent); }
.logo-sm { width: 20px; height: 20px; vertical-align: -4px; margin-right: 7px; }
.btn-new { background: var(--accent); color: #fff; border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.conv-list { flex: 1; overflow-y: auto; padding: 6px 10px; }
.conv-item { display: flex; align-items: center; gap: 6px; padding: 9px 12px;
             border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--text); }
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.conv-pin { font-size: 11px; flex-shrink: 0; }
.conv-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-acts { display: none; gap: 2px; flex-shrink: 0; }
.conv-item:hover .conv-acts, .conv-item.active .conv-acts { display: flex; }
.conv-acts button { font-size: 12px; color: var(--muted); padding: 1px 4px; border-radius: 5px; line-height: 1.4; }
.conv-acts button:hover { background: var(--border); color: var(--text); }
.side-foot { border-top: 1px solid var(--border); padding: 12px 16px; font-size: 13px; }
.side-foot .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.side-foot .who { font-weight: 600; }
.link-btn { color: var(--accent); font-size: 13px; }
.usage-bar { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.usage-bar i { display: block; height: 100%; background: var(--accent); }
.usage-text { color: var(--muted); font-size: 12px; margin-top: 3px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px;
           background: var(--panel); border-bottom: 1px solid var(--border); }
.btn-menu { display: none; font-size: 20px; padding: 4px 8px; }
.top-title { font-weight: 600; font-size: 15px; overflow: hidden; white-space: nowrap;
             text-overflow: ellipsis; flex: 1; }
.top-mount { font-size: 12px; color: var(--muted); background: var(--bg);
             padding: 3px 10px; border-radius: 20px; white-space: nowrap; cursor: pointer; }
.top-mount:hover { color: var(--accent); }
.mode-badge { font-size: 12px; color: var(--accent); background: var(--accent-soft);
              padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.conv-badge { font-size: 10px; color: var(--accent); background: var(--accent-soft);
              padding: 1px 6px; border-radius: 10px; flex-shrink: 0; }
/* 顶栏周报入口（v1.8.38：原在 .side-foot 文字链，窄屏会被抽屉藏起来） */
.btn-weekly { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
              font-size: 13px; font-weight: 600; white-space: nowrap;
              color: var(--accent); background: var(--accent-soft);
              padding: 4px 12px; border-radius: 20px; text-decoration: none; }
.btn-weekly:hover { filter: brightness(1.08); }
.btn-icon { font-size: 16px; padding: 4px 8px; border-radius: 8px; color: var(--muted); }
.btn-icon:hover { background: var(--hover); color: var(--text); }
.btn-icon.on { color: var(--accent); background: var(--accent-soft); }

.chat-box { flex: 1; overflow-y: auto; padding: 20px 16px; }
.chat-inner { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 86%; padding: 11px 15px; border-radius: 14px; white-space: pre-wrap;
          word-break: break-word; }
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--ai-bubble); border: 1px solid var(--border);
                  border-bottom-left-radius: 4px; }
.msg.ai .bubble.error { border-color: var(--danger); color: var(--danger); }

/* 气泡 markdown 排版（批次一）：AI 回复完成后由纯文本切换为 markdown 渲染 */
.bubble.md { white-space: normal; }
.bubble.md > div > :first-child { margin-top: 0; }
.bubble.md > div > :last-child { margin-bottom: 0; }
.bubble.md h1, .bubble.md h2, .bubble.md h3, .bubble.md h4 { margin: 14px 0 6px; line-height: 1.4; }
.bubble.md h1 { font-size: 17px; } .bubble.md h2 { font-size: 16px; }
.bubble.md h3, .bubble.md h4 { font-size: 15px; }
.bubble.md p { margin: 8px 0; }
.bubble.md ul, .bubble.md ol { margin: 8px 0; padding-left: 22px; }
.bubble.md li { margin: 3px 0; }
.bubble.md code { background: var(--code-bg); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.bubble.md pre { background: var(--code-bg); border-radius: 8px; padding: 10px 12px;
                 overflow-x: auto; margin: 8px 0; font-size: 13px; line-height: 1.6; }
.bubble.md pre code { background: none; padding: 0; }
.bubble.md hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.bubble.md a { color: var(--accent); overflow-wrap: anywhere; }
.trace { max-width: 86%; font-size: 12.5px; }
.trace summary { color: var(--muted); cursor: pointer; user-select: none; padding: 2px 0; }
.trace-item { color: var(--muted); padding: 3px 0 3px 14px; border-left: 2px solid var(--border);
              margin: 3px 0 3px 4px; overflow-wrap: anywhere; }
.typing { color: var(--muted); font-size: 13px; padding-left: 4px; }
.typing::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* 引用来源 chips */
.cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-width: 86%; }
.cite-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
             color: var(--accent); background: var(--accent-soft); border: 1px solid transparent;
             border-radius: 20px; padding: 3px 10px; max-width: 260px; }
.cite-chip .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cite-chip:hover { border-color: var(--accent); }
/* 多挂载时 chip 上标出工程（Phase 4a）：两个工程的同名报告，光看标题分不出是谁的 */
.cite-proj { flex-shrink: 0; max-width: 90px; overflow: hidden; white-space: nowrap;
             text-overflow: ellipsis; font-size: 11px; opacity: .75;
             padding-right: 4px; border-right: 1px solid currentColor; }

/* 消息操作条 / 编辑框 / 多选管理模式（批次二） */
.msg-acts { display: flex; gap: 2px; align-self: center; opacity: 0; transition: opacity .12s;
            flex-shrink: 0; }
.msg.ai .msg-acts { align-self: flex-start; margin-top: 2px; }
.msg:hover .msg-acts, .msg.ai:hover .msg-acts { opacity: 1; }
.msg-acts button { font-size: 12.5px; color: var(--muted); padding: 2px 6px; border-radius: 6px;
                   line-height: 1.5; }
.msg-acts button:hover { background: var(--hover); color: var(--text); }
.msg.user .msg-acts { margin-right: 6px; }
.bubble.stopped { color: var(--muted); }
.edit-box { width: min(86%, 680px); display: flex; flex-direction: column; gap: 8px; }
.edit-box textarea { width: 100%; min-height: 72px; resize: vertical; border: 1px solid var(--accent);
                     border-radius: 10px; padding: 10px 13px; background: var(--panel); }
.edit-acts { display: flex; gap: 8px; justify-content: flex-end; }
.edit-acts button { padding: 6px 14px; border-radius: 8px; font-weight: 600; }
.msg-check { display: none; font-size: 15px; color: var(--muted); padding: 0 6px;
             align-self: center; flex-shrink: 0; }
body.manage-mode .msg.user .msg-check { display: block; }
.msg-check.on { color: var(--accent); }
.manage-bar { max-width: 820px; margin: 0 auto 8px; display: flex; gap: 10px; align-items: center;
              font-size: 13px; color: var(--muted); }
.btn-primary.danger { background: var(--danger); }
.btn-send.stop { background: var(--danger); }

.input-bar { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--panel);
             border-top: 1px solid var(--border); }
.input-inner { max-width: 820px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
.input-inner textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px;
                        padding: 10px 13px; max-height: 140px; background: var(--bg); }
.input-inner textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn-send { background: var(--accent); color: #fff; border-radius: 10px; padding: 10px 18px;
            font-weight: 600; flex-shrink: 0; }
.btn-send:disabled { opacity: .5; cursor: default; }

/* 临时文件上传（批次三） */
.btn-attach { font-size: 17px; padding: 9px 10px; border-radius: 10px; color: var(--muted);
              flex-shrink: 0; }
.btn-attach:hover { background: var(--hover); color: var(--text); }
.upload-chips { max-width: 820px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.up-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px;
           color: var(--text); background: var(--bg); border: 1px solid var(--border);
           border-radius: 20px; padding: 3px 10px; }
.up-chip .name { max-width: 240px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.up-chip .del { color: var(--muted); padding: 0 2px; }
.up-chip .del:hover { color: var(--danger); }

/* ---------- 第三栏：报告面板 ---------- */
.report-panel { width: 0; flex-shrink: 0; background: var(--panel); border-left: 1px solid var(--border);
                display: flex; flex-direction: column; overflow: hidden; transition: width .2s; }
.app.report-open .report-panel { width: var(--report-w); }
.rp-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
           border-bottom: 1px solid var(--border); min-width: 320px; }
.rp-title { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden;
            white-space: nowrap; text-overflow: ellipsis; }
.rp-body { flex: 1; overflow-y: auto; padding: 10px 14px; min-width: 320px; }
.rp-empty { color: var(--muted); text-align: center; padding: 50px 20px; font-size: 13px; }

.rp-file { display: flex; align-items: baseline; gap: 8px; padding: 8px 10px; border-radius: 8px;
           cursor: pointer; font-size: 13.5px; }
.rp-file:hover { background: var(--hover); }
.rp-file .seq { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.rp-file .name { flex: 1; overflow-wrap: anywhere; }
.rp-file .open-new { color: var(--muted); font-size: 13px; flex-shrink: 0; padding: 0 4px;
                     border-radius: 5px; visibility: hidden; }
.rp-file:hover .open-new { visibility: visible; }
.rp-file .open-new:hover { color: var(--accent); background: var(--accent-soft); }
.rp-table-chip { display: inline-block; font-size: 12px; color: var(--muted); background: var(--bg);
                 border-radius: 6px; padding: 1px 8px; margin: 2px 0 2px 30px; cursor: pointer; }
.rp-table-chip:hover { color: var(--accent); background: var(--accent-soft); }

/* 目录树按挂载分组（Phase 4a）。组头只在多挂载时渲染 —— 单挂载再套一层标题是纯噪音，
   工程名本来就已经写在 .rp-title 上了。 */
.rp-group + .rp-group { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 6px; }
.rp-group-head { display: flex; align-items: baseline; gap: 6px; padding: 7px 8px;
                 border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px;
                 user-select: none; position: sticky; top: -10px; z-index: 1;
                 background: var(--panel); }
.rp-group-head:hover { background: var(--hover); }
.rp-group-head .arrow { font-size: 10px; color: var(--muted); flex-shrink: 0;
                        transition: transform .15s; }
.rp-group-head .gname { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rp-group-head .gmeta { color: var(--muted); font-weight: 400; font-size: 11.5px;
                        margin-left: auto; flex-shrink: 0; }
.rp-group.closed .arrow { transform: rotate(-90deg); }
.rp-group.closed .rp-group-body { display: none; }

/* 阅读器（markdown / 表格 / 纯文本） */
.rp-doc { font-size: 13.5px; line-height: 1.7; }
.rp-doc h1, .rp-doc h2, .rp-doc h3, .rp-doc h4 { margin: 14px 0 6px; line-height: 1.4; }
.rp-doc h1 { font-size: 17px; } .rp-doc h2 { font-size: 15.5px; }
.rp-doc h3 { font-size: 14px; } .rp-doc h4 { font-size: 13.5px; }
.rp-doc p { margin: 6px 0; }
.rp-doc ul, .rp-doc ol { margin: 6px 0; padding-left: 22px; }
.rp-doc blockquote, .bubble.md blockquote { border-left: 3px solid var(--accent);
                     color: var(--muted); background: var(--code-bg);
                     padding: 4px 12px; margin: 8px 0; border-radius: 0 6px 6px 0; }
.rp-doc code { background: var(--code-bg); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.rp-doc pre { background: var(--code-bg); border-radius: 8px; padding: 10px 12px; overflow-x: auto;
              margin: 8px 0; font-size: 12.5px; line-height: 1.6; }
.rp-doc pre code { background: none; padding: 0; }
.rp-doc hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.rp-doc a { color: var(--accent); }
/* 表格增强（批次一）：斑马纹 / 表头吸顶 / hover 高亮 / 圆角容器 / 横滚渐变遮罩。
   .rp-doc = 报告面板与阅读器页；.bubble.md = 聊天气泡 markdown 渲染，两处共用。 */
.tbl-outer { position: relative; margin: 8px 0; }
.tbl-outer::before, .tbl-outer::after { content: ""; position: absolute; top: 1px; bottom: 1px;
  width: 26px; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 2; }
.tbl-outer::before { left: 1px; border-radius: 8px 0 0 8px;
  background: linear-gradient(90deg, var(--table-scroll-fade), transparent); }
.tbl-outer::after { right: 1px; border-radius: 0 8px 8px 0;
  background: linear-gradient(270deg, var(--table-scroll-fade), transparent); }
.tbl-outer.fade-l::before, .tbl-outer.fade-r::after { opacity: 1; }
.rp-doc .tbl-wrap, .bubble.md .tbl-wrap { overflow: auto; max-height: 440px; margin: 0;
  border: 1px solid var(--table-border); border-radius: 8px; }
.rp-doc table, .bubble.md table { border-collapse: separate; border-spacing: 0;
  font-size: 12.5px; white-space: nowrap; min-width: 100%; }
.rp-doc th, .rp-doc td, .bubble.md th, .bubble.md td { padding: 6px 10px; text-align: left;
  border-bottom: 1px solid var(--table-border); }
.rp-doc tr:last-child td, .bubble.md tr:last-child td { border-bottom: none; }
.rp-doc th, .bubble.md th { background: var(--table-head-bg); position: sticky; top: 0;
  z-index: 1; font-weight: 600; box-shadow: 0 1px 0 var(--table-border); }
.rp-doc tr:nth-child(even), .bubble.md tr:nth-child(even) { background: var(--table-stripe); }
.rp-doc tr:hover:not(:first-child), .bubble.md tr:hover:not(:first-child) {
  background: var(--table-hover-bg); }
.rp-doc .tbl-wrap::-webkit-scrollbar, .bubble.md .tbl-wrap::-webkit-scrollbar,
.rp-doc pre::-webkit-scrollbar, .bubble.md pre::-webkit-scrollbar { height: 8px; width: 8px; }
.rp-doc .tbl-wrap::-webkit-scrollbar-thumb, .bubble.md .tbl-wrap::-webkit-scrollbar-thumb,
.rp-doc pre::-webkit-scrollbar-thumb, .bubble.md pre::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 4px; }
.rp-doc .flash { animation: flash 2.4s; }
@keyframes flash { 0%, 60% { background: var(--mark); } 100% { background: transparent; } }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50;
              display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--panel); border-radius: 14px; padding: 24px; width: 100%; max-width: 420px;
         max-height: 84dvh; overflow-y: auto; }
.modal.wide { max-width: 560px; }
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; padding: 10px; border-radius: 8px; font-weight: 600; }
.btn-ghost { border: 1px solid var(--border); color: var(--muted); }
.btn-solid { background: var(--accent); color: #fff; }
.btn-solid:disabled { opacity: .5; cursor: default; }
.mem-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0;
            border-bottom: 1px solid var(--border); font-size: 14px; }
.mem-item button { color: var(--danger); font-size: 13px; flex-shrink: 0; }
.mem-add { display: flex; gap: 8px; margin-top: 14px; }
.mem-add input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
                 background: var(--panel); }
.mem-add button { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 16px; }
.mem-sec-title { font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 2px; }
.mem-sec-hint { font-weight: 400; }
.mem-item .mem-ok { color: var(--accent); }
.mem-item .mem-edit { color: var(--muted); }
.mem-edit-input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border);
                  border-radius: 6px; background: var(--panel); font-size: 14px; }
.mem-badge { display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 4px;
             border-radius: 8px; background: var(--danger); color: #fff;
             font-size: 11px; line-height: 16px; text-align: center; }
.empty-hint { color: var(--muted); text-align: center; padding: 60px 20px; font-size: 14px; }

/* 报告库：分类 → 工程 两级树 */
.lib-cat { margin-bottom: 6px; }
.lib-free { display: block; width: 100%; text-align: left; padding: 12px 14px; margin: 10px 0 4px;
            border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft);
            color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; }
.lib-free:hover { filter: brightness(1.08); }
.lib-free-desc { display: block; margin-top: 3px; font-size: 12px; font-weight: 400; color: var(--muted); }
.lib-sep { color: var(--muted); font-size: 12.5px; margin: 12px 0 4px; }
.lib-cat-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px;
                cursor: pointer; font-weight: 600; font-size: 14px; user-select: none; }
.lib-cat-head:hover { background: var(--hover); }
.lib-cat-head .arrow { font-size: 11px; color: var(--muted); transition: transform .15s; }
.lib-cat.closed .arrow { transform: rotate(-90deg); }
.lib-cat.closed .lib-projs { display: none; }
.lib-cat-head .count { color: var(--muted); font-weight: 400; font-size: 12px; }
.lib-proj { display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 26px;
            border-radius: 8px; cursor: pointer; }
.lib-proj:hover { background: var(--accent-soft); }
.lib-proj .pname { font-size: 14px; }
.lib-proj .pmeta { color: var(--muted); font-size: 12px; }
/* 多选（Phase 4a）。⚠️ width:auto 是显式写死的：报告库是第一次往弹层里放复选框，
   将来若挪进 .field 容器，`.field input{width:100%}` 会把它撑成整行（账号管理踩过）。 */
.lib-proj .lib-proj-check { width: auto; flex-shrink: 0; margin: 0; cursor: pointer;
                            accent-color: var(--accent); }
.lib-proj.picked { background: var(--accent-soft); }
.lib-proj.disabled { opacity: .45; cursor: not-allowed; }
.lib-proj.disabled:hover { background: transparent; }
.lib-limit-hint { color: var(--muted); font-size: 12.5px; margin-top: 8px; text-align: right; }

/* ---------- 独立报告阅读器页（/report） ---------- */
.reader-page { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.reader-bar { display: flex; align-items: center; gap: 10px; padding: 10px 18px;
              background: var(--panel); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.reader-title { flex: 1; font-weight: 600; font-size: 15px; overflow: hidden;
                white-space: nowrap; text-overflow: ellipsis; }
.reader-body { flex: 1; overflow-y: auto; padding: 20px 24px 60px; }
.reader-doc { max-width: 920px; margin: 0 auto; font-size: 14.5px; }
.reader-doc h1 { font-size: 20px; } .reader-doc h2 { font-size: 17px; }
.reader-doc h3 { font-size: 15.5px; } .reader-doc h4 { font-size: 14.5px; }
.reader-body .rp-empty a { color: var(--accent); }

/* ---------- Phase 3：模型档位 / 模板 chips / 图表 / 导出中心 ---------- */
.model-select { border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
                color: var(--muted); font-size: 12.5px; padding: 4px 8px; max-width: 130px; }
.model-select:hover, .model-select:focus { color: var(--text); border-color: var(--accent); outline: none; }

.tpl-chips { max-width: 820px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.cmd-hint { max-width: 820px; margin: 0 auto 6px; font-size: 12px; color: var(--muted); padding: 0 4px; }
.cmd-hint code { font-size: 12px; }
.model-hint { max-width: 820px; margin: 0 auto 4px; font-size: 11px; color: var(--muted);
              padding: 0 4px; opacity: .85; }
.tpl-chip { font-size: 12.5px; color: var(--muted); background: var(--bg);
            border: 1px solid var(--border); border-radius: 20px; padding: 3px 12px; }
.tpl-chip:hover { color: var(--accent); border-color: var(--accent); }
.tpl-chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
/* 我的 Skill 的 chip（Phase 4b 批一）：与全员模板混排时必须一眼分得出 */
.tpl-chip.mine { border-style: dashed; }
.tpl-mine-tag { display: inline-block; margin-right: 5px; padding: 0 4px; border-radius: 4px;
                font-size: 10.5px; background: var(--accent-soft); color: var(--accent); }
.tpl-chip.active .tpl-mine-tag { background: rgba(255,255,255,.22); color: #fff; }

/* 「我的 Skill」弹层（Phase 4b 批一） */
.sk-intro { font-weight: 600; margin-bottom: 8px; }
.sk-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
           margin-bottom: 8px; }
.sk-head { display: flex; align-items: center; gap: 8px; }
.sk-head .sk-name { font-size: 14px; overflow: hidden; white-space: nowrap;
                    text-overflow: ellipsis; }
.sk-status { flex-shrink: 0; font-size: 11px; padding: 1px 7px; border-radius: 10px;
             background: var(--bg); color: var(--muted); }
.sk-status.pending { background: var(--mark); color: var(--text); }
.sk-status.approved { background: var(--accent-soft); color: var(--accent); }
.sk-status.rejected { background: var(--accent-soft); color: var(--danger); }
.sk-ops { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }
.sk-ops button { font-size: 12.5px; color: var(--muted); }
.sk-ops button:hover { color: var(--accent); }
.sk-ops .sk-ok { color: var(--accent); }
.sk-ops .sk-del { color: var(--danger); }
.sk-body { margin-top: 6px; font-size: 12.5px; color: var(--muted); line-height: 1.55;
           white-space: pre-wrap; max-height: 4.7em; overflow: hidden; }
.sk-note { margin-top: 6px; font-size: 12.5px; color: var(--danger); }
.sk-form { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
/* ⚠️ 不复用 admin 的 .adm-editor —— 那是 admin.html 专用尺寸，主站弹层里会顶穿 */
.sk-editor { width: 100%; height: 132px; resize: vertical; padding: 9px 12px;
             border: 1px solid var(--border); border-radius: 8px; background: var(--panel);
             color: var(--text); font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace; }
.sk-editor:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.sk-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.sk-actions button { flex: 0 0 auto; }

/* 对话沉淀的草稿弹层（Phase 4b 批二）。⚠️ 计数器写在 <label> 里，
   全局 `.field input{width:100%}` 只管 input，不会误伤它。 */
.skd-warn { margin-bottom: 12px; padding: 8px 10px; border-radius: 8px;
            background: var(--mark); color: var(--text); font-size: 12.5px; line-height: 1.5; }
.skd-count { float: right; font-variant-numeric: tabular-nums; }
.skd-count.over { color: var(--danger); font-weight: 600; }
#modal-skill-draft .sk-editor { height: 220px; }

/* admin 侧栏「Skill 审核」待审角标 */
.adm-dot { display: inline-block; min-width: 16px; margin-left: 5px; padding: 0 4px;
           border-radius: 8px; background: var(--danger); color: #fff;
           font-size: 11px; line-height: 16px; text-align: center; }

.chart-box { width: min(680px, 100%); height: 320px; margin: 10px 0; }
.chart-box.chart-err { height: auto; color: var(--muted); font-size: 13px; }

#modal-exports .modal { max-width: 520px; }
#exp-list .mem-item span:first-child { overflow-wrap: anywhere; }

/* ---------- admin 管理页 ---------- */
.admin-page { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.adm-who { color: var(--muted); font-size: 13px; }
.reader-bar a.btn-icon { text-decoration: none; }
.adm-denied { text-align: center; padding: 80px 20px; color: var(--muted); }
.adm-denied a { color: var(--accent); }
.adm-wrap { flex: 1; display: flex; overflow: hidden; }
.adm-nav { width: 180px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
           padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.adm-nav button { text-align: left; padding: 9px 14px; border-radius: 8px; font-size: 14px;
                  color: var(--text); }
.adm-nav button:hover { background: var(--hover); }
.adm-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.adm-main { flex: 1; overflow-y: auto; padding: 22px 26px 80px; }
.adm-main h2 { font-size: 17px; margin-bottom: 14px; }
.adm-main h3 { font-size: 15px; margin: 18px 0 10px; }
.adm-hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
/* T5'-b：编辑器上方的常驻警示条（L2 scope 标记不可删改 + 改动须回仓库） */
.adm-warn { max-width: 900px; margin-bottom: 10px; padding: 9px 13px; font-size: 12.5px;
            line-height: 1.75; border: 1px solid var(--warn-border, var(--border));
            border-left: 3px solid var(--accent); border-radius: 8px;
            background: var(--accent-soft); color: var(--text); }
.adm-warn code { background: var(--code-bg); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.adm-table { border-collapse: collapse; font-size: 13.5px; width: 100%; max-width: 900px;
             background: var(--panel); }
.adm-table th, .adm-table td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.adm-table th { background: var(--bg); }
.adm-table code { background: var(--code-bg); border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.adm-detail { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; max-width: 420px; }
.adm-num { width: 110px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
           background: var(--bg); }
.btn-primary.sm, .btn-ghost.sm, .btn-solid.sm { width: auto; padding: 5px 12px;
                                 font-size: 12.5px; margin: 0 4px 0 0; border-radius: 6px; }
.adm-cards { display: flex; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.adm-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
            padding: 14px 20px; min-width: 160px; }
.adm-card .num { font-size: 22px; font-weight: 700; }
.adm-card .lbl { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.adm-filters { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.adm-filters select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
                      background: var(--panel); font-size: 13px; }
.adm-pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; font-size: 13px; }
.adm-form { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
            padding: 18px 20px; max-width: 640px; margin-top: 8px; }
.adm-form .btn-primary { width: auto; padding: 9px 22px; }
.adm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.adm-result { margin-top: 12px; font-size: 13.5px; padding: 10px 12px; border-radius: 8px;
              white-space: pre-wrap; }   /* 匹配预览是多行文案，换行必须保住 */
.adm-result.ok { background: var(--accent-soft); color: var(--accent); }
.adm-result.err { background: var(--bg); color: var(--danger); }
/* warn ≠ err：「匹配到 0 行」未必是错（可能本周他名下就是没有预警产品） */
.adm-result.warn { background: var(--bg); color: var(--text);
                   border: 1px solid var(--danger); }
/* ── 账号管理（v1.8.84 §16⑪）────────────────────────────────── */
.adm-table.wide { max-width: 1280px; }
.adm-row-off td { opacity: .55; }                       /* 停用账号整行变灰 */
.adm-miss { color: var(--danger); }                     /* 空壳（缺真实姓名）标红 */
.adm-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.adm-editor { width: 100%; max-width: 900px; height: 55dvh; border: 1px solid var(--border);
              border-radius: 10px; background: var(--panel); padding: 12px 14px;
              font: 13px/1.6 ui-monospace, "SF Mono", Consolas, monospace; resize: vertical; }
.adm-editor.sm { height: 200px; }
.adm-editor:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
/* L2 规则只读预览（D2）：<pre> 复用 .adm-editor 观感，滚动与换行要自己给 */
.rules-view { overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.rules-view .diff-add { background: rgba(46, 160, 67, .18); }
.rules-view .diff-del { background: rgba(248, 81, 73, .16); opacity: .85; }
.adm-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
/* 多挂载上限表单（Phase 4a）：两个数字框跟在行内文字里，别被通吃规则撑成整行 */
.mount-policy { flex-wrap: wrap; gap: 8px; font-size: 13.5px; }
.mount-policy input { width: 84px; padding: 5px 8px; border: 1px solid var(--border);
                      border-radius: 6px; background: var(--panel); color: var(--text);
                      font-size: 13px; }
.adm-actions .btn-primary { width: auto; padding: 9px 22px; margin: 0; }
.adm-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px;
             margin: 4px 14px 4px 0; cursor: pointer; }
.adm-model, .adm-tpl { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
                       padding: 14px 18px; margin-bottom: 12px; max-width: 640px; }
.adm-model-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.adm-tag { font-size: 11.5px; color: var(--accent); background: var(--accent-soft);
           border-radius: 10px; padding: 1px 8px; }
.adm-tag.off { color: var(--muted); background: var(--bg); }
.adm-model-users { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; }
.adm-tpl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.adm-tpl-body { background: var(--code-bg); border-radius: 8px; padding: 8px 12px;
                font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere;
                max-height: 140px; overflow-y: auto; }
.adm-tpl .adm-actions button { color: var(--muted); }
.adm-tpl .act-del { color: var(--danger); }

@media (max-width: 768px) {
  .adm-wrap { flex-direction: column; }
  .adm-nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; }
  .adm-nav button { white-space: nowrap; }
  .adm-grid2 { grid-template-columns: 1fr; }
}

/* ---------- 响应式 ---------- */
.side-mask { display: none; }

@media (max-width: 1080px) {
  .report-panel { position: fixed; top: 0; bottom: 0; right: 0; width: min(420px, 94vw);
                  transform: translateX(100%); transition: transform .25s; z-index: 30;
                  box-shadow: 0 0 40px var(--shadow); }
  .app.report-open .report-panel { width: min(420px, 94vw); transform: translateX(0); }
  #rz-report { display: none; }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%);
             width: 280px; }
  #rz-side { display: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px var(--shadow); }
  .side-mask.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; }
  .btn-menu { display: block; }
  .bubble, .trace, .cites { max-width: 94%; }
  .top-mount { display: none; }
}

/* 拖拽图片落区提示（M4 批 C 需求 A）。
   与 .up-chip 同处输入区上方，出现时不顶掉布局 —— 用固定高度而非撑开容器，
   否则每次拖拽经过输入框，下面的整块内容都会跳一下。 */
.drop-hint {
  margin: 0 0 6px; padding: 7px 12px; border-radius: 10px;
  border: 1px dashed var(--accent); color: var(--accent);
  background: var(--accent-soft); font-size: 13px; text-align: center;
}
.drop-hint.hidden { display: none; }

/* ---------- 站内帮助中心（§十六 ⑤，help.js）----------
   class 一律 `hlp-` 前缀：app.css 与 weekly.css 在周报页**同时加载**，
   批 B 踩过 `.btn-menu` 撞车（主站移动端汉堡按钮的 display:none 让新按钮点不到）。

   ⚠️ z-index 70：必须高于 weekly.css 里的 60（`.wk-ai-float` AI 浮窗、`.hs-pop` 预警浮窗、
   `.panel-fab`）——它们是 fixed 定位，用 `.modal-mask` 的 50 会被压在下面，
   在历史页/详情页/批注看板上点帮助就会看到浮窗浮在遮罩之上。 */
/* ---------- 帮助入口：固定在每页右上角的耳麦按钮（help.js 注入，页面不写 DOM）----------
   z-index 65：要高于周报页那些 fixed 浮层的 60（.wk-ai-float / .hs-pop / .panel-fab），
   否则在预警详情页、批注看板、历史页上会被浮层压住点不到；同时低于弹窗遮罩 .hlp-mask 的 70，
   打开说明后这颗按钮理应被遮罩盖住。 */
.hlp-fab {
  position: fixed; top: 7px; right: 14px; z-index: 65;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.hlp-fab:hover { transform: scale(1.08); box-shadow: 0 4px 14px var(--shadow); }
.hlp-fab svg { width: 19px; height: 19px; display: block; }

/* ---------- 主题切换：固定在帮助浮标左边的浮标（theme.js 注入，页面不写 DOM）----------
   ⭐ 刻意**不复用 `.hlp-fab`** —— 那是帮助浮标的，两者各自独立，将来任一方调整位置
   不会牵连另一方。
   z-index 与 .hlp-fab 同为 65：同样要压过周报页那些 fixed 浮层的 60
   （.wk-ai-float / .hs-pop / .panel-fab），同样低于弹窗遮罩 .hlp-mask 的 70。
   横向排布：帮助浮标占右起 14~48px，本颗排在它左边、间距 8px ⇒ right: 56px，占 56~90px。
   外观刻意与帮助浮标区分：帮助是 accent 实心圆（主入口），本颗是面板底 + 描边（次级控件）；
   内容是 ☀️/🌙，由 theme.js 按当前主题写入。 */
.thm-fab {
  position: fixed; top: 7px; right: 56px; z-index: 65;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.thm-fab:hover { transform: scale(1.08); box-shadow: 0 4px 14px var(--shadow); }

/* 各页顶栏右侧让出**两颗浮标**的地盘。**新增页面的顶栏若右侧有控件，也要在这里补一条**，
   否则右上角的控件会被这两颗 fixed 按钮压住。（周报页顶栏 .wk-header 在 weekly.css 里、
   月报页 .fin-header 在 finance.css 里，同办。）
   ⚠️ 100px 是算出来的：帮助浮标 right:14px + 34px ⇒ 右起 48px；主题浮标间隔 8px 排在其左，
   right:56px + 34px ⇒ 右起 90px；再留 10px 舒适间距（与原先 58 = 48 + 10 同一算法）。
   ⇒ **改任一颗浮标的 right/width，这里要跟着重算。** */
.top-bar, .reader-bar { padding-right: 100px; }

.hlp-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 70;
            display: flex; align-items: center; justify-content: center; padding: 20px; }
.hlp-modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 880px;
             height: min(86dvh, 900px); display: flex; flex-direction: column; overflow: hidden;
             box-shadow: 0 10px 40px var(--shadow); }
.hlp-head { display: flex; align-items: baseline; gap: 10px; padding: 16px 20px 12px;
            border-bottom: 1px solid var(--border); flex-shrink: 0; }
.hlp-h-title { font-size: 17px; font-weight: 600; }
.hlp-h-date { font-size: 12px; color: var(--muted); flex: 1; }
.hlp-x { color: var(--muted); font-size: 16px; padding: 0 4px; }
.hlp-stale { flex-shrink: 0; margin: 12px 20px 0; padding: 9px 12px; border-radius: 8px;
             border: 1px solid var(--danger); color: var(--danger); font-size: 13px; }
.hlp-body { flex: 1; display: flex; min-height: 0; }
.hlp-toc { width: 200px; flex-shrink: 0; overflow-y: auto; padding: 14px 8px 20px 16px;
           border-right: 1px solid var(--border); }
.hlp-toc-i { display: block; padding: 5px 8px; border-radius: 6px; cursor: pointer;
             font-size: 13px; color: var(--text); }
.hlp-toc-i.sub { padding-left: 20px; font-size: 12.5px; color: var(--muted); }
.hlp-toc-i:hover { background: var(--hover); }
.hlp-content { flex: 1; overflow-y: auto; padding: 14px 24px 40px; }
.hlp-sec { padding-bottom: 10px; }
.hlp-sec + .hlp-sec { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 18px; }

/* 「你当前的可见范围」框：按当前登录用户实时渲染，内容不进 md。 */
.hlp-vis { margin: 10px 0; padding: 12px 14px; border-radius: 10px;
           background: var(--accent-soft); border: 1px solid var(--border); font-size: 13px; }
.hlp-vis-h { font-weight: 600; margin-bottom: 6px; }
.hlp-vis-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; align-items: baseline; }
.hlp-vis-k { color: var(--muted); min-width: 84px; flex-shrink: 0; }
.hlp-vis-v { font-weight: 600; }
.hlp-vis-hint { color: var(--muted); font-size: 12px; }

@media (max-width: 768px) {
  .hlp-modal { height: 92dvh; }
  .hlp-toc { display: none; }        /* 窄屏放不下目录栏，正文本身可滚 */
  .hlp-content { padding: 12px 16px 32px; }
}
