:root {
    --bg-main: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-user-msg: #F3F4F6;
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --border-color: #E4E4E7;
    --accent-blue: #3073D5;
    --sidebar-width: 280px;
    --font-family: -apple-system, BlinkMacMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.dark {
    --bg-main: #1A1D22;
    --bg-sidebar: #0E1012;
    --bg-input: #22252A;
    --bg-user-msg: #2C2F34;
    --text-primary: #FAFAFA;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --border-color: #32363D;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #1A1D22;
        --bg-sidebar: #0E1012;
        --bg-input: #22252A;
        --bg-user-msg: #2C2F34;
        --text-primary: #FAFAFA;
        --text-secondary: #9CA3AF;
        --text-muted: #6B7280;
        --border-color: #32363D;
    }
}

* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: var(--bg-main);
}

body {
    background: #FFFFFF;
}

.cp-layout {
    display: flex;
    height: 100vh;
    max-height: 100vh;
    width: 100vw;
    background-color: var(--bg-main);
    overflow: hidden;
}

/* ===== RAIL (mini sidebar always visible on desktop, like Gemini) ===== */
.cp-rail {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 56px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    flex-direction: column;
    align-items: center;
}

@media (min-width: 768px) {
    .cp-rail {
        display: flex;
    }
}

.cp-rail-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    width: 100%;
    padding: 0.5rem 0;
    gap: 0.25rem;
}

.cp-rail-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.cp-rail-btn:hover {
    background: #ECEDED;
}

.dark .cp-rail-btn:hover {
    background: #232323;
}

.cp-rail-divider {
    width: 24px;
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.cp-rail-spacer {
    flex: 1;
}

.rail-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===== SIDEBAR (fixed overlay like Gemini) ===== */
.cp-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    border-right: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    z-index: 999;
    color: var(--text-secondary);
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: none;
}

.cp-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.dark .cp-sidebar.open {
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4) !important;
}

.cp-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* ===== SIDEBAR HEADER (like Gemini) ===== */
.cp-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.75rem 0.5rem;
    min-height: 52px;
}

.cp-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
}

.cp-brand span {
    color: var(--text-primary);
}

.dark .cp-brand span {
    color: #FAFAFA;
}

.cp-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.cp-sidebar-close:hover {
    background: #ECEDED;
    color: var(--text-primary);
}

.dark .cp-sidebar-close:hover {
    background: #232323;
    color: #FAFAFA;
}

/* ===== SIDEBAR NAV ===== */
.cp-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0 0.5rem;
    width: 100%;
}

.cp-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
}

.cp-nav-item:hover {
    background: #ECEDED;
}

.dark .cp-nav-item:hover {
    background: #1A1D22;
}

.cp-nav-item.active {
    background: #ECEDED;
    color: #111827;
}

.dark .cp-nav-item.active {
    background: #1A1D22;
    color: #FAFAFA;
}

.cp-nav-item .nav-icon-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-main);
    font-size: 1rem;
}

.dark .cp-nav-item .nav-icon-wrap {
    background: #0E1012;
}

.cp-nav-item span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 200px;
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

/* ===== SECTION HEADER (collapsible, like Gemini) ===== */
.cp-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0.5rem 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
}

.cp-section-header:hover {
    background: #ECEDED;
}

.dark .cp-section-header:hover {
    background: #1A1D22;
}

.cp-chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.cp-chevron.open {
    transform: rotate(180deg);
}

/* ===== SIDEBAR HISTORY ===== */
.cp-sidebar-history {
    padding: 0.25rem 0.5rem 0.5rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    font-size: 0.875rem;
}

.history-item {
    display: flex;
    cursor: pointer;
    align-items: center;
    gap: 0.5rem;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: left;
    width: 100%;
    position: relative;
    transition: background 0.15s;
}

.history-item:hover {
    background: #ECEDED;
}

.dark .history-item:hover {
    background: #232323;
}

.history-item .text-truncate {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-height: 1.25rem;
}

.history-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.75rem;
}

.history-item-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
}

.history-item-wrap:hover .history-actions {
    display: flex;
}

.history-item-wrap .history-item {
    flex: 1;
    min-width: 0;
}

.history-actions {
    display: none;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}

.history-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}

.history-action-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
}

.dark .history-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.history-action-btn.delete:hover {
    color: #dc2626;
}

.history-action-btn.save {
    color: #16a34a;
}

.history-action-btn.cancel {
    color: #dc2626;
}

.history-edit-form {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    width: 100%;
}

.history-edit-input {
    flex: 1;
    min-width: 0;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--bg-main);
    color: var(--text-primary);
    outline: none;
}

.history-edit-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* ===== SIDEBAR FOOTER ===== */
.cp-sidebar-footer {
    padding: 0.5rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.cp-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.cp-settings-btn:hover {
    background: #ECEDED;
    color: var(--text-primary);
}

.dark .cp-settings-btn:hover {
    background: #232323;
    color: #FAFAFA;
}

/* ===== USER PROFILE ===== */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    background: transparent;
    transition: background 0.15s;
}

.user-profile:hover {
    background: #ECEDED;
}

.dark .user-profile:hover {
    background: #232323;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-blue);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.user-email {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark .user-email {
    color: #FCFCFC;
}

.user-badge {
    font-size: 0.65rem;
    color: #3C3C3C;
    background: #F4F4F4;
    padding: 0.2rem 0.3rem;
    border-radius: 3px;
    display: inline-block;
    border: 0.6px solid transparent;
    margin-top: 0.15rem;
    width: fit-content;
}

.dark .user-badge {
    color: white;
    background: #242424;
    border: none;
}

/* User Dropdown */
.user-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 70px);
    left: 0.675rem;
    right: 0.675rem;
    max-width: 248px;
    background: #FCFCFC;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    transition: height 0.3s;
    overflow: hidden;
    height: auto;
}

.dark .user-dropdown-menu {
    background: #181818;
    border-color: #2A2A2A;
}

.user-dropdown-menu button,
.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    text-align: left;
    font-size: 0.875rem;
    color: #000000;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    line-height: 1.2;
}

.dark .user-dropdown-menu button,
.dark .user-dropdown-menu a {
    color: #FCFCFC;
}

.user-dropdown-menu button:hover,
.user-dropdown-menu a:hover {
    background: rgba(11, 18, 21, 0.05);
}

.dark .user-dropdown-menu button:hover,
.dark .user-dropdown-menu a:hover {
    background: rgba(67, 67, 67, 0.5);
}

.user-dropdown-menu .menu-divider {
    height: 1px;
    background: #cdcdcd;
    margin: 0.5rem 0;
}

.dark .user-dropdown-menu .menu-divider {
    background: #2A2A2A;
}

.user-dropdown-menu .dropdown-icon-wrap {
    display: inline-flex;
    place-content: center;
    flex-shrink: 0;
}

.user-dropdown-menu .dropdown-icon-wrap svg {
    width: 16px;
    height: 16px;
}

/* ===== OVERLAY (mobile) ===== */
.cp-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 32;
    background: rgba(86, 88, 105, 0.75);
    transition: opacity 0.2s ease-linear;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    cursor: pointer;
}

.cp-sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* ===== MAIN CONTENT ===== */
.cp-main {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    height: 100%;
    width: 100%;
    min-width: 0;
    position: relative;
}

@media (min-width: 768px) {
    .cp-main {
        margin-left: 56px;
    }
}

/* ===== HEADER (unified, responsive) ===== */
.cp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    min-height: 60px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .cp-header {
        padding: 0.75rem 1.5rem;
        gap: 1rem;
    }

    .header-left {
        gap: 0.75rem;
    }

    .header-right {
        gap: 0.5rem;
    }
}

/* ===== HEADER BUTTONS ===== */
.cp-btn-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: 2.75rem;
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--accent-blue);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.dark .cp-btn-header {
    background: #1A1D22;
    color: white;
    border-color: #32363D;
}

.cp-btn-header:hover {
    background: #EFF6FF;
}

.dark .cp-btn-header:hover {
    background: rgba(48, 115, 213, 0.1);
}

.cp-btn-header .btn-label {
    font-size: 0.95rem;
    font-weight: 500;
}

.cp-btn-header .chevron {
    transition: transform 0.3s;
}

.cp-btn-header .chevron.open {
    transform: rotate(180deg);
}

.cp-btn-discover {
    position: relative;
    cursor: pointer;
}

.cp-btn-discover .new-badge {
    position: absolute;
    right: -0.35rem;
    top: -0.35rem;
    display: flex;
    border-radius: 50%;
    background: rgba(48, 115, 213, 0.1);
    padding: 0.15rem;
    color: #2872FA;
}

.dark .cp-btn-discover .new-badge {
    background: rgba(48, 115, 213, 0.3);
}

.cp-btn-discover:hover {
    background: linear-gradient(to right, rgba(62, 83, 184, 0.1), rgba(35, 147, 241, 0.1));
}

.cp-btn-pro {
    background: linear-gradient(to right, #3e53b8, #2393f1);
    color: white;
    border: none;
    border-radius: 100px;
    padding: 0.5rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: filter 0.2s;
    white-space: nowrap;
    height: 2.75rem;
}

.cp-btn-pro:hover {
    filter: brightness(1.15);
}

.cp-btn-icon-round {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: background 0.15s;
}

.cp-btn-icon-round:hover {
    background: #ECEDED;
}

.dark .cp-btn-icon-round:hover {
    background: #232323;
}

@media (max-width: 600px) {

    .cp-btn-header .btn-label,
    .cp-btn-header svg.chevron {
        display: none;
    }

    .cp-btn-header {
        padding: 0.5rem 0.7rem;
        height: 2.5rem;
    }

    .cp-btn-pro {
        padding: 0.5rem 0.85rem;
        height: 2.5rem;
        font-size: 0.85rem;
    }

    .cp-btn-pro svg {
        width: 16px;
        height: 16px;
    }

    .cp-btn-icon-round {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.1rem;
    }
}

/* ===== MODEL SELECTOR ===== */
.model-selector-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    border-radius: 50px;
    cursor: pointer;
}

.model-select {
    appearance: none;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-right: 1.5rem;
    cursor: pointer;
    outline: none;
}

.select-chevron {
    position: absolute;
    right: 0;
    color: var(--text-muted);
    pointer-events: none;
}

.ai-model-dropdown {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-radius: 100px;
    border: none;
    padding: 0.35rem 0.85rem 0.35rem 1rem;
    background: #f0f0f0;
    cursor: pointer;
    color: #1a1d22;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.dark .ai-model-dropdown {
    background: #2a2a2a;
    color: #FAFAFA;
}

.ai-model-dropdown:hover {
    background: #e5e5e5;
}

.dark .ai-model-dropdown:hover {
    background: #333;
}

.agent-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.375rem;
}

.dark .agent-dropdown-menu {
    background: #1A1D22;
    border-color: #2A2A2A;
}

.dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: transparent;
}

.agent-dropdown-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
    transition: background 0.15s;
}

.agent-dropdown-item:hover {
    background: #ECEDED;
}

.dark .agent-dropdown-item:hover {
    background: #232323;
}

.agent-dropdown-item.selected {
    background: #F0F7FF;
}

.dark .agent-dropdown-item.selected {
    background: #0A1929;
}

.agent-dropdown-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.agent-dropdown-item-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== EMPTY STATE ===== */
.cp-empty-state {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.empty-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 0.25rem;
}

.dark .empty-logo {
    filter: invert(1);
}

.cp-empty-state h1,
.empty-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1d22;
    margin: 0;
    letter-spacing: -0.02em;
}

.dark .cp-empty-state h1,
.dark .empty-title {
    color: #FAFAFA;
}

/* ===== MESSAGES ===== */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem 8rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    scroll-behavior: smooth;
}

.cp-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    scroll-behavior: smooth;
}

.cp-message-row {
    display: flex;
    gap: 1rem;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.cp-message-row.is-user {
    justify-content: flex-end;
}

.cp-message-row.is-ai {
    justify-content: flex-start;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.ai-avatar {
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
}

.msg-avatar.user-avatar {
    background: var(--bg-user-msg);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-bubble {
    max-width: 80%;
    line-height: 1.7;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.msg-bubble.ai {
    padding-top: 0.3rem;
}

.msg-bubble.user {
    background-color: var(--bg-user-msg);
    padding: 1rem 1.25rem;
    border-radius: 1.5rem;
    border-bottom-right-radius: 0.25rem;
    color: var(--text-primary);
}

.msg-response-time {
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    margin-top: 0.5rem;
    opacity: 0.75;
}

/* Attachments in chat */
.msg-attachments {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.att-chip {
    background: #e5e7eb;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== EXPERT REVIEW BUTTON ===== */
.expert-review-wrapper {
    display: flex;
    justify-content: flex-start;
    padding: 0.5rem 0 0 3rem;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.expert-review-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 100px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--accent-blue);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.expert-review-btn:hover:not(:disabled) {
    background: #EFF6FF;
}

.dark .expert-review-btn {
    background: #1A1D22;
    color: #60A5FA;
    border-color: #32363D;
}

.dark .expert-review-btn:hover:not(:disabled) {
    background: rgba(48, 115, 213, 0.1);
}

.expert-review-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ===== ATTACHMENT MENU ===== */
.attachment-menu-container {
    position: relative;
    display: inline-flex;
}

.attachment-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
    z-index: 100;
    min-width: 200px;
}

.dark .attachment-popup {
    background: #1A1D22;
    border-color: #32363D;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.attach-option-wrap {
    position: relative;
}

.attach-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
}

.attach-option:hover {
    background: #ECEDED;
}

.dark .attach-option:hover {
    background: #232323;
}

.attach-option span {
    flex: 1;
}

.cp-attach-input-hidden {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    font-size: 0;
}

/* ===== INPUT AREA BUTTONS ===== */
.cp-btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}

.cp-btn-icon:hover {
    background: #ECEDED;
}

.dark .cp-btn-icon:hover {
    background: #232323;
}

.cp-btn-icon:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-attach-plus {
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 1.3rem;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn-attach-plus:hover {
    background: #F3F4F6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transform: scale(1.05);
}

.dark .btn-attach-plus {
    background: #1A1D22;
    border-color: #32363D;
}

.dark .btn-attach-plus:hover {
    background: #25282D;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.icon-plus-attach {
    width: 20px;
    height: 20px;
}

/* ===== AUDIO RECORDING ===== */
.cp-btn-icon.recording {
    background: #FEE2E2;
    color: #EF4444;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

.dark .cp-btn-icon.recording {
    background: rgba(239, 68, 68, 0.2);
    color: #FCA5A5;
}

.recording-indicator {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #EF4444;
}

@keyframes pulse-recording {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* ===== TEXT INPUT CONTAINER (ChatPro style) ===== */
.text-input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.text-input-container > * {
    pointer-events: auto;
}

.text-input-inner {
    display: flex;
    align-items: flex-end;
    gap: 0;
    width: 100%;
    max-width: 740px;
    background: #eaeef2;
    border-radius: 20px;
    padding: 0.5rem;
    border: 1px solid #dde2e8;
}

.dark .text-input-inner {
    background: #1e1e1e;
    border-color: #333;
}

.input-left-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-left: 0.25rem;
    flex-shrink: 0;
}

.input-right-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.25rem;
    flex-shrink: 0;
}

.input-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.input-icon-btn:hover {
    background: rgba(0,0,0,0.06);
}

.dark .input-icon-btn:hover {
    background: rgba(255,255,255,0.08);
}

.input-icon-btn.send-btn {
    background: #1a1d22;
    color: white;
}

.input-icon-btn.send-btn:hover {
    background: #000;
}

.dark .input-icon-btn.send-btn {
    background: #2872FA;
}

.dark .input-icon-btn.send-btn:hover {
    background: #1a5fd4;
}

.input-icon-btn.recording {
    color: #ef4444;
    animation: pulse-rec 1.2s ease-in-out infinite;
}

@keyframes pulse-rec {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.text-input-inner textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 0.5rem 0.25rem;
    font-size: 1rem;
    color: #1a1d22;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    min-height: 24px;
    max-height: 120px;
}

.dark .text-input-inner textarea {
    color: #FAFAFA;
}

.text-input-inner textarea::placeholder {
    color: #9ca3af;
}

/* ===== Attachments preview ===== */
.cp-attachments-preview {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0 1rem;
}

.att-preview-chip {
    background: #f3f4f6;
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.att-preview-chip button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.att-preview-chip button:hover {
    color: #ef4444;
}

/* ===== SUGGESTED ACTIONS (ChatPro style) ===== */
.action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 480px;
    margin-bottom: 0.75rem;
}

.action-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #6b7280;
    transition: opacity 0.15s;
}

.action-btn:hover {
    opacity: 0.8;
}

.action-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eaeef2;
    color: #1a1d22;
    transition: background 0.15s;
}

.dark .action-icon-wrap {
    background: #2a2a2a;
    color: #FAFAFA;
}

.action-btn:hover .action-icon-wrap {
    background: #dde2e8;
}

.dark .action-btn:hover .action-icon-wrap {
    background: #3a3a3a;
}

.action-label {
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    color: #6b7280;
}

/* ===== DISCLAIMER ===== */
.cp-disclaimer {
    text-align: center;
    font-size: 0.65rem;
    color: #9ca3af;
    padding: 0.5rem 1rem 0;
    line-height: 1.3;
}

/* ===== EMPTY STATE SUBTITLE ===== */
.cp-empty-state p {
    font-size: 0.9rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

/* ===== BANNERS ===== */
.cp-alert-banner {
    text-align: center;
    padding: 0.75rem;
    margin: 0 2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.cp-alert-banner.danger {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #f87171;
}

.cp-alert-banner.info {
    background: #eff6ff;
    color: var(--accent-blue);
    border: 1px solid #60a5fa;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 0.4rem 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .cp-header {
        padding: 0.75rem 0.75rem;
    }

    .cp-messages-container {
        padding: 1rem;
        gap: 1.5rem;
    }

    .cp-empty-state h1 {
        font-size: 1.5rem;
    }

    .msg-bubble {
        max-width: 90%;
        font-size: 1rem;
    }

    .cp-input-area {
        padding: 0 1rem 1rem;
    }

    .cp-suggested-actions .actions-row {
        gap: 0.5rem;
    }

    .cp-suggested-actions {
        padding: 0 0.5rem;
    }

    .action-chip-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }

    .cp-sidebar-overlay {
        background: rgba(0, 0, 0, 0.4);
    }

    .history-item {
        padding: 0.6rem 0.75rem;
        min-height: 44px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .cp-messages-container {
        padding: 0.75rem;
        gap: 1rem;
    }

    .msg-bubble {
        max-width: 95%;
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .cp-empty-state {
        padding: 1rem;
    }

    .cp-empty-state h1 {
        font-size: 1.25rem;
    }

    .cp-empty-state p {
        font-size: 0.9rem;
    }

    .cp-header {
        padding: 0.5rem 0.6rem;
        min-height: 52px;
    }

    .cp-input-area {
        padding: 0 0.5rem 0.75rem;
    }

    .cp-input-pill-wrapper {
        padding: 0.35rem;
        border-radius: 1.25rem;
    }

    .cp-text-input {
        font-size: 0.95rem;
        padding: 0.4rem 0.75rem;
    }

    .cp-btn-send {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .cp-btn-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 0.9rem;
    }

    .cp-message-row {
        gap: 0.5rem;
    }

    .cp-suggested-actions .actions-row {
        gap: 0.4rem;
    }

    .action-chip-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .action-chip-label {
        font-size: 0.65rem;
    }

    .ai-model-dropdown {
        font-size: 0.85rem;
        padding: 0.25rem 0.75rem;
    }

    .cp-btn-header {
        padding: 0.4rem 0.5rem;
        height: 2.25rem;
        font-size: 0.8rem;
    }

    .cp-btn-icon-round {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }

    .cp-alert-banner {
        margin: 0 0.75rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .cp-disclaimer {
        font-size: 0.65rem;
        padding: 0.5rem;
    }
}

@media (max-width: 360px) {
    .cp-messages-container {
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .msg-bubble {
        font-size: 0.9rem;
    }

    .cp-input-area {
        padding: 0 0.25rem 0.5rem;
    }

    .cp-input-pill-wrapper {
        padding: 0.25rem;
        border-radius: 1rem;
    }

    .cp-text-input {
        font-size: 0.9rem;
        padding: 0.35rem 0.5rem;
    }

    .cp-btn-send {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .cp-btn-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .cp-header {
        padding: 0.4rem 0.5rem;
        min-height: 48px;
    }

    .header-left {
        gap: 0.25rem;
    }

    .model-selector-wrapper {
        max-width: 120px;
        overflow: hidden;
    }

    .ai-model-dropdown {
        font-size: 0.8rem;
        padding: 0.2rem 0.5rem;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .cp-layout {
        flex-direction: row;
    }

    .cp-header {
        min-height: 44px;
        padding: 0.4rem 0.75rem;
    }

    .cp-messages-container {
        padding: 0.5rem 1rem;
        gap: 0.75rem;
    }

    .cp-input-area {
        padding: 0 0.75rem 0.5rem;
    }

    .cp-input-pill-wrapper {
        padding: 0.3rem;
    }

    .cp-empty-state {
        padding: 0.5rem;
    }

    .cp-empty-state h1 {
        font-size: 1.1rem;
    }

    .cp-empty-state .action-chips {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    .cp-sidebar,
    .cp-sidebar-overlay,
    .cp-rail {
        transition: none !important;
    }
}

/* ===== SCROLLBAR ===== */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.cp-sidebar-history::-webkit-scrollbar {
    width: 4px;
}

.cp-sidebar-history::-webkit-scrollbar-track {
    background: transparent;
}

.cp-sidebar-history::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* ===== UTILITY CLASSES ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

@media (min-width: 768px) {
    .md\:hidden {
        display: none !important;
    }

    .md\:inline {
        display: inline !important;
    }

    .md\:flex {
        display: flex !important;
    }

    .inline-flex {
        display: inline-flex !important;
    }
}

.ml-2 {
    margin-left: 0.5rem;
}

.pl-2 {
    padding-left: 0.5rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-base {
    font-size: 1rem;
}

.text-sm {
    font-size: 0.875rem;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.text-gray-900 {
    color: #111827;
}

.dark .dark\:text-white {
    color: #FAFAFA;
}

.dark .dark\:text-gray-300 {
    color: #D1D5DB;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-1 {
    flex: 1;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-4 {
    gap: 1rem;
}

.mt-8 {
    margin-top: 2rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.overflow-hidden {
    overflow: hidden;
}

.whitespace-nowrap {
    white-space: nowrap;
}

.text-ellipsis {
    text-overflow: ellipsis;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.bottom-4 {
    bottom: 1rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.py-6 {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.pt-0 {
    padding-top: 0;
}

.pt-5 {
    padding-top: 1.25rem;
}

.pb-5 {
    padding-bottom: 1.25rem;
}

.px-\[0\.675rem\] {
    padding-left: 0.675rem;
    padding-right: 0.675rem;
}

.border-t {
    border-top-width: 1px;
    border-top-style: solid;
}

.border-t-\[\#cdcdcd\] {
    border-top-color: #cdcdcd;
}

.dark .dark\:border-t-\[\#2A2A2A\] {
    border-top-color: #2A2A2A;
}

/* ===== SIDEBAR PUSH LAYOUT (desktop) ===== */

@media (min-width: 768px) {
    .cp-sidebar {
        position: relative !important;
        transform: none !important;
        left: auto !important;
        top: auto !important;
        bottom: auto !important;
        width: 0 !important;
        height: 100vh;
        flex-shrink: 0;
        margin-left: 56px;
        transition: width 0.3s ease, margin-left 0.3s ease;
        overflow: hidden;
        box-shadow: none !important;
        border-right: none !important;
        padding: 0 !important;
    }

    .cp-sidebar.open {
        margin-left: 0 !important;
        width: var(--sidebar-width) !important;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12) !important;
        border-right: 1px solid var(--border-color) !important;
    }

    .cp-main {
        flex: 1;
        min-width: 0;
        margin-left: 0 !important;
        width: auto;
    }

    .cp-sidebar-overlay {
        display: none !important;
    }

    .cp-rail.rail-hidden {
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0s !important;
    }

    .cp-rail:not(.rail-hidden) {
        opacity: 1;
        pointer-events: auto;
        transition: opacity 0.2s ease 0.25s;
    }
}

/* ===== AUTH BUTTONS IN SIDEBAR ===== */
.cp-sidebar-footer-auth {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cp-auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    border: none;
    min-height: 44px;
}

.cp-auth-btn.btn-signup {
    background: var(--accent-blue);
    color: #fff;
}

.cp-auth-btn.btn-signup:hover {
    box-shadow: 0 4px 15px rgba(48, 115, 213, 0.4);
}

.cp-auth-btn.btn-login {
    background: transparent;
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
}

.cp-auth-btn.btn-login:hover {
    background: rgba(48, 115, 213, 0.08);
    box-shadow: 0 4px 15px rgba(48, 115, 213, 0.3);
}

.messages-area {
    overflow-y: auto;
    /* Permite el scroll vertical interno */
    touch-action: pan-y;
    /* Permite deslizar el dedo hacia arriba y abajo */
    -webkit-overflow-scrolling: touch;
    /* Scroll suave en dispositivos iOS */
}