/* ============================================
   RTHW 认证知识库 AI - 共用样式
   与 RTHW CBBS 视觉风格保持一致
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f7f6f3;
    --white: #ffffff;
    --text: rgba(0,0,0,0.95);
    --text-secondary: #615d59;
    --text-muted: #a39e98;
    --primary: #0075de;
    --primary-hover: #005bab;
    --primary-light: #f2f9ff;
    --green: #16a34a;
    --green-light: #f0fdf4;
    --red: #e03131;
    --red-light: #fef2f2;
    --border: rgba(0,0,0,0.1);
    --radius: 12px;
    --shadow-sm: 0 0.175px 1.04px rgba(0,0,0,0.01), 0 0.8px 2.925px rgba(0,0,0,0.02), 0 2.025px 7.847px rgba(0,0,0,0.027), 0 4px 18px rgba(0,0,0,0.04);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.01), 0 3px 7px rgba(0,0,0,0.02), 0 7px 15px rgba(0,0,0,0.02), 0 14px 28px rgba(0,0,0,0.04);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
    background: var(--bg);
    min-height: 100vh; color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ---------- 顶栏 ---------- */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 24px; height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-brand .logo {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, #0075de, #3aa0ff);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; flex: none;
}
.topbar-brand h1 {
    font-size: 15px; font-weight: 700; letter-spacing: -0.25px;
    min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-brand .tag {
    font-size: 11px; color: var(--text-muted); font-weight: 500;
    padding: 2px 8px; background: var(--bg); border-radius: 9999px;
    flex: none;
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; }
.topbar-user { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.topbar-user strong { color: var(--text); font-weight: 600; }
.role-badge {
    display: inline-block; padding: 2px 8px; border-radius: 9999px;
    font-size: 11px; font-weight: 600;
}
.role-badge.admin { background: var(--primary-light); color: var(--primary); }
.role-badge.user { background: rgba(0,0,0,0.05); color: var(--text-secondary); }
.topbar-actions { display: flex; gap: 6px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
    border: 1px solid var(--border); background: var(--white); color: var(--text-secondary);
    cursor: pointer; transition: all 0.15s; font-family: inherit; text-decoration: none;
}
.btn:hover { color: var(--primary); background: var(--primary-light); border-color: rgba(0,117,222,0.3); }
.btn-primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-danger { color: var(--red); border-color: var(--border); }
.btn-danger:hover { color: var(--red); background: var(--red-light); border-color: rgba(224,49,49,0.3); }
.btn-green { color: var(--green); border-color: var(--border); }
.btn-green:hover { color: var(--green); background: var(--green-light); border-color: rgba(22,163,74,0.3); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-icon { padding: 5px 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 前台主布局 ---------- */
.app {
    max-width: 1480px; margin: 0 auto; padding: 20px 24px 60px;
    display: grid; grid-template-columns: 240px 1fr 360px; gap: 18px; align-items: start;
}
@media (max-width: 1200px) {
    .app { grid-template-columns: 1fr 340px; }
    .conv-panel { display: none; }
    .app.sidebar-open .conv-panel {
        display: flex; position: fixed; left: 0; top: 56px; bottom: 0; width: 280px;
        z-index: 150; box-shadow: var(--shadow-md);
    }
}
.icon-btn {
    border: 1px solid var(--border); background: var(--white); border-radius: 8px;
    width: 32px; height: 32px; cursor: pointer; font-size: 14px; color: var(--text-secondary);
    display: none; align-items: center; justify-content: center;
}
@media (max-width: 1200px) { .icon-btn { display: inline-flex; } }

/* ---------- 会话侧边栏 ---------- */
.conv-panel {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 400px;
    overflow: hidden;
}
.conv-head {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.conv-head .t { font-size: 14px; font-weight: 700; }
.conv-list { flex: 1; overflow-y: auto; padding: 10px; }
.conv-empty { padding: 20px 12px; color: var(--text-muted); font-size: 12.5px; text-align: center; }
.conv-item {
    padding: 10px 12px; border-radius: 10px; cursor: pointer;
    border: 1px solid transparent; margin-bottom: 6px; transition: all 0.15s;
    position: relative;
}
.conv-item:hover { background: var(--bg); border-color: var(--border); }
.conv-item.active { background: var(--primary-light); border-color: rgba(0,117,222,0.25); }
.conv-info { min-width: 0; }
.conv-title {
    font-size: 13px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 44px;
}
.conv-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.conv-actions {
    position: absolute; right: 8px; top: 8px; display: none; gap: 2px;
}
.conv-item:hover .conv-actions { display: flex; }
.conv-btn {
    border: none; background: var(--white); cursor: pointer; font-size: 11px;
    width: 20px; height: 20px; border-radius: 5px; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
}
.conv-btn:hover { color: var(--primary); background: var(--primary-light); }
.conv-btn.del:hover { color: var(--red); background: var(--red-light); }

/* ---------- 知识库条目附件 ---------- */
.kb-atts { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.kb-att {
    font-size: 12px; padding: 4px 10px; border-radius: 8px;
    background: var(--primary-light); color: var(--primary);
    border: 1px solid rgba(0,117,222,0.2); text-decoration: none;
}
.kb-att:hover { background: var(--primary); color: #fff; }

/* ---------- 登录页 ---------- */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background: linear-gradient(135deg, #f7f6f3 0%, #eef3f8 100%);
}
.login-card {
    background: var(--white); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow-md); padding: 36px 34px; width: 100%; max-width: 400px;
}
.login-logo {
    width: 56px; height: 56px; border-radius: 16px;
    background: linear-gradient(135deg, #0075de, #3aa0ff);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #fff; margin: 0 auto 16px;
}
.login-card h2 { text-align: center; font-size: 18px; font-weight: 700; }
.login-sub { text-align: center; font-size: 12.5px; color: var(--text-muted); margin: 6px 0 24px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 13px; }
.chat-panel, .kb-panel {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}

/* ---------- 对话区 ---------- */
.chat-panel { display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 520px; }
.chat-head {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.chat-head .t { font-size: 15px; font-weight: 700; }
.chat-head .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 18px;
    background: linear-gradient(180deg, #fbfaf8, #fff 140px);
}
.msg { display: flex; gap: 12px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.msg.ai .avatar { background: linear-gradient(135deg, #0075de, #3aa0ff); color: #fff; }
.msg.user .avatar { background: rgba(0,0,0,0.07); }
.msg .bubble {
    padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.7;
    word-break: break-word; white-space: pre-wrap;
}
.msg.ai .bubble { background: var(--white); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
/* AI 消息纵向列：正文气泡在上、引用标签在下，互不挤压 */
.msg .msg-col { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.msg .bubble :global(p) { margin: 0 0 8px; }
.msg .bubble ol, .msg .bubble ul { padding-left: 20px; margin: 6px 0; }
.msg .bubble li { margin: 3px 0; }
.msg .bubble strong { font-weight: 600; }
.msg .bubble code {
    background: rgba(0,0,0,0.05); padding: 1px 6px; border-radius: 5px;
    font-size: 12.5px; font-family: 'SFMono-Regular', Consolas, monospace;
}
.msg .bubble pre {
    background: #1e1e2e; color: #e6e6e6; padding: 12px 14px; border-radius: 10px;
    overflow-x: auto; font-size: 12.5px; line-height: 1.6; margin: 8px 0;
}
.msg .bubble pre code { background: transparent; color: inherit; padding: 0; }

.msg .bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 13px; }
.msg .bubble th, .msg .bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.msg .bubble th { background: var(--bg); font-weight: 600; }

.kb-refs { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.kb-ref {
    font-size: 11px; padding: 3px 9px; border-radius: 9999px;
    background: var(--green-light); color: var(--green);
    border: 1px solid rgba(22,163,74,0.2); font-weight: 500;
    max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.typing-dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing-dots i {
    width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
    animation: blink 1.2s infinite both;
}
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.25; } 40% { opacity: 1; } }

.chat-input {
    padding: 16px 20px; border-top: 1px solid var(--border); background: var(--white);
}
.input-row { display: flex; gap: 10px; align-items: stretch; }
.input-box {
    flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--bg);
    padding: 12px 14px; font-size: 14px; line-height: 1.6; color: var(--text);
    resize: none; min-height: 88px; max-height: 68vh; overflow-y: auto; font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-text-size-adjust: 100%;
}
.input-box:focus { outline: none; border-color: rgba(0,117,222,0.5); background: #fff; box-shadow: 0 0 0 3px rgba(0,117,222,0.08); }
.input-box::placeholder { color: var(--text-muted); }
#btnSend { padding: 0 22px; flex: none; }
.input-resize {
    height: 14px; display: flex; align-items: center; justify-content: center;
    cursor: ns-resize; touch-action: none; user-select: none; -webkit-user-select: none;
    margin: 2px 0 -4px; border-radius: 6px;
}
.input-resize .grip {
    width: 44px; height: 4px; border-radius: 9999px; background: var(--border);
    transition: background 0.15s, width 0.15s;
}
.input-resize:hover .grip, .input-resize.dragging .grip { background: rgba(0,117,222,0.45); width: 60px; }
.input-hint { margin-top: 8px; font-size: 11.5px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }

.empty-state {
    text-align: center; color: var(--text-muted); padding: 60px 30px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state .icon { font-size: 44px; opacity: 0.5; }
.empty-state .suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.suggest-chip {
    padding: 7px 14px; border-radius: 9999px; border: 1px solid var(--border);
    background: var(--white); font-size: 13px; color: var(--text-secondary);
    cursor: pointer; transition: all 0.15s;
}
.suggest-chip:hover { border-color: rgba(0,117,222,0.4); color: var(--primary); background: var(--primary-light); }

/* ---------- 知识库面板 ---------- */
.kb-panel { display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 520px; }
.kb-head {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.kb-head .t { font-size: 15px; font-weight: 700; }
.kb-head .count { font-size: 12px; color: var(--text-muted); }
.kb-search { padding: 12px 20px 4px; }
.kb-search input {
    width: 100%; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border);
    font-size: 13px; background: var(--bg); font-family: inherit;
}
.kb-search input:focus { outline: none; border-color: rgba(0,117,222,0.5); background: #fff; }
.kb-cats {
    display: flex; gap: 8px; padding: 10px 20px 4px; flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}
.cat-chip {
    padding: 4px 12px; border-radius: 9999px; font-size: 12px; cursor: pointer;
    border: 1px solid var(--border); color: var(--text-secondary);
    background: var(--white); transition: all 0.15s; font-weight: 500;
}
.cat-chip:hover { border-color: rgba(0,117,222,0.4); }
.cat-chip.active { background: var(--primary); color: #fff; border-color: transparent; }
.kb-list { flex: 1; overflow-y: auto; padding: 12px 20px 20px; }
.kb-item {
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 10px; transition: all 0.15s; background: var(--white);
}
.kb-item:hover { border-color: rgba(0,117,222,0.35); box-shadow: var(--shadow-sm); }
.kb-item .kb-title { font-size: 14px; font-weight: 600; color: var(--text); }
.kb-item .kb-meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.kb-item .kb-cat {
    font-size: 11px; padding: 2px 8px; border-radius: 9999px;
    background: var(--primary-light); color: var(--primary); font-weight: 500;
}
.kb-item .kb-time { font-size: 11px; color: var(--text-muted); }
.kb-item .kb-content {
    font-size: 13px; color: var(--text-secondary); line-height: 1.7;
    margin-top: 8px; white-space: pre-wrap; display: none;
}
.kb-item.open .kb-content { display: block; }
.kb-item .kb-chevron { float: right; color: var(--text-muted); font-size: 12px; transition: transform 0.15s; }
.kb-item.open .kb-chevron { transform: rotate(180deg); }

/* ---------- 后台管理 ---------- */
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 24px 24px 80px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-sm);
}
.stat-card .num { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.stat-card .lbl { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-card .icon { float: right; font-size: 22px; opacity: 0.35; }

.card {
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin-bottom: 20px; overflow: hidden;
}
.card-head {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-head .t { font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 20px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="text"], .toolbar select {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px;
    font-size: 13px; background: var(--bg); font-family: inherit; color: var(--text);
}
.toolbar input[type="text"]:focus, .toolbar select:focus {
    outline: none; border-color: rgba(0,117,222,0.5); background: #fff;
}

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse; font-size: 13.5px;
}
table.data th, table.data td {
    padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top;
}
table.data th {
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    background: #fbfaf8; text-transform: uppercase; letter-spacing: 0.04em;
    white-space: nowrap;
}
table.data tr:hover td { background: #fcfbf9; }
table.data td.title-cell { max-width: 320px; }
table.data td.title-cell .t { font-weight: 600; color: var(--text); }
table.data td.title-cell .preview { color: var(--text-muted); font-size: 12px; margin-top: 3px; display: block; }
.cat-badge {
    display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 9999px;
    background: var(--primary-light); color: var(--primary); font-weight: 500; white-space: nowrap;
}
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.pill-count {
    display: inline-block; min-width: 20px; text-align: center; padding: 1px 7px;
    border-radius: 9999px; background: rgba(0,0,0,0.06); color: var(--text-secondary);
    font-size: 11px; font-weight: 600;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
    display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 20px;
    opacity: 0; pointer-events: none; transition: opacity 0.18s; overflow-y: auto;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--white); border-radius: 14px; width: 100%; max-width: 640px;
    box-shadow: var(--shadow-md); transform: translateY(10px); transition: transform 0.18s;
}
.modal-mask.show .modal { transform: translateY(0); }
.modal-head {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-head .t { font-size: 16px; font-weight: 700; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--text-muted); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group .req { color: var(--red); }
.form-group input[type="text"], .form-group textarea, .form-group select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
    font-size: 13.5px; font-family: inherit; color: var(--text); background: var(--white);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: rgba(0,117,222,0.5); box-shadow: 0 0 0 3px rgba(0,117,222,0.08);
}
.form-group textarea { min-height: 180px; line-height: 1.7; resize: vertical; }
.form-group .help { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; top: 70px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--text); color: #fff; padding: 11px 18px; border-radius: 10px;
    font-size: 13.5px; box-shadow: var(--shadow-md); animation: slideIn 0.2s ease;
    max-width: 360px; line-height: 1.5;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.out { opacity: 0; transform: translateX(20px); transition: all 0.3s; }

/* ---------- 空状态 / 提示 ---------- */
.note {
    padding: 12px 16px; border-radius: 10px; font-size: 13px; line-height: 1.6;
    background: var(--primary-light); color: var(--primary); border: 1px solid rgba(0,117,222,0.15);
}
.note.warn { background: #fffbeb; color: #b45309; border-color: rgba(180,83,9,0.2); }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
    .app { grid-template-columns: 1fr !important; }
    .conv-panel { display: none; }
    .app.sidebar-open .conv-panel {
        display: flex; position: fixed; left: 0; top: 56px; bottom: 0; width: 280px;
        z-index: 150; box-shadow: var(--shadow-md);
    }
    .chat-panel, .kb-panel { height: auto; }
    .chat-panel {
        height: calc(100vh - 128px);
        height: calc(100svh - 128px); /* 移动端浏览器地址栏收起时不超屏 */
        min-height: 420px;
    }
    .kb-panel { height: 60vh; }
}
@media (max-width: 640px) {
    .topbar { padding: 0 14px; }
    .app { padding: 14px 12px 40px; }
    .app > * { min-width: 0; }
    .topbar-user .username { display: none; }
    .msg { max-width: 100%; }
    .admin-wrap { padding: 16px 12px 60px; }
}

/* ---------- 批量上传：拖拽区 / 文件队列 ---------- */
.drop-zone {
    border: 2px dashed rgba(0,117,222,0.35); border-radius: var(--radius);
    background: #fafcff; padding: 28px 20px; text-align: center; cursor: pointer;
    transition: all 0.15s;
}
.drop-zone:hover, .drop-zone.over {
    border-color: var(--primary); background: var(--primary-light);
}
.drop-zone .dz-icon { font-size: 30px; opacity: 0.6; margin-bottom: 6px; }
.drop-zone .dz-t { font-size: 14px; font-weight: 600; color: var(--text); }
.drop-zone .dz-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.6; }

.file-queue {
    margin-top: 12px; border: 1px solid var(--border); border-radius: 10px;
    max-height: 240px; overflow-y: auto; background: var(--white);
}
.fq-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    border-bottom: 1px solid var(--border-light, rgba(0,0,0,0.05)); font-size: 12.5px;
}
.fq-row:last-child { border-bottom: none; }
.fq-name {
    font-weight: 600; color: var(--text); max-width: 44%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fq-size { color: var(--text-muted); flex: none; }
.fq-msg { color: var(--text-secondary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fq-status {
    flex: none; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 9999px;
    background: rgba(0,0,0,0.05); color: var(--text-secondary);
}
.fq-status.ok { background: var(--green-light); color: var(--green); }
.fq-status.skip { background: #fffbeb; color: #b45309; }
.fq-status.warn { background: #fff7ed; color: #c2410c; }
.fq-status.err { background: var(--red-light); color: var(--red); }
.fq-status.run { background: var(--primary-light); color: var(--primary); }

/* ---------- 分页器 ---------- */
.pager {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    margin-top: 12px; font-size: 12.5px;
}
.pager-info { color: var(--text-muted); margin-right: auto; }

/* ---------- 原文档链接 ---------- */
.orig-link { font-size: 15px; text-decoration: none; cursor: pointer; }
.orig-link:hover { opacity: 0.7; }

/* ---------- 移动端适配增强 ---------- */
/* 卡片头部按钮组 / 表单行：允许换行，避免窄屏横向溢出 */
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 140px; }

@media (max-width: 768px) {
    /* 顶栏收紧：隐藏次要标签，保留核心操作 */
    .topbar { padding: 0 12px; }
    .topbar-brand .tag,
    .topbar-user .tag { display: none; }
}

@media (max-width: 640px) {
    /* 顶栏 */
    .topbar { height: 52px; }
    .app.sidebar-open .conv-panel { top: 52px; }
    .topbar-brand { gap: 8px; }
    .topbar-right { gap: 6px; }
    .topbar-actions { gap: 4px; }
    .topbar-actions .btn { padding: 5px 8px; font-size: 12px; }
    .topbar-user .role-badge { display: none; }
    .btn-register .reg-full { display: none; }
    .btn-register::after { content: "\6ce8\518c"; }

    /* 后台：卡片头部与工具栏自适应 */
    .card-head { gap: 10px; }
    .toolbar input[type="text"] { width: 100% !important; min-width: 0 !important; }
    .toolbar select { width: 100%; }

    /* 后台：表格与统计卡紧凑 */
    table.data th, table.data td { padding: 9px 10px; }
    .stat-grid { gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-card .num { font-size: 24px; }

    /* 前台：对话区紧凑，小屏不强行撑高 */
    .chat-panel, .kb-panel { min-height: 0; }
    .chat-head { padding: 12px 14px; }
    .chat-messages { padding: 14px; }
    .chat-input { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
    .empty-state { padding: 36px 16px; }

    /* 前台输入区（手机）：16px 字号避免 iOS 聚焦自动放大；手柄触摸区加大 */
    .input-box { font-size: 16px; min-height: 76px; max-height: 42vh; padding: 10px 12px; }
    #btnSend { padding: 0 16px; }
    .input-resize { height: 22px; margin: 0 0 -2px; }
    .input-resize .grip { width: 64px; height: 5px; }
    .input-hint { gap: 4px 12px; font-size: 11px; }

    /* 弹窗：改为底部抽屉式，便于单手操作 */
    .modal-mask { padding: 4vh 10px 0; align-items: flex-end; }
    .modal { max-height: 88vh; overflow-y: auto; border-radius: 16px 16px 0 0; }
    .modal-head, .modal-foot { padding: 12px 16px; }
    .modal-body { padding: 16px; }

    /* toast 靠边不溢出 */
    .toast-wrap { right: 10px; left: 10px; }
    .toast { max-width: none; }
}
