/* ============================================================
   WeChat Agent — Premium UI (zero-build, self-contained)
   Light / Dark / System theme via [data-theme] on <html>.
   ============================================================ */

:root {
  --bg: #eef3fb;
  --bg-grad-1: #e8f1ff;
  --bg-grad-2: #e0f2fe;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --text: #1f2937;
  --text-soft: #64748b;
  --text-faint: #94a3b8;
  --accent: #2563eb;
  --accent-2: #06b6d4;
  --accent-grad: linear-gradient(135deg, #2563eb, #06b6d4);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 10px 40px -12px rgba(31, 41, 55, 0.18);
  --radius: 18px;
}

[data-theme="dark"] {
  --bg: #070d1a;
  --bg-grad-1: #0a1d3a;
  --bg-grad-2: #0a2c4a;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-solid: #0e1729;
  --border: rgba(255, 255, 255, 0.1);
  --text: #e8ecf5;
  --text-soft: #9aa6c0;
  --text-faint: #647089;
  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #3b82f6, #22d3ee);
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  transition: background 0.4s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  padding: 22px 16px;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; background: var(--accent-grad);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: 0 6px 20px -6px var(--accent);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--text-faint); }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 12px; color: var(--text-soft);
  font-size: 14px; font-weight: 500; transition: all .2s cubic-bezier(.16,1,.3,1);
}
.nav-link:hover { background: var(--surface-solid); color: var(--text); transform: translateX(2px); }
.nav-link.active { background: var(--accent-grad); color: #fff; box-shadow: 0 8px 22px -8px var(--accent); }
.nav-ico { width: 18px; text-align: center; }

.sidebar-foot { margin-top: auto; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }

.account-chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--surface-solid); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }

/* ---------- Theme toggle ---------- */
.theme-toggle { display: inline-flex; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.theme-toggle button { border: 0; background: transparent; color: var(--text-soft); width: 32px; height: 28px; border-radius: 999px; font-size: 14px; transition: all .2s; }
.theme-toggle button.on { background: var(--accent-grad); color: #fff; }

/* ---------- Cards ---------- */
.content { padding: 28px; }
.grid { display: grid; gap: 18px; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .sidebar { display: none; } .cols-3, .cols-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.16,1,.3,1), box-shadow .3s;
}
.card.magnetic:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 20px 50px -16px rgba(31,41,55,.32); }
.card h3 { margin: 0 0 6px; font-size: 14px; color: var(--text-soft); font-weight: 600; }
.metric { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-solid); color: var(--text); font-weight: 600; font-size: 14px;
  transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s, filter .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -10px rgba(31,41,55,.4); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.primary { background: var(--accent-grad); color: #fff; border: 0; box-shadow: 0 10px 26px -10px var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }

/* ---------- Persona management ---------- */
.persona-panel { margin-top: 18px; }
.persona-form { padding: 4px 2px 2px; border-top: 1px solid var(--border); }
.persona-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 14px; margin-bottom: 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .2s cubic-bezier(.16,1,.3,1), box-shadow .2s, border-color .2s;
}
.persona-row:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 12px 30px -16px rgba(37,99,235,.5); }
.persona-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: 12px; color: var(--text-faint); }
.persona-prompt { margin-top: 8px; font-size: 12.5px; line-height: 1.7; color: var(--text-soft); background: rgba(37,99,235,.06); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 0 8px 8px 0; }

/* ---------- Model picker modal ---------- */
.model-opt {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 12px 14px; margin-bottom: 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .18s cubic-bezier(.16,1,.3,1), border-color .18s, box-shadow .18s, background .18s;
}
.model-opt:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 12px 30px -16px rgba(37,99,235,.55); }
.model-opt.on { border-color: var(--accent); background: rgba(37,99,235,.08); box-shadow: 0 0 0 1px var(--accent) inset; }
.mo-name { font-weight: 600; font-size: 14px; color: var(--text); }
.mo-model { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.mo-badge { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600; color: #fff; background: var(--accent-grad); padding: 1px 8px; border-radius: 999px; vertical-align: middle; }


/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 7px; }
.input, .textarea, .select {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-solid); color: var(--text);
  font-size: 14px; font-family: inherit; transition: border-color .2s, box-shadow .2s;
}
.input:focus, .textarea:focus, .select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.16); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.65; }
.textarea.sm { min-height: 64px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.draft { background: rgba(100,116,139,.14); color: var(--text-soft); }
.badge.editing { background: rgba(37,99,235,.16); color: var(--accent); }
.badge.review { background: rgba(245,158,11,.16); color: var(--warning); }
.badge.published { background: rgba(16,185,129,.16); color: var(--success); }

/* ---------- Read-only banner (published article) ---------- */
.ro-banner { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.35); color: var(--success); font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.wx-toolbar.locked, .ai-assist.locked, .ai-chat.locked { pointer-events: none; opacity: .55; filter: grayscale(.2); }

/* ---------- Article editor ---------- */
.editor-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .editor-wrap { grid-template-columns: 1fr; } }
.preview { background: #fff; color: #222; border-radius: 14px; padding: 22px; border: 1px solid var(--border); min-height: 300px; overflow: auto; max-height: 70vh; }
.pipeline-steps { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.step.running { border-color: var(--accent); color: var(--accent); animation: pulse 1s infinite; }
.step:disabled { opacity: .5; cursor: not-allowed; }
.step.optimize { background: var(--accent-grad); color: #fff; border: 0; box-shadow: 0 6px 16px -8px var(--accent); }
.step.optimize:hover { filter: brightness(1.06); transform: translateY(-1px); }
@keyframes pulse { 50% { opacity: .5; } }

/* 文章底部版权声明（声明模板一键插入） */
.wx-copyright { margin: 22px 0 4px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 12.5px; line-height: 1.7; color: var(--text-faint); text-align: center; }

/* 声明模板弹窗 */
.dec-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.dec-main { flex: 1; min-width: 0; }
.dec-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.dec-content { font-size: 12.5px; line-height: 1.6; color: var(--text-faint); white-space: pre-wrap; word-break: break-word; }
.dec-actions { display: flex; gap: 6px; flex-shrink: 0; }
.dec-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

.issue { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 13px; border-left: 3px solid var(--danger); background: rgba(239,68,68,.08); }
.issue.warn { border-color: var(--warning); background: rgba(245,158,11,.08); }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); padding: 13px 20px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow); z-index: 50; animation: slidein .3s; pointer-events: none; max-width: 86vw; text-align: center; }
@keyframes slidein { from { transform: translateY(20px); opacity: 0; } }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 380px; }

/* ============================================================
   Article editor — visual (WYSIWYG) + media + phone preview
   ============================================================ */
.ed-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ed-actions .spacer { flex: 1; }
.auto-save-hint { font-size: 12px; color: var(--text-soft); opacity: .75; margin-right: 4px; white-space: nowrap; transition: opacity .2s; }
.auto-save-hint:empty { display: none; }

.seg { display: inline-flex; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--text-soft); padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: all .2s; }
.seg button.on { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 16px -8px var(--accent); }
.seg.sm button { padding: 6px 12px; font-size: 12px; }

/* AI 助手 card (unified with the editor — no tab switching) */
.ai-assist { margin-bottom: 16px; }
.ai-assist-head { font-weight: 700; font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.topics { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 8px; margin: 10px 0 4px; }
.topic-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform .18s cubic-bezier(.16,1,.3,1), border-color .18s, box-shadow .18s, background .18s;
}
.topic-row:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -8px rgba(37,99,235,.45);
}
.topic-row.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(37,99,235,.14), rgba(6,182,212,.10));
  box-shadow: 0 6px 20px -8px rgba(37,99,235,.5);
}
.topic-no {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.topic-row.selected .topic-no { background: var(--accent-grad); }
.topic-text { flex: 1; font-size: 14px; line-height: 1.5; font-weight: 500; }
.topic-check {
  flex: 0 0 auto; opacity: 0; font-size: 14px; font-weight: 700;
  color: var(--accent); transition: opacity .18s;
}
.topic-row.selected .topic-check { opacity: 1; }
.topic-count { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.topic-count .select { width: 78px; }
.topic-actions { display: flex; gap: 10px; margin-top: 2px; }
.topic-actions .btn { flex: 0 0 auto; }
.chosen { font-size: 13px; color: var(--text-soft); margin-top: 6px; }

/* WeChat-style toolbar */
.wx-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 6px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-solid); border-radius: 14px 14px 0 0; z-index: 5; }
.wx-tb { min-width: 34px; height: 32px; padding: 0 9px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; display: inline-flex; align-items: center; justify-content: center; transition: all .15s; }
.wx-tb:hover { background: var(--bg-grad-1); border-color: var(--border); }
.wx-tb.media { font-size: 12.5px; font-weight: 600; background: rgba(37,99,235,.1); color: var(--accent); }
.wx-tb.media:hover { background: var(--accent-grad); color: #fff; }
.wx-tb.optimize { font-size: 12.5px; font-weight: 700; background: var(--accent-grad); color: #fff; box-shadow: 0 6px 16px -8px var(--accent); }
.wx-tb.optimize:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* AI 互动面板 */
.ai-chat { display: flex; flex-direction: column; }
.ai-chat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 700; font-size: 14px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; padding: 4px 2px 8px; }
.chat-empty { font-size: 12.5px; line-height: 1.6; }
.chat-msg { font-size: 13px; line-height: 1.65; padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--accent-grad); color: #fff; max-width: 88%; border-bottom-right-radius: 4px; }
.chat-msg.ai { align-self: flex-start; background: var(--bg-grad-1); color: var(--text); max-width: 92%; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg.thinking { opacity: .7; font-style: italic; }
.chat-input-row { margin-top: 10px; }
.wx-sel { height: 32px; padding: 0 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-solid); color: var(--text); font-size: 13px; }
.wx-color { width: 34px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-solid); cursor: pointer; }
.wx-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* writing surface — always light, like WeChat backend */
.wx-editor { min-height: 380px; padding: 20px; background: #fff; color: #2b2b2b; border-radius: 0 0 14px 14px; outline: none; font-size: 15px; line-height: 1.8; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; overflow: auto; }
.wx-editor:focus { box-shadow: inset 0 0 0 2px rgba(37,99,235,.25); }
.wx-editor img { max-width: 100%; }
.wx-editor audio, .wx-editor video { max-width: 100%; }
.wx-hint { font-size: 12px; color: var(--text-faint); padding: 10px 4px 2px; }

/* ---------- WeChat-style editor enhancements ---------- */
/* toolbar active state */
.wx-tb.active { background: var(--accent-grad); color: #fff; border-color: transparent; }
.wx-tb.active:hover { filter: brightness(1.06); }
.wx-tb:disabled { opacity: .45; cursor: not-allowed; }

/* icon-only buttons */
.wx-tb-icon { font-size: 13px; font-weight: 700; letter-spacing: .2px; }

/* color picker wrapper: the color input sits on top of the visible icon button */
.wx-color-wrap { position: relative; display: inline-flex; vertical-align: top; }
.wx-color-wrap .wx-tb { position: relative; z-index: 1; padding-right: 16px; }
.wx-color-wrap .wx-color { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

/* dropdowns in toolbar */
.wx-dropdown { position: relative; display: inline-flex; }
.wx-dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  display: none; flex-direction: column; min-width: 110px; max-height: 280px; overflow: auto;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 20; padding: 4px;
}
.wx-dropdown.open .wx-dropdown-menu { display: flex; }
.wx-dropdown-menu button {
  border: 0; background: transparent; color: var(--text); font-size: 13px; padding: 7px 12px;
  border-radius: 6px; text-align: left; cursor: pointer; white-space: nowrap;
}
.wx-dropdown-menu button:hover { background: var(--bg-grad-1); }
.wx-emoji-menu { display: none; flex-direction: row; flex-wrap: wrap; min-width: 160px; max-width: 180px; }
.wx-dropdown.open .wx-emoji-menu { display: flex; }
.wx-emoji-menu button { font-size: 18px; padding: 5px; width: 36px; height: 32px; display: inline-flex; align-items: center; justify-content: center; }

/* editor typography — closer to WeChat backend */
.wx-editor p { margin: 0 0 10px; min-height: 1.4em; }
.wx-editor h1, .wx-editor h2, .wx-editor h3 { margin: 18px 0 10px; font-weight: 700; line-height: 1.4; }
.wx-editor h1 { font-size: 24px; }
.wx-editor h2 { font-size: 20px; }
.wx-editor h3 { font-size: 17px; }
.wx-editor blockquote {
  margin: 16px 0; padding: 12px 16px; border-left: 4px solid #07c160;
  background: #f7f8fa; color: #555; font-size: 14px; line-height: 1.7;
}
.wx-editor pre {
  margin: 16px 0; padding: 12px 16px; background: #f4f4f4; border-radius: 6px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.wx-editor code { font-family: "SF Mono", Monaco, "Courier New", monospace; font-size: 13px; color: #333; background: rgba(127,127,127,.08); padding: 1px 4px; border-radius: 4px; }
.wx-editor pre code { background: transparent; padding: 0; }
.wx-editor ul, .wx-editor ol { margin: 10px 0; padding-left: 26px; }
.wx-editor li { margin: 4px 0; }
.wx-editor hr { border: 0; border-top: 1px solid #e0e0e0; margin: 16px 0; }
.wx-editor table {
  width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; line-height: 1.6;
  border: 1px solid #e0e0e0;
}
.wx-editor table td, .wx-editor table th {
  border: 1px solid #e0e0e0; padding: 8px 10px; min-width: 60px; vertical-align: top;
}
.wx-editor table th { background: #f7f8fa; font-weight: 600; }
.wx-editor table td:empty::before { content: "\00a0"; }
.wx-editor section { margin: 16px 0; }

/* table quick-edit controls (shown on hover) */
.wx-editor table:hover { box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.wx-table-actions {
  position: absolute; display: none; gap: 4px; padding: 4px; background: var(--surface-solid);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); z-index: 10;
}
.wx-table-actions.show { display: flex; }
.wx-table-actions button { border: 0; background: var(--bg-grad-1); color: var(--text); font-size: 11px; padding: 4px 7px; border-radius: 5px; cursor: pointer; }
.wx-table-actions button:hover { background: var(--accent-grad); color: #fff; }

/* ensure dropdowns don't get clipped by overflow on small screens */
@media (max-width: 900px) {
  .wx-toolbar { gap: 2px; padding: 6px; }
  .wx-tb { min-width: 30px; height: 30px; padding: 0 6px; font-size: 13px; }
  .wx-dropdown-menu { left: auto; right: 0; transform: none; }
}
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.5); backdrop-filter: blur(4px); z-index: 60; }
.modal[hidden] { display: none !important; }
.modal-card { width: min(560px, 92vw); max-height: 86vh; overflow: auto; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px; }
.modal-x { border: 0; background: var(--bg); width: 30px; height: 30px; border-radius: 9px; cursor: pointer; color: var(--text-soft); font-size: 15px; }
.modal-body { padding: 18px 20px; }
.mat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.mat-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); cursor: pointer; padding: 0; text-align: center; transition: transform .15s; }
.mat-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.mat-item img { width: 100%; height: 84px; object-fit: cover; display: block; }
.mat-item span { display: block; font-size: 11px; color: var(--text-soft); padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* phone preview — mimics WeChat APP article reader */
.phone-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.55); backdrop-filter: blur(6px); z-index: 70; }
.phone { position: relative; width: 375px; height: 760px; max-height: 92vh; background: #0c0c0e; border-radius: 46px; padding: 12px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.7), inset 0 0 0 2px #2a2a2e; }
.phone-notch { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 150px; height: 26px; background: #0c0c0e; border-radius: 0 0 16px 16px; z-index: 3; }
.phone-screen { width: 100%; height: 100%; background: #fff; border-radius: 36px; overflow: hidden; position: relative; }
.phone-screen { overflow-y: auto; }
.wx-article { padding: 54px 20px 40px; min-height: 100%; background: #fff; }
.wx-title { font-size: 22px; font-weight: 700; color: #1a1a1a; line-height: 1.4; margin: 0 0 12px; }
.wx-meta { display: flex; gap: 14px; font-size: 13px; color: #888; align-items: center; }
.wx-meta .wx-src { color: #576b95; }
.wx-divider { height: 1px; background: #ededed; margin: 14px 0 18px; }
.wx-body { font-size: 17px; line-height: 1.8; color: #333; word-break: break-word; }
.wx-body img { max-width: 100% !important; border-radius: 6px; }
.wx-body section { margin: 16px 0; }
.phone-close { position: absolute; top: -14px; right: -14px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #1f2430; color: #fff; font-size: 18px; line-height: 1; cursor: pointer; z-index: 90; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.45); transition: transform .12s ease, background .12s ease; }
.phone-close:hover { background: #2d3340; transform: scale(1.06); }

/* ============================================================
   Account stats dashboard (AccountDetail)
   ============================================================ */
.detail-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.back-link { font-size: 13px; font-weight: 600; color: var(--text-soft); padding: 7px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-solid); transition: all .2s; }
.back-link:hover { color: var(--text); border-color: var(--accent); transform: translateX(-2px); }
.detail-title h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.detail-sub { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.source-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.source-badge.real { color: var(--success); background: rgba(16,185,129,.14); }
.source-badge.partial { color: var(--warning); background: rgba(245,158,11,.14); }
.source-badge.demo { color: var(--accent-2); background: rgba(6,182,212,.14); }
.toolbar { display: flex; gap: 8px; }

.demo-banner { background: linear-gradient(135deg, rgba(245,158,11,.12), rgba(37,99,235,.08)); border: 1px solid rgba(245,158,11,.32); color: var(--text); padding: 13px 16px; border-radius: 14px; font-size: 13px; line-height: 1.7; margin-bottom: 14px; }
.demo-banner b { color: var(--warning); }
.warn-list { margin-bottom: 14px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { border: 1px solid var(--border); background: var(--surface-solid); color: var(--text-soft); padding: 9px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .2s cubic-bezier(.16,1,.3,1); }
.tab:hover { color: var(--text); transform: translateY(-1px); }
.tab.on { background: var(--accent-grad); color: #fff; border-color: transparent; box-shadow: 0 8px 22px -8px var(--accent); }
.tab-count { display: inline-block; margin-left: 6px; font-size: 12px; opacity: .8; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi .kpi-lbl { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.kpi .kpi-val { font-size: 32px; font-weight: 800; letter-spacing: -.5px; margin: 8px 0 4px; }
.kpi .kpi-sub { font-size: 12px; color: var(--text-faint); }

/* Trend bar chart */
.legend { display: flex; gap: 14px; font-size: 12px; }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; color: var(--text-soft); }
.legend .lg::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.legend .lg.new::before { background: var(--accent); }
.legend .lg.unsub::before { background: var(--danger); }
.trend { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding-top: 22px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.trend-col .bars { display: flex; align-items: flex-end; gap: 4px; height: 100%; width: 100%; justify-content: center; }
.bar { width: 38%; max-width: 22px; border-radius: 6px 6px 0 0; position: relative; transition: height .5s cubic-bezier(.16,1,.3,1); min-height: 2px; }
.bar.new { background: linear-gradient(180deg, var(--accent), rgba(37,99,235,.4)); }
.bar.unsub { background: linear-gradient(180deg, var(--danger), rgba(239,68,68,.4)); }
.bar-tip { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-faint); white-space: nowrap; }
.trend-lbl { font-size: 11px; color: var(--text-faint); margin-top: 8px; }

/* Articles */
.art-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; padding: 16px 18px; }
.art-main { flex: 1; min-width: 0; }
.art-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-date { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.intensity { height: 6px; border-radius: 999px; background: rgba(37,99,235,.12); margin-top: 10px; overflow: hidden; max-width: 320px; }
.intensity > i { display: block; height: 100%; background: var(--accent-grad); border-radius: 999px; }
.art-stats { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.stat-pill { display: flex; flex-direction: column; align-items: center; padding: 8px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); min-width: 64px; }
.stat-pill .sp-k { font-size: 11px; color: var(--text-faint); }
.stat-pill .sp-v { font-size: 16px; font-weight: 800; margin-top: 2px; }

/* Fans */
.fan-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 760px) { .fan-grid { grid-template-columns: 1fr; } }
.fan-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar.grad, .cmt-avatar.grad { display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px; background: var(--accent-grad); }
.fan-meta { min-width: 0; }
.fan-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fan-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Comments */
.cmt-list { display: flex; flex-direction: column; gap: 12px; }
.cmt-row { display: flex; gap: 12px; padding: 14px 16px; }
.cmt-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.cmt-body { flex: 1; min-width: 0; }
.cmt-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cmt-name { font-weight: 700; font-size: 14px; }
.cmt-like { font-size: 12px; color: var(--accent); font-weight: 600; flex-shrink: 0; }
.cmt-text { font-size: 14px; line-height: 1.7; color: var(--text); margin: 6px 0; }
.cmt-meta { font-size: 12px; color: var(--text-faint); }

/* ============================================================
   AI 配图 · 对话式窗口
   ============================================================ */
.img-chat-card { width: min(640px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.img-chat-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.img-history {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 16px;
  min-height: 140px; max-height: 52vh;
  background: rgba(15, 23, 42, 0.025);
}
[data-theme="dark"] .img-history { background: rgba(255, 255, 255, 0.03); }
.img-turn { background: var(--surface-solid); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.img-turn.current { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.img-turn-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.img-role { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.img-role.user { background: var(--accent-grad); color: #fff; }
.img-role.ai { background: rgba(37, 99, 235, 0.1); color: var(--accent); }
.img-prompt { font-size: 13px; color: var(--text); line-height: 1.55; word-break: break-word; }
.img-params { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.img-params .chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(15, 23, 42, 0.05); color: var(--text-soft); }
[data-theme="dark"] .img-params .chip { background: rgba(255, 255, 255, 0.07); }
.img-params .chip.faint { background: transparent; color: var(--text-faint); }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.img-thumb {
  position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  padding: 0; background: var(--surface-solid); cursor: pointer; aspect-ratio: 1 / 1;
  transition: transform .12s ease, box-shadow .12s ease;
}
.img-thumb:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -10px rgba(31, 41, 55, 0.45); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-insert-hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 11px;
  padding: 3px 0; opacity: 0; transition: opacity .12s ease;
}
.img-thumb:hover .img-insert-hint { opacity: 1; }
.img-input { border-top: 1px solid var(--border); padding: 12px 14px; background: var(--surface-solid); display: flex; flex-direction: column; gap: 8px; }
.img-opts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.img-opts .select { flex: 1; min-width: 88px; }
.img-status { font-size: 12px; }

/* AI 处理中过渡提示（点击 AI 动作即时显示，遮挡操作防误触） */
.ai-overlay { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(17, 24, 39, .45); backdrop-filter: blur(2px); align-items: center; justify-content: center; }
.ai-overlay.show { display: flex; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; } }
.ai-overlay-card {
  background: var(--surface-solid, #fff);
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: var(--shadow, 0 20px 50px -16px rgba(31, 41, 55, .32));
  border-radius: 16px; padding: 28px 34px;
  display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 240px;
}
.ai-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 4px solid rgba(37, 99, 235, .18); border-top-color: var(--accent, #2563eb);
  animation: ai-spin .8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-overlay-text { font-size: 14px; font-weight: 600; color: var(--text, #1f2937); text-align: center; }
.ai-overlay-sub { font-size: 12px; color: var(--text-faint, #9ca3af); text-align: center; }

