:root {
    --bg-top: #f6efe2;
    --bg-bottom: #eef4fb;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-border: rgba(34, 58, 90, 0.12);
    --text: #162235;
    --muted: #5a6980;
    --accent: #0f6db6;
    --accent-strong: #0a4f84;
    --assistant-bg: #f8fbff;
    --user-bg: #0f6db6;
    --user-text: #fff;
    --shadow: 0 18px 45px rgba(22, 34, 53, 0.12);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 209, 138, 0.36), transparent 28rem),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.chat-shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2.25rem 1rem 2rem;
}

.chat-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1rem;
}

.hero-link {
    display: inline-flex;
    align-items: center;
    padding: .45rem .8rem;
    border-radius: 999px;
    border: 1px solid rgba(15, 109, 182, 0.18);
    background: rgba(255, 255, 255, 0.65);
    color: var(--accent-strong);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-link:hover {
    background: rgba(255, 255, 255, 0.92);
}

h1 {
    margin: 0 0 .35rem;
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    line-height: .95;
    letter-spacing: -.04em;
}

.hero-copy {
    margin: 0;
    max-width: 42rem;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.5;
}

.status-card {
    padding: 1rem 1.1rem;
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.status-card__label {
    display: block;
    margin-bottom: .7rem;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.status-card__text {
    margin: .8rem 0 0;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1.5;
}

.service-pill {
    display: inline-flex;
    align-items: center;
    padding: .45rem .8rem;
    border-radius: 999px;
    font-size: .84rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.service-pill.ready {
    background: #e4f6ea;
    color: #1f6f3d;
}

.service-pill.reindexing {
    background: #fff0d9;
    color: #9b5e00;
}

.service-pill.error,
.service-pill.unavailable {
    background: #fde7eb;
    color: #a52745;
}

.chat-panel {
    display: grid;
    gap: 1rem;
}

.messages,
.composer {
    border: 1px solid var(--panel-border);
    border-radius: 26px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.messages {
    min-height: 56vh;
    max-height: 68vh;
    overflow-y: auto;
    padding: 1.1rem;
}

.message {
    max-width: 78%;
    margin-bottom: 1rem;
    padding: .95rem 1rem;
    border-radius: 18px;
    line-height: 1.5;
}

.message:last-child {
    margin-bottom: 0;
}

.message--assistant {
    background: var(--assistant-bg);
    border: 1px solid rgba(15, 109, 182, 0.1);
}

.message--user {
    margin-left: auto;
    background: var(--user-bg);
    color: var(--user-text);
}

.message--pending {
    border-style: dashed;
}

.message__meta {
    margin-bottom: .45rem;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    opacity: .72;
}

.message__body p {
    margin: 0 0 .75rem;
}

.message__body p:last-child {
    margin-bottom: 0;
}

.message__body ul {
    margin: 0;
    padding-left: 1.2rem;
}

.message__body code {
    padding: .12rem .32rem;
    border-radius: .35rem;
    background: rgba(22, 34, 53, 0.08);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: .9em;
}

.source-list {
    margin-top: .85rem;
    padding-top: .85rem;
    border-top: 1px solid rgba(22, 34, 53, 0.08);
}

.source-list__label {
    display: block;
    margin-bottom: .55rem;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.source-list ul {
    margin: 0;
    padding-left: 1rem;
}

.source-list li {
    margin-bottom: .45rem;
    color: var(--muted);
    font-size: .9rem;
}

.composer {
    padding: 1rem;
}

.composer__label {
    display: block;
    margin-bottom: .55rem;
    font-size: .85rem;
    font-weight: 700;
    color: var(--muted);
}

.composer__input {
    width: 100%;
    resize: vertical;
    padding: .9rem 1rem;
    border: 1px solid rgba(22, 34, 53, 0.14);
    border-radius: 18px;
    font: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.85);
    min-height: 6.5rem;
}

.composer__input:focus {
    outline: none;
    border-color: rgba(15, 109, 182, 0.5);
    box-shadow: 0 0 0 4px rgba(15, 109, 182, 0.08);
}

.composer__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: .8rem;
}

.composer__hint {
    margin: 0;
    color: var(--muted);
    font-size: .88rem;
}

.composer__button {
    border: none;
    border-radius: 999px;
    padding: .8rem 1.2rem;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    cursor: pointer;
}

.composer__button:disabled,
.composer__input:disabled {
    opacity: .7;
    cursor: default;
}

@media (max-width: 880px) {
    .chat-hero {
        grid-template-columns: 1fr;
    }

    .messages {
        min-height: 52vh;
        max-height: none;
    }

    .message {
        max-width: 100%;
    }

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

    .composer__button {
        width: 100%;
    }
}
