* { box-sizing: border-box; }

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --white: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --placeholder: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-drawer: 2px 0 12px rgba(0, 0, 0, 0.12);
}

html, body {
    min-height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--white);
    font-size: 14px;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 500; }
p { margin: 0; }

/* 登录页 */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 28px 16px; }
.auth-shell { width: 100%; max-width: 480px; }
.narrow-shell { max-width: 500px; }
.install-shell { max-width: 560px; }
.auth-panel { width: 100%; padding: 36px 42px; background: var(--white); border: 1px solid var(--border); border-radius: 2px; box-shadow: var(--shadow); }
.brand-mark { margin-bottom: 26px; color: var(--primary); font-size: 22px; font-weight: 600; text-align: center; }
.auth-panel h1 { margin: 0 0 8px; font-size: 24px; font-weight: 500; text-align: center; }
.muted { margin: 0 0 26px; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: center; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 7px; font-size: 13px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 12px 14px; color: var(--text); background: var(--white);
    border: 1px solid var(--border); border-radius: 2px; outline: none;
    transition: border-color 0.2s;
}
.form-group textarea { min-height: 128px; resize: vertical; line-height: 1.6; }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--placeholder); }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.section-title { margin: 26px 0 16px; padding-bottom: 9px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 10px 16px; color: var(--text); background: var(--white);
    border: 1px solid var(--border); border-radius: 2px; cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
}
.button:hover { color: var(--primary-hover); border-color: var(--primary); }
.button:disabled, .button.is-disabled { cursor: not-allowed; opacity: 0.5; }
.button:disabled:hover, .button.is-disabled:hover { color: var(--text); border-color: var(--border); }
.button-primary { color: var(--white); background: var(--primary); border-color: var(--primary); }
.button-primary:hover { color: var(--white); background: var(--primary-hover); border-color: var(--primary-hover); }
.button-danger { color: var(--danger); border-color: var(--danger); }
.button-danger:hover { color: var(--white); background: var(--danger); border-color: var(--danger); }
.button-small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.button-block { width: 100%; }
.form-error { margin-bottom: 18px; padding: 11px 12px; color: var(--danger); border: 1px solid var(--danger); border-radius: 2px; line-height: 1.7; }
.notice, .token-box { margin: 16px 0; padding: 12px 14px; color: var(--muted); border: 1px solid var(--border); border-radius: 2px; line-height: 1.6; }
.token-box span { display: block; margin-bottom: 8px; font-size: 12px; }
.token-box code { display: block; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }

/* 后台 */
.app-page { min-height: 100vh; background: var(--white); }
.app-header { border-bottom: 1px solid var(--border); background: var(--white); }
.header-inner, .app-main { width: min(1480px, calc(100% - 32px)); margin: 0 auto; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; padding-left: 64px; }
.app-title { margin: 0; font-size: 20px; font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.admin-name { color: var(--muted); font-size: 13px; }
.app-main { padding: 24px 0 40px; }

/* 视图切换 */
.view { display: block; }
.view[hidden] { display: none; }

/* 状态行 */
.status-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 2px; }
.status-copy { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.status-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--muted); }
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); }
.status-dot.error { background: var(--warning); }
.status-title { font-weight: 600; }
.status-detail { color: var(--muted); font-size: 12px; }

/* 统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-item { padding: 17px 16px; border: 1px solid var(--border); border-radius: 2px; }
.stat-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.stat-value { font-size: 25px; font-weight: 500; }

/* 工具栏 */
.tool-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-tab { min-height: 34px; padding: 7px 12px; color: var(--muted); background: var(--white); border: 1px solid var(--border); border-radius: 2px; cursor: pointer; }
.filter-tab:hover, .filter-tab.active { color: var(--primary); border-color: var(--primary); }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* 批量操作栏 */
.bulk-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; padding: 10px 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 2px; font-size: 12px; }
.bulk-bar[hidden] { display: none; }
.bulk-help { margin-left: auto; color: var(--placeholder); }
.bulk-actions { display: flex; justify-content: flex-end; }

/* 会话列表 */
.conversation-section { margin-bottom: 18px; padding: 14px; border: 1px solid var(--border); border-radius: 2px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { font-size: 15px; font-weight: 600; }
.section-heading span { color: var(--muted); font-size: 12px; }
.conversation-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.conversation-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px; color: var(--text); text-align: left; background: var(--white); border: 1px solid var(--border); border-radius: 2px; cursor: pointer; }
.conversation-item:hover, .conversation-item.active { border-color: var(--primary); }
.conversation-item.active { background: #eff6ff; }
.avatar { width: 38px; height: 38px; flex: 0 0 38px; object-fit: cover; background: var(--white); border: 1px solid var(--border); border-radius: 2px; }
.conversation-meta { min-width: 0; overflow: hidden; }
.conversation-name { display: block; overflow: hidden; margin-bottom: 3px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.conversation-uin { display: inline-block; max-width: 100%; overflow: hidden; color: var(--danger); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-kind { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.active-mark { display: inline-block; margin-left: 4px; color: var(--success); }

/* 消息表格 */
.table-shell { overflow: hidden; border: 1px solid var(--border); border-radius: 2px; }
.table-scroll { overflow-x: auto; }
.message-table { width: 100%; min-width: 1040px; border-collapse: collapse; }
.select-column { width: 54px; text-align: center !important; }
.message-table th, .message-table td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; }
.message-table th { color: var(--muted); background: var(--white); font-size: 12px; font-weight: 500; white-space: nowrap; }
.message-table tbody tr:last-child td { border-bottom: 0; }
.message-table tbody tr:hover td { background: #f8fbff; }
.message-user { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.message-user .avatar { width: 32px; height: 32px; flex-basis: 32px; }
.message-user-name { margin-bottom: 3px; font-weight: 500; }
.message-user-uin { color: var(--danger); font-size: 11px; }
.message-text { max-width: 280px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.message-reply { max-width: 240px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.muted-cell, .sub-cell { color: var(--muted); font-size: 12px; }
.send-error { margin-top: 6px; color: var(--danger); font-size: 12px; }
.recall-state { margin-top: 6px; }
.modal-field-spaced { margin-top: 18px; }
.status-badge, .recall-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 7px; border: 1px solid currentColor; border-radius: 2px; font-size: 12px; white-space: nowrap; }
.status-pending { color: var(--danger); }
.status-replied { color: var(--success); }
.status-sent { color: var(--muted); }
.recall-success { color: var(--success); }
.recall-failed { color: var(--danger); }
.recall-pending, .recall-dispatched { color: var(--warning); }
.action-list { display: flex; flex-wrap: wrap; gap: 6px; min-width: 130px; }
.empty-state, .loading-state { padding: 42px 20px; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; }
.page-number { color: var(--muted); font-size: 13px; }

/* 弹窗 */
.modal-backdrop { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(255, 255, 255, 0.88); }
.modal-backdrop.open { display: flex; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; background: var(--white); border: 1px solid var(--border); border-radius: 2px; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 8px; font-size: 18px; font-weight: 500; }
.modal-description { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.checkbox-line input, .message-table input[type="checkbox"] { accent-color: var(--primary); }

/* Toast */
.toast-container { position: fixed; top: 20px; left: 50%; z-index: 2000; display: flex; flex-direction: column; gap: 12px; transform: translateX(-50%); }
.toast { display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: min(420px, calc(100vw - 32px)); padding: 14px 17px; background: var(--white); border: 1px solid var(--border); border-radius: 2px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); animation: toastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast-message { flex: 1; line-height: 1.5; }
.toast-close { padding: 2px; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.toast.hiding { animation: toastOut 0.25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-18px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-10px) scale(0.96); } }

/* 汉堡菜单 */
.hamburger {
    position: fixed; top: 16px; left: 16px; z-index: 1100;
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text); background: var(--white);
    border: 1px solid var(--border); border-radius: 2px;
    font-size: 20px; cursor: pointer;
    box-shadow: var(--shadow);
}
.hamburger:hover { color: var(--primary); border-color: var(--primary); }

.drawer {
    position: fixed; top: 0; left: 0; z-index: 1200;
    width: 260px; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--white);
    box-shadow: var(--shadow-drawer);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-header strong { font-size: 15px; font-weight: 600; }
.drawer-close {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); background: transparent; border: none;
    border-radius: 2px; font-size: 20px; line-height: 1; cursor: pointer;
}
.drawer-close:hover { color: var(--danger); }
.drawer-nav { flex: 1; display: flex; flex-direction: column; padding: 8px 0; overflow-y: auto; }
.drawer-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; color: var(--text);
    font-size: 14px; text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.drawer-nav a i { font-size: 18px; width: 18px; text-align: center; }
.drawer-nav a:hover { color: var(--primary); background: #f3f7ff; border-left-color: var(--primary); }
.drawer-nav a.active { color: var(--primary); background: #eff6ff; border-left-color: var(--primary); }
.drawer-footer { padding: 12px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 1100; background: rgba(0, 0, 0, 0.35); }
.drawer-backdrop[hidden] { display: none; }

/* ===== 自绘内联 SVG 图标（不再依赖外部 CDN） ===== */
.ic {
    display: inline-block; width: 18px; height: 18px; flex: 0 0 18px;
    background: currentColor;
    -webkit-mask: no-repeat center / contain;
    mask: no-repeat center / contain;
}
.ic-sm { width: 16px; height: 16px; flex-basis: 16px; }
.ic-lg { width: 22px; height: 22px; flex-basis: 22px; }
.ic-home      { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5L12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3Cpath d='M9.5 21v-6h5v6'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5L12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3Cpath d='M9.5 21v-6h5v6'/%3E%3C/svg%3E"); }
.ic-messages  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16v11H8l-4 4z'/%3E%3Cpath d='M8 9h8M8 12.5h5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16v11H8l-4 4z'/%3E%3Cpath d='M8 9h8M8 12.5h5'/%3E%3C/svg%3E"); }
.ic-list      { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11'/%3E%3Cpath d='M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11'/%3E%3Cpath d='M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); }
.ic-send      { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 3L10.5 13.5'/%3E%3Cpath d='M21 3l-7 18-3.5-7.5L3 10z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 3L10.5 13.5'/%3E%3Cpath d='M21 3l-7 18-3.5-7.5L3 10z'/%3E%3C/svg%3E"); }
.ic-refresh   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 0 0-14.3-4.7M4 5v5h5'/%3E%3Cpath d='M4 13a8 8 0 0 0 14.3 4.7M20 19v-5h-5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 0 0-14.3-4.7M4 5v5h5'/%3E%3Cpath d='M4 13a8 8 0 0 0 14.3 4.7M20 19v-5h-5'/%3E%3C/svg%3E"); }
.ic-logout    { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-3'/%3E%3Cpath d='M9 12h12M18 9l3 3-3 3'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-3'/%3E%3Cpath d='M9 12h12M18 9l3 3-3 3'/%3E%3C/svg%3E"); }
.ic-menu      { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 6h16M4 12h16M4 18h16'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 6h16M4 12h16M4 18h16'/%3E%3C/svg%3E"); }
.ic-x         { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
.ic-back      { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E"); }
.ic-user      { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4 3.6-6.5 8-6.5s8 2.5 8 6.5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4 3.6-6.5 8-6.5s8 2.5 8 6.5'/%3E%3C/svg%3E"); }
.ic-info      { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E"); }

/* ===== 聊天页 ===== */
.chat-page { display: flex; flex-direction: column; height: 100vh; background: #f5f6f8; }
.chat-topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 10px;
    height: 56px; padding: 0 12px;
    background: var(--white); border-bottom: 1px solid var(--border);
}
.chat-back {
    width: 38px; height: 38px; flex: 0 0 38px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text); background: transparent; border: 0; border-radius: 50%; cursor: pointer;
}
.chat-back:hover { background: #f3f4f6; color: var(--primary); }
.chat-head { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.chat-head .avatar { width: 40px; height: 40px; flex-basis: 40px; border-radius: 50%; }
.chat-head-meta { min-width: 0; flex: 1; }
.chat-head-name { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-sub { display: block; color: var(--muted); font-size: 12px; }
.chat-online-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.chat-online-dot.online { background: var(--success); }
.chat-info-btn {
    width: 38px; height: 38px; flex: 0 0 38px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); background: transparent; border: 0; border-radius: 50%; cursor: pointer;
}
.chat-info-btn:hover { color: var(--primary); background: #f3f4f6; }

.chat-stream { flex: 1; overflow-y: auto; padding: 16px 12px 24px; -webkit-overflow-scrolling: touch; }
.day-divider { margin: 14px 0; text-align: center; }
.day-divider span { padding: 3px 10px; color: var(--muted); background: #e9ebef; border-radius: 2px; font-size: 11px; }
.msg-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.msg-row.me { flex-direction: row-reverse; }
.msg-row .avatar { width: 36px; height: 36px; flex-basis: 36px; border-radius: 50%; }
.msg-bubble-wrap { max-width: 72%; display: flex; flex-direction: column; }
.msg-row.me .msg-bubble-wrap { align-items: flex-end; }
.msg-name { margin: 0 4px 4px; color: var(--muted); font-size: 11px; }
.msg-bubble {
    position: relative;
    padding: 9px 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
    background: var(--white); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.msg-row.me .msg-bubble { color: var(--white); background: var(--primary); border-color: var(--primary); }
.msg-bubble.is-pending { background: #fef9ec; border-color: #fde68a; color: #92400e; }
.msg-row.me .msg-bubble.is-pending { background: var(--warning); border-color: var(--warning); color: #fff; }
.msg-bubble.is-recalling { opacity: 0.6; }
.msg-bubble.is-recalled { color: var(--muted); font-style: italic; background: #f3f4f6; border-style: dashed; }
.msg-meta { margin-top: 4px; padding: 0 4px; color: var(--placeholder); font-size: 10px; }

.chat-inputbar {
    position: sticky; bottom: 0; z-index: 50;
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px; background: var(--white); border-top: 1px solid var(--border);
}
.chat-inputbar textarea {
    flex: 1; min-height: 40px; max-height: 120px; padding: 10px 12px;
    background: #f3f4f6; border: 1px solid transparent; border-radius: 8px; outline: none; resize: none; line-height: 1.5;
}
.chat-inputbar textarea:focus { background: var(--white); border-color: var(--primary); }
.chat-send {
    width: 44px; height: 44px; flex: 0 0 44px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--white); background: var(--primary); border: 0; border-radius: 50%; cursor: pointer;
}
.chat-send:hover { background: var(--primary-hover); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* 长按操作菜单 */
.msg-action-menu {
    position: fixed; left: 50%; bottom: 18%; z-index: 3000;
    min-width: 180px; padding: 6px;
    background: var(--white); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.22);
    transform: translateX(-50%);
}
.msg-action-menu button {
    display: block; width: 100%; padding: 11px 14px;
    background: transparent; border: 0; border-radius: 6px; cursor: pointer; text-align: center; font-size: 14px;
}
.msg-action-menu button:hover { background: #f3f4f6; }
.msg-action-menu button.danger { color: var(--danger); }

/* 用户信息抽屉 */
.profile-panel { position: fixed; top: 0; right: 0; z-index: 1500; width: min(320px, 88vw); height: 100vh; display: flex; flex-direction: column; background: var(--white); box-shadow: -4px 0 18px rgba(0,0,0,0.14); transform: translateX(100%); transition: transform 0.22s ease; }
.profile-panel.open { transform: translateX(0); }
.profile-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.profile-panel-body { flex: 1; overflow-y: auto; padding: 20px 16px; }
.profile-avatar { width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 50%; border: 1px solid var(--border); }
.profile-name { text-align: center; font-size: 18px; font-weight: 600; }
.profile-uin { text-align: center; margin: 4px 0 18px; color: var(--muted); font-size: 13px; }
.profile-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 2px; border-bottom: 1px solid #f0f1f3; font-size: 13px; }
.profile-row span:first-child { color: var(--muted); }
.profile-row span:last-child { text-align: right; word-break: break-all; }

@media (max-width: 780px) {
    .header-inner, .app-main { width: min(100% - 24px, 1480px); }
    .header-inner { align-items: flex-start; flex-direction: column; justify-content: center; padding: 12px 0 12px 64px; }
    .header-actions { width: 100%; justify-content: space-between; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .status-line { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 520px) {
    .auth-panel { padding: 28px 20px; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .stats-grid { gap: 8px; }
    .stat-item { padding: 13px 12px; }
    .stat-value { font-size: 21px; }
    .conversation-list { grid-template-columns: 1fr; }
    .tool-row, .toolbar-actions, .filter-tabs { width: 100%; }
    .toolbar-actions .button, .filter-tabs .filter-tab { flex: 1; }
    .app-header .header-inner { padding-left: 56px; }
}