:root {
    --bg: #f4efe6;
    --bg-strong: #13343b;
    --panel: rgba(255, 252, 246, 0.78);
    --panel-strong: #fffaf1;
    --panel-border: rgba(19, 52, 59, 0.12);
    --text: #173038;
    --muted: #5d6f72;
    --accent: #d85b35;
    --accent-soft: #f6c9a8;
    --assistant: #f8e7db;
    --user: #d8ebe4;
    --shadow: 0 24px 60px rgba(19, 52, 59, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    font-family: "IBM Plex Sans", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(216, 91, 53, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(19, 52, 59, 0.16), transparent 28%),
        var(--bg);
    color: var(--text);
}

body {
    height: 100vh;
    overflow: hidden;
}

.page-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    padding: 28px;
    background: linear-gradient(180deg, #173d44 0%, #10292f 100%);
    color: #f7f1e7;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
    overflow-y: auto;
}

.brand-logo {
    display: block;
    width: 100px;
    height: auto;
    margin: 0 auto 12px;
    cursor: pointer;
}

.brand-block p,
.sidebar,
.text-link {
    color: rgba(247, 241, 231, 0.82);
}

.brand-kicker,
.chat-header-label,
.section-header h2,
.composer-label,
.message-role,
.header-pill,
.meta-card span {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sessions-section {
    flex: 1;
    min-height: 0;
}

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

.section-header h2 {
    margin: 0;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.session-item {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    color: inherit;
    text-align: left;
}

button.session-item {
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button.session-item:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.14);
}

.session-item.active {
    background: rgba(246, 201, 168, 0.14);
    border-color: rgba(246, 201, 168, 0.32);
}

.session-item strong,
.session-item span {
    display: block;
}

.session-item strong {
    margin-bottom: 4px;
    color: #fffaf1;
}

.session-item span {
    color: rgba(247, 241, 231, 0.7);
    font-size: 0.92rem;
}

.chat-stage {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 28px;
    gap: 18px;
}

.message-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 6px 12px;
}

.empty-state {
    display: grid;
    place-items: center;
    flex: 1;
    min-height: 0;
}

.empty-panel {
    padding: 36px;
    max-width: 520px;
    border-radius: 28px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
}

.empty-panel h3 {
    margin-top: 0;
    font-family: "IBM Plex Serif", serif;
    font-size: 1.8rem;
}

.message-card {
    padding: 18px 20px;
    border-radius: 24px;
    border: 1px solid #f1f1f1;
    box-shadow: 0 2px 10px rgba(19, 52, 59, 0.04);
    color: rgb(68, 68, 68);
    background: var(--panel-strong);
}

.message-card.message-enter {
    animation: message-fade-in 260ms ease-out;
}

.message-card.user {
    align-self: flex-end;
    width: min(78%, 760px);
    background: var(--user);
}

.message-card.assistant {
    align-self: flex-start;
    width: min(82%, 820px);
    background: var(--assistant);
}

.message-card.loading {
    opacity: 0.9;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--muted);
}

.message-body {
    line-height: 1.6;
    white-space: pre-wrap;
}

.message-body-loading {
    display: flex;
    align-items: flex-start;
    min-height: 0;
}

.assistant-loading-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.assistant-loading-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 10px;
    border-radius: 16px;
    background: rgba(255, 250, 241, 0.72);
    border: 1px solid rgba(216, 91, 53, 0.12);
}

.assistant-loading-label {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    flex-shrink: 0;
}

.typing-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
    animation: typing-bounce 1.2s ease-in-out infinite;
    will-change: transform, opacity;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.18s;
    background: #c8693f;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.36s;
    background: #a85a36;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: translateY(0) scale(0.85);
        opacity: 0.35;
    }
    40% {
        transform: translateY(-6px) scale(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .typing-dot {
        animation: typing-pulse 1.4s ease-in-out infinite;
    }

    @keyframes typing-pulse {
        0%, 100% { opacity: 0.35; }
        50% { opacity: 1; }
    }
}

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.context-panel {
    padding: 18px 20px;
}

.context-panel.hidden {
    display: none;
}

.context-panel h3 {
    margin: 0 0 14px;
    font-family: "IBM Plex Serif", serif;
}

.context-list {
    display: grid;
    gap: 12px;
}

.context-item {
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.62);
}

.context-item strong {
    display: block;
    margin-bottom: 6px;
}

.context-item span {
    color: var(--muted);
    font-size: 0.9rem;
}

.composer-panel {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex-shrink: 0;
    border-radius: 26px;
    border: 1px solid var(--panel-border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

#message-input {
    width: 100%;
    resize: vertical;
    min-height: 120px;
    border-radius: 22px;
    border: 1px solid rgba(19, 52, 59, 0.12);
    padding: 18px;
    font: inherit;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
}

#message-input:focus {
    outline: 2px solid rgba(216, 91, 53, 0.24);
    border-color: rgba(216, 91, 53, 0.36);
}

.composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.composer-status {
    color: var(--muted);
}

.primary-button,
.ghost-button,
.text-link {
    font: inherit;
}

.primary-button,
.ghost-button {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.primary-button {
    background: linear-gradient(135deg, #d85b35, #e88a51);
    color: white;
    box-shadow: 0 18px 30px rgba(216, 91, 53, 0.28);
}

.ghost-button {
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
}

.primary-button:hover,
.ghost-button:hover,
.text-link:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
    opacity: 0.58;
    cursor: wait;
}

.sidebar-meta {
    margin-top: auto;
}

.meta-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
}

.text-link {
    color: #f6c9a8;
    text-decoration: none;
}

@media (max-width: 980px) {
    .page-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .sidebar {
        min-height: auto;
        padding: 18px 20px;
        gap: 0;
        overflow: visible;
        align-items: center;
        justify-content: center;
    }

    .sidebar > :not(.brand-block) {
        display: none;
    }

    .brand-block {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .brand-logo {
        margin: 0;
        width: 40px;
    }

    .chat-stage {
        padding-top: 0;
    }

    .message-card.user,
    .message-card.assistant {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .sidebar,
    .chat-stage {
        padding: 16px;
    }

    .chat-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .composer-actions {
        flex-direction: column;
        align-items: stretch;
    }
}