/* ============================================================
   B3.Chat.Widget — Component Stylesheet
   All classes prefixed with "b3chat-" to avoid collisions
   with Bootstrap or host application styles.
   ============================================================ */

/* ===== DARK THEME (FullPage mode) ===== */
.b3chat-theme-dark {
    --b3chat-bg: #0f172a;
    --b3chat-bg2: #1e293b;
    --b3chat-bg3: #334155;
    --b3chat-text: #e2e8f0;
    --b3chat-text2: #94a3b8;
    --b3chat-blue: #3b82f6;
    --b3chat-green: #22c55e;
    --b3chat-red: #ef4444;
    --b3chat-yellow: #eab308;
    --b3chat-radius: 8px;
    --b3chat-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --b3chat-sidebar-w: 260px;
    --b3chat-right-w: 280px;
    --b3chat-msg-user-bg: var(--b3chat-blue);
    --b3chat-msg-user-text: #ffffff;
    --b3chat-msg-assistant-bg: var(--b3chat-bg2);
    --b3chat-msg-assistant-text: var(--b3chat-text);
    --b3chat-msg-assistant-border: var(--b3chat-bg3);
    --b3chat-code-bg: var(--b3chat-bg);
    --b3chat-code-border: var(--b3chat-bg3);
    --b3chat-code-text: #e2e8f0;
    --b3chat-inline-code-bg: var(--b3chat-bg);
    --b3chat-input-bg: var(--b3chat-bg2);
    --b3chat-input-border: var(--b3chat-bg3);
    --b3chat-input-text: var(--b3chat-text);
    --b3chat-status-bg: var(--b3chat-bg);
    --b3chat-status-border: var(--b3chat-bg3);
}

/* ===== LIGHT THEME (Panel mode — embedded in AIS) ===== */
.b3chat-theme-light {
    --b3chat-bg: #ffffff;
    --b3chat-bg2: #f5f5f5;
    --b3chat-bg3: #e0e0e0;
    --b3chat-text: #333333;
    --b3chat-text2: #666666;
    --b3chat-blue: #1a237e;
    --b3chat-green: #2e7d32;
    --b3chat-red: #c62828;
    --b3chat-yellow: #f57f17;
    --b3chat-radius: 8px;
    --b3chat-font: 'Poppins', sans-serif;
    --b3chat-sidebar-w: 260px;
    --b3chat-right-w: 280px;
    --b3chat-msg-user-bg: var(--b3chat-blue);
    --b3chat-msg-user-text: #ffffff;
    --b3chat-msg-assistant-bg: #f0f4ff;
    --b3chat-msg-assistant-text: var(--b3chat-text);
    --b3chat-msg-assistant-border: transparent;
    --b3chat-code-bg: #1e293b;
    --b3chat-code-border: transparent;
    --b3chat-code-text: #e2e8f0;
    --b3chat-inline-code-bg: rgba(0, 0, 0, 0.06);
    --b3chat-input-bg: #ffffff;
    --b3chat-input-border: var(--b3chat-bg3);
    --b3chat-input-text: var(--b3chat-text);
    --b3chat-status-bg: #fafafa;
    --b3chat-status-border: var(--b3chat-bg3);
}


/* ===== ROOT CONTAINER ===== */
.b3chat {
    font-family: var(--b3chat-font);
    color: var(--b3chat-text);
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}
.b3chat-fullpage {
    background: var(--b3chat-bg);
}
.b3chat-panel-mode {
    flex-direction: column;
    background: var(--b3chat-bg);
}


/* ===== LEFT SIDEBAR (FullPage) ===== */
.b3chat-sidebar {
    width: var(--b3chat-sidebar-w);
    background: var(--b3chat-bg2);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--b3chat-bg3);
    flex-shrink: 0;
    transition: width 0.2s ease, opacity 0.2s ease;
    overflow: hidden;
}
.b3chat-sidebar.collapsed {
    width: 0;
    border-right: none;
}
.b3chat-sidebar.collapsed .b3chat-sidebar-inner {
    opacity: 0;
    pointer-events: none;
}
.b3chat-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: var(--b3chat-sidebar-w);
    opacity: 1;
    transition: opacity 0.15s ease;
}
.b3chat-sidebar-header {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--b3chat-bg3);
}
.b3chat-sidebar-header h2 {
    font-size: 0.9375rem;
    white-space: nowrap;
    margin: 0;
}
.b3chat-btn-new {
    background: var(--b3chat-blue);
    color: white;
    border: none;
    border-radius: var(--b3chat-radius);
    padding: 0.3rem 0.625rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
}
.b3chat-btn-new:hover { opacity: 0.9; }

.b3chat-conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.375rem;
}
.b3chat-conv-item {
    padding: 0.5rem 0.625rem;
    border-radius: var(--b3chat-radius);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--b3chat-text2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1px;
}
.b3chat-conv-item:hover { background: var(--b3chat-bg3); color: var(--b3chat-text); }
.b3chat-conv-item.active { background: var(--b3chat-bg3); color: var(--b3chat-text); }
.b3chat-conv-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.b3chat-delete-btn {
    display: none;
    background: none;
    border: none;
    color: var(--b3chat-text2);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 0.25rem;
    flex-shrink: 0;
}
.b3chat-conv-item:hover .b3chat-delete-btn { display: block; }

.b3chat-sidebar-footer {
    padding: 0.625rem 1rem;
    border-top: 1px solid var(--b3chat-bg3);
    font-size: 0.75rem;
    color: var(--b3chat-text2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.b3chat-sidebar-footer a { color: var(--b3chat-text2); text-decoration: none; }
.b3chat-sidebar-footer a:hover { color: var(--b3chat-text); }


/* ===== OVERLAY ===== */
.b3chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.b3chat-overlay.active { display: block; }


/* ===== MAIN AREA ===== */
.b3chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* Header — FullPage */
.b3chat-main-header {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--b3chat-bg3);
    gap: 0.5rem;
    flex-shrink: 0;
    min-height: 48px;
}
.b3chat-main-header h3 {
    font-size: 0.875rem;
    color: var(--b3chat-text2);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}
.b3chat-btn-toggle {
    background: none;
    border: 1px solid var(--b3chat-bg3);
    color: var(--b3chat-text2);
    border-radius: var(--b3chat-radius);
    cursor: pointer;
    padding: 0.4rem 0.625rem;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    height: 32px;
}
.b3chat-btn-toggle:hover { color: var(--b3chat-text); border-color: var(--b3chat-text2); }

/* Header — Panel mode */
.b3chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--b3chat-bg3);
    background: var(--b3chat-blue);
    color: white;
    flex-shrink: 0;
}
.b3chat-panel-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.b3chat-header-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    border-radius: var(--b3chat-radius);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 13px;
    transition: all 0.15s;
}
.b3chat-header-btn:hover { color: white; border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.1); }

/* Model select inline (Panel mode header) */
.b3chat-model-select-inline {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--b3chat-radius);
    padding: 2px 6px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.b3chat-model-select-inline option { background: #1a237e; color: white; }

.b3chat-lock-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color 0.15s;
}
.b3chat-lock-btn:hover { color: rgba(255,255,255,0.8); }
.b3chat-lock-btn.locked { color: var(--b3chat-yellow, #eab308); }
.b3chat-theme-light .b3chat-main-header .b3chat-lock-btn { color: rgba(0,0,0,0.3); }
.b3chat-theme-light .b3chat-main-header .b3chat-lock-btn:hover { color: rgba(0,0,0,0.7); }
.b3chat-theme-light .b3chat-main-header .b3chat-lock-btn.locked { color: #d97706; }

.b3chat-powered-label {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* ===== MESSAGES ===== */
.b3chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.b3chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--b3chat-text2);
    text-align: center;
    padding: 2rem;
    gap: 12px;
    font-size: 13px;
    line-height: 1.5;
}
.b3chat-empty-state h2 {
    font-size: 1.5rem;
    color: var(--b3chat-text);
    margin-bottom: 0.5rem;
}
.b3chat-empty-state p { max-width: 400px; line-height: 1.5; }

/* Message bubbles — base */
.b3chat-msg {
    font-size: 0.9375rem;
    line-height: 1.6;
    padding: 0.875rem 1rem;
    border-radius: var(--b3chat-radius);
    word-break: break-word;
}

/* Panel mode: smaller messages */
.b3chat-panel-mode .b3chat-msg {
    font-size: 13px;
    line-height: 1.55;
    padding: 8px 12px;
    max-width: 95%;
}

/* User messages */
.b3chat-msg.user {
    background: var(--b3chat-msg-user-bg);
    color: var(--b3chat-msg-user-text);
    border-bottom-right-radius: 2px;
    white-space: pre-wrap;
}
.b3chat-fullpage .b3chat-msg.user {
    margin-left: auto;
    margin-right: 0;
    max-width: 600px;
}
.b3chat-panel-mode .b3chat-msg.user {
    align-self: flex-end;
}

/* Assistant messages */
.b3chat-msg.assistant {
    background: var(--b3chat-msg-assistant-bg);
    color: var(--b3chat-msg-assistant-text);
    border: 1px solid var(--b3chat-msg-assistant-border);
    border-bottom-left-radius: 2px;
}
.b3chat-fullpage .b3chat-msg {
    max-width: 800px;
    margin: 0 auto 1rem;
}
.b3chat-panel-mode .b3chat-msg.assistant {
    align-self: flex-start;
}

/* Markdown content inside assistant messages */
.b3chat-msg.assistant p { margin: 0.5rem 0; }
.b3chat-msg.assistant p:first-child { margin-top: 0; }
.b3chat-msg.assistant p:last-child { margin-bottom: 0; }
.b3chat-msg.assistant pre {
    background: var(--b3chat-code-bg);
    color: var(--b3chat-code-text);
    border: 1px solid var(--b3chat-code-border);
    border-radius: 6px;
    padding: 0.75rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.8125rem;
}
.b3chat-msg.assistant code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.8125rem;
}
.b3chat-msg.assistant :not(pre) > code {
    background: var(--b3chat-inline-code-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}
.b3chat-msg.assistant ul, .b3chat-msg.assistant ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}
.b3chat-msg.assistant li { margin: 2px 0; }
.b3chat-msg.assistant h1, .b3chat-msg.assistant h2,
.b3chat-msg.assistant h3, .b3chat-msg.assistant h4 {
    margin: 0.75rem 0 0.25rem;
}
.b3chat-msg.assistant h2 { font-size: 1.125rem; }
.b3chat-msg.assistant h3 { font-size: 1rem; }
.b3chat-msg.assistant h4 { font-size: 0.9rem; }
.b3chat-msg.assistant a { color: var(--b3chat-blue); }
.b3chat-msg.assistant strong { font-weight: 600; }

.b3chat-cursor {
    display: inline-block;
    animation: b3chat-blink 1s step-end infinite;
    color: var(--b3chat-blue);
    font-weight: 300;
}
@keyframes b3chat-blink { 50% { opacity: 0; } }


/* ===== INPUT AREA ===== */
.b3chat-input-area {
    border-top: 1px solid var(--b3chat-bg3);
    padding: 10px 12px;
    flex-shrink: 0;
    background: var(--b3chat-status-bg);
}
.b3chat-fullpage .b3chat-input-area {
    padding: 0.75rem 1rem 1rem;
}

.b3chat-model-switch-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--b3chat-blue);
    background: color-mix(in srgb, var(--b3chat-blue) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--b3chat-blue) 25%, transparent);
    border-radius: 4px;
    padding: 5px 10px;
    margin-bottom: 8px;
}
.b3chat-model-switch-bar i { font-size: 13px; flex-shrink: 0; }
.b3chat-model-switch-bar strong { color: var(--b3chat-text); }

.b3chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--b3chat-text2);
    padding: 0 2px 8px;
}

.b3chat-cancel-btn {
    background: none;
    border: 1px solid var(--b3chat-bg3);
    color: var(--b3chat-text2);
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
}
.b3chat-cancel-btn:hover {
    background: var(--b3chat-red);
    color: white;
    border-color: var(--b3chat-red);
}

.b3chat-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--b3chat-bg3);
    border-top-color: var(--b3chat-blue);
    border-radius: 50%;
    animation: b3chat-spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes b3chat-spin { to { transform: rotate(360deg); } }

.b3chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.b3chat-fullpage .b3chat-input-row {
    max-width: 800px;
    margin: 0 auto;
}

.b3chat-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--b3chat-input-border);
    border-radius: var(--b3chat-radius);
    background: var(--b3chat-input-bg);
    color: var(--b3chat-input-text);
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 300px;
    line-height: 1.4;
    overflow-y: auto;
}
.b3chat-fullpage .b3chat-input {
    font-size: 1rem;
    min-height: 88px;
    line-height: 1.5;
}
.b3chat-input:focus { border-color: var(--b3chat-blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.b3chat-input:disabled { opacity: 0.6; }

.b3chat-send-btn {
    background: var(--b3chat-blue);
    color: white;
    border: none;
    border-radius: var(--b3chat-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
    font-weight: 500;
}
.b3chat-panel-mode .b3chat-send-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
}
.b3chat-fullpage .b3chat-send-btn {
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    height: 44px;
}
.b3chat-send-btn:hover { opacity: 0.9; }
.b3chat-send-btn:disabled { opacity: 0.4; cursor: default; }


/* ===== RIGHT PANEL (FullPage) ===== */
.b3chat-right-panel {
    width: var(--b3chat-right-w);
    background: var(--b3chat-bg2);
    border-left: 1px solid var(--b3chat-bg3);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}
.b3chat-panel-section {
    padding: 0.75rem;
    border-bottom: 1px solid var(--b3chat-bg3);
}
.b3chat-panel-section:last-child { border-bottom: none; }
.b3chat-panel-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--b3chat-text2);
    margin-bottom: 0.5rem;
}
.b3chat-model-select {
    width: 100%;
    background: var(--b3chat-bg);
    color: var(--b3chat-text2);
    border: 1px solid var(--b3chat-bg3);
    border-radius: var(--b3chat-radius);
    padding: 0.4rem 0.5rem;
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.b3chat-model-select:focus { border-color: var(--b3chat-blue); }
.b3chat-model-select option { background: var(--b3chat-bg); color: var(--b3chat-text); }

/* Skills */
.b3chat-skills-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 375px;
    overflow-y: auto;
}
.b3chat-skill-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--b3chat-radius);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--b3chat-text2);
    transition: background 0.1s;
}
.b3chat-skill-item:hover { background: var(--b3chat-bg3); }
.b3chat-skill-item input[type="checkbox"] {
    margin-top: 0.125rem;
    accent-color: var(--b3chat-blue);
    flex-shrink: 0;
}
.b3chat-skill-name {
    font-weight: 500;
    color: var(--b3chat-text);
    font-size: 0.8125rem;
    line-height: 1.3;
}
.b3chat-skill-desc {
    font-size: 0.6875rem;
    color: var(--b3chat-text2);
    line-height: 1.3;
    margin-top: 0.125rem;
}
.b3chat-reset-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--b3chat-text2);
    cursor: pointer;
}
.b3chat-reset-label input { accent-color: var(--b3chat-blue); cursor: pointer; }

/* Tool log */
.b3chat-tool-log-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0.75rem;
}
.b3chat-tool-log {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.b3chat-tool-entry {
    font-size: 0.6875rem;
    color: var(--b3chat-text2);
    padding: 0.125rem 0;
    line-height: 1.3;
}
.b3chat-tool-entry .icon { margin-right: 0.25rem; }
.b3chat-tool-entry.success .icon { color: var(--b3chat-green); }
.b3chat-tool-entry.error .icon { color: var(--b3chat-red); }
.b3chat-tool-entry.running .icon { color: var(--b3chat-yellow); }

.b3chat-status-indicator {
    display: none;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    background: var(--b3chat-bg);
    border: 1px solid var(--b3chat-bg3);
    border-radius: var(--b3chat-radius);
    font-size: 0.75rem;
    color: var(--b3chat-text2);
    margin-bottom: 0.5rem;
}
.b3chat-status-indicator.active { display: flex; }

.b3chat-empty-log {
    font-size: 0.75rem;
    color: var(--b3chat-text2);
    opacity: 0.5;
    text-align: center;
    padding: 1rem 0;
}

/* Panel mobile header */
.b3chat-panel-mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--b3chat-bg3);
}
.b3chat-panel-mobile-header h2 { font-size: 0.9375rem; font-weight: 600; margin: 0; }
.b3chat-btn-close-panel {
    background: none;
    border: 1px solid var(--b3chat-bg3);
    color: var(--b3chat-text2);
    border-radius: var(--b3chat-radius);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
}
.b3chat-btn-close-panel:hover { color: var(--b3chat-text); border-color: var(--b3chat-text2); }


/* ===== RESTART MODAL ===== */
.b3chat-restart-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.b3chat-restart-content {
    background: var(--b3chat-bg2);
    border: 1px solid var(--b3chat-bg3);
    border-radius: 12px;
    padding: 2rem 3rem;
    text-align: center;
    min-width: 320px;
}
.b3chat-restart-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.b3chat-restart-status { font-size: 0.85rem; color: var(--b3chat-text2); margin-bottom: 1.5rem; }
.b3chat-restart-bar-wrap {
    background: var(--b3chat-bg3);
    border-radius: 8px;
    height: 8px;
    overflow: hidden;
}
.b3chat-restart-bar {
    height: 100%;
    background: linear-gradient(90deg, #7c3aed, #06b6d4);
    transition: width 0.3s ease;
    border-radius: 8px;
}


/* ===== TOASTS ===== */
.b3chat-toast-container {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9997;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.b3chat-toast {
    background: var(--b3chat-bg2);
    border: 1px solid var(--b3chat-bg3);
    border-radius: var(--b3chat-radius);
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    color: var(--b3chat-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 250px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: auto;
    border-left: 3px solid var(--b3chat-blue);
}


/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .b3chat-right-panel { --b3chat-right-w: 240px; width: var(--b3chat-right-w); }
}
@media (max-width: 768px) {
    .b3chat-sidebar {
        position: fixed;
        left: calc(-1 * var(--b3chat-sidebar-w));
        top: 0;
        bottom: 0;
        z-index: 100;
        width: var(--b3chat-sidebar-w) !important;
        transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .b3chat-sidebar:not(.collapsed) {
        left: 0;
    }
    .b3chat-right-panel {
        position: fixed;
        right: -300px;
        top: 0;
        bottom: 0;
        z-index: 101;
        width: 280px;
        transition: right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -4px 0 24px rgba(0,0,0,0.3);
    }
    .b3chat-right-panel.open { right: 0; }
    .b3chat-panel-mobile-header { display: flex; }
    .b3chat-panel-toggle { display: inline-flex !important; }
}


/* ===== BLOCK CATALOG ===== */

.b3chat-blocks-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.6);
    color: #fff;
    border-radius: var(--b3chat-radius);
    cursor: pointer;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.b3chat-blocks-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: #fff;
}

.b3chat-block-catalog {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
}

.b3chat-block-catalog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--b3chat-bg3);
    flex-shrink: 0;
}

.b3chat-block-catalog-header h4 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--b3chat-text);
}

.b3chat-block-cancel-btn {
    background: none;
    border: 1px solid var(--b3chat-bg3);
    border-radius: var(--b3chat-radius);
    color: var(--b3chat-text2);
    font-size: 0.75rem;
    padding: 3px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.b3chat-block-cancel-btn:hover {
    background: var(--b3chat-bg2);
    color: var(--b3chat-text);
    border-color: var(--b3chat-text2);
}

.b3chat-block-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--b3chat-bg3);
    transition: background 0.12s ease;
}
.b3chat-block-item:hover {
    background: var(--b3chat-bg2);
}

.b3chat-block-info {
    flex: 1;
    min-width: 0;
}

.b3chat-block-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--b3chat-text);
    margin-bottom: 2px;
}

.b3chat-block-desc {
    font-size: 0.7rem;
    color: var(--b3chat-text2);
    line-height: 1.35;
}

.b3chat-block-add-btn {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--b3chat-blue);
    border-radius: var(--b3chat-radius);
    color: var(--b3chat-blue);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    cursor: pointer;
    white-space: nowrap;
    margin-top: 2px;
    transition: all 0.15s ease;
}
.b3chat-block-add-btn:hover {
    background: var(--b3chat-blue);
    color: #fff;
}

/* ===== CHAT HISTORY (Panel mode) ===== */

.b3chat-history-item {
    cursor: pointer;
}
