:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #18181b;
  --text-dim: #71717a;
  --text-faint: #a1a1aa;
  --accent: #1d9bf0;
  --accent-soft: #e8f5fe;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --blue: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316;
    --surface: #1c1c20;
    --border: #2a2a30;
    --border-strong: #3a3a42;
    --text: #f4f4f5;
    --text-dim: #a1a1aa;
    --text-faint: #71717a;
    --accent: #4cb3f7;
    --accent-soft: #10263a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 显式 display 会盖掉 hidden 属性的 UA 样式，这里强制生效 */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 700;
}
.brand-title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--text-faint); line-height: 1.2; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.status-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot.on    { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.18); animation: pulse 2.2s infinite; }
.dot.warn  { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,.18); }
.dot.err   { background: var(--red);   box-shadow: 0 0 0 3px rgba(220,38,38,.18); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* 两个平台各一组：状态 + 启停按钮 */
.engine { display: flex; align-items: center; gap: 6px; }
.chip-name { font-weight: 600; color: var(--text); }

/* ============ 横幅 ============ */
.banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 11px 24px; font-size: 13px; flex-wrap: wrap;
}
.banner strong { margin-right: 8px; }
.banner-warn { background: #fef3c7; color: #78350f; }
.banner-info { background: #dbeafe; color: #1e3a5f; }
@media (prefers-color-scheme: dark) {
  .banner-warn { background: #3a2c0a; color: #fcd34d; }
  .banner-info { background: #17273f; color: #93c5fd; }
}
.banner-actions { display: flex; gap: 8px; }

/* ============ Tabs ============ */
.tabs {
  display: flex; gap: 2px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 11px 14px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-family: inherit; color: var(--text-dim);
  border-bottom: 2px solid transparent; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 550; }
.nav-group-label { align-self: center; padding: 0 5px 0 14px; border-left: 1px solid var(--border); color: var(--text-faint); font-size: 11px; white-space: nowrap; }
.workflow { display: grid; gap: 10px; }
.workflow p, .workflow-links { color: var(--text-dim); font-size: 13px; }
.workflow-actions, .workflow-links { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.workflow-links { margin-bottom: 16px; }
.setup-guide { display: grid; gap: 8px; }
.setup-guide p { color: var(--text-dim); }
[id^="settings-"] { scroll-margin-top: 85px; }
.badge {
  min-width: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}

main { max-width: 1080px; margin: 0 auto; padding: 20px 24px 60px; }
.panel { display: none; }
.panel.active { display: block; }

/* ============ 卡片 ============ */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.card-value { font-size: 30px; font-weight: 680; letter-spacing: -.02em; line-height: 1.15; }
.card-label { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.card-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; min-height: 17px; }
.accent-green { color: var(--green); }

/* ============ 区块 ============ */
.section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.section-head h2 { font-size: 14.5px; font-weight: 620; }
.section-head p { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

/* ============ 图表 ============ */
.chart {
  display: flex; align-items: flex-end; gap: 5px; height: 150px;
}
.bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; height: 100%; gap: 5px; min-width: 0;
}
.bar-num { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.bar {
  width: 100%; max-width: 34px; min-height: 3px;
  background: var(--border-strong); border-radius: 4px 4px 0 0;
  transition: height .4s ease;
}
.bar.today { background: var(--accent); }
.bar-day { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }

.author-list { display: flex; flex-direction: column; gap: 7px; }
.author-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.author-name { width: 130px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.author-bar { height: 7px; background: var(--accent); border-radius: 4px; min-width: 3px; }
.author-num { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 28px 0; }

/* ============ 审核队列 ============ */
.filter-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter {
  padding: 5px 12px; border-radius: 16px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-family: inherit; color: var(--text-dim);
}
.filter:hover { border-color: var(--border-strong); }
.filter.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }

.queue { display: flex; flex-direction: column; gap: 12px; }
.item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.item-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.item-author { font-weight: 600; font-size: 13.5px; }
.item-meta { font-size: 11.5px; color: var(--text-faint); }
.tag {
  padding: 1px 8px; border-radius: 5px; font-size: 11px; font-weight: 550;
  border: 1px solid transparent;
}
.tag-pending  { background: #fef3c7; color: #92400e; }
.tag-approved { background: #dbeafe; color: #1e40af; }
.tag-sent     { background: #dcfce7; color: #166534; }
.tag-failed   { background: #fee2e2; color: #991b1b; }
.tag-rejected { background: #f4f4f5; color: #52525b; }
.tag-skipped  { background: #f4f4f5; color: #71717a; }
.tag-blocked  { background: #ffedd5; color: #9a3412; }
.tag-ignored  { background: #f4f4f5; color: #52525b; }
@media (prefers-color-scheme: dark) {
  .tag-pending  { background: #3a2c0a; color: #fcd34d; }
  .tag-approved { background: #17273f; color: #93c5fd; }
  .tag-sent     { background: #0f2e1a; color: #86efac; }
  .tag-failed   { background: #3a1414; color: #fca5a5; }
  .tag-rejected { background: #27272a; color: #a1a1aa; }
  .tag-skipped  { background: #27272a; color: #a1a1aa; }
  .tag-blocked  { background: #3a1f0a; color: #fdba74; }
  .tag-ignored  { background: #27272a; color: #a1a1aa; }
}

.item-thumb {
  width: 44px; height: 44px; border-radius: 7px; object-fit: cover;
  flex: none; border: 1px solid var(--border); cursor: pointer; background: var(--bg);
}
.item-body { display: flex; gap: 12px; align-items: flex-start; }
.item-main { flex: 1; min-width: 0; }
/* 推文上下文：审核时先看清对方是在哪条推文下说的。
   刻意做得比评论本身轻，它是背景信息不是主体。 */
.note-context {
  display: flex; gap: 7px; align-items: baseline; margin-bottom: 7px;
  font-size: 12px; color: var(--text-dim); line-height: 1.5;
  word-break: break-word;
}
.note-label {
  flex: none; padding: 1px 6px; border-radius: 4px;
  background: var(--border); color: var(--text-dim);
  font-size: 11px; letter-spacing: .3px;
}
.note-context-missing { color: var(--amber, #b45309); font-style: italic; }
.quote {
  background: var(--bg); border-left: 2.5px solid var(--border-strong);
  padding: 9px 12px; border-radius: 0 7px 7px 0;
  font-size: 13px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
}
.draft {
  width: 100%; margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 13.5px; line-height: 1.6;
  resize: vertical; min-height: 62px;
}
.draft:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.draft[readonly] { color: var(--text-dim); }
.item-error {
  margin-top: 8px; font-size: 12px; color: var(--red);
  background: rgba(220,38,38,.07); padding: 7px 10px; border-radius: 6px;
  word-break: break-word;
}
.item-actions { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }

/* ============ 表单 ============ */
.form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-label { font-size: 12.5px; font-weight: 550; color: var(--text-dim); }
.field-hint { font-size: 11.5px; color: var(--text-faint); }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 13px;
}
textarea { line-height: 1.65; resize: vertical; font-size: 12.5px; }
#x-system_prompt, #safety-sensitive_keywords {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-msg { font-size: 12.5px; color: var(--text-dim); }
.form-msg.ok  { color: var(--green); }
.form-msg.err { color: var(--red); }

/* ============ 按钮 ============ */
.btn {
  padding: 7px 15px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 500;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--bg); border-color: var(--text-faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); background: var(--accent); }
.btn-ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ok:hover:not(:disabled) { filter: brightness(1.07); background: var(--green); }
.btn-danger-ghost { color: var(--red); border-color: var(--border-strong); }
.btn-danger-ghost:hover:not(:disabled) { background: rgba(220,38,38,.07); border-color: var(--red); }

/* ============ 日志 ============ */
.logs {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; line-height: 1.75;
  max-height: 62vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
}
.log-line { display: flex; gap: 9px; padding: 1px 0; word-break: break-word; }
.log-time { color: var(--text-faint); flex: none; }
.log-level { flex: none; width: 52px; font-weight: 600; }
.log-src { color: var(--text-faint); flex: none; width: 72px; }
.lv-INFO { color: var(--blue); }
.lv-WARNING { color: var(--amber); }
.lv-ERROR, .lv-CRITICAL { color: var(--red); }
.lv-DEBUG { color: var(--text-faint); }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px);
  padding: 10px 18px; border-radius: 9px;
  background: #18181b; color: #fff; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .22s; z-index: 999;
  max-width: 88vw; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }
.toast.ok  { background: var(--green); }

/* ============ 链接与计数 ============ */
.item-author a, .follower-name a { color: inherit; text-decoration: none; }
.item-author a:hover, .follower-name a:hover { text-decoration: underline; }
.item-link { font-size: 11.5px; color: var(--blue); text-decoration: none; }
.item-link:hover { text-decoration: underline; }
.char-count { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; text-align: right; }
.char-count.over { color: var(--red); font-weight: 600; }

.risk {
  font-size: 12px; line-height: 1.65; color: #9a3412;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 9px 12px;
}
@media (prefers-color-scheme: dark) {
  .risk { color: #fdba74; background: #2a1708; border-color: #5a3010; }
}
.notice.notice-warn { border-left-color: var(--amber); }

.notice {
  font-size: 12.5px; color: var(--text-dim); line-height: 1.65;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px; margin-bottom: 14px;
}

/* ============ X 新关注者 ============ */
.follower { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  object-fit: cover; background: var(--bg); border: 1px solid var(--border);
}
.follower-name { font-weight: 600; font-size: 13.5px; }
.follower-handle { color: var(--text-faint); font-size: 12.5px; }
.follower-stats { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.follower-bio {
  font-size: 13px; color: var(--text-dim); margin-top: 6px;
  white-space: pre-wrap; word-break: break-word;
}
.flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.flag {
  padding: 1px 7px; border-radius: 5px; font-size: 11px;
  background: #ffedd5; color: #9a3412;
}
@media (prefers-color-scheme: dark) {
  .flag { background: #3a1f0a; color: #fdba74; }
}

/* ============ 单向关注 ============ */
.filter-tools { display: flex; gap: 8px; align-items: center; }
.filter-tools select { width: auto; max-width: 100%; padding: 5px 8px; font-size: 12.5px; }
.select-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; font-size: 13px;
}
.select-bar.active { background: var(--accent-soft); border-color: var(--accent); }
.select-bar .sel-count { margin-right: auto; color: var(--text-faint); }
.select-bar.active .sel-count { color: var(--text); font-weight: 550; }
.sel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pick { width: 16px; height: 16px; margin-top: 14px; flex: none; cursor: pointer; accent-color: var(--accent); }
.load-more { text-align: center; margin-top: 14px; }
.notice .scan-line { margin-top: 4px; color: var(--text); }
.notice .scan-error { margin-top: 4px; color: var(--red); }

@media (max-width: 640px) {
  .topbar, .tabs, main, .banner { padding-left: 14px; padding-right: 14px; }
  .topbar { flex-wrap: wrap; }
  .topbar-right { flex-wrap: wrap; }
  .card-value { font-size: 25px; }
  .item-body { flex-direction: column; }
  .author-name { width: 88px; }
  .filter-tools { width: 100%; }
  .filter-tools select { flex: 1; min-width: 0; }
}

/* ============ 融合版：内容创作、图床预览、情报与复盘 ============ */
.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 780px) { .grid-2 { grid-template-columns: 1fr; } }

.pill-type {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}

.pill-pillar {
  background: var(--bg); border: 1px solid var(--border); color: var(--text-dim);
}


.pub-card {
  display: grid; grid-template-columns: 1fr 220px; gap: 16px;
}
.pub-card.no-img { grid-template-columns: 1fr; }
@media (max-width: 720px) { .pub-card { grid-template-columns: 1fr; } }

.pub-media {
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
}
.pub-thumb {
  width: 100%; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); object-fit: cover; max-height: 220px; cursor: zoom-in;
}
.thread-box {
  margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--border-strong);
  display: flex; flex-direction: column; gap: 6px;
}
.thread-seg {
  font-size: 12.5px; color: var(--text-dim); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px;
  white-space: pre-wrap;
}

.model-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.model-chip {
  padding: 3px 9px; font-size: 11.5px; border-radius: 6px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-dim);
}
.model-chip:hover { border-color: var(--accent); color: var(--accent); }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 6px; }

.workspace-nav { background: var(--bg); }
.settings-subtabs {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.subtab {
  padding: 6px 14px; border-radius: 18px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-family: inherit; color: var(--text-dim);
  transition: all .15s;
}
.subtab:hover { border-color: var(--border-strong); color: var(--text); }
.subtab.active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
details.section > summary { cursor: pointer; font-weight: 600; }
details.section[open] > summary { margin-bottom: 16px; }
.settings-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.settings-task { display: flex; flex-direction: column; gap: 7px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.settings-task span, .settings-task small { color: var(--text-dim); font-size: 12px; }
.settings-task strong { font-size: 14px; overflow-wrap: anywhere; }
.settings-automation-state { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--text-dim); line-height: 1.8; }
.settings-advanced { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.settings-advanced summary { cursor: pointer; font-weight: 600; }
.settings-advanced summary span { float: right; color: var(--text-dim); font-size: 12px; font-weight: 400; }
.settings-advanced[open] summary { margin-bottom: 14px; }
.settings-advanced .field-row { margin: 14px 0; }
.settings-original-link { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 14px; background: var(--accent-soft); border-radius: 10px; font-size: 13px; }
@media (max-width: 900px) { .settings-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .settings-overview { grid-template-columns: 1fr; } }
