:root {
  color: #1f2937;
  background: #f7f7f8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: #155eef; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar { height: 64px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e7eb; background: white; }
.brand { color: #111827; font-weight: 700; }
.landing { max-width: 760px; margin: 0 auto; padding: 140px 24px; text-align: center; }
.landing h1 { font-size: clamp(36px, 7vw, 64px); line-height: 1.05; margin: 0 0 24px; }
.landing p { font-size: 20px; line-height: 1.6; color: #6b7280; }
.actions { display: flex; justify-content: center; gap: 12px; margin-top: 32px; }
.button { border: 1px solid #111827; border-radius: 7px; padding: 10px 16px; color: white; background: #111827; display: inline-block; }
.button.secondary { color: #111827; background: white; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card { width: min(100%, 420px); background: white; border: 1px solid #e5e7eb; border-radius: 10px; padding: 32px; }
.auth-card h1 { margin: 32px 0 8px; }
.auth-card > p { color: #6b7280; }
.auth-card form { display: grid; gap: 18px; margin-top: 28px; }
label { display: grid; gap: 7px; font-weight: 600; }
input, textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 7px; padding: 10px 12px; background: white; color: #111827; }
input:focus, textarea:focus { outline: 2px solid #93b4fd; border-color: #155eef; }
.error { margin-top: 18px; padding: 10px 12px; border-radius: 7px; background: #fef2f2; color: #b42318; }
.auth-switch { margin-top: 24px; font-size: 14px; }

.primary-shell { min-height: 100vh; background: white; }
.primary-main { height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: white; }
.primary-header { min-height: 64px; padding: 14px 24px; background: white; border-bottom: 1px solid #e5e7eb; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 20px; }
.primary-account { display: flex; align-items: center; gap: 14px; color: #6b7280; font-size: 13px; }
.primary-account form { display: inline-flex; }
.link-button { border: 0; background: none; color: #155eef; padding: 4px 0; text-align: left; }
.status { color: #b54708; font-size: 13px; }
.status.connected { color: #067647; }
.messages { padding: 28px max(24px, calc((100% - 780px) / 2)); overflow-y: auto; background: white; }
.message { margin-bottom: 22px; line-height: 1.55; overflow-wrap: anywhere; }
.message.assistant { color: #374151; }
.message.user { display: flex; justify-content: flex-end; }
.message.user .message-content { max-width: min(85%, 620px); padding: 10px 14px; border-radius: 18px; background: #f4f4f4; color: #111827; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.markdown p { margin: .55em 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { color: #111827; line-height: 1.25; margin: 1em 0 .45em; }
.markdown h1 { font-size: 1.45em; }
.markdown h2 { font-size: 1.3em; }
.markdown h3 { font-size: 1.15em; }
.markdown ul, .markdown ol { margin: .6em 0; padding-left: 1.6em; }
.markdown li + li { margin-top: .25em; }
.markdown blockquote { margin: .75em 0; padding-left: 14px; border-left: 3px solid #d1d5db; color: #6b7280; }
.markdown code { padding: .12em .35em; border-radius: 4px; background: #eef0f3; font: .9em ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.markdown pre { overflow-x: auto; margin: .75em 0; padding: 14px; border-radius: 7px; background: #111827; color: #f9fafb; }
.markdown pre code { padding: 0; background: none; color: inherit; white-space: pre; }
.markdown hr { border: 0; border-top: 1px solid #e5e7eb; margin: 1em 0; }
.empty-state { max-width: 520px; margin: 18vh auto 0; text-align: center; color: #6b7280; }
.empty-state h2 { color: #111827; }
.chat-form { background: white; border-top: 1px solid #e5e7eb; padding: 16px max(24px, calc((100% - 780px) / 2)) 22px; }
.chat-form textarea { display: block; min-height: 0; max-height: none; overflow-y: hidden; resize: none; line-height: 1.5; }
.chat-status-row { min-height: 30px; margin-bottom: 7px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stop-button { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; padding: 0; border: 1px solid #111827; border-radius: 6px; background: #111827; color: white; }
.stop-button:hover { border-color: #000; background: #000; }
.stop-button:disabled { cursor: not-allowed; opacity: .55; }
.stop-button svg { width: 16px; height: 16px; fill: currentColor; }
.stop-button[hidden] { display: none; }
#task-status { color: #6b7280; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .messages { min-height: 45vh; }
  .primary-header { grid-template-columns: 1fr auto; }
  .primary-header .status { grid-column: 1 / -1; }
  .primary-account > span:nth-child(2) { display: none; }
}
