/* ============================================================
 * webtg — 统一样式表 (取代 styles / theme-light / shell / mobile 四层覆盖)
 * 主题: 默认跟随系统; <html data-theme="light|dark"> 强制指定
 * 旧变量名(--bg-surface 等)保留, app.js 的行内样式仍在使用
 * ============================================================ */

/* ---------------- 设计令牌: 浅色 ---------------- */
:root {
  --bg-app:        #f3f5f9;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f2f4f8;
  --bg-hover:      #eef1f6;
  --bg-active:     #e6f0fd;
  --bg-chat:       #e7edf3;
  --accent:        #3390ec;
  --accent-hover:  #1f7fdc;
  --accent-soft:   rgba(51, 144, 236, .12);
  --accent-text:   #1a73c9;
  --bubble-out:    #e1f7d1;
  --bubble-in:     #ffffff;
  --bubble-out-meta: #5e9a4f;
  --text-primary:  #18212d;
  --text-secondary:#5a6676;
  --text-muted:    #8c97a6;
  --border:        #e5e8ee;
  --border-light:  #d6dbe3;
  --online:        #22a559;
  --success:       #22a559;
  --success-soft:  rgba(34, 165, 89, .12);
  --danger:        #e5484d;
  --danger-soft:   rgba(229, 72, 77, .1);
  --warn:          #c27c0e;
  --warn-soft:     rgba(214, 140, 20, .12);
  --warn-bg:       #fff8e6;
  --warn-border:   #f0dca6;
  --warn-text:     #8a6212;
  --info-bg:       #eef6ff;
  --info-border:   #cfe3fb;
  --badge-unread:  #3390ec;
  --badge-muted:   #a7b1be;
  --scrollbar:     #c8cfd8;
  --shadow-sm:     0 1px 2px rgba(16, 24, 40, .05);
  --shadow:        0 4px 14px rgba(16, 24, 40, .07);
  --shadow-lg:     0 18px 50px rgba(16, 24, 40, .16);
  --overlay:       rgba(15, 20, 30, .38);
  --radius-sm:     8px;
  --radius:        12px;
  --radius-lg:     16px;
  --side-w:        232px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* ---------------- 设计令牌: 深色 ---------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-app: #0f141b; --bg-surface: #171d26; --bg-elevated: #1e2631; --bg-hover: #212a36; --bg-active: #1f3550;
    --bg-chat: #0c1117; --accent: #4a9ff0; --accent-hover: #6cb2f5; --accent-soft: rgba(74, 159, 240, .16); --accent-text: #79b8f5;
    --bubble-out: #2b5278; --bubble-in: #1e2631; --bubble-out-meta: #9fc3e6;
    --text-primary: #e7ecf2; --text-secondary: #9aa6b4; --text-muted: #6e7a89;
    --border: #232c38; --border-light: #2f3a48;
    --online: #3cc675; --success: #3cc675; --success-soft: rgba(60, 198, 117, .14);
    --danger: #f2555a; --danger-soft: rgba(242, 85, 90, .14); --warn: #e3a338; --warn-soft: rgba(227, 163, 56, .14);
    --warn-bg: #2b2414; --warn-border: #5a4718; --warn-text: #f0c674; --info-bg: #15263a; --info-border: #22405f;
    --badge-muted: #4a5666; --scrollbar: #344050;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 4px 14px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
    --overlay: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg-app: #0f141b; --bg-surface: #171d26; --bg-elevated: #1e2631; --bg-hover: #212a36; --bg-active: #1f3550;
  --bg-chat: #0c1117; --accent: #4a9ff0; --accent-hover: #6cb2f5; --accent-soft: rgba(74, 159, 240, .16); --accent-text: #79b8f5;
  --bubble-out: #2b5278; --bubble-in: #1e2631; --bubble-out-meta: #9fc3e6;
  --text-primary: #e7ecf2; --text-secondary: #9aa6b4; --text-muted: #6e7a89;
  --border: #232c38; --border-light: #2f3a48;
  --online: #3cc675; --success: #3cc675; --success-soft: rgba(60, 198, 117, .14);
  --danger: #f2555a; --danger-soft: rgba(242, 85, 90, .14); --warn: #e3a338; --warn-soft: rgba(227, 163, 56, .14);
  --warn-bg: #2b2414; --warn-border: #5a4718; --warn-text: #f0c674; --info-bg: #15263a; --info-border: #22405f;
  --badge-muted: #4a5666; --scrollbar: #344050;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 4px 14px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --overlay: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
code { font-family: var(--mono); font-size: .92em; background: var(--bg-elevated); border-radius: 4px; padding: 1px 5px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border-light); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--text-muted); background: var(--bg-surface); }
a { color: var(--accent-text); }

* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* 图标 */
.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* 工具类 */
.muted { color: var(--text-muted); font-weight: 400; }
.mono { font-family: var(--mono) !important; font-size: 12.5px !important; line-height: 1.6 !important; }
.break { word-break: break-all; }
.row { display: flex; align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.flex-1 { flex: 1; }
.mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------------- 表单 ---------------- */
input, select, textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
::placeholder { color: var(--text-muted); }
textarea { resize: vertical; line-height: 1.5; }
select { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); box-shadow: none; cursor: pointer; flex-shrink: 0; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

.field { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; font-weight: 500; }
.field > input, .field > textarea, .field > select, .field > div { margin-top: 6px; }
.field-title { display: block; }
.field-hint { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 4px; }
.hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-primary); cursor: pointer; user-select: none; }
.check--block { display: flex; align-items: flex-start; margin-bottom: 14px; color: var(--text-secondary); line-height: 1.45; }
.check--block input { margin-top: 2px; }

/* ---------------- 按钮 ---------------- */
button { font-family: inherit; cursor: pointer; color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; font-weight: 600;
  transition: background .15s, transform .05s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(51, 144, 236, .3);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary.is-loading::before, .btn.is-loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn, .btn-lite {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; min-height: 34px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s, filter .15s;
}
.btn:hover, .btn-lite:hover { background: var(--bg-hover); }
.btn:disabled, .btn-lite:disabled { opacity: .5; cursor: not-allowed; }
.btn .i, .btn-lite .i { width: 16px; height: 16px; }
.btn-sm { padding: 4px 10px; min-height: 28px; font-size: 12.5px; }
.btn-sm .i { width: 14px; height: 14px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.06); background: var(--danger); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }

.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn .i { width: 20px; height: 20px; }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn--sm .i { width: 17px; height: 17px; }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }

/* 分段控件 */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-elevated); border-radius: 10px; border: 1px solid var(--border); }
.seg button {
  border: none; background: transparent; padding: 5px 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--text-secondary); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text-primary); }
.seg button.on, .seg button.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.seg button em { font-style: normal; font-size: 11px; color: var(--text-muted); }
.seg--full { display: flex; width: 100%; }
.seg--full button { flex: 1; justify-content: center; padding: 7px 0; }

/* chip */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; border: 1px solid var(--border-light);
  background: var(--bg-surface); color: var(--text-secondary);
}
.chip--btn { cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.chip--btn:hover { border-color: var(--accent); color: var(--accent-text); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 600; }

/* 搜索框 */
.search-input { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.search-input .i { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search-input input { padding-left: 34px; height: 36px; border-radius: 10px; background: var(--bg-elevated); border-color: transparent; }
.search-input input:focus { background: var(--bg-surface); }
.search-input--sm { max-width: 240px; }
.search-input--sm input { height: 32px; }

/* ---------------- 外壳: 侧边栏 ---------------- */
#shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; transition: grid-template-columns .2s ease; }
html.side-collapsed #shell, #shell.ws-full { --side-w: 68px; }
#sidebar {
  background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px 12px; gap: 10px;
  min-width: 0; overflow: hidden; z-index: 20;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 8px; min-height: 42px; }
.side-logo {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, #4aa8f5, #2a7bd4); box-shadow: 0 4px 12px rgba(51, 144, 236, .3);
}
.side-logo svg { width: 20px; height: 20px; }
.side-name { font-size: 16px; font-weight: 700; letter-spacing: .2px; flex: 1; white-space: nowrap; }
.side-collapse { margin-left: auto; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; }
.side-group { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: .6px; padding: 12px 12px 4px; white-space: nowrap; }
.side-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border: none; border-radius: 10px;
  background: transparent; color: var(--text-secondary);
  font-size: 14px; font-weight: 500; text-align: left; white-space: nowrap;
  transition: background .15s, color .15s;
}
.side-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.side-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.side-item.active::before { content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-badge {
  margin-left: auto; font-style: normal; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.side-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.side-search {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elevated);
  color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden;
}
.side-search:hover { border-color: var(--border-light); color: var(--text-secondary); }
.side-search kbd { margin-left: auto; }
.side-search .i { width: 16px; height: 16px; }
.side-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 2px; }
.ws-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.ws-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; box-shadow: 0 0 0 3px var(--warn-soft); }
.ws-pill.ok i { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.ws-pill.bad i { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.side-count { font-size: 12px; color: var(--text-muted); padding: 0 4px; white-space: nowrap; }

/* 收起态: 只留图标 */
html.side-collapsed #sidebar .side-name, html.side-collapsed #sidebar .side-item span, html.side-collapsed #sidebar .side-group,
html.side-collapsed #sidebar .side-search span, html.side-collapsed #sidebar .side-search kbd, html.side-collapsed #sidebar .ws-pill span,
html.side-collapsed #sidebar .side-count,
#shell.ws-full #sidebar .side-name, #shell.ws-full #sidebar .side-item span, #shell.ws-full #sidebar .side-group,
#shell.ws-full #sidebar .side-search span, #shell.ws-full #sidebar .side-search kbd, #shell.ws-full #sidebar .ws-pill span,
#shell.ws-full #sidebar .side-count { display: none; }
html.side-collapsed #sidebar .side-item, #shell.ws-full #sidebar .side-item { justify-content: center; padding: 10px 0; }
html.side-collapsed #sidebar .side-brand, #shell.ws-full #sidebar .side-brand { flex-direction: column; padding: 2px 0 8px; gap: 8px; }
html.side-collapsed #sidebar .side-collapse, #shell.ws-full #sidebar .side-collapse { margin: 0; }
html.side-collapsed #sidebar .side-search, #shell.ws-full #sidebar .side-search { justify-content: center; padding: 8px 0; }
html.side-collapsed #sidebar .side-foot-row, #shell.ws-full #sidebar .side-foot-row { flex-direction: column; }
html.side-collapsed .side-badge, #shell.ws-full .side-badge { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
#shell.ws-full #sidebar .side-collapse { display: none; }

/* ---------------- 页面通用 ---------------- */
#page-host { position: relative; overflow: hidden; min-width: 0; }
.page { height: 100%; overflow-y: auto; padding: 28px 36px 48px; animation: page-in .22s ease-out; }
.page > * { max-width: 1320px; margin-left: auto; margin-right: auto; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page--flush { padding: 0; overflow: hidden; animation: none; }
.page--flush > * { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.page-sub { font-size: 15px; font-weight: 600; margin: 26px 0 12px; }
.page-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.65; max-width: 780px; margin-top: 4px; }
.page > .page-desc { max-width: 1320px; margin-bottom: 4px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-head .page-sub { margin: 0; }

/* 卡片 */
.card, .ui-cardx {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .card-title { margin-bottom: 0; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.card-title .i { color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search-input { max-width: 340px; }

/* 提示条 */
.banner-warn, .banner-info {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius); padding: 12px 14px; font-size: 13px; line-height: 1.55; margin-bottom: 16px;
}
.banner-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }
.banner-info { background: var(--info-bg); border: 1px solid var(--info-border); color: var(--text-secondary); }
.banner-info .i { color: var(--accent); }
.banner-warn .i, .banner-info .i { margin-top: 1px; }

.details { margin: 4px 0 14px; border: 1px dashed var(--border-light); border-radius: var(--radius-sm); padding: 4px 12px; font-size: 13px; color: var(--text-secondary); }
.details summary { cursor: pointer; padding: 6px 0; display: flex; align-items: center; gap: 6px; list-style: none; font-weight: 500; }
.details summary::-webkit-details-marker { display: none; }
.details summary .i { width: 15px; height: 15px; }
.details[open] { padding-bottom: 12px; border-style: solid; }
.details[open] summary { margin-bottom: 6px; }

/* 状态徽标 */
.st-badge, .ui-badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
}
.st-badge::before, .ui-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-active, .ui-badge-success { color: var(--success); background: var(--success-soft); }
.st-auth_dead, .st-restricted, .ui-badge-error { color: var(--danger); background: var(--danger-soft); }
.st-error { color: var(--warn); background: var(--warn-soft); }
.st-unknown, .ui-badge-neutral { color: var(--text-muted); background: var(--bg-elevated); }

/* 空状态 / 骨架 */
.empty { padding: 34px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.empty .i { width: 30px; height: 30px; display: block; margin: 0 auto 10px; opacity: .55; }
.vault-empty, .al-empty { color: var(--text-muted); font-size: 13px; }
.vault-empty { padding: 26px; text-align: center; }
.skel { background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 37%, var(--bg-elevated) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; border-radius: 6px; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------- 仪表盘 ---------------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.dash-stat {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm);
}
.dash-stat-ic { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dash-stat-ic .i { width: 21px; height: 21px; }
.dash-stat .num { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-stat .lbl { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.dash-stat .num.ok { color: var(--success); }
.dash-stat .num.bad { color: var(--danger); }
.ic-blue { background: var(--accent-soft); color: var(--accent); }
.ic-green { background: var(--success-soft); color: var(--success); }
.ic-red { background: var(--danger-soft); color: var(--danger); }
.ic-amber { background: var(--warn-soft); color: var(--warn); }
.ic-violet { background: rgba(139, 92, 246, .13); color: #8b5cf6; }
.health-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; margin-top: 14px; background: var(--bg-elevated); }
.health-bar span { height: 100%; transition: width .4s; }
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; }
.dash-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dash-action {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; text-align: left; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.dash-action:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.dash-action > * { min-width: 0; }
.dash-action-ic { grid-row: span 2; width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.dash-action strong { font-size: 14px; font-weight: 600; }
.dash-action span:not(.dash-action-ic) { font-size: 12px; color: var(--text-secondary); }
.dash-tasks { display: flex; flex-direction: column; gap: 8px; }
.task-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.task-row:hover { border-color: var(--border-light); background: var(--bg-hover); }
.task-row .dash-action-ic { width: 34px; height: 34px; border-radius: 10px; }
.task-row .dash-action-ic .i { width: 17px; height: 17px; }
.task-row .t-main { flex: 1; min-width: 0; }
.task-row .t-title { font-size: 13.5px; font-weight: 600; }
.task-row .t-sub { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-row .t-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-account-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.dash-account-row {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font-size: 13px; transition: border-color .15s;
}
.dash-account-row:hover { border-color: var(--border-light); }
.dash-account-row .who { flex: 1; min-width: 0; }
.dash-account-row .who strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.dash-account-row .who span { font-size: 12px; color: var(--text-muted); }

/* ---------------- 账号管理 ---------------- */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.account-card {
  position: relative; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.account-card:hover { box-shadow: var(--shadow); border-color: var(--border-light); }
.account-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ac-select { position: absolute; top: 14px; right: 14px; }
.ac-head { display: flex; align-items: center; gap: 12px; padding-right: 26px; }
.ac-title { min-width: 0; flex: 1; }
.ac-title .name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-title .phone { font-size: 12.5px; color: var(--text-secondary); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.ac-2fa { font-family: var(--mono); font-size: 11.5px; background: var(--bg-elevated); padding: 2px 8px; border-radius: 6px; cursor: pointer; }
.ac-check-detail { font-size: 12px; color: var(--text-secondary); line-height: 1.5; padding: 7px 10px; background: var(--bg-elevated); border-radius: var(--radius-sm); }
.ac-check-detail:empty { display: none; }
.ac-check-detail.err { color: var(--danger); background: var(--danger-soft); }
.ac-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border); }
.ac-actions .btn-lite, .ac-actions .btn { flex: 0 0 auto; }
.ac-actions .spacer { flex: 1; }
.bulkbar {
  position: sticky; top: -28px; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius);
  background: var(--bg-surface); border: 1px solid var(--accent); box-shadow: var(--shadow);
}
.bulkbar .check { margin-right: 6px; font-weight: 600; }

/* 开关 */
.ak-switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; font-size: 12px; color: var(--text-secondary); margin-left: auto; }
.ak-switch input { display: none; }
.ak-slider { width: 32px; height: 18px; border-radius: 999px; background: var(--border-light); position: relative; transition: background .18s; flex-shrink: 0; }
.ak-slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.ak-switch input:checked + .ak-slider { background: var(--accent); }
.ak-switch input:checked + .ak-slider::after { transform: translateX(14px); }
.ak-switch input:disabled + .ak-slider { opacity: .55; cursor: wait; }

/* ---------------- 自动登录 / 日志 / 表格 ---------------- */
.al-grid { display: grid; grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); gap: 16px; align-items: start; }
.al-log {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  max-height: 300px; min-height: 120px; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; color: var(--text-secondary);
}
.al-log.tall { max-height: 460px; min-height: 260px; }
.al-log p, .al-log .ln { white-space: pre-wrap; word-break: break-all; }
.al-log .ln.ok, .al-log p.ok { color: var(--success); }
.al-log .ln.err, .al-log p.err { color: var(--danger); }
.al-log .ln.phase, .al-log p.phase { color: var(--accent-text); font-weight: 600; }
.al-vault { overflow-x: auto; }
.vault-table, .data-table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.vault-table { min-width: 560px; }
.vault-table th, .data-table th {
  text-align: left; font-size: 12px; color: var(--text-secondary); font-weight: 600;
  padding: 10px 14px; background: var(--bg-elevated); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.vault-table td, .data-table td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.vault-table tr:first-child td, .data-table tr:first-child td { border-top: none; }
.vault-table tbody tr:hover, .data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .ell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vault-pw { font-family: var(--mono); }
.table-wrap { overflow-x: auto; }

/* 账号勾选列表 */
.acc-pick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px; max-height: 240px; overflow-y: auto;
}
.acc-pick > label { display: flex !important; align-items: center; gap: 8px; padding: 6px 8px !important; border-radius: 7px; font-size: 13px; cursor: pointer; min-width: 0; }
.acc-pick > label:hover { background: var(--bg-surface); }
.acc-pick > label > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-pick > label:first-child:has(#show-restricted-toggle) { grid-column: 1 / -1; border-bottom: 1px solid var(--border); border-radius: 7px 7px 0 0; color: var(--text-muted); }
.acc-pick .pick-tools { grid-column: 1 / -1; display: flex; gap: 6px; padding: 2px 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }

/* 资料改造选项 */
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s; }
.option:hover { border-color: var(--accent); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { margin-top: 2px; }
.option strong { display: block; font-size: 13px; }
.option small { font-size: 11.5px; color: var(--text-muted); }

/* 列表行(来源私信/频道文案) */
.list-rows > div { border-bottom: 1px solid var(--border) !important; }
.list-rows > div:last-child { border-bottom: none !important; }
.stat-line { margin-top: 12px; font-size: 12px; color: var(--text-secondary); line-height: 1.7; }
.stat-line:empty { display: none; }

/* ---------------- 工作区 ---------------- */
.app { display: grid; grid-template-columns: 72px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100%; }
#account-rail {
  background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 0; overflow-y: auto; overflow-x: hidden;
}
.account-dot { flex-shrink: 0; cursor: pointer; transition: box-shadow .15s, transform .15s, border-radius .2s; position: relative; }
.account-dot:hover { transform: scale(1.04); }
.account-dot.active { box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--accent); }
.account-dot .conn-dot { position: absolute; right: -1px; bottom: -1px; width: 12px !important; height: 12px !important; border: 2px solid var(--bg-surface) !important; }
#add-account-btn, #settings-btn {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: transparent; color: var(--text-secondary);
  transition: border-color .15s, color .15s, background .15s;
}
#add-account-btn { margin-top: auto; border: 2px dashed var(--border-light); }
#add-account-btn:hover { border-color: var(--accent); color: var(--accent); }
#settings-btn { border: none; }
#settings-btn:hover { color: var(--accent); background: var(--bg-hover); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.tabbar {
  height: 54px; flex-shrink: 0; background: var(--bg-surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px; padding: 0 16px 0 8px;
}
.tabs { display: flex; height: 100%; gap: 2px; }
.tab {
  height: 100%; padding: 0 14px; background: none; border: none; color: var(--text-secondary);
  font-size: 14px; font-weight: 600; position: relative; display: inline-flex; align-items: center; gap: 7px;
  transition: color .15s;
}
.tab .i { width: 17px; height: 17px; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-text); }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; background: var(--accent); border-radius: 3px 3px 0 0; }
.tabbar-right:hover .st-badge { filter: brightness(.95); text-decoration: underline; }
.tabbar-right { margin-left: auto; color: var(--text-secondary); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; display: flex; align-items: center; gap: 8px; }
.m-only { display: none; }
.views { flex: 1; min-height: 0; }
.view { height: 100%; }
.view-scroll { height: 100%; overflow-y: auto; }
.view-inner { max-width: 820px; margin: 0 auto; padding: 24px 20px 48px; }

/* ===== 对话视图 ===== */
#view-chats { display: grid; grid-template-columns: 340px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100%; }
.dialog-col { background: var(--bg-surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.dialog-search { padding: 10px 12px 6px; flex-shrink: 0; }
.dialog-filters { display: flex; gap: 4px; padding: 2px 12px 8px; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.dialog-filters::-webkit-scrollbar { display: none; }
.dialog-filters button {
  border: none; background: var(--bg-elevated); color: var(--text-secondary); border-radius: 999px;
  padding: 4px 11px; font-size: 12.5px; font-weight: 500; white-space: nowrap; display: inline-flex; gap: 4px; align-items: center;
}
.dialog-filters button:hover { color: var(--text-primary); }
.dialog-filters button.on { background: var(--accent); color: #fff; }
.dialog-filters button em { font-style: normal; font-size: 11px; opacity: .8; }
#dialog-list { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 6px; }
.dialog-item {
  display: flex; align-items: center; gap: 11px; min-height: 64px; padding: 8px 10px;
  border-radius: 10px; cursor: pointer; transition: background .12s;
}
.dialog-item:hover { background: var(--bg-hover); }
.dialog-item.active { background: var(--accent); }
.dialog-item.active .dialog-title, .dialog-item.active .dialog-preview, .dialog-item.active .dialog-time,
.dialog-item.active .d-ic, .dialog-item.active .d-prefix { color: #fff !important; }
.dialog-item.active .pill { background: #fff; color: var(--accent); }
.dialog-body { flex: 1; min-width: 0; }
.dialog-top, .dialog-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dialog-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; display: flex; align-items: center; gap: 4px; }
.dialog-title > span { overflow: hidden; text-overflow: ellipsis; }
.d-ic { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.d-ic.verified { color: var(--accent); }
.dialog-time { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.dialog-preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; margin-top: 2px; }
.d-prefix { color: var(--accent-text); }
.d-meta { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.search-section-hdr { padding: 12px 10px 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.pill {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--badge-unread); color: #fff; font-size: 11.5px; font-weight: 600;
  line-height: 20px; text-align: center; flex-shrink: 0;
}
.pill--muted { background: var(--badge-muted); }
.pill--at { background: var(--badge-unread); padding: 0; width: 20px; }
.dlg-skel { display: flex; gap: 11px; align-items: center; padding: 10px; }
.dlg-skel .a { width: 48px; height: 48px; border-radius: 50%; }
.dlg-skel .l1 { height: 12px; width: 60%; margin-bottom: 8px; }
.dlg-skel .l2 { height: 10px; width: 85%; }

/* 头像 */
.avatar {
  position: relative; border-radius: 50%; color: #fff;
  background: linear-gradient(135deg, var(--av1, #5aa9f0), var(--av2, #2f7fd6));
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0; user-select: none; overflow: visible;
}
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; opacity: 0; transition: opacity .2s; }
.avatar-img.loaded { opacity: 1; }
.avatar[data-peer] { cursor: pointer; }
.avatar--96 { width: 96px; height: 96px; font-size: 32px; }
.avatar--48 { width: 48px; height: 48px; font-size: 16px; }
.avatar--44 { width: 44px; height: 44px; font-size: 15px; }
.avatar--40 { width: 40px; height: 40px; font-size: 14px; }
.avatar--36 { width: 36px; height: 36px; font-size: 13px; }
.avatar--msg { width: 34px; height: 34px; font-size: 12px; }

/* 右栏 */
.chat-col { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-chat); }
.chat-col::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(circle at 1px 1px, var(--border-light) 1px, transparent 0);
  background-size: 22px 22px;
}
.chat-col > * { position: relative; }
#chat-header {
  height: 58px; flex-shrink: 0; background: var(--bg-surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 10px 0 16px;
  font-size: 15px; font-weight: 600; color: var(--text-muted); z-index: 2;
}
.chat-header-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; flex: 1; cursor: pointer; }
.chat-header-title { font-size: 15px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-sub { font-size: 12.5px; font-weight: 400; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-actions { display: flex; gap: 2px; }
.chat-leave { display: none; }
.chat-col.no-chat #chat-header, .chat-col.no-chat .composer, .chat-col.no-chat #message-list { display: none; }
.chat-empty { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 24px; color: var(--text-secondary); }
.chat-col.no-chat .chat-empty { display: flex; }
.chat-empty-ic { width: 72px; height: 72px; border-radius: 50%; background: var(--bg-surface); display: flex; align-items: center; justify-content: center; color: var(--accent); box-shadow: var(--shadow); margin-bottom: 6px; }
.chat-empty-ic .i { width: 32px; height: 32px; }
.chat-empty-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.chat-empty-sub { font-size: 13px; max-width: 360px; line-height: 1.6; }

.chat-search-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--bg-surface); border-bottom: 1px solid var(--border); flex-shrink: 0; z-index: 2; }
.chat-search-bar .muted { font-size: 12px; white-space: nowrap; min-width: 48px; text-align: center; }

#message-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 14px 0 10px; }
#message-list > *:first-child { margin-top: auto; }
.msg-loading { padding: 24px; text-align: center; color: var(--text-secondary); font-size: 13px; }

/* 气泡 */
.msg { display: flex; align-items: flex-end; margin: 2px 0; padding: 0 max(16px, calc((100% - 860px) / 2)); }
.msg.out, .msg.msg-out { justify-content: flex-end; }
.msg.grouped { margin-top: 1px; }
.msg.flash .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow-sm); } }
.msg-inner { display: flex; flex-direction: column; max-width: min(540px, 76%); min-width: 0; align-items: flex-start; }
.msg.out .msg-inner, .msg.msg-out .msg-inner { align-items: flex-end; }
.bubble {
  max-width: 100%; padding: 6px 10px 7px 11px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.42; position: relative;
  overflow-wrap: anywhere; min-width: 56px; box-shadow: var(--shadow-sm);
}
.msg.in .bubble, .msg.msg-in .bubble { background: var(--bubble-in); border-bottom-left-radius: 5px; }
.msg.out .bubble, .msg.msg-out .bubble { background: var(--bubble-out); border-bottom-right-radius: 5px; }
.msg.has-media-only .bubble { padding: 3px; }
.msg.has-media-only .bubble .meta { position: absolute; right: 9px; bottom: 9px; margin: 0; padding: 1px 7px; border-radius: 10px; background: rgba(0,0,0,.45); color: #fff !important; }
.bubble .text { white-space: pre-wrap; }
.bubble .text:empty { display: none; }
.bubble .meta {
  float: right; margin: 7px -3px -4px 10px; font-size: 11px; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 3px; user-select: none; white-space: nowrap;
}
.msg.out .bubble .meta, .msg.msg-out .bubble .meta { color: var(--bubble-out-meta); }
.meta .edited { font-style: italic; }
.meta .i { width: 13px; height: 13px; }
.bubble .sender { font-size: 13px; font-weight: 600; margin-bottom: 1px; color: var(--sc, var(--accent-text)) !important; }
.fwd-label { font-size: 12.5px; color: var(--accent-text); margin-bottom: 3px; display: flex; align-items: center; gap: 4px; }
.fwd-label .i { width: 13px; height: 13px; }
.reply-quote {
  display: block; border-left: 3px solid var(--accent) !important; background: var(--accent-soft) !important;
  border-radius: 5px !important; padding: 3px 8px !important; margin: 2px 0 5px !important;
  font-size: 13px !important; color: var(--text-secondary) !important; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.reply-quote b { display: block; color: var(--accent-text); font-size: 12px; }
.msg.out .reply-quote { border-left-color: var(--success) !important; background: rgba(34,165,89,.1) !important; }
.msg.out .reply-quote b { color: var(--success); }
.msg-action {
  position: absolute; top: 4px; right: -32px; width: 26px; height: 26px; border: none; border-radius: 50%;
  background: var(--bg-surface); color: var(--text-secondary); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .12s;
}
.msg.out .msg-action { right: auto; left: -32px; }
.msg-action .i { width: 16px; height: 16px; }
.msg:hover .msg-action { opacity: 1; }
.msg-service { align-self: center; margin: 6px auto; padding: 3px 12px; border-radius: 12px; font-size: 12.5px; color: #fff; background: rgba(0, 0, 0, .28); max-width: 80%; text-align: center; }
.msg > .avatar { margin-right: 8px; margin-bottom: 1px; }
.msg > .avatar-spacer { width: 34px; margin-right: 8px; flex-shrink: 0; }

/* 文本格式 */
.fmt-code { font-family: var(--mono); font-size: .9em; background: rgba(127, 127, 127, .15); padding: 1px 5px; border-radius: 4px; }
.fmt-pre { display: block; font-family: var(--mono); font-size: 12.5px; background: rgba(127, 127, 127, .13); padding: 8px 10px; border-radius: 8px; margin: 4px 0; white-space: pre-wrap; overflow-x: auto; }
.fmt-spoiler { background: var(--text-secondary); color: transparent; border-radius: 4px; cursor: pointer; transition: all .2s; }
.fmt-spoiler.shown { background: rgba(127,127,127,.15); color: inherit; }
.fmt-quote { display: block; border-left: 3px solid var(--accent); padding-left: 8px; margin: 3px 0; color: var(--text-secondary); }
.msg-mention, .msg-link, .msg-cmd { color: var(--accent-text); cursor: pointer; word-break: break-all; }
.msg-mention:hover, .msg-link:hover, .msg-cmd:hover { text-decoration: underline; }
.search-hit { background: rgba(255, 200, 0, .45); color: inherit; border-radius: 3px; }

/* 媒体 */
.msg-media { max-width: 340px; border-radius: 11px; overflow: hidden; cursor: pointer; position: relative; margin: 1px 0 4px; }
.msg.has-media-only .msg-media { margin: 0; }
.msg-photo { display: block; width: 100%; height: auto; max-height: 380px; object-fit: cover; background: var(--bg-elevated); min-height: 80px; min-width: 120px; }
.msg-media.media-fail { min-height: 0; padding: 14px 18px; background: var(--bg-elevated); text-align: center; color: var(--text-muted); font-size: 12px; cursor: default; }
.msg-media.media-fail img { display: none; }
.msg-media.media-fail::after { content: "媒体加载失败 / 过大"; }
.msg-video .play-badge { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50px; height: 50px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; backdrop-filter: blur(4px); }
.video-dur { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 8px; }
.msg-video-player { max-width: 340px; max-height: 380px; border-radius: 11px; display: block; margin: 1px 0 4px; }
.msg-album { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; max-width: 340px; border-radius: 11px; overflow: hidden; margin: 1px 0 4px; }
.msg-album.n3 > .msg-media:first-child { grid-column: span 2; }
.msg-album .msg-media { margin: 0; border-radius: 0; max-width: none; }
.msg-album .msg-photo { height: 130px; max-height: 130px; min-height: 0; min-width: 0; }
.msg-sticker { max-width: 160px; background: transparent; }
.msg.has-sticker .bubble { background: transparent !important; box-shadow: none; padding: 0; }
.msg.has-sticker .bubble .meta { background: rgba(0,0,0,.4); color: #fff !important; padding: 1px 7px; border-radius: 10px; }
.msg-sticker img { width: 100%; height: auto; display: block; }
.msg-doc {
  display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 2px; cursor: pointer;
  font-size: 13.5px; margin: 2px 0 4px; max-width: 320px; min-width: 200px;
}
.doc-ic { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg.out .doc-ic { background: var(--success); }
.doc-ic .i { width: 20px; height: 20px; }
.doc-info { min-width: 0; }
.doc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-size { color: var(--text-muted); font-size: 12px; }
.msg-webpage { border-left: 3px solid var(--accent); padding: 2px 0 2px 9px; margin: 4px 0; font-size: 13px; cursor: pointer; max-width: 360px; }
.msg-webpage .wp-site { color: var(--accent-text); font-weight: 600; font-size: 12.5px; }
.msg-webpage .wp-title { font-weight: 600; }
.msg-webpage .wp-desc { color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.msg-poll { min-width: 240px; max-width: 360px; margin: 2px 0 4px; position: relative; }
.msg-poll.busy { opacity: .6; pointer-events: none; }
.msg-poll .poll-q { font-weight: 600; margin-bottom: 4px; display: flex; gap: 6px; align-items: flex-start; }
.msg-poll .poll-q .i { margin-top: 3px; color: var(--accent); }
.msg-poll .poll-tags { display: flex; gap: 6px; margin-bottom: 8px; }
.msg-poll .poll-tags span { font-size: 11px; color: var(--text-muted); border: 1px solid var(--border-light); border-radius: 99px; padding: 0 7px; }
.msg-poll.is-quiz .poll-tags span:first-child { color: var(--accent-text); border-color: var(--accent); }
.poll-a { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 1px solid var(--border-light); border-radius: 9px; margin-bottom: 5px; font-size: 13.5px; background: transparent; color: inherit; text-align: left; overflow: hidden; }
button.poll-a { cursor: pointer; transition: border-color .12s, background .12s; }
button.poll-a:hover { border-color: var(--accent); background: var(--accent-soft); }
button.poll-a.sel { border-color: var(--accent); background: var(--accent-soft); }
.poll-a .pa-text { position: relative; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-a .pa-pct { position: relative; font-weight: 600; font-size: 12.5px; color: var(--text-secondary); }
.poll-a .pa-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); transition: width .35s; }
.poll-a.chosen { border-color: var(--accent); }
.poll-a.correct { border-color: var(--success); }
.poll-a.correct .pa-bar { background: var(--success-soft); }
.poll-a.wrong { border-color: var(--danger); }
.poll-a.wrong .pa-bar { background: var(--danger-soft); }
.pa-radio, .pa-box { position: relative; width: 16px; height: 16px; border: 2px solid var(--border-light); flex-shrink: 0; }
.pa-radio { border-radius: 50%; }
.pa-box { border-radius: 4px; }
.poll-a.sel .pa-box, .poll-a.sel .pa-radio { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 2px var(--bg-surface); }
.poll-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.poll-foot .poll-submit { margin-left: auto; }
.poll-foot .poll-refresh { margin-left: auto; padding: 2px 6px; min-height: 24px; }
.poll-foot .poll-submit + .poll-refresh, .poll-foot .poll-retract + .poll-refresh { margin-left: 0; }
.poll-solution { margin-top: 6px; padding: 7px 10px; border-radius: 9px; background: var(--warn-soft); font-size: 13px; line-height: 1.5; }
.msg-geo, .msg-contact { display: flex; align-items: center; gap: 10px; padding: 4px 2px; font-size: 13.5px; cursor: pointer; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 10000; display: flex; align-items: center; justify-content: center; cursor: zoom-out; animation: fade .15s; backdrop-filter: blur(6px); }
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox-bar { position: fixed; top: 14px; right: 14px; display: flex; gap: 8px; }
.lightbox-bar a, .lightbox-bar button { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; border: none; display: flex; align-items: center; justify-content: center; }
.lightbox-bar a:hover, .lightbox-bar button:hover { background: rgba(255,255,255,.25); }
@keyframes fade { from { opacity: 0; } }

/* 日期分隔 */
.date-chip {
  position: sticky; top: 6px; z-index: 1; align-self: center; margin: 10px auto;
  background: rgba(0, 0, 0, .3); color: #fff; font-size: 12.5px; font-weight: 500;
  padding: 3px 11px; border-radius: 12px; backdrop-filter: blur(6px);
}

/* 内联键盘 */
.msg-kb { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; width: 100%; }
.msg-kb-row { display: flex; gap: 3px; }
.kb-btn {
  flex: 1; min-width: 0; background: var(--bg-surface); border: none; border-radius: 9px;
  padding: 8px 10px; color: var(--accent-text); font-size: 13px; font-weight: 500; line-height: 1.3;
  text-align: center; white-space: normal; word-break: break-word; box-shadow: var(--shadow-sm);
  transition: background .15s, color .15s;
}
.kb-btn:hover { background: var(--accent); color: #fff; }
/* 固定在输入框上方的回复键盘 */
.kb-panel { flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; padding: 8px 14px; background: var(--bg-surface); border-top: 1px solid var(--border); max-height: 220px; overflow-y: auto; }
.kb-panel .kbp-row { display: flex; gap: 4px; }
.kb-panel .kb-btn { background: var(--bg-elevated); box-shadow: none; padding: 9px 10px; color: var(--text-primary); }
.kb-panel .kb-btn:hover { background: var(--accent); color: #fff; }
.kb-btn.is-loading { opacity: .6; pointer-events: none; }
.kb-btn.is-loading::before { margin-right: 6px; display: inline-block; vertical-align: -2px; }
.kb-copy, .kb-switch { color: var(--text-secondary); }
.kb-btn-disabled, .kb-btn-disabled:hover { color: var(--text-muted); background: var(--bg-surface); cursor: default; }

/* 回到底部 */
.scroll-down {
  position: absolute !important; right: 20px; bottom: 82px; z-index: 5;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--bg-surface); color: var(--text-secondary); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; animation: fade .15s;
}
.scroll-down:hover { color: var(--accent); }
.scroll-down em { position: absolute; top: -6px; right: -4px; font-style: normal; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; line-height: 20px; }
.drop-zone { position: absolute !important; inset: 8px; z-index: 20; border: 2px dashed var(--accent); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--bg-surface) 85%, transparent); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; color: var(--accent-text); pointer-events: none; }
.drop-zone .i { width: 34px; height: 34px; display: block; margin: 0 auto 8px; }

/* 回复/编辑栏 */
#reply-bar { display: flex; align-items: center; gap: 12px; flex-shrink: 0; padding: 8px 14px 6px 18px; background: var(--bg-surface); border-top: 1px solid var(--border); }
.reply-ic { color: var(--accent); width: 22px; height: 22px; }
.reply-body { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 10px; }
.reply-label { font-size: 13px; color: var(--accent-text); font-weight: 600; }
.reply-preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* composer */
.composer { flex-shrink: 0; display: flex; align-items: flex-end; gap: 4px; padding: 10px 14px; background: var(--bg-surface); border-top: 1px solid var(--border); }
#reply-bar:not([hidden]) + .composer { border-top: none; }
#msg-input {
  flex: 1; resize: none; border-radius: 20px; border-color: transparent; background: var(--bg-elevated);
  padding: 10px 16px; min-height: 42px; max-height: 180px; line-height: 1.45; margin: 0 4px;
}
#msg-input:focus { box-shadow: none; border-color: var(--accent); background: var(--bg-surface); }
#send-btn {
  width: 42px; height: 42px; flex-shrink: 0; border: none; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
#send-btn svg { width: 20px; height: 20px; }
#send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
#send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* 浮层: 菜单 / 表情 / 命令 */
.ctx-menu {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 5px;
  min-width: 180px; box-shadow: var(--shadow-lg); animation: pop .12s ease-out; transform-origin: top left;
}
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.ctx-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.ctx-item .i { width: 17px; height: 17px; color: var(--text-secondary); }
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger, .ctx-item.danger .i { color: var(--danger); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.picker-panel { position: fixed; z-index: 9997; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 8px; animation: pop .12s ease-out; }
.emoji-panel { width: 320px; max-height: 260px; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-cell { border: none; background: transparent; font-size: 21px; line-height: 1; height: 36px; border-radius: 8px; }
.emoji-cell:hover { background: var(--bg-hover); }
.cmd-panel, .cmd-popup { min-width: 240px; max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.cmd-tip { font-size: 11px; color: var(--text-muted); padding: 4px 8px 6px; }
.cmd-cell { border: none; background: transparent; text-align: left; font-size: 13px; padding: 8px 10px; border-radius: 8px; }
.cmd-cell:hover { background: var(--bg-hover); }
.cmd-name { font-family: var(--mono); color: var(--accent-text); }
.cmd-desc { color: var(--text-secondary); margin-left: 6px; }
#older-indicator {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 30;
  font-size: 12px; color: var(--text-secondary); background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; box-shadow: var(--shadow); pointer-events: none;
}

/* ===== 定时 / 群发视图 ===== */
#view-scheduled { display: grid; grid-template-columns: 420px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100%; }
.sched-form-panel { background: var(--bg-surface); border-right: 1px solid var(--border); padding: 22px; overflow-y: auto; min-height: 0; }
.sched-list-panel { padding: 22px; overflow-y: auto; min-height: 0; min-width: 0; }
.panel-divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
#sched-list button { font-size: 12px; }
.bc-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.bc-card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.bc-status { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--bg-elevated); }
.bc-card-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.bc-card-msg { font-size: 13px; margin-top: 8px; padding: 8px 10px; background: var(--bg-elevated); border-radius: var(--radius-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-card-ops { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.bc-btn { background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: 7px; padding: 4px 12px; font-size: 12.5px; transition: border-color .15s, background .15s; }
.bc-btn:hover { background: var(--bg-hover); }
.bc-btn.danger { color: var(--danger); }
.bc-btn.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.bc-logs { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); max-height: 220px; overflow-y: auto; font-size: 12px; font-family: var(--mono); }
.bc-log-line { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-log-time { color: var(--text-muted); }
.bc-log-detail { color: var(--text-secondary); }
.prog { height: 6px; border-radius: 6px; background: var(--bg-elevated); overflow: hidden; margin-top: 8px; }
.prog span { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ===== AI 加群 / 进群 ===== */
.aijoin-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 12px; align-items: end; }
.aijoin-srcs { display: flex; gap: 14px; align-items: center; min-height: 38px; margin-top: 6px; }
.join-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#join-progress { margin-top: 16px; }
.join-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* ---------------- 弹窗 ---------------- */
.overlay {
  position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; animation: fade .15s;
}
.modal {
  width: min(420px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 24px 22px; box-shadow: var(--shadow-lg); position: relative; animation: modal-in .2s cubic-bezier(.2,.9,.3,1.15);
}
.modal--wide { width: min(520px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-sub, .step-indicator { font-size: 13px; color: var(--text-secondary); margin-bottom: 18px; }
.modal-text { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin: 6px 0 20px; white-space: pre-wrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .btn { min-width: 84px; min-height: 38px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: none; border-radius: 50%; background: transparent; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-hero { display: flex; justify-content: center; margin-bottom: 12px; }
.modal-hero-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.modal-hero-ic .i { width: 28px; height: 28px; }
.modal-hero + .modal-title { text-align: center; }
.modal-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.modal-icon .i { width: 22px; height: 22px; }
.steps { display: flex; list-style: none; gap: 6px; margin: 10px 0 20px; counter-reset: s; }
.steps li { flex: 1; text-align: center; font-size: 12px; color: var(--text-muted); padding-top: 8px; border-top: 3px solid var(--border); counter-increment: s; }
.steps li::before { content: counter(s) ". "; }
.steps li.on { color: var(--accent-text); border-top-color: var(--accent); font-weight: 600; }
.steps li.done { color: var(--success); border-top-color: var(--success); }
.code-input { font-size: 22px !important; letter-spacing: 8px; text-align: center; font-family: var(--mono); }
#login-error, #settings-error { color: var(--danger); font-size: 12.5px; margin-top: 10px; min-height: 16px; line-height: 1.4; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 4px 0 16px; }
.profile-name { font-size: 19px; font-weight: 700; text-align: center; }
.profile-bot { font-size: 11px; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 6px; vertical-align: middle; }
.profile-rows { display: flex; flex-direction: column; margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.profile-row { display: flex; gap: 12px; font-size: 13.5px; padding: 10px 14px; border-top: 1px solid var(--border); }
.profile-row:first-child { border-top: none; }
.profile-k { color: var(--text-muted); flex-shrink: 0; width: 56px; }
.profile-v { word-break: break-word; min-width: 0; flex: 1; }
.profile-copy { border: none; background: none; color: var(--text-muted); padding: 0 2px; }
.profile-copy:hover { color: var(--accent); }
.settings-tabs { margin-bottom: 18px; }
.settings-tab.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.settings-h3 { font-size: 14px; font-weight: 600; margin: 4px 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#set-2fa-status { font-size: 12px; font-weight: 500; }
.session-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.session-item:last-child { border-bottom: none; }
.session-info { flex: 1; min-width: 0; }
.session-app { font-size: 14px; font-weight: 600; }
.session-cur { font-size: 11px; color: var(--success); background: var(--success-soft); padding: 1px 7px; border-radius: 99px; font-weight: 600; margin-left: 4px; }
.session-dev { font-size: 13px; color: var(--text-secondary); }
.session-meta { font-size: 12px; color: var(--text-muted); }

/* 上传预览 */
.up-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; margin-bottom: 14px; }
.up-item { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.up-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--bg-elevated); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.up-meta { min-width: 0; flex: 1; font-size: 13px; }
.up-meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-meta span { color: var(--text-muted); font-size: 12px; }
.up-big { max-width: 100%; max-height: 280px; border-radius: 10px; display: block; margin: 0 auto 14px; }

/* 选择列表(转发目标等) */
.pick-list { max-height: 340px; overflow-y: auto; margin: 0 -8px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.pick-row:hover, .pick-row.kb { background: var(--bg-hover); }
.pick-row .pr-main { min-width: 0; flex: 1; }
.pick-row .pr-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-row .pr-sub { font-size: 12px; color: var(--text-muted); }

/* 命令面板 ⌘K */
.cmdk { position: fixed; inset: 0; z-index: 1100; background: var(--overlay); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fade .12s; backdrop-filter: blur(3px); }
.cmdk-box { width: min(560px, calc(100vw - 24px)); background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: modal-in .16s ease-out; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input .i { color: var(--text-muted); }
.cmdk-input input { border: none; padding: 0; font-size: 16px; background: transparent; box-shadow: none !important; }
.cmdk-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 8px 10px 4px; letter-spacing: .5px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.cmdk-item .i { color: var(--text-secondary); }
.cmdk-item small { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.cmdk-item.on { background: var(--accent-soft); }
.cmdk-item.on .i { color: var(--accent); }
.cmdk-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); }

/* ---------------- toast ---------------- */
#toast-container { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 11000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; pointer-events: auto;
  background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px 10px 12px; font-size: 13.5px; max-width: min(560px, 88vw);
  box-shadow: var(--shadow-lg); animation: toast-in .2s cubic-bezier(.2,.9,.3,1.2); word-break: break-word;
}
.toast .i { width: 18px; height: 18px; color: var(--accent); }
.toast.success .i { color: var(--success); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.toast.error .i { color: var(--danger); }
.toast.warn .i { color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* 实时连接横幅(断线时) */
#conn-state { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9000; font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow); }
#conn-state.bad { color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-border); }
#conn-state.ok { color: var(--success); background: var(--bg-surface); border: 1px solid var(--border); }

/* ---------------- 密码门 ---------------- */
#panel-gate { position: fixed; inset: 0; z-index: 12000; display: flex; align-items: center; justify-content: center; background: var(--bg-app); }
#panel-gate .gate-card { width: 360px; max-width: calc(100vw - 32px); background: var(--bg-surface); border: 1px solid var(--border); border-radius: 20px; padding: 34px 28px 28px; text-align: center; box-shadow: var(--shadow-lg); animation: modal-in .25s ease-out; }
#panel-gate .gate-logo { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, #4aa8f5, #2a7bd4); box-shadow: 0 8px 24px rgba(51,144,236,.3); }
#panel-gate h1 { font-size: 19px; font-weight: 700; }
#panel-gate .gate-sub { color: var(--text-secondary); font-size: 13px; margin: 6px 0 22px; }
#panel-gate #gate-form { display: flex; flex-direction: column; gap: 10px; }
#panel-gate #gate-password { text-align: center; letter-spacing: 1px; height: 44px; }
#panel-gate #gate-submit { height: 44px; border: none; border-radius: var(--radius-sm); background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; }
#panel-gate #gate-submit:disabled { opacity: .6; }
#panel-gate .gate-error { color: var(--danger); font-size: 13px; }

/* 手机端非工作区页面的菜单按钮 */
.m-fab {
  display: none; position: fixed; top: 10px; left: 10px; z-index: 900;
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow);
  align-items: center; justify-content: center;
}
.m-fab .i { width: 20px; height: 20px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .dash-cols { grid-template-columns: minmax(0, 1fr); }
  #view-chats { grid-template-columns: 290px minmax(0, 1fr); }
  #view-scheduled { grid-template-columns: 360px minmax(0, 1fr); }
  .tab span { display: none; }
  .tab { padding: 0 14px; }
}
@media (max-width: 900px) {
  .al-grid { grid-template-columns: 1fr; }
  #view-scheduled { grid-template-columns: 1fr; overflow-y: auto; }
  .sched-form-panel { border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .sched-list-panel { overflow: visible; }
  .page { padding: 22px 20px 40px; }
}

/* 手机: 侧栏抽屉 + 对话二选一 + 底部标签栏 */
@media (max-width: 640px) {
  #shell, html.side-collapsed #shell, #shell.ws-full { grid-template-columns: minmax(0, 1fr); --side-w: 0px; }
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 1200;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  body.m-nav-open #sidebar { transform: none; box-shadow: var(--shadow-lg); }
  /* 抽屉里始终展开显示文字 */
  #shell.ws-full #sidebar .side-name, #shell.ws-full #sidebar .side-item span, #shell.ws-full #sidebar .side-group,
  #shell.ws-full #sidebar .side-search span, #shell.ws-full #sidebar .ws-pill span, #shell.ws-full #sidebar .side-count,
  html.side-collapsed #sidebar .side-name, html.side-collapsed #sidebar .side-item span, html.side-collapsed #sidebar .side-group,
  html.side-collapsed #sidebar .side-search span, html.side-collapsed #sidebar .ws-pill span, html.side-collapsed #sidebar .side-count { display: initial; }
  #shell.ws-full #sidebar .side-item, html.side-collapsed #sidebar .side-item { justify-content: flex-start; padding: 12px 14px; }
  #shell.ws-full #sidebar .side-brand, html.side-collapsed #sidebar .side-brand { flex-direction: row; }
  #shell.ws-full #sidebar .side-foot-row, html.side-collapsed #sidebar .side-foot-row { flex-direction: row; }
  .side-collapse, #cmdk-btn kbd { display: none !important; }
  #m-nav-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 1190; }
  .m-only { display: inline-flex; }
  .page { padding: 60px 14px 32px; }
  .page.page--flush { padding: 0; }
  .page-title { font-size: 19px; }
  .m-fab { display: flex !important; }
  body.on-ws .m-fab { display: none !important; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head-actions .btn { flex: 1; }
  .m-top { display: flex !important; }
  input, select, textarea { font-size: 16px !important; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dash-stat { padding: 12px; gap: 10px; }
  .dash-stat-ic { width: 34px; height: 34px; }
  .dash-stat .num { font-size: 21px; }
  .dash-actions { grid-template-columns: minmax(0, 1fr); }
  .accounts-grid, .dash-account-list { grid-template-columns: 1fr; }
  .grid-2, .option-grid, .join-opts { grid-template-columns: 1fr; }
  .toolbar .search-input { max-width: none; flex-basis: 100%; }

  .app { grid-template-columns: minmax(0, 1fr); }
  #account-rail { display: none; }
  .tabbar { padding: 0 6px; height: 52px; }
  #back-to-accounts { display: none; }
  .tabbar .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--bg-surface); border-top: 1px solid var(--border); z-index: 1100;
  }
  .tabbar .tabs .tab { flex: 1; flex-direction: column; justify-content: center; gap: 2px; font-size: 11px; padding: 0; }
  .tabbar .tabs .tab span { display: inline; }
  .tabbar .tabs .tab.active::after { display: none; }
  .tabbar-right { max-width: none; flex: 1; }
  .views { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  body.m-in-chat .views { padding-bottom: 0; }
  body.m-in-chat .tabbar .tabs { display: none; }
  #view-chats { grid-template-columns: minmax(0, 1fr); }
  .dialog-col { display: flex; border-right: none; }
  .chat-col { display: none; }
  body.m-in-chat .dialog-col { display: none; }
  body.m-in-chat .chat-col { display: flex; }
  .msg { padding: 0 10px; }
  .msg-inner { max-width: 86%; }
  .msg-action { opacity: 1; position: static; display: none; }
  .composer { padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .composer #schedule-btn { display: none; }
  #view-scheduled { display: block; overflow-y: auto; }
  .sched-form-panel, .sched-list-panel { padding: 16px 14px; }
  .view-inner { padding: 16px 14px 32px; }
  .modal { padding: 22px 18px 18px; }
  #toast-container { bottom: 76px; }
  .lightbox img { max-width: 100vw; }
}
@media (min-width: 641px) { .m-back { display: none !important; } }
