:root {
  --surface: #faf9f7; --rail: #f0eee6; --raised: #fff;
  --ink: #1f1e1d; --muted: #73706a; --hairline: #e6e2d9;
  --accent: #d97757; --accent-ink: #fff; --danger: #b4483a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #262624; --rail: #1a1917; --raised: #30302e;
    --ink: #edeae4; --muted: #9a958c; --hairline: #3a3936;
    --accent: #d97757; --accent-ink: #1f1e1d; --danger: #e0806f;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--surface); color: var(--ink);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.serif { font-family: ui-serif, Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.01em; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.shell { display: flex; height: 100%; }
.sidebar {
  width: 260px; flex: 0 0 260px; display: flex; flex-direction: column;
  background: var(--rail); border-right: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 600; }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  background: var(--accent); color: var(--accent-ink); font-weight: 500;
  border-radius: 10px; padding: 9px 12px;
}
.btn-primary:disabled { opacity: .3; cursor: default; }
a.btn-primary { text-decoration: none; }
.pad { padding: 0 12px; }
.field {
  width: 100%; border: 1px solid var(--hairline); background: var(--surface);
  border-radius: 9px; padding: 7px 11px; outline: none;
}
.field:focus { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.chats { flex: 1; overflow-y: auto; padding: 8px; }
.chats h2 { margin: 8px 0 4px; padding: 0 10px; font-size: 11px; font-weight: 500; color: var(--muted); }
.chat-row { display: flex; align-items: center; }
.chat-row button.title {
  flex: 1; min-width: 0; text-align: left; padding: 6px 10px; border-radius: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-row button.title:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.chat-row.active button.title { background: var(--surface); font-weight: 500; }
.chat-row .more { opacity: 0; padding: 2px 6px; color: var(--muted); }
.chat-row:hover .more { opacity: 1; }

.connections { border-top: 1px solid var(--hairline); padding: 12px; }
.connections h2 { margin: 0 0 8px; padding: 0 4px; font-size: 11px; font-weight: 500; color: var(--muted); }
.conn { display: flex; align-items: center; gap: 8px; padding: 2px 4px; }
.dot { width: 8px; height: 8px; border-radius: 99px; flex: 0 0 8px; background: color-mix(in srgb, var(--muted) 40%, transparent); }
.dot.on { background: var(--accent); }
.conn .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn .act, .notion-card .act { font-size: 12px; color: var(--muted); }
.conn .act.link { color: var(--accent); font-weight: 500; }
.connections .tools-link { margin-top: 6px; padding: 2px 4px; font-size: 12px; font-weight: 500; color: var(--accent); }
.account { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--hairline); padding: 10px 12px; font-size: 12px; color: var(--muted); }
.account .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.banner { border-bottom: 1px solid var(--hairline); background: var(--rail); padding: 11px 16px; font-size: 14px; }
.banner .inner { max-width: 48rem; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.banner a, .banner button.link { color: var(--accent); font-weight: 500; }
.scroll { flex: 1; overflow-y: auto; }
.thread { max-width: 48rem; margin: 0 auto; padding: 32px 16px; display: flex; flex-direction: column; gap: 24px; }
.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; }
.empty h1 { font-size: 2rem; margin: 0; }
.empty p { color: var(--muted); max-width: 28rem; margin: 8px 0 0; }
.starters { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.starters button {
  border: 1px solid var(--hairline); background: var(--raised); color: var(--muted);
  border-radius: 99px; padding: 6px 14px;
}
.starters button:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { max-width: 85%; background: var(--rail); border-radius: 16px; padding: 10px 16px; white-space: pre-wrap; }
.msg.error { border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 6%, transparent); color: var(--danger); border-radius: 12px; padding: 12px 16px; }
.prose { line-height: 1.7; }
.prose > * + * { margin-top: .85rem; }
.prose h1, .prose h2, .prose h3 { line-height: 1.3; font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .3rem; }
.prose a { color: var(--accent); text-underline-offset: 2px; }
.prose code { background: color-mix(in srgb, var(--muted) 16%, transparent); padding: .12em .36em; border-radius: 4px; font-size: .87em; }
.prose pre { background: var(--rail); border: 1px solid var(--hairline); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }

.chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  border: 1px solid var(--hairline); background: var(--rail);
  border-radius: 99px; padding: 4px 12px; font-size: 12px; color: var(--muted);
}
.chip .state { color: var(--accent); }
.chip .state.pending { color: var(--muted); animation: blink 1.1s ease-in-out infinite; }
.chip .state.bad { color: var(--danger); }
.chip.steps { cursor: pointer; font: inherit; font-size: 12px; text-align: left; }
.chip.steps:hover { color: var(--ink); border-color: var(--muted); }
.chip.steps .caret { margin-left: 2px; }
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.composer { border-top: 1px solid var(--hairline); padding: 12px 16px 20px; }
.composer .inner { max-width: 48rem; margin: 0 auto; }
.box {
  display: flex; align-items: flex-end; gap: 8px;
  border: 1px solid var(--hairline); background: var(--raised);
  border-radius: 16px; padding: 8px 12px;
}
.box:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.box textarea { flex: 1; border: 0; background: none; resize: none; outline: none; max-height: 260px; padding: 6px 0; }
.engine {
  flex: 0 0 auto; align-self: center; max-width: 12rem;
  border: 1px solid var(--hairline); background: var(--rail); color: var(--muted);
  border-radius: 8px; font: inherit; font-size: 12px; padding: 4px 6px;
}
.send { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.send:disabled { opacity: .3; }
.send.stop { background: var(--ink); color: var(--surface); }
.hint { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

.centered { max-width: 32rem; margin: 0 auto; padding: 48px 24px; display: flex; flex-direction: column; justify-content: center; min-height: 100%; }
.card { border: 1px solid var(--hairline); background: var(--raised); border-radius: 12px; padding: 16px; }
.card + .card { margin-top: 12px; }
.card .head { display: flex; align-items: center; gap: 12px; }
.card .head .grow { flex: 1; min-width: 0; }
.card .head .grow p { margin: 2px 0 0; color: var(--muted); }
.btn-small { background: var(--accent); color: var(--accent-ink); border-radius: 9px; padding: 6px 12px; font-weight: 500; }
.sub { font-size: 12px; color: var(--muted); }
.steps { margin: 10px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.steps li + li { margin-top: 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.copyrow { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.copyrow code { flex: 1; min-width: 0; overflow-x: auto; background: var(--rail); border-radius: 6px; padding: 5px 8px; white-space: nowrap; }
.copyrow button { border: 1px solid var(--hairline); border-radius: 6px; padding: 4px 9px; font-size: 12px; color: var(--muted); }
.err { color: var(--danger); font-size: 12px; margin-top: 8px; }

.tools { max-width: 48rem; margin: 0 auto; padding: 32px 16px; }
.tools-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tools-head h1 { font-size: 1.9rem; margin: 0; }
.tools .title { font-weight: 500; margin: 24px 0 8px; }
.tools .card .title { margin: 0; }
.tools h3 { font-size: 13px; font-weight: 500; margin: 18px 0 0; }
/* Commands are long; wrapped, the whole of one can be read before it is pasted. */
.tools .copyrow code { white-space: pre-wrap; overflow-wrap: anywhere; }
.token-form { display: flex; gap: 8px; margin-top: 10px; }
.token-form .btn-small { flex: 0 0 auto; }
.shown { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--hairline); }
.token { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.token + .token { border-top: 1px solid var(--hairline); }
.token .grow { flex: 1; min-width: 0; }
.token .grow p { margin: 0; }
.token .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token button { border: 1px solid var(--hairline); border-radius: 6px; padding: 4px 9px; font-size: 12px; color: var(--danger); }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

.brand svg { width: 18px; height: 18px; }

/* Citation chips and the sources under an answer */
.prose .cite {
  display: inline-block; min-width: 1.35em; padding: 0 .38em; margin: 0 .1em;
  font-size: .72em; line-height: 1.55; text-align: center; vertical-align: super;
  color: var(--muted); background: color-mix(in srgb, var(--muted) 16%, transparent);
  border-radius: 999px; text-decoration: none;
}
.prose a.cite:hover { color: var(--accent-ink); background: var(--accent); }
.sources { margin-top: .6rem; padding-left: 1.4rem; font-size: .82rem; color: var(--muted); }
.sources li + li { margin-top: .15rem; }
.sources a { color: var(--muted); text-underline-offset: 2px; }
.sources a:hover { color: var(--accent); }

/* Thumbs under an answer */
.rating { display: flex; gap: .25rem; margin-top: .4rem; }
.thumb {
  padding: .1rem .45rem; font-size: .85rem; line-height: 1.4; cursor: pointer;
  background: none; border: 1px solid transparent; border-radius: 6px; opacity: .55;
}
.thumb:hover { opacity: 1; border-color: var(--hairline); }
.thumb[aria-pressed="true"] { opacity: 1; background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }

.notion-card { margin-top: 10px; padding: 8px 4px 0; border-top: 1px solid var(--hairline); }
.notion-card .name { font-weight: 500; }
.notion-card p, .notion-card ol { margin: 4px 0; }
.notion-card ol { padding-left: 18px; }
.notion-card .field { margin: 4px 0 8px; }
.notion-card .btn-small { margin-right: 8px; }
.notion-card .bad { color: #b3261e; }
