:root {
  --bg: #0a1224; --bg2: #101b35; --panel: #14223f; --line: #243558;
  --ink: #eaf1ff; --muted: #9aa8c2; --blue: #2a7bff; --red: #ff3b3b; --user: #1d4fb8;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f7fd; --bg2: #ffffff; --panel: #ffffff; --line: #d6deee;
  --ink: #16233f; --muted: #5d6c8a; --user: #dbe7ff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(1200px 600px at 20% -10%, #14305f55, transparent), var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; min-height: 100dvh; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 1.25rem; font-weight: 700; }
.brand b { color: var(--red); }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.who { color: var(--muted); font-size: .9rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stripe { height: 4px; background: linear-gradient(90deg, var(--blue) 0 33.3%, #fff 33.3% 66.6%, var(--red) 66.6%); }
.btn, .chip { font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: var(--panel); padding: 8px 16px; }
.btn { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn:hover { filter: brightness(1.1); }
.chip:hover { border-color: var(--blue); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.app { flex: 1; width: min(860px, 100%); margin: 0 auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.model { display: flex; align-items: center; gap: 8px; color: var(--muted); }
select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; max-width: 70vw; }
.quota { margin-left: auto; color: var(--muted); font-size: .9rem; }
.quota b { color: var(--ink); }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px; min-height: 40vh; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 30ch; }
.empty h2 { color: var(--ink); margin: 0 0 6px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); border-color: transparent; }
.msg.bot { align-self: flex-start; }
.msg.err { align-self: flex-start; border-color: var(--red); color: #ffb4b4; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin-bottom: 0; }
.msg code { background: #0004; padding: 1px 5px; border-radius: 5px; font: .9em ui-monospace, Consolas, monospace; }
.msg pre { background: #0006; padding: 10px; border-radius: 10px; overflow-x: auto; margin: 6px 0; }
.msg pre code { background: none; padding: 0; }
.dots::after { content: "…"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.notice { border: 1px solid var(--red); background: #ff3b3b18; padding: 10px 14px; border-radius: 12px; }
.notice a, .notice button { color: var(--blue); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
textarea { flex: 1; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; resize: none; max-height: 40vh; }
textarea:focus, select:focus, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.foot { margin: 0; text-align: center; color: var(--muted); font-size: .8rem; }
@media (max-width: 520px) { .quota { margin-left: 0; width: 100%; } .msg { max-width: 96%; } }
.banner { background: linear-gradient(90deg, #2a7bff33, #ff3b3b33); border-bottom: 1px solid var(--line); text-align: center; padding: 8px 16px; }

[hidden] { display: none !important; }
