:root {
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #64748b;
    --line: #d9dfd3;
    --accent: #2f6b4f;
    --accent-strong: #214d3a;
    --user: #e3efe8;
    --assistant: #ffffff;
    --error: #9f1239;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--accent-strong);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
}

.brand {
    font-weight: 700;
    text-decoration: none;
    color: var(--ink);
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
}

.topbar form {
    margin: 0;
}

button {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font: inherit;
    font-weight: 650;
    padding: 10px 14px;
    cursor: pointer;
}

button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.auth-panel {
    width: min(440px, calc(100vw - 32px));
    margin: 64px auto;
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.consent-panel {
    width: min(720px, calc(100vw - 32px));
    margin: 40px auto;
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.consent-panel h1 {
    margin-top: 0;
}

.consent-text p {
    line-height: 1.6;
    margin-bottom: 14px;
}

.consent-form {
    margin-top: 20px;
}

button.primary {
    background: var(--accent);
}

.auth-panel h1 {
    margin: 0 0 22px;
    font-size: 28px;
}

.stack-form p {
    display: grid;
    gap: 6px;
}

.stack-form input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    font: inherit;
}

.helptext,
.stack-form ul {
    color: var(--muted);
    font-size: 13px;
}

.chat-shell {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    height: calc(100vh - 57px);
}

.side-panel {
    border-right: 1px solid var(--line);
    padding: 28px 24px;
    background: #eef2eb;
}

.side-panel h1 {
    margin: 0 0 18px;
    font-size: 30px;
    line-height: 1.1;
}

.side-panel p {
    color: var(--muted);
    line-height: 1.55;
}

.memory-panel {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.memory-panel h2 {
    margin: 0 0 12px;
    font-size: 15px;
}

.memory-panel dl {
    display: grid;
    gap: 8px;
    margin: 0;
}

.memory-panel dt {
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 750;
}

.memory-panel dd {
    margin: -4px 0 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.status-block {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-strong);
    font-size: 14px;
    font-weight: 650;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
}

.chat-panel {
    display: grid;
    grid-template-rows: 1fr auto;
    min-width: 0;
}

.message-list {
    overflow-y: auto;
    padding: 28px;
}

.message {
    max-width: min(760px, 92%);
    margin: 0 0 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    line-height: 1.55;
    white-space: pre-wrap;
}

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

.message.assistant {
    background: var(--assistant);
}

.message.failed {
    border-color: var(--error);
    color: var(--error);
}

.message .meta {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.rag-meta,
.usage-meta {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.usage-meta {
    margin-top: 4px;
}

.supervisor-shell,
.supervisor-detail {
    width: min(1120px, calc(100vw - 32px));
    margin: 32px auto;
}

.supervisor-shell h1,
.detail-header h1 {
    margin: 0 0 20px;
}

.supervisor-list {
    display: grid;
    gap: 10px;
}

.supervisor-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
}

.supervisor-row small,
.muted {
    color: var(--muted);
}

.detail-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 18px;
}

.summary-grid article,
.message-audit {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
}

.summary-grid h2,
.message-audit h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.summary-grid dl {
    margin: 0;
}

.summary-grid dt {
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 750;
}

.summary-grid dd {
    margin: 4px 0 14px;
    color: var(--ink);
    line-height: 1.5;
}

.note-form {
    display: grid;
    gap: 12px;
}

.note-form textarea {
    width: 100%;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    font: inherit;
    line-height: 1.45;
}

.message-audit {
    margin-top: 18px;
}

.audit-message {
    border-top: 1px solid var(--line);
    padding: 14px 0;
}

.audit-message:first-of-type {
    border-top: 0;
}

.audit-message span,
.audit-message small {
    color: var(--muted);
    font-size: 12px;
}

.audit-message p {
    white-space: pre-wrap;
    line-height: 1.55;
}

@media (max-width: 860px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
}

.composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 18px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
}

.composer textarea {
    width: 100%;
    resize: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 14px;
    font: inherit;
    line-height: 1.45;
}

@media (max-width: 760px) {
    .chat-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100vh - 57px);
    }

    .side-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 20px;
    }

    .side-panel h1 {
        font-size: 24px;
    }

    .chat-panel {
        min-height: 68vh;
    }

    .message-list {
        padding: 18px;
    }

    .composer {
        grid-template-columns: 1fr;
    }
}
