:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --border: #dde1e6;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --user: #e8f0f8;
  --error: #a4262c;
  --code: #f0f2f5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1c2026;
    --text: #e6e9ed;
    --muted: #9aa3ad;
    --border: #2e343c;
    --accent: #5b9bd5;
    --accent-text: #0d1117;
    --user: #1f2a36;
    --error: #ff8a8f;
    --code: #262b33;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand h1 { font-size: 1.1rem; margin: 0; }
.sub { margin: 0; color: var(--muted); font-size: 0.85rem; }
.who { color: var(--muted); font-size: 0.9rem; display: flex; gap: 0.75rem; align-items: center; }
main { flex: 1; overflow-y: auto; padding: 1rem; }
main > * { max-width: 52rem; margin-inline: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; }
.empty { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.hint { font-size: 0.9rem; }
.log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.msg { border-radius: 12px; padding: 0.75rem 1rem; border: 1px solid var(--border); background: var(--surface); overflow-wrap: anywhere; }
.msg.user { background: var(--user); align-self: flex-end; max-width: 85%; white-space: pre-wrap; }
.msg.pending { color: var(--muted); font-style: italic; }
.msg.failed { border-color: var(--error); color: var(--error); }
.msg :first-child { margin-top: 0; }
.msg :last-child { margin-bottom: 0; }
.msg table { border-collapse: collapse; display: block; overflow-x: auto; margin: 0.5rem 0; }
.msg th, .msg td { border: 1px solid var(--border); padding: 0.3rem 0.5rem; text-align: left; vertical-align: top; }
.msg code { background: var(--code); padding: 0.1em 0.3em; border-radius: 4px; font-size: 0.9em; }
.msg pre { background: var(--code); padding: 0.75rem; border-radius: 8px; overflow-x: auto; }
.msg a { color: var(--accent); }
.draft { margin-top: 0.75rem; border-top: 1px dashed var(--border); padding-top: 0.75rem; }
.draft summary { cursor: pointer; font-weight: 600; }
.draft pre { white-space: pre-wrap; font-size: 0.85rem; max-height: 22rem; overflow-y: auto; }
.draft .status { color: var(--muted); font-size: 0.9rem; margin-left: 0.5rem; }
.ask {
  border-top: 1px solid var(--border); background: var(--surface); padding: 0.75rem 1rem;
}
.ask > * { max-width: 52rem; margin-inline: auto; }
.ask textarea {
  display: block; width: 100%; resize: vertical; min-height: 3rem; max-height: 40vh;
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.75rem;
}
.ask-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
.primary {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px; padding: 0.5rem 1.1rem; font-weight: 600;
}
.link { background: none; border: 0; color: var(--accent); padding: 0.25rem; }
.error { color: var(--error); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 600px) {
  .sub { display: none; }
  .msg.user { max-width: 100%; }
}
