:root {
    --accent: #2f6fe1;
    --accent-orange: #f4b740;
    --accent-ghost: rgba(47, 111, 225, 0.08);
    --text-strong: #0f1b2d;
    --text: #42546b;
    --muted: #5f7187;
    --surface: #ffffff;
    --surface-soft: #eef3f9;
    --border: #d9e3ef;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Sora", "Segoe UI", "Segoe UI Web", "Segoe UI Variable", Arial, sans-serif;
    color: var(--text);
    background: #f2f5fa;
}

h1,
h2,
h3 {
    font-family: "Fraunces", "Sora", "Segoe UI", Arial, sans-serif;
    color: var(--text-strong);
}

.agent-page {
    display: grid;
    gap: 20px;
    padding-bottom: 24px;
}

.agent-hero {
    background: var(--surface);
    border-bottom: 1px solid #e6edf6;
}

.section-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 32px;
}

.hero-inner {
    padding-top: 28px;
    padding-bottom: 24px;
}

.hero-copy h1 {
    font-size: clamp(28px, 3.8vw, 40px);
    margin: 2px 0 10px;
}

.hero-copy p {
    margin: 0;
    max-width: 760px;
    line-height: 1.6;
    color: #4c5a70;
}

.section-kicker {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent-orange);
    font-weight: 600;
    margin: 0;
}

.app-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    width: 100%;
    padding: 0 24px;
}

.thread-pane,
.chat-pane {
    background: var(--surface);
    border: 1px solid #e4ecf5;
    border-radius: 18px;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.06);
}

.thread-pane {
    display: flex;
    flex-direction: column;
    min-height: 70vh;
    overflow: hidden;
}

.thread-head {
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 18px 18px 16px;
}

.thread-head h2 {
    margin: 0;
    font-size: 22px;
}

.thread-head p {
    margin: 6px 0 14px;
    color: #5f7187;
    font-size: 14px;
    line-height: 1.5;
}

button {
    border: 0;
    border-radius: 999px;
    font: inherit;
    cursor: pointer;
}

#new-thread-button {
    width: 100%;
    padding: 11px 16px;
    color: #fff;
    font-weight: 600;
    background: #16a34a;
    border: 1px solid #15803d;
    box-shadow: 0 10px 18px rgba(22, 163, 74, 0.22);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#new-thread-button:hover,
#new-thread-button:focus-visible {
    transform: translateY(-1px);
    background: #15803d;
    box-shadow: 0 14px 24px rgba(22, 163, 74, 0.26);
}

.thread-list {
    display: grid;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
}

.thread-item {
    border: 1px solid #e4ecf5;
    border-radius: 14px;
    background: #ffffff;
    padding: 11px 12px;
    text-align: left;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.thread-item:hover {
    border-color: var(--accent);
    background: #f6f9ff;
    transform: translateY(-1px);
}

.thread-item.active {
    border-color: var(--accent);
    background: #eef5ff;
}

.thread-item-title {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-strong);
}

.thread-item-meta {
    font-size: 12px;
    color: #6a7b91;
}

.chat-pane {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 70vh;
}

.chat-head {
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border);
    background: #f8fbff;
}

.chat-head h2 {
    margin: 0;
    font-size: 24px;
}

.chat-head p {
    margin: 4px 0 0;
    color: #5f7187;
    font-size: 13px;
}

.messages {
    overflow-y: auto;
    padding: 16px;
    display: grid;
    gap: 10px;
    align-content: start;
}

.message {
    max-width: min(88%, 820px);
    border-radius: 14px;
    border: 1px solid #e4ecf5;
    background: #ffffff;
    padding: 11px 12px;
    display: grid;
    gap: 8px;
}

.message.user {
    justify-self: end;
    background: #eef3f9;
    border-color: #d7e2f0;
}

.message.assistant {
    justify-self: start;
    background: #e8f5ec;
    border-color: #cbe7d3;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: #5b6d83;
    font-size: 11px;
}

.message-role {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.message-text {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.45;
    color: #2f3a4b;
}

.message-citations {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.message-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #607287;
}

.message-feedback-label {
    opacity: 0.9;
}

.message-feedback-button {
    background: transparent;
    color: #3e556f;
    border: 1px solid #c8d7ea;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 11px;
    line-height: 1.4;
}

.message-feedback-button:hover,
.message-feedback-button:focus-visible {
    background: #eef5ff;
    border-color: #adc8ea;
}

.message-feedback-button-positive {
    color: #1d6a44;
    border-color: #b9dcc8;
}

.message-feedback-button-positive:hover,
.message-feedback-button-positive:focus-visible {
    background: #eaf7ef;
    border-color: #9dceaf;
}

.message-feedback-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.message-feedback-status {
    color: #4f6379;
}

.citation {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid #d4e3f9;
    background: #eef5ff;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
}

.composer {
    border-top: 1px solid var(--border);
    background: #f8fbff;
    padding: 14px 16px;
}

.composer label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 6px;
}

#message-input {
    width: 100%;
    resize: vertical;
    min-height: 74px;
    border: 1px solid #d9e3ef;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    background: #ffffff;
    color: var(--text-strong);
}

#message-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ghost);
}

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

.scope-note {
    font-size: 12px;
    color: #6a7b91;
}

#send-button {
    min-width: 110px;
    padding: 10px 16px;
    color: #fff;
    background: var(--accent);
    border: 1px solid #285fc0;
    font-weight: 600;
    box-shadow: 0 10px 18px rgba(47, 111, 225, 0.22);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#send-button:hover,
#send-button:focus-visible {
    transform: translateY(-1px);
    background: #285fc0;
    box-shadow: 0 14px 24px rgba(47, 111, 225, 0.28);
}

#send-button:disabled,
#new-thread-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .thread-pane {
        min-height: 260px;
    }

    .chat-pane {
        min-height: calc(100vh - 320px);
    }
}

@media (max-width: 640px) {
    .app-shell {
        padding: 0 12px;
    }

    .section-inner {
        padding: 0 18px;
    }

    .hero-inner {
        padding-top: 24px;
        padding-bottom: 18px;
    }

    .chat-head h2 {
        font-size: 21px;
    }

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