:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --text: #1d2433;
    --muted: #667085;
    --line: #dde3ee;
    --brand: #2a5298;
    --brand-dark: #1e3c72;
    --user: #e8eefb;
    --error: #b42318;
    --note: #9a6700;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12161f;
        --panel: #1b2130;
        --text: #e6e9f0;
        --muted: #98a2b3;
        --line: #2c3446;
        --brand: #5b8def;
        --brand-dark: #3f6fd1;
        --user: #233152;
        --error: #f97066;
        --note: #f5c451;
    }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    display: flex;
    flex-direction: column;
}
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: #fff;
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo {
    display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
    background: rgba(255, 255, 255, .2); font-size: 13px;
}
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
.usage { opacity: .85; }
.name { font-weight: 600; }
.inline { display: inline; margin: 0; }

main { flex: 1; display: flex; justify-content: center; min-height: 0; padding: 16px; }

.btn {
    border: 1px solid var(--line); background: var(--panel); color: var(--text);
    border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none;
    display: inline-block;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.topbar .btn.small { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .35); }

.notice {
    align-self: flex-start; margin-top: 10vh; max-width: 520px; width: 100%;
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px;
    text-align: center;
}
.notice h1 { margin-top: 0; font-size: 22px; }

.chat {
    width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 12px; min-height: 0;
}
.privacy {
    font-size: 12.5px; color: var(--muted); background: var(--panel);
    border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.messages {
    flex: 1; overflow-y: auto; min-height: 200px; display: flex; flex-direction: column; gap: 12px;
    padding: 4px;
}
.empty { margin: auto; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 4px; }
.msg {
    max-width: 85%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
    background: var(--panel); position: relative;
}
.msg.user { align-self: flex-end; background: var(--user); }
.msg.assistant { align-self: flex-start; }
.msg.pending { color: var(--muted); font-style: italic; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .note { font-size: 12px; color: var(--note); margin-top: 6px; }
.msg .copy { margin-top: 8px; }

.composer {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
    display: flex; flex-direction: column; gap: 10px;
}
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
    cursor: pointer; user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
textarea {
    width: 100%; resize: vertical; min-height: 110px; max-height: 45vh; font: inherit; color: var(--text);
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
}
textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.composer-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.counter { font-size: 12px; color: var(--muted); }
.error { flex: 1; color: var(--error); font-size: 13px; min-width: 120px; }

@media (max-width: 600px) {
    main { padding: 10px; }
    .msg { max-width: 95%; }
    .usage { display: none; }
}
