:root {
  --brand: #2f6bff;
  --brand-dark: #1f52d6;
  --brand-soft: #eaf0ff;
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #e6eaf2;
  --text: #1c2333;
  --text-2: #5a6478;
  --text-3: #98a1b3;
  --danger: #e5484d;
  --green: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 6px 20px rgba(20, 30, 60, .05);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── 顶栏 ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 18px;
  background: linear-gradient(180deg, #ffffff, #fbfcfe);
  border-bottom: 1px solid var(--line);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #3d7bff, #2f6bff);
  color: #fff; display: grid; place-items: center;
  font-size: 24px; font-weight: 800;
  box-shadow: 0 4px 12px rgba(47, 107, 255, .35);
}
.brand h1 { margin: 0; font-size: 18px; line-height: 1.2; letter-spacing: .3px; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 按钮 ── */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.btn:hover { border-color: #c9d2e6; background: #f8faff; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #f3c6c8; }
.btn-danger:hover { background: #fff5f5; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 布局 ── */
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 18px; padding: 18px; max-width: 1200px; margin: 0 auto;
}

/* ── 分类侧栏 ── */
.sidebar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; height: fit-content; box-shadow: var(--shadow); }
.sidebar-title { font-size: 12px; color: var(--text-3); padding: 4px 8px 8px; letter-spacing: 1px; }
.cat-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); position: relative;
}
.cat-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.cat-item .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .cat-count { font-size: 11px; background: #eef2fa; color: var(--text-3); border-radius: 20px; padding: 1px 7px; }
.cat-item.active .cat-count { background: #dbe6ff; color: var(--brand); }
.cat-menu { position: relative; }
.cat-op {
  border: none; background: transparent; color: var(--text-3); font-size: 14px; cursor: pointer;
  padding: 2px 5px; border-radius: 6px; opacity: 0;
}
.cat-item:hover .cat-op { opacity: 1; }
.cat-op:hover { background: rgba(0,0,0,.06); color: var(--text); }
.dropdown {
  position: absolute; right: 0; top: 100%; z-index: 30; min-width: 120px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20,30,60,.14);
  padding: 5px; display: none; flex-direction: column;
}
.dropdown.open { display: flex; }
.dropdown button { border: none; background: none; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.dropdown button:hover { background: var(--brand-soft); color: var(--brand); }
.dropdown button.danger:hover { background: #fff0f0; color: var(--danger); }
.new-cat { margin-top: 8px; margin-left: 4px; padding: 6px 0; }

/* ── 两级分类·桌面侧栏 ── */
.side-group { margin: 2px 0 6px; }
.side-group-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px;
  cursor: pointer; color: var(--text); font-weight: 600; position: relative; font-size: 13px;
}
.side-group-head:hover { background: #f6f9ff; }
.side-group-head.active { color: var(--brand); }
.side-group-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-group .cat-count { font-size: 10px; background: #eef2fa; color: var(--text-3); border-radius: 20px; padding: 1px 7px; }
.side-sub {
  display: flex; align-items: center; gap: 6px; margin: 2px 0 2px 12px; padding: 8px 10px;
  border-radius: 10px; cursor: pointer; color: var(--text-2); position: relative;
}
.side-sub.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-sub .sub-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-group-head:hover .cat-op, .side-sub:hover .cat-op { opacity: 1; }

/* ── 手机顶部横滑导航（两级）默认为桌面隐藏 ── */
.mobile-nav { display: none; }
.nav-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px; -webkit-overflow-scrolling: touch; }
.nav-pill {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  border-radius: 20px; padding: 7px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.nav-pill.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* ── 分类弹窗：层级单选 + 所属业务下拉 ── */
.cat-type { display: flex; gap: 16px; margin-bottom: 10px; }
.type-opt { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.type-opt input { accent-color: var(--brand); }
#catParentWrap select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field label { font-size: 13px; color: var(--text-2); }

/* ── 问答区 ── */
.qa-area { min-width: 0; }
.area-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.area-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.area-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.qa-list { display: flex; flex-direction: column; gap: 12px; }
.empty { text-align: center; color: var(--text-3); padding: 50px 16px; border: 1px dashed #cdd6e8; border-radius: var(--radius); background: #fbfcff; }
.hidden { display: none !important; }

/* ── 问答卡片 ── */
.qa-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.qa-q { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; cursor: pointer; position: relative; }
.qa-q:hover { background: #fafcff; }
.qa-q .q-text { flex: 1; font-weight: 600; }
.qa-q .q-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; margin-top: 2px; }
.qa-q .chev { color: var(--text-3); flex: none; transition: transform .2s; font-size: 13px; }
.qa-q .q-ops { display: inline-flex; gap: 6px; margin-left: 4px; flex: none; align-self: center; }
.qa-q .q-op { font-size: 12px; padding: 3px 9px; border: 1px solid var(--line); background: #fff; color: var(--text-2); border-radius: 6px; cursor: pointer; }
.qa-q .q-op:hover { border-color: var(--brand); color: var(--brand); }
.qa-q .q-op.danger { color: var(--danger); border-color: #fdd; }
.qa-q .q-op.danger:hover { background: #fef2f2; border-color: var(--danger); }
.qa-card.open .chev { transform: rotate(180deg); }

.qa-body { border-top: 1px solid var(--line); padding: 16px; background: #fbfcfe; }
.answer-block { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.answer-block .ans-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 20px; }
.badge.manual { background: #eef2fa; color: var(--text-2); }
.badge.ai { background: #e7f6ec; color: var(--green); }
.answer-block .ans-content { font-size: 15px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.answer-tools { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.edit-ans-btn { display:inline-flex; align-items:center; justify-content:center; border:1px solid #2f6bff; color:#2f6bff; background:#fff; border-radius:10px; padding:10px 16px; font-weight:600; cursor:pointer; white-space:nowrap; flex:0 0 auto; }
.edit-ans-btn:active { background:var(--brand-soft); }
.copy-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: none; border-radius: 10px;
  padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all .15s ease; min-height: 46px;
}
.copy-btn:hover { background: var(--brand-dark); }
.copy-btn:active { transform: scale(.98); }
.copy-btn.copied { background: var(--green); }
.copy-btn.loading { opacity: .75; pointer-events: none; }
.copy-btn:disabled { cursor: not-allowed; }
.copy-hint { width: 100%; font-size: 12px; color: var(--text-3); text-align: center; margin-top: 6px; }

.variants { margin-top: 16px; }
.variants-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.variants-title { font-size: 13px; font-weight: 600; color: var(--text-2); }
.variant-item { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 8px; }
.variant-item.current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.variant-item .v-content { flex: 1; font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.variant-item .v-ops { display: flex; gap: 4px; flex: none; }
.v-item-op { border: none; background: none; color: var(--text-3); cursor: pointer; font-size: 13px; padding: 3px 6px; border-radius: 6px; }
.v-item-op:hover { background: var(--brand-soft); color: var(--brand); }
.v-item-op.danger:hover { background: #fff0f0; color: var(--danger); }
.add-variant { width: 100%; border: 1px dashed #c4cfe4; background: #fff; border-radius: 10px; padding: 9px; color: var(--text-3); cursor: pointer; font-size: 13px; }
.add-variant:hover { color: var(--brand); border-color: var(--brand); background: #f8faff; }

/* ── 弹窗 ── */
.modal-mask { position: fixed; inset: 0; background: rgba(18, 28, 54, .42); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .18s ease; }
.modal { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: pop .2s ease; }
.modal-wide { max-width: 640px; }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.label-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.label-row label { margin-bottom: 0; }
.btn-draft { flex: none; border-color: #c7d6ff; color: var(--brand); background: var(--brand-soft); }
.btn-draft:hover { background: #dbe6ff; border-color: var(--brand); }
.draft-hint { margin: 6px 0 0; font-size: 12px; color: var(--green); }
.draft-hint::before { content: '✓ '; }
.field textarea, .modal input[type=text] { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--text); resize: vertical; }
.field textarea:focus, .modal input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.tip-desc { font-size: 13px; color: var(--text-2); margin: 0 0 12px; }
.tips-loading { font-size: 14px; color: var(--text-3); padding: 20px; text-align: center; }
.tips-list { max-height: 46vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.tip-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; }
.tip-item.checked { border-color: var(--brand); background: #f4f8ff; }
.tip-item input[type=checkbox] { margin-top: 4px; accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
.tip-item textarea { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 14px; color: var(--text); resize: none; min-height: 24px; }
.tip-item textarea:focus { outline: none; }

/* ── Toast ── */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #1c2333; color: #fff; padding: 10px 18px; border-radius: 24px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 200; animation: pop .2s ease; }
.toast.ok { background: var(--green); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── 响应式：手机 ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .sidebar { display: none; }
  .mobile-nav {
    display: flex; flex-direction: column; gap: 4px; padding: 4px;
    position: sticky; top: 64px; z-index: 15; background: var(--page);
  }
  .nav-pill { flex: none; }
  .subtitle { max-width: 150px; }
  .copy-btn { width: 100%; }
  .area-title { font-size: 16px; }
}

/* ── 顶栏右侧：用户区 ── */
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-area { display: flex; align-items: center; gap: 8px; padding-left: 8px; border-left: 1px solid var(--line); }
.user-meta { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; color: var(--text); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: #eef2fa; color: var(--text-2); flex: none; }
.user-role.role-admin { background: #e7f0ff; color: var(--brand); }

/* ── 账号管理弹窗 ── */
.acct-add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.acct-add input { flex: 1 1 160px; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; }
.acct-add input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.acct-add select { flex: none; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; }
.acct-pw { background: #f4f8ff; border: 1px solid #d6e3ff; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acct-pw-tip { font-size: 13px; color: var(--text-2); margin: 0; flex: 1 1 100%; }
.acct-pw-code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 15px; font-weight: 700; color: var(--brand-dark); background: #fff; border: 1px dashed var(--brand); border-radius: 8px; padding: 6px 12px; letter-spacing: 1px; user-select: all; }
.acct-list { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.acct-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.acct-uname { font-weight: 600; font-size: 14px; }
.acct-dname { font-size: 12px; color: var(--text-3); }
.acct-ops { display: flex; align-items: center; gap: 6px; flex: none; }
.acct-self { font-size: 12px; color: var(--text-3); padding: 3px 8px; }
.danger-badge { background: #fdecec; color: var(--danger); }

/* ── AI 生成区块（问答卡片内） ── */
.ai-gen { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.ai-gen-head { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.ai-gen-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 文案助手弹窗 ── */
.cw-q { background: var(--brand-soft); border: 1px solid #d6e3ff; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.cw-q span { color: var(--text); font-weight: 600; }
.cw-plats { display: flex; gap: 14px; flex-wrap: wrap; }
.cw-plat-opt { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.cw-plat-opt input { accent-color: var(--brand); }
.cw-section-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 14px 0 8px; }
.cw-result { display: flex; flex-direction: column; gap: 10px; }
.cw-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.cw-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cw-plat { font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.cw-douyin { background: #fdecec; color: #e5484d; }
.cw-video { background: #e7f0ff; color: var(--brand); }
.cw-xhs { background: #ffeef3; color: #e6356f; }
.cw-tone { font-size: 12px; color: var(--text-3); }
.cw-del { margin-left: auto; border: none; background: none; color: var(--danger); cursor: pointer; font-size: 12px; }
.cw-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.cw-body { font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.cw-topics { font-size: 12px; color: var(--brand); margin-top: 8px; word-break: break-word; }
.cw-copy { margin-top: 10px; }
.cw-saved-hint { font-size: 12px; color: var(--text-3); padding: 8px 0; }
.cw-warn { background: #fff7e6; border: 1px solid #ffd591; color: #ad6800; font-size: 12px; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; }