body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #0b1220;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
header {
    padding: 18px 24px;
    border-bottom: 1px solid #1f2a44;
    background: #111a2e;
}
header h1 {
    margin: 0;
    font-size: 1.4rem;
}
header p {
    margin: 4px 0 0 0;
    color: #94a3b8;
    font-size: 0.9rem;
}
#chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.input-bar {
    display: flex;
    gap: 12px;
    padding: 18px;
    border-top: 1px solid #1f2a44;
    background: #111a2e;
}
textarea {
    flex: 1;
    resize: none;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    font-size: 0.95rem;
    min-height: 56px;
    outline: none;
}
textarea:focus {
    border-color: #2563eb;
}
button {
    border: none;
    background: #2563eb;
    color: white;
    padding: 0 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
}
button:hover {
    background: #1d4ed8;
}
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Message bubbles ── */
.msg {
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 12px;
    max-width: 75%;
    line-height: 1.6;
}
.msg.user {
    background: #2563eb;
    align-self: flex-end;
    margin-left: auto;
    color: #fff;
    white-space: pre-wrap;
}
.msg.assistant {
    background: #f8fafc;
    align-self: flex-start;
    margin-right: auto;
    color: #1a1a2e;
}

/* ── Markdown rendering inside assistant bubbles ── */
.msg.assistant p {
    margin: 0 0 8px;
}
.msg.assistant p:last-child {
    margin-bottom: 0;
}
.msg.assistant strong {
    font-weight: 700;
    color: #1e40af;
}
.msg.assistant em {
    color: #475569;
}
.msg.assistant ul,
.msg.assistant ol {
    margin: 6px 0 8px 20px;
    padding: 0;
}
.msg.assistant li {
    margin-bottom: 4px;
    line-height: 1.55;
}
.msg.assistant h1,
.msg.assistant h2,
.msg.assistant h3 {
    margin: 10px 0 4px;
    font-size: 1rem;
    font-weight: 700;
    color: #1e3a8a;
}
.msg.assistant code {
    background: #e0e7ff;
    color: #1e40af;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.msg.assistant pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.88em;
    margin: 8px 0;
}
.msg.assistant pre code {
    background: none;
    color: inherit;
    padding: 0;
}
.msg.assistant blockquote {
    border-left: 3px solid #2563eb;
    margin: 8px 0;
    padding: 4px 12px;
    color: #475569;
}
.msg.assistant hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 10px 0;
}

.msg.error {
    background: #2d0e0e;
    border: 1px solid #7f1d1d;
    color: #fca5a5;
    align-self: flex-start;
    margin-right: auto;
    font-weight: 500;
}
.msg.warn {
    background: #2d2500;
    border: 1px solid #854d0e;
    color: #fde68a;
    align-self: flex-start;
    margin-right: auto;
    font-weight: 500;
}