:root {
    --bg: #fafafa;
    --text: #111111;
    --muted: #666666;
    --line: #eaeaea;
    --accent: #2f6fed;
    --ok: #2e7d32;
    --bad: #c62828;
    --needs: #a12f1b;
    --composer-offset: 24px;
    --composer-height: 92px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

.topbar {
    height: 56px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    position: sticky;
    top: 0;
    background: var(--bg);
}

.top-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.top-left strong {
    font-size: 18px;
    font-weight: 600;
}

.top-left span,
.top-right {
    font-size: 14px;
    color: var(--muted);
}

.top-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-name {
    white-space: nowrap;
}

.header-module-select {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 7px 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    max-width: 280px;
}

.app-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 20px 16px calc(var(--composer-height) + var(--composer-offset) + 54px);
}

.app-main.has-transcript {
    padding-bottom: calc(var(--composer-height) + var(--composer-offset) + 72px);
}

.chat-area {
    min-height: 56vh;
    transition: opacity 0.16s ease;
}

.chat-area.resetting {
    opacity: 0;
}

.chat-empty {
    margin-top: 20vh;
    text-align: center;
    color: var(--muted);
}

.chat-empty h2 {
    color: var(--text);
    font-weight: 600;
    margin: 0 0 8px;
}

.chat-stack {
    display: grid;
    gap: 24px;
}

.msg {
    font-size: 15px;
    line-height: 1.55;
}

.msg.user {
    background: #f5f5f5;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    gap: 8px;
}

.prompt {
    color: var(--muted);
}

.msg.assistant {
    background: #fff;
}

.sys {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 6px;
}

.step {
    color: var(--muted);
}

.msg.assistant h3 {
    margin: 14px 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.out {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--text);
}

.composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--composer-offset);
    border-top: 0;
    background: transparent;
    padding: 0 14px;
    transition: top 0.24s ease, bottom 0.24s ease, transform 0.24s ease;
    z-index: 20;
}

.composer-centered {
    left: 0;
    right: 0;
    top: 52%;
    bottom: auto;
    transform: translateY(-50%);
    padding: 0 14px;
}

.composer-form {
    max-width: 760px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 8px 28px rgba(17, 17, 17, 0.06);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
}

.text-input,
.comment {
    border: 0;
    border-radius: 6px;
    background: transparent;
    padding: 10px 8px;
    font-family: inherit;
    font-size: 15px;
}

.upload-btn {
    border: 1px solid var(--line);
    border-radius: 6px;
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #fff;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    user-select: none;
}

.run-btn {
    border: 0;
    border-radius: 10px;
    padding: 8px 12px;
    background: #111;
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    min-width: 62px;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.run-btn.running {
    background: #2f6fed;
    opacity: 0.92;
}

.feedback {
    margin-top: 12px;
    font-size: 14px;
}

.feedback form {
    margin-top: 6px;
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 8px;
    align-items: center;
}

.fb {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
}

.clarify-list {
    margin: 8px 0 10px;
    padding-left: 18px;
    color: var(--muted);
}

.clarify-inline {
    margin-top: 10px;
}

.clarify-inline .clarify-title {
    color: #a12f1b !important;
}

.upload-state {
    display: none;
    color: var(--muted);
    font-size: 12px;
}

.upload-state:not(:empty) {
    display: block;
    margin-top: 6px;
}

.upload-state.busy {
    color: var(--accent);
}

.feedback-ok {
    color: var(--ok);
    margin-top: 6px;
}

@media (max-width: 768px) {
    .topbar {
        height: auto;
        padding: 10px 12px;
        align-items: flex-start;
    }

    .top-right {
        flex-direction: column;
        align-items: flex-end;
    }

    .header-module-select {
        max-width: 210px;
    }

    .input-row {
        grid-template-columns: 1fr auto;
    }

    .run-btn {
        grid-column: 1 / -1;
    }

    .feedback form {
        grid-template-columns: auto auto;
    }

    .comment {
        grid-column: 1 / -1;
    }
}
