:root {
  --bg: #f6f6f4; --panel: #ffffff; --text: #1c1d1f; --muted: #6b6e73; --line: #dcdcd8;
  --accent: #1f5f8b; --accent-text: #ffffff; --user: #e7eef4; --code: #f0f0ec; --err: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --panel: #1d2024; --text: #e6e7e9; --muted: #9a9ea5; --line: #33373d;
    --accent: #6fb1dd; --accent-text: #0e1216; --user: #24323d; --code: #26292e; --err: #f2998f;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
code, pre { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--code); padding: 1px 4px; border-radius: 3px; overflow-wrap: anywhere; }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { width: 100%; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 12px; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.link { border: 0; background: none; color: var(--muted); padding: 2px 4px; text-decoration: underline; }
.icon { padding: 4px 9px; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--err); min-height: 1.5em; margin: 8px 0 0; font-size: 14px; }

.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.card label { display: block; margin-bottom: 12px; font-size: 14px; }
.card label input { margin-top: 4px; }
.card button { width: 100%; }
.card ol { padding-left: 18px; margin: 0 0 8px; }
.qr { display: block; width: 190px; height: 190px; margin: 8px auto; background: #fff; }

.app { display: flex; height: 100%; }
.side { width: 260px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.side-top { display: flex; gap: 8px; padding: 12px; }
.side-top .primary { flex: 1; }
.tasks { flex: 1; overflow-y: auto; padding: 0 8px; }
.tasks button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 8px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tasks button:hover { background: var(--bg); }
.tasks button[aria-current="true"] { background: var(--user); font-weight: 600; }
.side-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.log { flex: 1; overflow-y: auto; padding: 16px; }
.msg { max-width: 780px; margin: 0 auto 16px; overflow-wrap: anywhere; }
.msg p { margin: 0 0 8px; }
.msg ul, .msg ol { margin: 0 0 8px; padding-left: 22px; }
.msg.user .body { background: var(--user); padding: 8px 12px; border-radius: 8px; white-space: pre-wrap; }
.msg pre { position: relative; background: var(--code); padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 0 0 8px; }
.msg pre code { background: none; padding: 0; overflow-wrap: normal; }
.msg .copy { position: absolute; top: 4px; right: 4px; font-size: 12px; padding: 1px 7px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.fb[aria-pressed="true"] { background: var(--user); border-color: var(--accent); }
.fb { padding: 1px 8px; font-size: 13px; }
.fix { max-width: 780px; margin: 6px 0 0; display: flex; gap: 8px; }
.empty { max-width: 560px; margin: 12vh auto 0; text-align: center; color: var(--muted); }
.notice { color: var(--muted); font-size: 13px; }
.notice.bad { color: var(--err); }
.composer { display: flex; gap: 8px; align-items: flex-end; max-width: 812px; width: 100%; margin: 0 auto; padding: 10px 16px 14px; }
.composer textarea { resize: none; max-height: 40vh; }

.only-small { display: none; }
@media (max-width: 720px) {
  .only-small { display: inline-block; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 2; width: min(84vw, 300px); transform: translateX(-100%); }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .35); }
  #model { display: none; }
}
@media (prefers-reduced-motion: no-preference) { .side { transition: transform .15s ease; } }
