.chat-page {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 32px;
    box-sizing: border-box;
    height: calc(100vh - 64px);
    min-height: 640px;
    background: radial-gradient(circle at 10% -10%, #f8fbff 0%, #eef1f7 45%, #e8ebf2 100%);
    color: var(--mud-palette-text-primary, #0f172a);
}

@supports (height: 100dvh) {
    .chat-page {
        height: calc(100dvh - 64px);
    }
}

.chat-page-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 8px;
}

.chat-shell {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    min-height: 0;
    position: relative;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: 0 28px 80px -60px rgba(15, 23, 42, 0.68);
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.chat-sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.chat-sidebar-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-sidebar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-collapse {
    display: none !important;
}

.chat-sidebar-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 24px 24px;
    overflow-y: auto;
}

.chat-sidebar-create {
    justify-content: flex-start;
    gap: 10px;
    border-radius: 14px;
    font-weight: 600;
    box-shadow: 0 24px 60px -40px rgba(21, 94, 239, 0.65);
}

.chat-loading-state {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 0;
}

.chat-empty-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 24px;
    border-radius: 18px;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    background: rgba(248, 250, 252, 0.6);
}

.chat-session-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
}

.chat-session-item {
    cursor: pointer;
    border-radius: 18px;
    padding: 16px 18px;
    border: 1px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease, background 0.2s ease;
}

.chat-session-item:hover {
    transform: translateY(-2px);
    background: rgba(248, 250, 252, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.25);
    box-shadow: 0 18px 60px -48px rgba(99, 102, 241, 0.6);
}

.chat-session-item.selected {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(56, 189, 248, 0.12));
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 22px 70px -50px rgba(56, 189, 248, 0.75);
}

.chat-session-item-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-session-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.session-title {
    flex: 1;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-chevron {
    color: rgba(15, 23, 42, 0.35);
}

.chat-session-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: rgba(71, 85, 105, 0.9);
}

.session-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(21, 94, 239, 0.12);
    color: #155eef;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.session-date {
    opacity: 0.8;
}

.chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 28px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(247, 249, 252, 0.92) 100%);
    box-shadow: 0 36px 100px -70px rgba(15, 23, 42, 0.85);
    overflow: hidden;
}

.chat-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 28px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(18px);
}

.chat-toolbar-texts {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-toggle {
    display: none !important;
}

.new-session-button {
    border-radius: 12px;
    font-weight: 600;
    padding: 0 18px;
}

.chat-main-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 32px;
}

.chat-container > * {
    flex: 1;
    min-height: 0;
}

.empty-chat-state {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 48px;
    border-radius: 24px;
    border: 1px dashed rgba(99, 102, 241, 0.35);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(14, 165, 233, 0.08));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
    max-width: 420px;
}

.empty-chat-state .mud-button-root {
    align-self: flex-start;
}

.empty-chat-subtitle {
    line-height: 1.5;
}

.chatbot-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    border-radius: 24px;
    background: transparent;
    box-shadow: none;
    border: none;
}

.chat-messages-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 32px;
    overflow-y: auto;
    background: transparent;
}

.chat-input-area {
    padding: 20px 28px;
    backdrop-filter: blur(16px);
}

.chat-input-area .mud-input-root {
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.8);
}

.chat-input-area .mud-button-root {
    border-radius: 14px;
    padding: 0 18px;
    font-weight: 600;
}

.chat-shell-overlay {
    display: none;
}

.chat-sidebar-body::-webkit-scrollbar,
.chat-messages-container::-webkit-scrollbar {
    width: 8px;
}

.chat-sidebar-body::-webkit-scrollbar-track,
.chat-messages-container::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.6);
    border-radius: 8px;
}

.chat-sidebar-body::-webkit-scrollbar-thumb,
.chat-messages-container::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.7);
    border-radius: 8px;
}

.chat-sidebar-body::-webkit-scrollbar-thumb:hover,
.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.8);
}

@media (max-width: 1400px) {
    .chat-shell {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 1024px) {
    .chat-page {
        padding: 24px 20px;
        height: auto;
        min-height: calc(100vh - 56px);
    }

    .chat-shell {
        display: flex;
    }

    .chat-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(340px, 90vw);
        max-width: 90vw;
        z-index: 6;
        box-shadow: 0 32px 100px -60px rgba(15, 23, 42, 0.85);
    }

    .chat-sidebar.collapsed {
        transform: translateX(-110%);
        opacity: 0;
        pointer-events: none;
    }

.chat-input-area {
    padding: 16px 24px;
}

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

    .chat-shell-overlay {
        display: block;
        position: absolute;
        inset: 0;
        border-radius: 28px;
        background: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(4px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 5;
    }

    .chat-shell-overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .chat-toolbar {
        gap: 12px;
    }

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

    .chat-main {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .chat-page {
        padding: 16px;
    }

    .chat-toolbar {
        padding: 20px;
    }

    .chat-container {
        padding: 24px 16px;
    }

    .chat-messages-container {
        padding: 24px 16px;
    }

    .chat-input-area {
        padding: 16px 20px;
    }

    .empty-chat-state {
        padding: 32px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .chat-toolbar {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .new-session-button {
        width: 100%;
    }
}
