/* ── CSS 变量（浅色主题） ── */
:root {
  --bg: #f8f9fb;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f1f6ff;
  --bg-mode-tab: #f1f4f9;
  --bg-mode-tab-active: #ffffff;
  --border: #e3e7ee;
  --control-border: #cfd6e1;
  --surface-soft: #f7f9fc;
  --text: #24282f;
  --text-secondary: #454e5b;
  --text-muted: #626c7a;
  --text-sidebar: #454e5b;
  --accent: #2563eb;
  --accent-hover: #1d55d0;
  --accent-light: #edf4ff;
  --danger: #c63746;
  --danger-light: #fff2f3;
  --success: #16814b;
  --warning: #9a6700;
  --shadow: 0 1px 3px rgba(30,42,61,0.035);
  --shadow-md: 0 8px 28px rgba(30,42,61,0.12);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 200px;
  --font-body: 13px;
  --font-ui: 12px;
  --font-heading: 13px;
  --font-note: 12px;
  --font-stat: 28px;
  --transition: 0.18s ease;
}

/* Match pywebview's text_select=False: command labels, buttons, tabs and
   table chrome are not copyable. Explicitly opt text-bearing controls back
   in below so logs and user-entered values remain usable. */
body {
  user-select: none;
  -webkit-user-select: none;
}
body * , body *::before, body *::after {
  user-select: none !important;
  -webkit-user-select: none !important;
}
body input,
body textarea,
body select,
body [contenteditable="true"],
body .log-box,
body .selectable {
  user-select: text !important;
  -webkit-user-select: text !important;
}
body .log-box * , body .selectable * {
  user-select: text !important;
  -webkit-user-select: text !important;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d2e;
  --bg-sidebar: #13151f;
  --bg-input: #22263a;
  --bg-hover: #22263a;
  --bg-mode-tab: #22263a;
  --bg-mode-tab-active: #2d3150;
  --border: #2a2e45;
  --control-border: #46506a;
  --surface-soft: #202537;
  --text: #e8eaf6;
  --text-secondary: #d0d7e4;
  --text-muted: #a7b1c3;
  --text-sidebar: #b7c1d2;
  --accent: #6b8fff;
  --accent-hover: #5a7ef0;
  --accent-light: #1e2540;
  --danger: #f87171;
  --danger-light: #2a1a1a;
  --success: #4ade80;
  --warning: #fbbf24;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
}

/* ── 重置 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  transition: background var(--transition), color var(--transition);
}

/* Native buttons otherwise keep the browser's default control font. Explicit
   monospace controls retain their own, more specific font-family rules. */
button { font-family: inherit; }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── 侧边栏 ── */
#sidebar {
  --sidebar-row-height: clamp(30px, calc((100vh - 144px) / 15), 40px);
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
  transition: background var(--transition);
}

#sidebar .sidebar-logo {
  position: relative;
  flex: none;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 6px 10px;
  color: var(--text);
}
#sidebar .sidebar-brand-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#sidebar .logo-text {
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sidebar .sidebar-license {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-sidebar);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 16px;
  white-space: nowrap;
}
#sidebar .license-status-dot {
  width: 4px;
  height: 4px;
  flex: none;
  border-radius: 50%;
  background: var(--text-muted);
}
#sidebar .sidebar-license[data-loaded="true"] .license-status-dot { background: var(--success); }
#sidebar .sidebar-more-btn {
  width: 28px;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-sidebar);
  cursor: pointer;
}
#sidebar .sidebar-more-btn:hover,
#sidebar .sidebar-more-btn[aria-expanded="true"] { background: var(--bg-hover); }
#sidebar .sidebar-more-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 4px;
  width: 172px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-sidebar);
  box-shadow: var(--shadow-md);
  z-index: 5;
}
#sidebar .sidebar-more-menu[hidden] { display: none; }
#sidebar .license-unbind-btn {
  display: block;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--danger);
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
#sidebar .license-unbind-btn:hover:not(:disabled) {
  background: var(--danger-light);
}
#sidebar .license-unbind-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#sidebar .sidebar-nav {
  display: flex; flex-direction: column; gap: 2px; flex: 1;
  position: relative; isolation: isolate;
  min-height: 0;
  margin-top: 6px;
}

#sidebar .nav-indicator {
  position: absolute; top: 0; left: 0; z-index: 0;
  background: var(--accent-light); border-radius: var(--radius-sm);
  pointer-events: none;
}
#sidebar .sidebar-nav.nav-indicator-ready .nav-indicator {
  transition: transform 160ms cubic-bezier(.2,.8,.2,1), width 160ms ease, height 160ms ease, background 160ms ease;
}

#sidebar .nav-item {
  position: relative; z-index: 1; flex: 0 0 var(--sidebar-row-height); width: 100%; height: var(--sidebar-row-height); min-height: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  border: none; background: transparent; font-family: inherit; text-align: left;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  cursor: pointer;
  text-decoration: none;
  font-size: var(--font-body);
  line-height: 18px;
  transition: background 160ms ease, color 160ms ease;
  user-select: none;
}
#sidebar .nav-item:hover { background: var(--bg-hover); color: var(--accent); }
#sidebar .nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
#sidebar .sidebar-nav.nav-has-indicator .nav-item.active { background: transparent; }
#sidebar .nav-icon { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: none; }
#sidebar .nav-icon svg { display: block; width: 18px; height: 18px; transition: transform 160ms cubic-bezier(.2,.8,.2,1); }
#sidebar .nav-item:hover .nav-icon svg { transform: translateX(1px) scale(1.05); }
#sidebar .nav-item:active .nav-icon svg { transform: scale(.94); }
#sidebar .nav-item:focus-visible,
#sidebar .sidebar-more-btn:focus-visible,
#sidebar .license-unbind-btn:focus-visible,
#sidebar .instance-status:focus-visible,
#sidebar .theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) {
  #sidebar .sidebar-nav.nav-indicator-ready .nav-indicator, #sidebar .nav-item, #sidebar .nav-icon svg { transition: none; }
  #sidebar .nav-item:hover .nav-icon svg, #sidebar .nav-item:active .nav-icon svg { transform: none; }
}
#sidebar .nav-beta {
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
  color: #fff; background: var(--accent);
  padding: 1px 5px; border-radius: 4px;
  margin-left: 4px; vertical-align: middle; line-height: 1.6;
  opacity: 0.85;
}

#sidebar .sidebar-bottom {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 4px 2px;
  border-top: 1px solid var(--border);
  flex: none;
}
#sidebar .instance-status {
  flex: 1;
  min-width: 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-radius: 7px;
  color: var(--text-sidebar);
  font-size: 12px;
  line-height: 16px;
}
#sidebar .instance-status svg { flex: none; }
#sidebar .instance-status-path {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sidebar .theme-toggle {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none; border: none; cursor: pointer;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sidebar);
  transition: background var(--transition);
}
#sidebar .theme-toggle svg { width: 16px; height: 16px; }
#sidebar #theme-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#sidebar .instance-status:hover,
#sidebar .theme-toggle:hover { background: var(--bg-hover); }

/* ── 主内容 ── */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 24px 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── 页面切换 ── */
.page { display: none; }
.page.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* two-col 所在页面撑满 */
.page.active .two-col {
  flex: 1;
  min-height: 0;
}

/* ── 页头 ── */
.page-header {
  display: flex; align-items: center; justify-content: flex-end;
  margin-bottom: 12px;
  flex-shrink: 0;
  gap: 16px;
}
.page-title { font-size: 22px; font-weight: 700; flex: 0 0 auto; }
.page-title-status { margin-right: auto; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vf-actions {
  gap: 5px;
  flex-wrap: nowrap;
  min-width: 0;
  flex: 1;
  justify-content: flex-end;
  overflow: visible;
}
.vf-actions .btn-sm { padding: 4px 7px; }
.vf-actions .toggle-label { flex: 0 0 auto; gap: 5px; }
.vf-actions .count-badge { margin-left: 2px; padding: 1px 6px; }

/* ── 卡片 ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}
.card-title {
  font-size: var(--font-heading); font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 14px;
}

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: var(--font-ui); font-weight: 500;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: var(--danger-light); color: var(--danger); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 24%, transparent); }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-ghost {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--control-border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }
.btn-ghost.btn-danger { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.btn-ghost.btn-warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); border-color: rgba(245, 158, 11, 0.45); }
.btn-sm { padding: 4px 10px; font-size: var(--font-ui); }

/* Telegram 原生核对清单卡片编辑器 */
.checklist-card-preview,
.checklist-append-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  padding: 14px;
}
.checklist-card-title-row,
.checklist-append-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checklist-card-icon {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}
.checklist-card-title {
  flex: 1;
  font-weight: 600;
}
.checklist-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.checklist-append-head > span:first-child {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* 账号管理页顶部按钮组：压成单行，优先使用右侧空白宽度 */
.acct-actions {
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 5px;
  overflow: visible;
}
.acct-actions .btn {
  padding: 5px 9px;
  font-size: 12px;
  letter-spacing: 0;
  flex: 0 0 auto;
}

/* ── 表单 ── */
.session-converter-layout {
  display: grid;
  grid-template-columns: minmax(380px, 1.25fr) minmax(360px, 0.9fr);
  gap: 12px;
  min-height: 0;
  flex: 1;
}
.session-converter-accounts {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.session-converter-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.session-converter-settings {
  flex: 0 0 auto;
  margin-bottom: 12px;
  padding: 12px 14px;
}
.session-converter-settings .form-group {
  margin-bottom: 0;
}
.session-converter-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.session-converter-settings-grid .form-group {
  min-width: 0;
}
.session-converter-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.session-converter-table td,
.session-converter-table th {
  padding: 7px 8px;
  font-size: 12px;
}
.session-converter-proxies {
  height: 58px;
  min-height: 58px;
  max-height: 58px;
  resize: none;
  line-height: 1.45;
}
.session-converter-proxy-group {
  grid-column: 1 / -1;
  margin-bottom: 0;
}
#tools-panel-session-converter .bc-log-card {
  flex: 1;
  min-height: 0;
  margin-top: 0;
}
@media (max-width: 980px) {
  .session-converter-layout {
    grid-template-columns: 1fr;
  }
  .session-converter-settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: var(--font-ui); font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

.input, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: var(--font-body);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.input:focus-visible, .textarea:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); opacity: 1; }
.input:disabled, .textarea:disabled { background: var(--surface-soft); color: var(--text-muted); }
.textarea { resize: vertical; min-height: 80px; }

.range-input { display: flex; align-items: center; gap: 6px; }
.range-input .input { width: 70px; flex: none; }
.range-input span { color: var(--text-muted); }

.input-row { display: flex; gap: 8px; align-items: flex-start; }
.input-row .input { flex: 1; }

/* ── 复选框 / 开关 ── */
.toggle-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 4px 0;
  font-size: var(--font-ui); color: var(--text);
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── 模式标签 ── */
.mode-tabs {
  display: flex; gap: 4px;
  background: var(--bg-mode-tab);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
}
.mode-tab {
  flex: 1; padding: 6px 8px;
  border: none; cursor: pointer;
  border-radius: 6px;
  font-size: var(--font-ui); font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  transition: all var(--transition);
}
.mode-tab.active {
  background: var(--bg-mode-tab-active);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.mode-panel { display: none; }
.mode-panel.active { display: block; }

/* ── 状态徽章 ── */
.status-badge {
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px; font-weight: 600;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.status-badge.running { background: #dcfce7; color: #16a34a; border-color: #86efac; }
.status-badge.stopping { background: #fef3c7; color: #d97706; border-color: #fcd34d; }

[data-theme="dark"] .status-badge.running { background: #14532d; color: #4ade80; border-color: #166534; }
[data-theme="dark"] .status-badge.stopping { background: #451a03; color: #fbbf24; border-color: #78350f; }

.count-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 11px; font-weight: 600;
  margin-left: 4px;
}

/* ── 两列布局 ── */
.two-col {
  display: flex; gap: 16px;
  align-items: stretch;
  min-height: 0;
}
.col-left { flex: 0 0 340px; display: flex; flex-direction: column; }
.col-right { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* col-left 最后一个卡片撑满剩余高度 */
.col-left .card:last-child {
  flex: 1;
  margin-bottom: 0;
}

/* col-right 最后一个卡片撑满剩余高度 */
.col-right .card:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.col-right .card:last-child .log-box {
  flex: 1;
  height: auto;
  min-height: 160px;
}

/* ── 群发模式面板行 ── */
.bc-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 28px;
}
.bc-panel-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.bc-panel-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── 统计表格 ── */
.stats-table-wrap { overflow-x: auto; overflow-y: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: var(--font-body); table-layout: fixed; }
.stats-table th {
  text-align: left; padding: 6px 8px;
  color: var(--text-secondary); font-weight: 600;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface-soft);
  white-space: nowrap;
}
.stats-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table tr:hover td { background: var(--bg-hover); }
.stats-table .broadcast-stat-row { height: 38px; }
.stats-table .broadcast-stat-row > td { height: 38px; box-sizing: border-box; }
.stats-table .broadcast-spacer > td { padding: 0 !important; border: 0 !important; width: auto !important; line-height: 0; font-size: 0; background: transparent !important; }
#broadcast-stats-scroll { overflow-anchor: none; }

/* 列宽：原账号列表序号固定，账号和手机号稍宽 */
.stats-table th:nth-child(1),
.stats-table td:nth-child(1) { width: 48px; text-align: center; }
.stats-table th:nth-child(2),
.stats-table td:nth-child(2) { width: 25%; }
.stats-table th:nth-child(3),
.stats-table td:nth-child(3) { width: 18%; }
.stats-table th:nth-child(4),
.stats-table td:nth-child(4),
.stats-table th:nth-child(5),
.stats-table td:nth-child(5),
.stats-table th:nth-child(6),
.stats-table td:nth-child(6),
.stats-table th:nth-child(7),
.stats-table td:nth-child(7) { width: 8%; text-align: center; }
.stats-table th:nth-child(8),
.stats-table td:nth-child(8) { width: 12%; }
.stats-table th:nth-child(9),
.stats-table td:nth-child(9) { width: 64px; text-align: right; }

/* 统计卡片去掉 card-title 后减少顶部 padding */
.bc-stats-card { padding: 0; }
.bc-stats-card .stats-table-wrap { padding: 0; }

/* ── 日志框 ── */
.log-box {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  height: 160px;
  overflow-y: auto;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
/* 在 flex 卡片内由父级撑高，不用固定 height */
.bc-log-card .log-box { height: 100%; min-height: 0; }
.col-right .card:last-child .log-box { height: 100%; min-height: 0; }

/* ── 账号列表 ── */
#page-accounts.active {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.account-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(79, 126, 248, 0.08);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  pointer-events: none;
}
.account-drop-overlay.active { display: flex; }
.account-drop-box {
  min-width: 260px;
  padding: 18px 22px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.account-drop-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.account-drop-subtitle {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.account-list-wrap {
  flex: 0 1 auto;
  min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  padding: 0;
}

.select-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  margin-bottom: 10px;
}
.checkbox-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: var(--font-ui); }
.checkbox-label input { accent-color: var(--accent); width: 15px; height: 15px; }
.select-count { color: var(--text-muted); font-size: 12px; flex: 1; }
.account-range-picker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.account-range-picker .input {
  width: 54px;
  flex: 0 0 54px;
  padding: 4px 6px;
  font-size: 12px;
  text-align: center;
}
.account-range-picker .btn { white-space: nowrap; }
@media (max-width: 760px) {
  .select-bar { flex-wrap: wrap; gap: 8px; }
  .select-count { flex: 1 1 auto; }
  .account-range-picker { order: 3; width: 100%; }
  .select-bar .account-range-picker { order: 2; width: auto; }
  .select-bar .select-count { order: 3; }
}

/* ── 账号表格 ── */
.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.col-check  { width: 56px; }
.col-name   { width: 200px; }
.col-id     { width: 102px; }
.col-phone  { width: 132px; }
.col-status { width: 90px; }
.col-proxy  { width: 82px; }
.col-premium{ width: 112px; }
.col-spam   { width: 130px; }
#page-accounts .account-table { min-width: 904px; }

.account-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-weight: 600; font-size: 12px;
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.account-table tbody tr.account-item {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.account-table tbody tr.account-item:hover { background: var(--bg-input); }
.account-table td {
  padding: 7px 8px;
  vertical-align: middle;
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-check { text-align: left; padding-left: 2px !important; white-space: nowrap; }
.ac-index { display: inline-block; width: 22px; margin-right: 8px; color: var(--text); text-align: right; vertical-align: middle; font-size: 13px; font-weight: 500; }
.ac-check input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; vertical-align: middle; }
.ac-name  { font-weight: 500; }
.ac-id, .ac-phone, .ac-status, .ac-proxy { white-space: nowrap; }
.ac-status, .ac-proxy, .ac-premium { text-align: center; }
.account-table thead th { text-align: left; }
.account-table thead th.th-center { text-align: center; }
.ac-spam  { white-space: normal; text-align: center; padding-left: 12px; }

.account-spam-wrap { display: flex; flex-direction: column; gap: 1px; }
.account-spam { font-size: 11px; font-weight: 600; color: #f59e0b; }
.account-spam-detail { font-size: 10px; color: #fbbf24; }
.sc-account-row { display: flex; align-items: center; gap: 7px; }
.sc-account-row .sc-account-name { flex: 1; min-width: 0; }
.bc-account-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; color: var(--text-muted); font-size: 12px; }
.bc-function-menu-wrap { position: relative; }
.bc-function-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 80; min-width: 210px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); box-shadow: 0 8px 28px #0003; }
.bc-function-menu[hidden] { display: none; }
.bc-function-menu > button { display: flex; justify-content: space-between; align-items: center; width: 100%; margin: 2px 0; }
.bc-function-menu > label { display: flex; margin: 8px 4px; }
.bc-direct-menu-wrap { position: relative; flex-shrink: 0; }
.bc-direct-settings-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 80; width: 270px; max-width: calc(100vw - 24px); padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); box-shadow: 0 8px 28px #0003; }
.bc-direct-settings-menu[hidden] { display: none; }
.bc-direct-settings-menu > .toggle-label { display: flex; margin: 2px 0; min-height: 26px; }
.bc-direct-suffix-setting { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; margin: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.bc-direct-suffix-lengths { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-left: 20px; }
.bc-direct-settings-menu input:focus-visible,
.bc-direct-settings-menu select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bc-direct-suffix-lengths .bc-direct-affix-select { flex: 1; min-width: 0; width: auto; padding: 5px 7px; font-size: 12px; }
.bc-account-row-actions { padding: 6px 8px !important; overflow: visible !important; white-space: nowrap; }
.bc-account-row-actions input { width: 12px; height: 12px; margin: 0; vertical-align: middle; }
.bc-account-more { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; min-width: 24px; padding: 0; margin: 0 0 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font: inherit; font-size: 18px; line-height: 1; vertical-align: middle; cursor: pointer; }
.bc-account-more:hover { background: var(--bg-hover); color: var(--text); }
.bc-account-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bc-account-action-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bc-account-content-body { display: flex; flex-direction: column; gap: 12px; }
.bc-content-hint { color: var(--text-muted); font-size: 12px; line-height: 1.6; margin: 0; }
.bc-account-content-context { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
.bc-account-content-context strong { padding: 3px 10px; border-radius: 6px; background: var(--bg-input); color: var(--text); font-size: 12px; }
.bc-content-source-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bc-content-source-choice { padding: 11px 12px; text-align: left; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-card); color: var(--text); cursor: pointer; font-family: inherit; }
.bc-content-source-choice strong, .bc-content-source-choice span { display: block; }
.bc-content-source-choice strong { font-size: 13px; margin-bottom: 4px; }
.bc-content-source-choice span { color: var(--text-muted); font-size: var(--font-note); line-height: 1.5; }
.bc-content-source-choice[aria-pressed="true"] { border-color: var(--accent); background: var(--bg-input); box-shadow: inset 0 0 0 1px var(--accent); }
.bc-content-source-choice[aria-pressed="true"] strong { color: var(--accent); }
.bc-content-source-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#bc-account-content-fields { display: flex; flex-direction: column; gap: 10px; }
#bc-account-content-fields textarea { min-height: 68px; max-height: 150px; resize: vertical; }
.bc-content-section { display: flex; flex-direction: column; gap: 8px; }
.bc-content-section[hidden], #bc-account-direct-list[hidden], .bc-account-content-modal button[hidden], .bc-account-content-modal p[hidden] { display: none; }
.bc-account-mode-options { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-input); }
.bc-account-option-row { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.bc-account-mode-options .toggle-label { font-size: 12px; gap: 6px; padding: 0; }
.bc-account-option-range { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--text-muted); font-size: 12px; }
.bc-account-option-range .input { width: 60px; padding: 5px 7px; }
.bc-account-option-range .bc-account-affix-select { width: 104px; }
.bc-account-option-range .bc-account-delay { width: 82px; }
.bc-account-mode-options input:disabled { opacity: 0.55; }
#bc-account-direct-options-conflict { color: var(--danger); }
.bc-content-section .form-group { margin-bottom: 0; }
.bc-content-section-heading, .bc-content-composer-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text); font-size: 12px; }
.bc-content-section-heading strong { font-size: 13px; }
.bc-content-composer-heading { min-height: 26px; }
.bc-content-media-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
#bc-account-media-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 11px; }
.bc-content-composer-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.bc-content-composer-footer .btn { flex-shrink: 0; }
.bc-content-extra { border-top: 1px solid var(--border); padding-top: 10px; }
.bc-content-extra summary { cursor: pointer; color: var(--text); font-size: 12px; line-height: 1.7; }
.bc-content-extra summary .bc-content-hint { margin-left: 6px; }
.bc-content-extra .form-group { margin: 10px 0 6px; }
.bc-content-timing-hint { padding-top: 10px; border-top: 1px solid var(--border); }
#bc-account-direct-list { max-height: 140px; overflow-y: auto; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; }
.bc-account-direct-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.bc-account-direct-item:last-child { border-bottom: 0; }
.bc-account-direct-number { flex: 0 0 18px; color: var(--text-muted); font-size: 11px; padding-top: 3px; }
.bc-account-direct-preview { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 65px; overflow: hidden; font-size: 12px; line-height: 1.5; }
.bc-account-direct-actions { display: flex; flex-shrink: 0; gap: 3px; }
.bc-account-direct-item small { display: block; color: var(--text-muted); }
.sc-account-index { width: 24px; color: var(--text); text-align: right; font-size: 13px; flex: 0 0 24px; }
.sc-account-row input[type="checkbox"] { margin: 0; vertical-align: middle; }
.account-status, .proxy-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  line-height: 18px; vertical-align: middle;
  border-radius: 99px; display: inline-block; white-space: nowrap;
}
.proxy-badge {
  max-width: 82px;
  padding: 2px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--bg-input);
  color: var(--text-muted);
}
.proxy-badge.connected_proxy { background: #dbeafe; color: #2563eb; }
.proxy-badge.connected_direct { background: #f3f4f6; color: #6b7280; }
.proxy-badge.pending_proxy { background: #f3f4f6; color: #6b7280; }
.proxy-badge.pending_direct { background: var(--bg-input); color: var(--text-muted); }
.proxy-badge.error { background: #fee2e2; color: #dc2626; }
.status-normal { background: #dcfce7; color: #16a34a; }
.status-frozen { background: #fef3c7; color: #d97706; }
.status-banned { background: #fee2e2; color: #dc2626; }
.status-unknown { background: var(--bg-input); color: var(--text-muted); }

[data-theme="dark"] .status-normal { background: #14532d; color: #4ade80; }
[data-theme="dark"] .status-frozen { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .status-banned { background: #450a0a; color: #f87171; }
[data-theme="dark"] .proxy-badge.connected_proxy { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .proxy-badge.connected_direct { background: #272b3f; color: #9ca3af; }
[data-theme="dark"] .proxy-badge.pending_proxy { background: #272b3f; color: #9ca3af; }
[data-theme="dark"] .proxy-badge.error { background: #450a0a; color: #f87171; }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px; font-size: 13px; }

/* 账号选择弹窗列表 */
.sc-account-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  cursor: pointer;
}
.sc-account-row:hover { background: var(--bg-input); }
.sc-account-row input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; flex-shrink: 0; cursor: pointer; }
.sc-account-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.clone-task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
}

.clone-task-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.clone-task-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.clone-task-item.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.clone-task-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--font-heading);
  font-weight: 600;
  color: var(--text);
}

.clone-task-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clone-task-title .status-badge { flex-shrink: 0; white-space: nowrap; }
.clone-task-item { flex-shrink: 0; }

.clone-task-meta {
  margin-top: 4px;
  font-size: var(--font-note);
  color: var(--text-muted);
  line-height: 1.45;
}

#page-clone .clone-summary-card,
#page-clone .col-right > .clone-stats-card:last-child { flex: 0 0 auto; margin-bottom: 0; }
#page-clone .col-right > .bc-log-card { flex: 0 0 160px; min-height: 160px; }
/* 余下高度用于任务列表和群链接输入，摘要与统计保持紧凑。 */
#page-clone .clone-task-sidebar > .card { flex: 0 0 auto; }
#page-clone .clone-task-sidebar > .clone-list-card { display: flex; flex-direction: column; flex: 1 0 156px; min-height: 156px; }
#page-clone .clone-list-card > .card-title { flex: none; }
#page-clone .clone-task-list { flex: 1; min-height: 0; max-height: none; }
#page-clone .clone-config-card { display: flex; flex-direction: column; flex: 1 0 auto; }
#page-clone .clone-config-card > :not(.clone-chat-fields) { flex: none; }
#page-clone .clone-chat-fields { flex: 1; min-height: 142px; }
#page-clone .clone-chat-fields > .form-group { display: flex; flex-direction: column; min-height: 0; }
#page-clone .clone-chat-fields .textarea { flex: 1; height: auto !important; min-height: 120px; }
#page-clone .clone-workflow-card { container-type: inline-size; }
#page-clone .clone-workflow-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
#page-clone .clone-workflow-grid > .form-group { display: flex; flex-direction: column; min-width: 0; }
#page-clone .clone-workflow-grid > .form-group > label { line-height: 18px; white-space: nowrap; }
#page-clone .clone-workflow-grid .input { height: 36px; }
#page-clone .clone-history-hours-control { position: relative; }
#page-clone .clone-history-hours-control > .input { padding-right: 78px; }
#page-clone .clone-history-hours-hint { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 11px; line-height: 18px; color: var(--text-muted); white-space: nowrap; pointer-events: none; }
@container (max-width: 580px) {
  #page-clone .clone-workflow-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.clone-task-summary { font-size: var(--font-ui); color: var(--text-secondary); line-height: 1.5; }
.clone-summary-state { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.clone-summary-phase, .clone-summary-label { color: var(--text-muted); }
.clone-summary-details { display: grid; gap: 6px; }
.clone-summary-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.clone-summary-row .clone-summary-value { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clone-summary-value { color: var(--text); font-variant-numeric: tabular-nums; min-width: 0; }
.clone-summary-accounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 0; margin-top: 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.clone-summary-accounts > div, .clone-summary-progress > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.clone-summary-accounts .clone-summary-value { font-weight: 500; }
.clone-summary-progress { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.clone-summary-progress .clone-summary-value { font-size: var(--font-body); font-weight: 600; }
.clone-summary-error { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.clone-summary-error .clone-summary-value { color: var(--danger); overflow-wrap: anywhere; }

/* ── 群发页专属布局 ── */
#page-broadcast.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#page-broadcast .page-header {
  margin-bottom: 12px;
}
#page-broadcast .page-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
#page-broadcast .page-title-status {
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1;
}
#page-broadcast .header-actions {
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 3px;
  overflow: visible;
  padding-bottom: 1px;
}
#page-broadcast .header-actions .btn {
  padding: 3px 5px;
  font-size: 12px;
  flex: 0 0 auto;
  min-height: 26px;
}
#page-broadcast .header-actions .toggle-label {
  flex: 0 0 auto;
  font-size: 12px;
  gap: 4px;
  min-height: 26px;
}
#page-broadcast .bc-round-limit {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  margin: 0 2px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
#page-broadcast .bc-round-limit .input {
  width: 48px;
  min-height: 26px;
  padding: 3px 5px;
  font-size: 12px;
}
#page-broadcast .header-actions .count-badge {
  margin-left: 2px;
  padding: 1px 4px;
  font-size: 10px;
}

/* ── 群发顶部设置卡片（两行布局） ── */
.bc-top-card {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  margin-bottom: 10px;
  flex-shrink: 0;
  gap: 8px;
}

#page-broadcast .bc-run-compact,
#page-broadcast .bc-run-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
#page-broadcast .bc-run-toggle { min-width: 86px; }
#page-broadcast .bc-run-switch-icon { color: var(--text-muted); }
#page-broadcast .bc-run-links[hidden] { display: none; }

/* 第一行：间隔设置，横向一行 */
.bc-row1 {
  display: flex;
  align-items: center;
  gap: 6px;
}

#page-broadcast .bc-row1 {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}

#page-broadcast .bc-row1 .bc-sm-label,
#page-broadcast .bc-row1 .bc-num {
  flex-shrink: 0;
}

/* 第二行：模式 tab + 参数，横向一行，细线分隔 */
.bc-row2 {
  display: flex;
  align-items: center;
  gap: 0;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* 模式 tab，固定宽度不撑大 */
.bc-mode-tabs {
  display: flex;
  gap: 3px;
  background: var(--bg-mode-tab);
  border-radius: var(--radius-sm);
  padding: 3px;
  flex-shrink: 0;
}
.bc-mode-pill {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all var(--transition);
}
.bc-mode-pill.active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.bc-mode-pill:hover:not(.active) { color: var(--text); }
.bc-mode-pill:disabled { cursor: default; opacity: .7; }
@media (max-width: 1100px) {
  #page-broadcast .bc-row1 { flex-wrap: wrap; overflow: visible; row-gap: 6px; }
  #page-broadcast .bc-row2 { flex-wrap: wrap; row-gap: 6px; }
  #page-broadcast .bc-mode-tabs { max-width: 100%; overflow-x: auto; }
  #page-broadcast .bc-param-wrap { flex-basis: 100%; }
  #page-broadcast .bc-param-panel { flex-wrap: wrap; }
  #page-broadcast .bc-row2 > .bc-row-sep { display: none; }
  #page-broadcast .bc-param-panel .toggle-label span { white-space: nowrap; }
}

/* 参数区，撑满剩余 */
.bc-param-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.bc-param-panel {
  display: none;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  width: 100%;
}
.bc-param-panel.active { display: flex; }

/* 共用小元素 */
.bc-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.bc-num {
  width: 52px !important;
  padding: 4px 6px !important;
  font-size: var(--font-body) !important;
  text-align: center;
}
.bc-tilde, .bc-unit { font-size: 12px; color: var(--text-muted); }
.bc-datetime {
  padding: 4px 6px !important;
  font-size: var(--font-body) !important;
  width: 148px !important;
}
.bc-time {
  padding: 4px 6px !important;
  font-size: var(--font-body) !important;
  width: 88px !important;
  flex-shrink: 0;
}
.bc-sm-label { font-size: 12px !important; }

.broadcast-assist-grid {
  display: grid;
  gap: 12px;
}
.broadcast-assist-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg-card);
}
.broadcast-assist-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}
.broadcast-assist-title {
  font-size: var(--font-heading);
  font-weight: 600;
  color: var(--text);
}
.broadcast-assist-sub,
.broadcast-assist-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.broadcast-assist-sub { margin-top: 3px; }
.broadcast-assist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}
.broadcast-assist-row > label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  width: 64px;
  flex-shrink: 0;
}
.broadcast-assist-toggle {
  margin-top: 8px;
  font-size: 12px;
}
.broadcast-assist-hint {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.broadcast-refill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  flex-wrap: wrap;
}
.broadcast-refill-row + .broadcast-refill-row {
  margin-top: 8px;
}
.broadcast-refill-row > label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
}
.broadcast-refill-links {
  min-height: 150px;
  line-height: 1.5;
  resize: vertical;
}

.vf-scope-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.vf-scope-actions.import-fingerprint-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.vf-scope-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.vf-scope-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.vf-scope-title {
  display: block;
  font-size: var(--font-heading);
  font-weight: 600;
  margin-bottom: 6px;
}
.vf-scope-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* 行内竖线分隔 */
@media (max-width: 720px) {
  .vf-scope-actions.import-fingerprint-actions {
    grid-template-columns: 1fr;
  }
}

.bc-row-sep {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 6px;
}
.bc-vsep {
  display: inline-block;
  width: 1px;
  height: 14px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 6px;
}

.bc-top-card .toggle-label { font-size: 12px; }
.bc-top-card .btn-sm { padding: 3px 8px; font-size: var(--font-ui); }
#page-broadcast .bc-top-card .btn-sm { font-size: 12px; }
.bc-top-card .count-badge { font-size: 10px; padding: 1px 5px; }

/* 旧的 bc-top-row 样式保留给私信页使用 */
.bc-top-row {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  margin-bottom: 10px;
  align-items: stretch;
}
.bc-interval-card { flex: 0 0 auto; margin-bottom: 0; padding: 12px 14px; }
.bc-mode-card { flex: 1; min-width: 0; margin-bottom: 0; padding: 12px 14px; }
.bc-top-row .card-title { margin-bottom: 8px; font-size: var(--font-heading); }
.bc-top-row label { font-size: var(--font-ui); margin-bottom: 4px; }
.bc-top-row .input { padding: 5px 8px; font-size: var(--font-body); }
.bc-top-row .mode-tabs { margin-bottom: 10px; padding: 3px; flex-wrap: nowrap; }
.bc-top-row .mode-tab { padding: 4px 10px; font-size: 12px; white-space: nowrap; flex: 1; }
.bc-top-row .toggle-label { font-size: 12px; padding: 2px 0; }
.bc-top-row .btn-sm { padding: 3px 8px; font-size: var(--font-ui); }
.bc-top-row .count-badge { font-size: 10px; padding: 1px 6px; }

/* 旧的 bc-top-row 样式保留给私信页使用 */
.bc-top-row {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  margin-bottom: 10px;
  align-items: stretch;
}
.bc-interval-card { flex: 0 0 auto; margin-bottom: 0; padding: 12px 14px; }
.bc-mode-card { flex: 1; min-width: 0; margin-bottom: 0; padding: 12px 14px; }
.bc-top-row .card-title { margin-bottom: 8px; font-size: var(--font-heading); }
.bc-top-row label { font-size: var(--font-ui); margin-bottom: 4px; }
.bc-top-row .input { padding: 5px 8px; font-size: var(--font-body); }
.bc-top-row .mode-tabs { margin-bottom: 10px; padding: 3px; flex-wrap: nowrap; }
.bc-top-row .mode-tab { padding: 4px 10px; font-size: 12px; white-space: nowrap; flex: 1; }
.bc-top-row .toggle-label { font-size: 12px; padding: 2px 0; }
.bc-top-row .btn-sm { padding: 3px 8px; font-size: var(--font-ui); }
.bc-top-row .count-badge { font-size: 10px; padding: 1px 6px; }

/* 中间统计：flex 撑满，内部滚动 */
.bc-stats-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}
.bc-stats-card .stats-table-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* 底部日志：固定高度，不抢账号统计空间 */
.bc-log-card {
  flex: 0 0 160px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  padding: 0;
  overflow: hidden;
}
/* 日志标题行压缩 */
.bc-log-card .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--font-heading);
}
.bc-log-card .log-box {
  flex: 1;
  height: 100%;
  min-height: 0;
  border-radius: 0;
  border: none;
}
.bc-log-card .log-box {
  flex: 1;
  height: 100%;
  min-height: 0;
}

/* ── 私信页专属布局 ── */
#page-dm.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#page-dm .page-header {
  margin-bottom: 12px;
}
#page-dm .page-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
#page-dm .page-title-status {
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1;
}
#page-dm .header-actions {
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 3px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 1px;
}
#page-dm .header-actions .btn {
  padding: 3px 5px;
  font-size: 12px;
  flex: 0 0 auto;
  min-height: 26px;
}
#page-dm .header-actions .toggle-label {
  flex: 0 0 auto;
  font-size: 12px;
  gap: 4px;
  min-height: 26px;
}
#page-dm .header-actions .count-badge {
  margin-left: 2px;
  padding: 1px 4px;
  font-size: 10px;
}

/* 私信顶部控制较多，允许在小窗口下自动换行 */
#page-dm .bc-row1 {
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}
#page-dm .bc-row1 .bc-row-sep {
  margin-left: 2px;
  margin-right: 2px;
}
#page-dm .bc-row1 .bc-sm-label {
  font-size: var(--font-ui) !important;
}
#page-dm .bc-row1 .bc-datetime {
  width: 148px !important;
}

/* 私信页日志框：固定高度，不抢目标用户区空间 */
#page-dm .bc-log-card {
  flex: 0 0 160px;
  min-height: 0;
}

/* 中间：目标用户 + 统计左右分栏 */
.dm-mid-row {
  display: flex;
  gap: 10px;
  flex: 1;
  min-height: 0;
  margin-bottom: 10px;
}
.dm-users-card {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.dm-users-card .textarea {
  flex: 1;
  min-height: 0;
  resize: none;
}
.vf-groups-card {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.vf-groups-card .textarea {
  flex: 1;
  min-height: 100px;
  width: 100%;
  resize: none;
}
.vf-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.vf-inline-row .toggle-label {
  flex: 1;
  min-width: 180px;
}
#page-verifier .bc-interval-card {
  flex: 0 0 390px;
  width: 390px;
  max-width: 390px;
  padding: 10px 12px;
}
#page-verifier .bc-interval-card .card-title {
  margin-bottom: 6px;
}
#page-verifier .bc-interval-card .form-group {
  margin-bottom: 0;
}
#page-verifier .bc-interval-card .input {
  padding: 4px 8px;
  min-height: 28px;
}
#page-verifier .bc-interval-card .range-input .input {
  width: 70px;
}
#page-verifier .bc-interval-card .toggle-label {
  padding: 1px 0;
  margin-bottom: 2px;
}
#page-verifier .bc-interval-card .btn-sm {
  padding: 2px 7px;
}
.vf-limit-row {
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 8px;
}
.vf-limit-row .toggle-label {
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
}
.vf-limit-row #vf-single-account-limit {
  flex: 0 0 64px;
  width: 64px !important;
}
@media (max-width: 960px) {
  #page-verifier .bc-top-row {
    flex-wrap: wrap;
  }
  #page-verifier .bc-interval-card {
    flex: 1 1 390px;
    width: auto;
    max-width: none;
  }
}
.dm-stat-card {
  flex: 0 0 160px;
  margin-bottom: 0;
}

#page-verifier .bc-top-row > .dm-stat-card {
  flex-basis: 238px;
}

/* ── 私信统计 ── */
.dm-stats { display: flex; gap: 32px; padding: 4px 0; align-items: center; }
.dm-stat-item { text-align: center; }
.dm-stat-num { font-family: inherit; font-size: var(--font-stat); font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dm-stat-num.success { color: var(--success); }
.dm-stat-num.danger { color: var(--danger); }
.dm-stat-label { font-size: var(--font-ui); color: var(--text-muted); margin-top: 4px; }

.vf-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(64px, 1fr));
  gap: 10px 12px;
  align-items: start;
  padding: 2px 0;
}
.vf-stats .dm-stat-item {
  min-width: 0;
}
.vf-stats .dm-stat-item:last-child {
  grid-column: span 2;
}
.vf-stats .dm-stat-label {
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

@media (max-width: 900px) {
  .vf-stats {
    grid-template-columns: repeat(2, minmax(64px, 1fr));
  }
}

/* ── 配置页 ── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
.config-full { grid-column: 1 / -1; }

/* 配置页撑满，代理卡片拖到底 */
#page-config.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}
#page-config .config-grid {
  flex: 1;
  min-height: 0;
  grid-template-rows: auto 1fr;
  align-items: stretch;
}
#page-config .config-full {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
#page-config .config-full .textarea {
  flex: 1;
  min-height: 80px;
  resize: none;
}

/* ── 弹窗 ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 480px; max-width: 95vw;
  max-height: 85vh;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  animation: modal-in 0.18s ease;
}
.modal-lg { width: 620px; }
.modal-xl { width: 780px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--text-muted);
  padding: 4px 6px; border-radius: 6px;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--bg-hover); }

.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
}
.modal-footer .account-range-picker { margin-left: auto; }

.monitor-rules-modal {
  width: min(1180px, 96vw);
  max-height: 90vh;
}
.monitor-rules-body {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
  height: min(650px, calc(90vh - 132px));
  min-height: 0;
  overflow: hidden;
}
.monitor-rules-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#monitor-rule-list {
  flex: 1;
  max-height: none;
  overflow-y: auto;
  margin-top: 0;
}
.monitor-rule-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.monitor-rule-editor {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

@media (max-width: 860px) {
  .monitor-rules-body {
    grid-template-columns: 1fr;
    height: min(720px, calc(90vh - 132px));
    overflow-y: auto;
  }
  .monitor-rules-sidebar {
    min-height: 190px;
  }
  #monitor-rule-list {
    max-height: 220px;
  }
  .monitor-rule-empty {
    min-height: 220px;
  }
}

/* ── 列表弹窗条目 ── */
.list-items { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow-y: auto; margin-top: 10px; }
.list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'Consolas', monospace;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition);
}
.list-item.selected { border-color: var(--accent); background: var(--accent-light); }
.list-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.list-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 预设文件行 ── */
.preset-file-row {
  display: flex; align-items: center; gap: 8px;
}
.preset-file-label {
  font-size: 12px; color: var(--text-muted);
  width: 28px; flex-shrink: 0;
}
.preset-file-btn {
  flex: 1; text-align: left; font-family: 'Consolas', monospace; font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Toast ── */
#toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  min-width: 220px; max-width: 360px;
  display: flex; align-items: center; gap: 8px;
  animation: toast-in 0.2s ease;
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── 采集器页专属布局 ── */
#page-scraper.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 采集器页日志框：固定高度 */
#page-scraper .bc-log-card {
  flex: 0 0 160px;
  min-height: 0;
}

#page-scraper .dm-mid-row {
  flex: 1;
  min-height: 0;
}

.sc-stat-card {
  flex: 0 0 160px;
  margin-bottom: 0;
}

.scraper-kw-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── 过验证页专属布局 ── */
#page-verifier.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* bc-log-card 在过验证页撑满剩余空间 */
#page-verifier .bc-log-card {
  flex: 1;
  min-height: 0;
}

/* ── 频道评论页专属布局 ── */
#page-channel-comment.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.cc-body-row {
  display: flex;
  gap: 10px;
  flex: 0 0 310px;
  min-height: 0;
  margin-bottom: 10px;
}
.cc-channel-card {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.cc-settings-card {
  flex: 0 0 330px;
  margin-bottom: 0;
  padding: 12px 14px;
  overflow: visible;
}
.cc-stat-card {
  flex: 0 0 250px;
}
.form-grid-compact {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 10px;
  align-items: center;
}
.form-grid-compact label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 0;
}
.cc-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(54px, 1fr));
  gap: 10px 12px;
  align-items: start;
  padding: 2px 0;
}
.cc-stats .dm-stat-label {
  white-space: nowrap;
  word-break: keep-all;
}
#page-channel-comment .bc-log-card {
  flex: 1;
  min-height: 0;
}

/* bc-log-card 在综合工具页撑满剩余空间 */
#page-tools .bc-log-card {
  flex: 1;
  min-height: 0;
}

#page-tools.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 独立私信自动回复：内容与节奏分区，运行记录保留充足空间。 */
.private-reply-workspace {
  display: grid;
  grid-template-columns: minmax(330px, .9fr) minmax(0, 1.25fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
}
.private-reply-settings { min-width: 0; overflow-y: auto; padding: 1px 2px 4px; }
.private-reply-settings > .card { padding: 20px; margin-bottom: 14px; }
.private-reply-section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.private-reply-section-mark {
  flex: 0 0 30px; height: 30px; display: grid; place-items: center;
  color: var(--accent); background: var(--accent-light); border-radius: 9px;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.private-reply-section-heading h3 { font-size: var(--font-heading); font-weight: 600; color: var(--text); }
.private-reply-section-heading p { margin-top: 4px; font-size: var(--font-note); line-height: 1.5; color: var(--text-sidebar); }
.private-reply-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 5px; margin-bottom: 18px; }
.private-reply-modes .mode-tab { min-width: 0; padding: 10px 3px; border: 1px solid transparent; }
.private-reply-modes .mode-tab strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; }
.private-reply-modes .mode-tab span { display: block; margin-top: 5px; font-size: 10px; white-space: nowrap; color: var(--text-sidebar); }
.private-reply-modes .mode-tab.active { border-color: var(--accent); box-shadow: 0 2px 6px rgba(35, 66, 135, .08); }
.private-reply-modes .mode-tab:hover:not(.active) { background: var(--bg-card); color: var(--text); }
.private-reply-modes .mode-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.private-reply-materials { border-top: 1px solid var(--border); padding-top: 8px; }
.private-reply-material-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }
.private-reply-material-row > div { display: flex; align-items: center; gap: 4px; }
.private-reply-material-label { font-size: 13px; color: var(--text); }
.private-reply-material-row .btn { white-space: nowrap; }
.private-reply-materials .toggle-label { margin-top: 5px; font-size: 12px; color: var(--text-sidebar); }
.private-reply-options { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.private-reply-timing-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.private-reply-timing-field > label { white-space: nowrap; font-size: 12px; color: var(--text-sidebar); }
.private-reply-input-range { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.private-reply-input-range .input { width: 65px; padding: 8px; text-align: center; font-variant-numeric: tabular-nums; }
#monitor-private-reply-cooldown { width: 92px; }
.private-reply-hint { margin-top: 8px; font-size: var(--font-note); line-height: 1.7; color: var(--text-sidebar); }
.private-reply-settings-note { padding: 0 8px; font-size: var(--font-note); line-height: 1.7; color: var(--text-muted); }
.private-reply-activity { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.private-reply-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); flex-shrink: 0; padding: 20px 8px; margin: 0; }
.private-reply-stat { padding: 0 12px; min-width: 0; }
.private-reply-stat + .private-reply-stat { border-left: 1px solid var(--border); }
.private-reply-stat-label { display: block; color: var(--text-sidebar); font-size: var(--font-ui); white-space: nowrap; }
.private-reply-stat strong { display: block; margin-top: 7px; font-family: inherit; font-size: var(--font-stat); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.private-reply-stat.is-success strong { color: var(--success); }
.private-reply-stat.is-failed strong { color: var(--danger); }
#page-tools .private-reply-log-card { display: flex; flex-direction: column; margin: 0; padding: 0; overflow: hidden; }
.private-reply-log-card .card-title { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; margin: 0; color: var(--text); border-bottom: 1px solid var(--border); }
.private-reply-log-card .log-box { flex: 1; border: 0; border-radius: 0; padding: 14px 16px; min-height: 180px; }
.private-reply-log-card .log-box:empty::before { content: attr(data-empty-text); display: block; padding-top: 28px; text-align: center; color: var(--text-muted); font-size: 12px; }
@media (max-width: 980px) {
  .private-reply-panel { overflow-y: auto; }
  .private-reply-workspace { grid-template-columns: minmax(0, 1fr); flex: none; }
  .private-reply-settings { overflow: visible; }
  .private-reply-activity { min-height: 380px; }
  .private-reply-settings > .card { padding: 18px; }
  .private-reply-modes .mode-tab { padding: 10px 6px; }
}

#tools-panel-handwritten .account-table td,
#tools-panel-handwritten .account-table th {
  padding: 8px 7px;
}
#tools-panel-handwritten .account-table tbody tr {
  cursor: default;
}

@media (max-width: 860px) {
  #tools-panel-handwritten > div[style*="display:flex"] {
    flex-direction: column;
    overflow-y: auto;
  }
  #tools-panel-handwritten > div[style*="display:flex"] > .card:first-child {
    flex: 0 0 auto !important;
    width: 100%;
  }
  #tools-panel-handwritten > .card:first-child > div[style*="display:grid"] {
    grid-template-columns: 1fr 1fr !important;
  }
  #tools-panel-handwritten > .card:first-child > div[style*="display:grid"] > :first-child {
    grid-column: 1 / -1;
  }
}

#page-monitor.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#page-monitor .bc-log-card {
  flex: 1;
  min-height: 0;
}

/* body 整体无需额外 padding，原生标题栏由系统管理 */

/* ── 群成员采集页专属布局 ── */
#page-member-scraper.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 主体行：左侧群组框 + 右侧设置/统计 */
.ms-body-row {
  display: flex;
  gap: 10px;
  flex: 1;
  min-height: 0;
  margin-bottom: 10px;
}

/* 左侧目标群组卡片撑满高度 */
.ms-groups-card {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.ms-groups-card .textarea {
  flex: 1;
  min-height: 0;
  resize: none;
}

/* 右侧列：固定宽度，纵向排列 */
.ms-right-col {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ms-stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  align-items: center;
}

.ms-stats-row > div {
  min-width: 0;
}

.ms-stats-row > div > div:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#page-member-scraper .bc-log-card {
  flex: 0 0 180px;
  min-height: 0;
}

#page-chat-history.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#page-chat-history .bc-log-card {
  flex: 0 0 180px;
  min-height: 0;
}

/* ── 直发媒体管理弹窗条目 ── */
.dm-media-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition);
}
.dm-media-item:hover { border-color: var(--border); }
.dm-media-item.selected { border-color: var(--accent); background: var(--accent-light); }
.dm-media-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.dm-media-item-body { flex: 1; min-width: 0; }
.dm-media-item-text {
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 60px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}
.dm-media-item-file {
  font-size: 11px;
  color: var(--accent);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 名片管理弹窗条目 ── */
.contact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition);
}
.contact-item:hover { border-color: var(--border); }
.contact-item.selected { border-color: var(--accent); background: var(--accent-light); }
.contact-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.contact-item-body { flex: 1; min-width: 0; }
.contact-item-name { font-size: 13px; font-weight: 600; color: var(--text); }
.contact-item-phone { font-size: var(--font-note); color: var(--text-muted); margin-top: 2px; font-family: 'Consolas', monospace; }

/* ── 强拉页专属布局 ── */
#page-inviter.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#page-inviter .dm-mid-row {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--inviter-control-width);
}

#page-inviter { --inviter-control-width: 190px; }
#page-inviter > .bc-top-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--inviter-control-width) var(--inviter-control-width); }
#page-inviter .inviter-target-card { display: flex; flex-direction: column; min-width: 0; }
#page-inviter #inviter-target { flex: 1; min-height: 80px; }
#page-inviter .dm-stat-card { min-width: 0; }
#page-inviter .dm-stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
#page-inviter .dm-stat-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#page-inviter .dm-stat-label { order: -1; margin-top: 0; white-space: nowrap; }

#page-inviter .bc-log-card {
  flex: 0 0 180px;
  min-height: 0;
}

.verifier-log-title {
  gap: 8px;
}
.verifier-log-tabs {
  width: 220px;
  margin-bottom: 0;
  padding: 3px;
  flex-shrink: 0;
}
.verifier-log-tabs .mode-tab {
  padding: 4px 8px;
  font-size: 12px;
}
.verifier-log-panel {
  flex: 1;
}

/* ── 桌面视觉与布局：保留各功能字号，统一操作高度和明暗层次 ── */
.page-header .btn,
.cd-toolbar .btn,
.cd-chat-header > .btn,
.ai-settings-actions .btn {
  height: 26px;
  min-height: 26px;
  padding: 3px 5px;
  gap: 5px;
  flex: 0 0 auto;
  justify-content: center;
}
.page-header .header-actions,
.cd-toolbar-actions { column-gap: 4px; row-gap: 6px; }
.page-header .count-badge { padding: 1px 4px; margin-left: 2px; }
.btn:focus-visible, .mode-tab:focus-visible, .bc-mode-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-ghost:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 40%, var(--control-border)); }
.btn-primary { box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 16%, transparent); }
.btn-primary:active:not(:disabled) { background: var(--accent-hover); }
.bc-log-card .card-title, .bc-account-toolbar { color: var(--text-secondary); }
.card-title small { font-weight: 400; letter-spacing: 0; text-transform: none; }
.form-grid-compact label, .bc-sm-label, .bc-panel-label { color: var(--text-secondary); }
.input, .textarea, .form-group, .range-input { min-width: 0; }
.input-row, .range-input { align-items: center; }
.form-group > .toggle-label, .form-group > .checkbox-label { display: flex; align-items: center; }
.toggle-label input, .checkbox-label input { flex-shrink: 0; }
.mode-tab, .bc-mode-pill { color: var(--text-secondary); }
.mode-tab.active, .bc-mode-pill.active { color: var(--accent); }
.mode-tabs, .bc-mode-tabs { background: var(--bg-mode-tab); }
.account-table tbody tr.account-item:hover { background: var(--bg-hover); }
.account-table tbody tr.account-item:has(input:checked) { background: var(--accent-light); }
.account-table :is(td, th) { height: auto; }
.ac-spam { padding-left: 8px; }
.session-converter-table { min-width: 340px; }
.session-converter-table th:nth-child(2) { width: calc(100% - 182px); }
.session-converter-table th:nth-child(3) { width: 60px; }
.session-converter-table th:nth-child(4) { width: 88px; }
.session-converter-accounts { min-width: 0; }
.sc-account-row { min-width: 0; }
.bc-account-more { background: transparent; border-color: transparent; }

/* 设置横条 → 输入与结果并排 → 日志，按实际窗口分配空间。 */
#page-checker .checker-top-row { flex: none; }
#page-checker .checker-settings { display: flex; align-items: center; gap: 24px; width: 100%; min-width: 0; }
#page-checker .checker-settings > .card-title { flex: none; margin: 0; }
.checker-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; min-width: 0; }
.checker-fields .form-group { display: flex; align-items: center; gap: 8px; }
.checker-fields .form-group > label { margin: 0; }
#page-checker .checker-workspace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; flex: 0 1 340px; min-height: 230px; }
#page-checker .checker-workspace > .card { min-width: 0; padding: 14px 16px; }
#page-checker .checker-workspace .card-title { display: flex; align-items: center; gap: 6px; min-height: 26px; margin-bottom: 10px; }
#page-checker .bc-log-card { flex: 1 0 180px; min-height: 180px; }

/* 统计按横向阅读，避免把少量数字拉成一整列。 */
#page-scraper .sc-stat-card { flex: 0 0 310px; padding: 14px 16px; }
.sc-stat-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 8px 0; }
.sc-stat-summary .dm-stat-item { min-width: 0; }
.sc-stat-summary .dm-stat-label { white-space: nowrap; }
#page-scraper .sc-stat-card > div:last-child { flex-direction: row !important; flex-wrap: wrap; gap: 6px !important; margin-top: 16px !important; }
#page-scraper .sc-stat-card > div:last-child .btn { flex: 1 1 auto; justify-content: center; }

/* 卡片由实际控件高度撑开，日志和输入区仍可独立滚动。 */
#page-channel-comment.active, #page-member-scraper.active, #page-chat-history.active { height: auto; min-height: 100%; flex: 1 0 auto; }
.cc-body-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(310px, 1.02fr) minmax(180px, .68fr); flex: 0 0 auto; min-height: 320px; gap: 12px; }
.cc-settings-card, .cc-stat-card { min-width: 0; }
.cc-settings-card .form-grid-compact { grid-template-columns: 92px minmax(0, 1fr); }
.cc-settings-card .range-input .input { min-width: 0; flex: 0 1 70px; }
.cc-settings-card .toggle-label { align-items: flex-start; }
.cc-settings-card .toggle-label input { margin-top: 2px; }
.cc-channel-card .textarea { min-height: 180px !important; }
#page-channel-comment .bc-log-card { flex: 1 0 160px; min-height: 160px; }
.ms-right-col { min-width: 0; }
.ms-right-col > .card { flex: 0 0 auto !important; height: auto; overflow: visible !important; }
.ms-body-row { flex-shrink: 0; }
#page-member-scraper .bc-log-card, #page-chat-history .bc-log-card { min-height: 180px; }
#tools-panel-handwritten .card-title { flex-wrap: wrap; gap: 8px; }
#tools-panel-handwritten .card-title > div { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
#tools-panel-handwritten .handwritten-editor .form-group { margin-bottom: 8px; }

@media (max-width: 1100px) {
  .main-content { padding: 20px; }
  .page-header .header-actions { flex-wrap: wrap; overflow: visible; }
  #page-dm .header-actions { flex-wrap: wrap; overflow: visible; }
  .select-bar { flex-wrap: wrap; row-gap: 8px; }
  .cc-body-row { grid-template-columns: minmax(0, 1fr) minmax(310px, 1fr); }
  .cc-stat-card { grid-column: 1 / -1; padding: 12px 16px; }
  .cc-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #page-scraper .sc-stat-card { flex-basis: 270px; }
  #page-scraper .dm-mid-row { min-height: 220px; }
  .two-col > .col-left, .two-col > .col-right { min-width: 0; }
  #page-clone .clone-basic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #page-clone .clone-basic-grid > .form-group:last-child { grid-column: 1 / -1; }
  #page-clone .col-right .bc-log-card, #tools-panel-channel-clone .bc-log-card, #tools-panel-session-converter .bc-log-card { min-height: 160px; flex-shrink: 0; }
}
@media (max-width: 940px) {
  .main-content { padding: 16px; }
  #page-checker .checker-settings { gap: 14px; flex-wrap: wrap; }
  #page-checker .checker-settings > .card-title { flex-basis: 100%; }
  #page-tools.active, #page-clone.active, #page-verifier.active, #page-scraper.active { height: auto; min-height: 100%; flex: 1 0 auto; }
  #page-tools .bc-log-card, #page-verifier .bc-log-card, #page-scraper .bc-log-card { min-height: 160px; flex-shrink: 0; }
  #tools-panel-session-converter { flex: none !important; }
  .session-converter-accounts { min-height: 210px; }
  .session-converter-table-wrap { max-height: 300px; }
  #page-clone .two-col { flex: none; }
  #page-clone .col-left, #page-clone .col-right { overflow: visible; }
  #page-scraper .dm-mid-row { flex-wrap: wrap; }
  #page-scraper .sc-stat-card { flex: 1 1 100%; }
  #page-scraper .dm-users-card { min-height: 190px; flex: 1 1 100%; }
}
@media (max-width: 820px) {
  #page-inviter > .bc-top-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #page-inviter .inviter-target-card { grid-column: 1 / -1; }
  #page-inviter .dm-mid-row { grid-template-columns: minmax(0, 1fr); min-height: 320px; }
  #page-inviter .dm-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #page-inviter .dm-stat-item { flex-direction: column; gap: 4px; }
  .cc-body-row { grid-template-columns: minmax(0, 1fr); }
  .cc-stat-card { grid-column: auto; }
  .cc-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #page-checker.active { height: auto; min-height: 100%; }
  #page-checker .checker-workspace { grid-template-columns: minmax(0, 1fr); flex: none; }
  #page-checker .checker-workspace .textarea { min-height: 170px !important; }
  .checker-fields { gap: 10px 16px; }
  .checker-fields .form-group { flex-wrap: wrap; }
}

#page-accounts .account-list-wrap { flex: 1 1 0; overflow-anchor: none; }
#page-accounts .account-list-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#page-accounts .account-table { border-collapse: separate; border-spacing: 0; }
#page-accounts .account-item, #page-accounts .account-item > td { height: 36px; }
#page-accounts .account-item > td { box-sizing: border-box; padding-top: 6px; padding-bottom: 6px; line-height: 18px; border-bottom: 1px solid var(--border); }
#page-accounts .account-item > .ac-spam { padding-top: 4px; padding-bottom: 4px; }
#page-accounts .account-spam-wrap { max-height: 27px; overflow: hidden; }
#page-accounts .account-spam, #page-accounts .account-spam-detail { line-height: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#page-accounts .account-spacer, #page-accounts .account-spacer > td { padding: 0; border: 0; line-height: 0; font-size: 0; }
