: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;
}

.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;
}

.section-header h2 {
    margin: 0;
}

.session-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 10px;
    overflow: auto;
    min-height: 160px;
    padding-right: 6px;
}

.session-item {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 14px;
    text-align: left;
    color: inherit;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.session-item:hover,
.session-item.active {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(246, 201, 168, 0.55);
}

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

.session-item span {
    margin-top: 4px;
    opacity: 0.72;
    font-size: 0.88rem;
}

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

.chat-header,
.composer-panel,
.context-panel,
.empty-panel {
    border: 1px solid var(--panel-border);
    background: var(--panel);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.chat-header {
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.chat-header h2 {
    margin: 8px 0 0;
    font-family: "IBM Plex Serif", serif;
    font-size: 2rem;
}

.header-pill {
    border-radius: 999px;
    padding: 11px 16px;
    background: rgba(216, 91, 53, 0.12);
    color: var(--accent);
}

.message-thread {
    flex: 1;
    min-height: 400px;
    overflow: hidden;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-state {
    display: grid;
    place-items: center;
}

.empty-panel {
    padding: 36px;
    max-width: 520px;
}

.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 var(--panel-border);
    background: var(--panel-strong);
}

.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-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;
}

.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;
    margin-top: auto;
}

#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;
    }

    .sidebar {
        gap: 18px;
    }

    .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;
    }
}