/* 聊天工作区：侧栏 + 主对话区（深度优化） */

.hbm-chat-shell {
    height: calc(100vh - 140px);
    min-height: 520px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    border: 1px solid #e8eef5;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hbm-chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
}

.hbm-chat-sidebar {
    width: 292px;
    flex-shrink: 0;
    border-right: 1px solid #e8eef5;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef3f9 100%);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.hbm-sidebar-close {
    display: none;
}

.hbm-sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    overflow-y: auto;
    min-height: 0;
    flex: 1;
}

.hbm-agent-selector h3,
.hbm-chat-history h3 {
    margin: 0 0 10px;
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
}

.hbm-chat-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hbm-action-btn {
    border: none;
    border-radius: 10px;
    padding: 11px 12px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.hbm-action-btn:hover {
    transform: translateY(-1px);
}

.hbm-action-primary {
    background: linear-gradient(135deg, #1576e8, #1d4ed8);
    color: #fff;
    box-shadow: 0 6px 16px rgba(21, 118, 232, 0.25);
}

.hbm-action-warm {
    background: #fff;
    color: #b45309;
    border: 1px solid #f3d2a8;
}

.hbm-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hbm-history-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 10px 10px 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.hbm-history-item:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.06);
}

.hbm-history-item.active {
    border-color: #1576e8;
    background: #f8fbff;
    box-shadow: 0 0 0 1px rgba(21, 118, 232, 0.12);
}

.hbm-history-main {
    flex: 1;
    min-width: 0;
}

.hbm-history-title {
    font-size: 13px;
    color: #1e293b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hbm-history-meta {
    margin-top: 6px;
    font-size: 12px;
    color: #94a3b8;
}

.hbm-history-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.55;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
    padding: 0;
}

.hbm-history-item:hover .hbm-history-delete,
.hbm-history-item.active .hbm-history-delete {
    opacity: 1;
}

.hbm-history-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

.hbm-history-empty {
    color: #94a3b8;
    font-size: 13px;
    padding: 8px 0;
}

.hbm-sidebar-overlay {
    display: none;
}

.hbm-chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.hbm-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #eef2f7;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    position: relative;
    z-index: 1;
    min-width: 0;
}

.hbm-chat-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    flex: 1 1 auto;
    min-width: 0;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hbm-mobile-toggle {
    display: none;
    border: 1px solid #d0dceb;
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    color: #334155;
    font-size: 13px;
}

.hbm-chat-info {
    font-size: 12px;
    color: #94a3b8;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f1f5f9;
}

.hbm-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    flex-wrap: nowrap;
}

.hbm-turn-nav {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
}

.hbm-turn-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #334155;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.hbm-turn-btn:hover { background: #eff6ff; color: #1d4ed8; }
.hbm-turn-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.hbm-turn-jump {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #475569;
    user-select: none;
    margin: 0;
}

.hbm-turn-jump input {
    width: 42px;
    height: 26px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
    padding: 0 4px;
    -moz-appearance: textfield;
}

.hbm-turn-jump input::-webkit-outer-spin-button,
.hbm-turn-jump input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hbm-turn-jump input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.hbm-turn-total {
    color: #64748b;
    min-width: 28px;
}

.hbm-attach-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
}

.hbm-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    font-size: 12px;
    color: #334155;
}

.hbm-attach-chip img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
}

.hbm-attach-chip .name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hbm-attach-chip .remove {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}

.hbm-attach-chip .remove:hover { color: #dc2626; }

.message.user .hbm-user-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.message.user .hbm-user-attachments img {
    max-width: 160px;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
}

.message.user .hbm-user-file {
    font-size: 12px;
    color: #64748b;
    background: rgba(255,255,255,.55);
    border-radius: 6px;
    padding: 4px 8px;
}

.main-answer-content .md-img {
    max-width: 100%;
    border-radius: 8px;
    margin: 0.5em 0;
}

.message[data-turn].hbm-turn-flash {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.hbm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px 20px 28px;
    background:
        radial-gradient(1200px 280px at 50% -40px, rgba(37, 99, 235, 0.05), transparent 60%),
        #f5f7fb;
}

.hbm-welcome {
    max-width: 640px;
    margin: 48px auto;
    text-align: center;
    color: #475569;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.04);
}

.hbm-welcome-badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.hbm-welcome h3 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: 20px;
}

.hbm-welcome .tip {
    margin-top: 14px;
    font-size: 13px;
    color: #64748b;
}

.hbm-welcome-opening {
    text-align: left;
    line-height: 1.7;
    color: #334155;
    font-size: 14px;
    margin: 12px 0 0;
}

.hbm-welcome-desc {
    margin: 12px 0 0;
    font-size: 13px;
    color: #64748b;
    text-align: left;
    line-height: 1.6;
}

.hbm-suggest-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    margin-top: 18px;
    text-align: left;
}

.hbm-suggest-q {
    appearance: none;
    border: 1px solid #dbe3f0;
    background: #f8fafc;
    color: #1e3a5f;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.45;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hbm-suggest-q:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

/* ===== 消息气泡 ===== */
.message {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 14px;
    position: relative;
    max-width: min(860px, 88%);
    word-break: break-word;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.04);
    animation: hbmMsgIn 0.22s ease;
}

@keyframes hbmMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    margin-left: auto;
    background: linear-gradient(135deg, #1576e8, #1d4ed8);
    color: #fff;
    border-bottom-right-radius: 6px;
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(29, 78, 216, 0.18);
}

.message.assistant {
    margin-right: auto;
    background: #fff;
    color: #202124;
    border-bottom-left-radius: 6px;
    border-color: #e2e8f0;
    padding-top: 12px;
}

.message.system {
    margin: 10px auto;
    max-width: 90%;
    text-align: center;
    background: #e8f0fe;
    color: #1a73e8;
    border: 1px solid #c2d7ff;
    box-shadow: none;
}

.message-toolbar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
    margin: 10px 0 0;
    min-height: 28px;
}

.message-content {
    line-height: 1.65;
    font-size: 15px;
}

.message.assistant .message-content {
    margin-bottom: 0;
}

/* 复制按钮：对话气泡左下角 */
.copy-btn {
    position: static;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.copy-btn:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.copy-btn.is-copied {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.copy-btn .layui-icon {
    font-size: 14px;
}

/* 思考折叠块 */
.thinking-details,
details.thinking-details {
    margin: 0 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    overflow: hidden;
}

.thinking-details.is-streaming {
    border-color: #bfdbfe;
    background: linear-gradient(180deg, #f8fbff 0%, #eff6ff 100%);
}

.thinking-details > summary,
.thinking-summary,
details.thinking-details > summary {
    cursor: pointer;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-details > summary::-webkit-details-marker,
.thinking-summary::-webkit-details-marker {
    display: none;
}

.thinking-chevron {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: #e2e8f0;
    position: relative;
    flex-shrink: 0;
    transition: transform 0.15s ease, background 0.15s ease;
}

.thinking-chevron::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 4px;
    width: 6px;
    height: 6px;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(-45deg);
}

.thinking-details[open] > summary .thinking-chevron {
    transform: rotate(90deg);
    background: #dbeafe;
}

.thinking-details[open] > summary .thinking-chevron::before {
    border-color: #2563eb;
}

.thinking-label {
    color: #334155;
}

.thinking-details.is-streaming .thinking-label {
    color: #1d4ed8;
}

.thinking-expand-hint {
    margin-left: auto;
    font-weight: 400;
    font-size: 12px;
    color: #94a3b8;
}

.thinking-details.is-streaming .thinking-expand-hint {
    color: #3b82f6;
}

.thinking-content,
.thinking-details .thinking-body {
    padding: 0 14px 12px;
    font-size: 13px;
    color: #64748b;
    line-height: 1.65;
    border-top: 1px dashed #e2e8f0;
    margin-top: 0;
    padding-top: 12px;
    max-height: 280px;
    overflow-y: auto;
}

.thinking-content .md-p,
.thinking-content p {
    color: #64748b !important;
    margin: 0.4em 0;
}

.thinking-details.is-streaming .thinking-content {
    border-top-color: #bfdbfe;
}


/* Markdown 可视化 */
.main-answer-content .md-h {
    margin: 0.85em 0 0.4em;
    color: #0f172a;
    font-weight: 700;
    line-height: 1.35;
}
.main-answer-content h1.md-h { font-size: 1.35em; }
.main-answer-content h2.md-h { font-size: 1.22em; }
.main-answer-content h3.md-h { font-size: 1.1em; }
.main-answer-content h4.md-h,
.main-answer-content h5.md-h,
.main-answer-content h6.md-h { font-size: 1em; }

.main-answer-content .md-p {
    margin: 0.55em 0;
    color: #202124;
}

.main-answer-content .md-list {
    margin: 0.5em 0 0.5em 1.2em;
    padding: 0;
    color: #202124;
}

.main-answer-content .md-list li {
    margin: 0.25em 0;
}

.main-answer-content .md-quote {
    margin: 0.6em 0;
    padding: 8px 12px;
    border-left: 3px solid #1576e8;
    background: #f8fafc;
    color: #334155;
}

.main-answer-content .md-hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 1em 0;
}

.main-answer-content .md-inline-code,
.main-answer-content code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.92em;
    color: #0f172a;
}

.main-answer-content .md-code {
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.7em 0;
    font-size: 13px;
    line-height: 1.5;
}

.main-answer-content .md-code code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.md-table-wrap {
    overflow-x: auto;
    margin: 0.7em 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #fff;
}

.md-table th,
.md-table td {
    border: 1px solid #e2e8f0;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
    color: #202124;
}

.md-table th {
    background: #f1f5f9;
    font-weight: 600;
}

.md-table tr:nth-child(even) td {
    background: #fafbfc;
}

.stream-stopped {
    color: #94a3b8;
    margin-top: 8px;
    font-size: 13px;
}

.stream-error {
    color: #dc2626;
}

/* ===== 输入区 ===== */
.hbm-chat-input {
    border-top: 1px solid #eef2f7;
    padding: 14px 16px 16px;
    background: #fff;
}

.hbm-input-container {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.hbm-input-container textarea {
    flex: 1;
    min-height: 78px;
    max-height: 180px;
    resize: vertical;
    border: 1px solid #d7e3f4;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.55;
    background: #fbfdff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.hbm-input-container textarea:focus {
    outline: none;
    border-color: #93c5fd;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.hbm-input-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: flex-end;
    min-width: 92px;
}

.hbm-input-actions .layui-btn {
    min-width: 92px;
    margin: 0;
    height: 38px;
    line-height: 38px;
    border-radius: 10px;
    font-weight: 500;
}

.hbm-input-actions .layui-btn-normal {
    background: linear-gradient(135deg, #1576e8, #1d4ed8);
    border: none;
    box-shadow: 0 6px 14px rgba(21, 118, 232, 0.22);
}

.hbm-input-actions .layui-btn-danger {
    background: #fff;
    color: #dc2626;
    border: 1px solid #fecaca;
    box-shadow: none;
}

.hbm-input-actions .layui-btn-danger:hover {
    background: #fef2f2;
}

.hbm-attach-btn {
    background: #fff !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
}

.hbm-attach-btn:hover {
    background: #f8fafc !important;
    border-color: #94a3b8 !important;
}

.hbm-login-tip {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    background: #e8f0fe;
    text-align: center;
    color: #1e3a5f;
}

.thinking-progress-container {
    display: none;
}

.thinking-progress-container.active {
    display: block;
}

@media screen and (max-width: 900px) {
    .hbm-chat-shell {
        height: calc(100vh - 120px);
        border-radius: 0;
        box-shadow: none;
        border-left: none;
        border-right: none;
    }

    .hbm-mobile-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .hbm-chat-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: 8px 0 24px rgba(15, 23, 42, 0.18);
        width: min(320px, 86vw);
    }

    .hbm-chat-shell.sidebar-open .hbm-chat-sidebar {
        transform: translateX(0);
    }

    .hbm-sidebar-overlay {
        display: none;
        position: absolute;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 15;
    }

    .hbm-chat-shell.sidebar-open .hbm-sidebar-overlay {
        display: block;
    }

    .message {
        max-width: 94%;
    }

    .hbm-history-delete {
        opacity: 1;
    }
}
