:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e4e7ec;
  --text: #1b2432;
  --muted: #67707d;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}
* { box-sizing: border-box; }
/* 修复：任何元素显式设置了 display（如弹窗遮罩 flex、登录页 flex）会覆盖 hidden 属性，
   导致“隐藏”失效、遮罩层拦截所有点击。这里用 !important 统一兜底。 */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
h1, h2, h3 { margin: 0 0 10px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--err); margin-top: 8px; font-size: 13px; }

/* ---- 登录 ---- */
#login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f5f6f8 45%);
}
.login-card {
  background: var(--panel); width: 340px; padding: 32px 28px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08); text-align: center;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 30px; line-height: 56px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}
.login-card input { margin-bottom: 10px; }
.login-card h1 { font-size: 20px; }
.login-card p { margin-bottom: 18px; }

/* ---- 布局 ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 0 22px; height: 54px;
}
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tabs { display: flex; gap: 2px; flex: 1; }
.tab {
  border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--muted);
  padding: 6px 14px; border-radius: 8px; position: relative;
}
.tab:hover { background: #eef1f6; color: var(--text); }
.tab.active { background: #e7edfb; color: var(--accent-dark); font-weight: 600; }
.dot-badge {
  display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 4px; height: 16px;
  line-height: 16px; font-size: 11px; border-radius: 8px; background: var(--accent); color: #fff; text-align: center;
}
main { max-width: 1100px; margin: 0 auto; padding: 20px 22px 80px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel.narrow { max-width: 720px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.split { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
@media (max-width: 780px) { .split { grid-template-columns: 1fr; } }
.xhs-input-row { display: flex; gap: 10px; align-items: flex-start; }
.xhs-input-row textarea { flex: 1; }
.xhs-input-row .btn { white-space: nowrap; padding: 9px 22px; }
@media (max-width: 620px) { .xhs-input-row { flex-direction: column; } .xhs-input-row .btn { width: 100%; } }
.local-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.local-row input[type="text"] { flex: 1; min-width: 200px; max-width: 360px; }

/* ---- 卡片 ---- */
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fbfcfe; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 14px; }
.mat-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.mat-thumb {
  width: 100%; aspect-ratio: 16/10; object-fit: cover; background: #111; display: block;
  cursor: zoom-in;
}
.mat-thumb.placeholder { display: flex; align-items: center; justify-content: center; color: #9aa2ad; font-size: 13px; }
.mat-body { padding: 10px 12px 12px; }
.mat-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; word-break: break-all; }
.mat-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.mat-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.spin {
  display: inline-block; width: 12px; height: 12px; border: 2px solid #c7d2fe; border-top-color: var(--accent);
  border-radius: 50%; animation: rot 0.8s linear infinite; vertical-align: -2px; margin-right: 4px;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---- 标签 / 徽章 ---- */
.chip, .badge, .status {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 1px 9px; font-size: 12px; line-height: 1.7;
}
.badge { background: #eef2ff; color: #3730a3; }
.badge.mock { background: #fff7e6; color: #b45309; }
.badge.off { background: #eef0f3; color: var(--muted); }
.chip { border: 1px solid var(--line); background: #f3f4f6; color: #374151; cursor: pointer; }
.chip.origin-xhs { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
.chip.kind-video { background: #ecfeff; color: #0e7490; border-color: #cffafe; }
.chip.kind-image { background: #f0fdf4; color: #15803d; border-color: #dcfce7; }
.chip.enh { background: #eef2ff; color: #3730a3; border-color: #e0e7ff; }
.chip.ok-chip { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.chip.warn-chip { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.status { color: #fff; border: 0; }
.status.ok, .status.success { background: var(--ok); }
.status.busy { background: var(--warn); }
.status.fail { background: var(--err); }
.status.idle { background: #9aa2ad; }

/* ---- 表单 ---- */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 8px 11px; border: 1px solid #d5dae2; border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 14px 0; font-size: 13px; cursor: pointer; }
.check input { margin-top: 3px; width: auto; }

/* ---- 按钮 ---- */
.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #c2cad6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eef1f6; color: var(--text); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; padding: 10px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- 账号 ---- */
.account-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.acct-card {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer;
  min-width: 190px; background: #fff; display: flex; gap: 10px; align-items: center;
}
.acct-card:hover { border-color: #b6c4e8; }
.acct-card.selected { border-color: var(--accent); background: #f5f8ff; }
.acct-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #dbe4ff; color: #1d4ed8;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none;
}
.acct-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.acct-name { font-weight: 600; font-size: 13px; }
.acct-sub { font-size: 12px; color: var(--muted); }
.acct-card.dim { opacity: 0.55; cursor: not-allowed; }
.pick-box {
  width: 18px; height: 18px; border: 1.5px solid #c2cad6; border-radius: 5px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; color: #fff;
}
.acct-card.selected .pick-box { background: var(--accent); border-color: var(--accent); }

/* ---- 发布内容预览 ---- */
.pub-preview {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; min-height: 44px;
}
.pub-preview.empty { color: var(--muted); }
/* ---- 批量发布 ---- */
.batch-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: #f0f5ff; border: 1px solid #d6e2ff; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px;
}
.batch-info { font-size: 13px; }
.batch-accounts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.batch-accounts .topic-chip { font-size: 12px; padding: 3px 10px; }
.mat-card { position: relative; }
.mat-card.picked { outline: 2px solid var(--accent); outline-offset: -2px; }
.mat-pick {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer;
  border: 1.5px solid #d5dae2; background: rgba(255,255,255,0.92);
  color: #fff; font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.mat-pick:hover { border-color: var(--accent); }
.mat-pick.on { background: var(--accent); border-color: var(--accent); }

.final-preview {
  margin-top: 8px; padding: 9px 12px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.6;
  word-break: break-word;
}
.final-preview .muted { margin-right: 4px; }
.final-preview #pub-final-text.empty { color: var(--muted); }
.pub-quick-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.topic-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.pub-custom { margin: 4px 0 14px; }
.pub-custom summary { cursor: pointer; padding: 4px 0; }
.pub-custom summary:hover { color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---- 话题选择 ---- */
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.topic-chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--text);
  padding: 4px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.topic-chip:hover { border-color: #b6c4e8; }
.topic-chip.on { border-color: var(--accent); background: #f0f5ff; color: var(--accent-dark); font-weight: 600; }
.topic-chip .hot {
  font-size: 11px; background: #fff1f2; color: #e11d48; border-radius: 6px; padding: 0 5px;
}
.topic-chip.disabled { opacity: .45; cursor: not-allowed; }
.topic-chip .tag-cnt { font-size: 11px; color: var(--muted); }

/* ---- 记录 ---- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; background: #fafbfc; }
td.limit { max-width: 260px; word-break: break-all; }
td.nowrap { white-space: nowrap; }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto;
}
.modal {
  background: #fff; border-radius: 12px; width: 460px; max-width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2); padding: 18px;
}
.modal.wide { width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .compare { grid-template-columns: 1fr; } }
.compare figure { margin: 0; text-align: center; }
.compare img, .compare video { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.compare figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.radio-row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.radio-opt { border: 1.5px solid var(--line); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.radio-opt.selected { border-color: var(--accent); background: #f5f8ff; }
.radio-opt small { display: block; color: var(--muted); }

/* ---- 其他 ---- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: #111827; color: #fff; padding: 9px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); max-width: 80vw;
}
.toast.err { background: var(--err); }
.add-local input { margin-top: 10px; }
#upload-status { margin-top: 8px; }
#parse-result { margin-top: 10px; }
.parse-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.parse-card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty { color: #9aa2ad; text-align: center; padding: 30px 0; }
