:root { --bg: #fff; --fg: #18181b; --muted: #71717a; --line: #e4e4e7; --user: #f4f4f5; --accent: #18181b; --accent-fg: #fff; --err: #b91c1c; }
@media (prefers-color-scheme: dark) { :root { --bg: #111113; --fg: #f4f4f5; --muted: #a1a1aa; --line: #2a2a2e; --user: #1e1e22; --accent: #f4f4f5; --accent-fg: #111113; --err: #f87171; } }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, sans-serif; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.5em; margin: 0; }
.card { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
.card h1 { font-size: 1.4rem; margin-bottom: 4px; }
label { display: block; margin: 12px 0; font-size: .9rem; }
input, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: inherit; font: inherit; }
button { padding: 10px 16px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-fg); font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; color: var(--muted); padding: 0; text-decoration: underline; }
.app { display: flex; height: 100%; }
.side { width: 270px; flex: none; border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; font-size: .9rem; }
.side h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.side > button { width: 100%; }
.side ul { list-style: none; padding: 0; margin: 0; }
.common button, .recent button.open { width: 100%; text-align: left; background: transparent; color: inherit; padding: 6px 8px; border-radius: 8px; font-size: .85rem; }
.common button:hover, .recent li:hover, .recent li.current { background: var(--user); }
.recent li { display: flex; align-items: center; border-radius: 8px; }
.recent button.open { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent button.del { background: transparent; color: var(--muted); padding: 4px 8px; visibility: hidden; }
.recent li:hover button.del, .recent li.current button.del { visibility: visible; }
.small { font-size: .8rem; }
.menu { display: none; }
@media (max-width: 800px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 2; background: var(--bg); transform: translateX(-100%); transition: transform .15s; box-shadow: 0 0 24px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .menu { display: inline; }
}
.chat { display: flex; flex-direction: column; height: 100%; flex: 1; min-width: 0; max-width: 760px; margin: 0 auto; padding: 0 16px; }
.chat header { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
#log { flex: 1; overflow-y: auto; padding: 16px 0; }
.msg { margin: 0 0 16px; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { background: var(--user); padding: 10px 14px; border-radius: 14px; margin-left: auto; width: fit-content; max-width: 85%; white-space: pre-wrap; }
.msg.assistant table { border-collapse: collapse; display: block; overflow-x: auto; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--line); padding: 4px 10px; text-align: left; }
.msg.error { color: var(--err); }
.msg.pending { color: var(--muted); }
.empty ul { list-style: none; padding: 0; }
.suggestion { background: transparent; color: inherit; border: 1px solid var(--line); text-align: left; margin: 4px 0; width: 100%; }
#ask-form { display: flex; gap: 8px; padding: 8px 0; align-items: flex-end; }
#ask-form textarea { resize: none; max-height: 160px; }
.foot { font-size: .75rem; margin: 0 0 12px; text-align: center; }

.summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.summary select { width: auto; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: inherit; font: inherit; }
.summary button { padding: 6px 12px; background: transparent; color: inherit; border: 1px solid var(--line); }

.banner { margin: 0; padding: 6px 10px; background: var(--user); border-radius: 8px; font-size: .8rem; color: var(--muted); }
.trace { margin: 0 0 16px; font-size: .8rem; color: var(--muted); }
.trace pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; background: var(--user); padding: 8px; border-radius: 8px; margin: 6px 0; }
