:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182334;
  background: #fff;
  font-synthesis: none;
  --ink: #182334;
  --muted: #536278;
  --line: #dce4ee;
  --accent: #1764c9;
  --accent-dark: #104c9e;
  --selection: #e7f0ff;
  --chrome: #f1f4f9;
  --paper: #fff;
  --hover: #eaf0f8;
  --conversation-width: 1180px;
  --conversation-gutter: clamp(16px, 3.4vw, 46px);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea, select {
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 8px 10px;
}
textarea { resize: vertical; }
::placeholder { color: #62738a; }
#app { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
#app:has(> .notice) { grid-template-rows: auto auto minmax(0, 1fr); }
#app > .notice { margin: 0; padding: 8px 18px; border-radius: 0; }

.workspace-tools {
  min-width: 0;
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 5px clamp(10px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
}
.workspace-tools button { border-radius: 7px; min-height: 34px; padding: 4px 8px; }
.workspace-tools button:hover:enabled { background: var(--hover); }
.project-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-right: auto;
  max-width: 100%;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}
.project-switch span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switch span[aria-hidden] { color: var(--muted); flex: none; }
.project-switch kbd { white-space: nowrap; margin-inline-start: 2px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; font: 11px system-ui; color: var(--muted); background: var(--paper); }
#next-project, #ideas-button { white-space: nowrap; font-size: 13px; }
.ready-count { display: inline-block; padding: 1px 5px; margin-left: 2px; border-radius: 5px; background: var(--selection); color: var(--accent-dark); font-variant-numeric: tabular-nums; font-size: 11px; }
.icon-button { flex: none; min-width: 34px; min-height: 34px; border-radius: 5px; font-size: 18px; }
.icon-button:hover { background: var(--hover); }

#workspace { min-width: 0; min-height: 0; overflow: auto; }
#workspace.active-project {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}
.thread {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  outline-offset: -3px;
}
.conversation {
  width: min(var(--conversation-width), calc(100% - 2 * var(--conversation-gutter)));
  margin-inline: auto;
  padding: 20px 0 12px;
}
.handoff-card { overflow-wrap: anywhere; }
.report-meta, .turn-picker, .watch-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}
.report-meta { justify-content: space-between; }
.turn-picker select { max-width: 100%; min-width: 0; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 25px; font-weight: 630; }
h2 { font-size: 20px; font-weight: 640; margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 640; margin: 23px 0 8px; }
.handoff-card h3[tabindex="-1"]:focus { outline: 2px solid var(--accent); outline-offset: 4px; }
.handoff-card > p, .handoff-summary, .message-body, .live-response {
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.handoff-summary { margin-bottom: 12px; }
.handoff-summary, .handoff-card > p, .message-body { max-width: 82ch; }
.handoff-card > p { margin: 8px 0; }
.claim small, .analysis-status { color: var(--muted); }
.claim button, .message-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.analysis-status { margin: 12px 0; font-size: 13px; }
.decision-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 8px; margin: 10px 0 14px; }
.decision-option {
  display: grid;
  gap: 3px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  background: var(--paper);
  font-size: 14px;
  line-height: 1.45;
  align-content: start;
}
.decision-option:hover:enabled { border-color: #a7c4ed; background: #f5f8ff; }
.decision-option span { color: var(--muted); }
.decision-context { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; margin: 12px 0; font-size: 14px; line-height: 1.5; }
.decision-context summary { cursor: pointer; color: var(--accent-dark); }
.decision-context > div, .decision-context > details { margin-top: 9px; }
.decision-context p, .decision-context ul { margin: 3px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.decision-context ul { padding-left: 1.25em; }
.decision-context .message-body { margin-top: 6px; }
@media (min-width: 900px) {
  .decision-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
  .decision-body .decision-options { grid-template-columns: 1fr; }
}
.source-list details { border-top: 1px solid var(--line); }
.source-list summary, .full-response summary { cursor: pointer; font-size: 14px; padding: 10px 0; }
.full-response { border-top: 1px solid var(--line); color: var(--muted); }
.full-response .message-body { color: var(--ink); }
.report-evidence, .chat-history { border-top: 1px solid var(--line); margin: 12px 0; }
.report-evidence > summary, .chat-history > summary { padding: 10px 0; font-size: 14px; cursor: pointer; color: var(--muted); }
.report-evidence > summary:hover, .chat-history > summary:hover { color: var(--accent-dark); }
.message { padding: 10px 0; margin: 5px 0 16px; }
.report-message { padding-block: 12px; }
.message.user {
  width: fit-content;
  max-width: 88%;
  margin-left: auto;
  padding: 9px 15px;
  background: var(--hover);
  border-radius: 15px 15px 5px 15px;
}
.message-label { font-size: 12px; font-weight: 620; color: var(--muted); margin-bottom: 5px; }
.message-label span { margin-left: 8px; font-weight: 400; }
.message-heading { display: inline-block; margin: 8px 0; }
code, pre { font-size: .88em; background: var(--chrome); border-radius: 5px; }
code { padding: 2px 4px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px; }
.source-list pre { max-height: 16rem; overflow: auto; margin-top: 0; }
.live-response { margin: 16px 0; }
.notice, .error-card {
  background: var(--selection);
  color: #234775;
  padding: 8px 11px;
  border-radius: 6px;
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.notice[role="alert"] { background: #fff5e7; color: #634615; }
.error-card { background: #f8eeeb; color: #76372b; }
.error-card p { margin: 7px 0; }

.composer-wrap {
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
  background: #f8faff;
  padding: 9px var(--conversation-gutter) calc(12px + env(safe-area-inset-bottom));
  max-height: 48dvh;
}
#composer, .composer-wrap > .notice { max-width: var(--conversation-width); margin-inline: auto; }
#composer { display: grid; gap: 6px; }
.reply-box {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 8px;
  background: var(--paper);
  border: 1px solid #cdd8e7;
  border-radius: 18px;
  box-shadow: 0 3px 12px #182f5510;
}
.reply-box:focus-within { border-color: #91b5e8; box-shadow: 0 0 0 2px #1764c91c; }
.reply-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 2px; }
.provider-picker { display: inline-flex; flex: none; gap: 2px; padding: 2px; border-radius: 8px; background: var(--chrome); }
.provider-picker button { min-height: 27px; font-size: 13px; color: var(--muted); border-radius: 6px; padding: 3px 8px; }
.provider-picker button[aria-pressed="true"] { background: var(--selection); color: var(--accent-dark); box-shadow: 0 1px 2px #1a3b6221; font-weight: 600; }
.provider-picker button:hover:enabled { color: var(--ink); }
#permission { margin-left: auto; padding: 4px 2px; font-size: 12px; border-color: transparent; color: var(--muted); background: none; cursor: pointer; }
#permission:hover:enabled { border-color: var(--line); }
#prompt {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  height: 54px;
  max-height: 24dvh;
  border: 0;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 7px;
  resize: none;
}
#prompt:focus-visible { outline: none; }
@supports (field-sizing: content) { #prompt { field-sizing: content; height: auto; } }
.reply-status { color: var(--muted); font-size: 13px; padding-inline: 6px; }
.composer-note { font-size: 12px; color: var(--muted); line-height: 1.45; }
.composer-note:empty { display: none; }
#reply-connection-notice .notice { margin-bottom: 0; }
#watched-result-notice .notice { margin-bottom: 0; }
.demo-tag { font-size: 13px; color: var(--muted); }
.primary-button, .send-button { background: var(--accent); color: white; border-radius: 8px; font-size: 14px; font-weight: 600; padding: 8px 14px; }
.primary-button:hover:enabled, .send-button:hover:enabled { background: var(--accent-dark); }
.send-button { display: grid; flex: none; width: 33px; height: 33px; padding: 0; place-items: center; border-radius: 11px; font-size: 20px; line-height: 1; }
.reply-stop { padding: 5px 7px; }
.secondary-button { border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.secondary-button:hover:enabled { background: var(--hover); }
.text-button { color: var(--accent); padding: 2px 0; font-size: 13px; }
.text-button:hover:enabled { text-decoration: underline; text-underline-offset: 3px; }
.decision-jump { white-space: nowrap; }
dialog {
  width: min(530px, calc(100vw - 26px));
  max-height: 88dvh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 56px #182d5128;
}
dialog::backdrop { background: #15264155; }
.modal-head { float: right; margin: -6px -6px 0 10px; }
.modal-intro, .fine-print, .form-hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
dialog input:not([type="checkbox"]), dialog textarea { width: 100%; }
dialog form label { display: grid; gap: 5px; margin-bottom: 13px; font-size: 13px; }
dialog textarea { min-height: 76px; }
.menu-actions { display: flex; flex-wrap: wrap; gap: 5px 8px; margin-block: 10px; }
.menu-actions > :is(button:not(.primary-button),a) { padding: 7px 9px; font-size: 13px; text-decoration: none; border: 1px solid var(--line); border-radius: 5px; }
.menu-actions > :is(button:enabled,a):hover { background: var(--hover); color: var(--ink); }
.menu-actions + .menu-actions { border-top: 1px solid var(--line); padding-top: 10px; }
.auto-toggle { display: flex; gap: 7px; align-items: center; font-size: 13px; margin-top: 15px; }
.auto-toggle input { accent-color: var(--accent); }
.project-list, .discovery-list { max-height: 50dvh; overflow: auto; margin-top: 8px; }
.chat-group > h3 { margin: 10px 5px 3px; color: var(--muted); font-size: 12px; }
.project-row, .discovery-row { display: flex; align-items: flex-start; width: 100%; border-bottom: 1px solid var(--line); padding: 9px 5px; text-align: left; gap: 9px; }
.project-row { flex-direction: column; gap: 2px; }
.project-row:hover, .discovery-row:hover { background: var(--hover); }
.project-row[aria-current="true"] { background: var(--selection); }
.project-name, .discovery-row strong { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.project-sub, .discovery-row small, .discovery-row p, .discovery-row i { color: var(--muted); font-size: 12px; line-height: 1.45; }
.discovery-row span:nth-child(2) { flex: 1; min-width: 0; }
.discovery-row small { display: block; }
.discovery-row p { margin: 3px 0 0; }
.discovery-loading, .loading { padding: 25px; color: var(--muted); font-size: 14px; }
.state-dot { width: 7px; height: 7px; flex: none; margin-top: 7px; border-radius: 50%; background: #8494aa; }
.state-dot.ready { background: #6596e4; }
.state-dot.running, .state-dot.stopping { background: #1764c9; }
.form-pair, .usage-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.usage-form { flex: 1 1 180px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.usage-form p, .connection-card p, .context-kicker, .goal, .decision-list { font-size: 13px; line-height: 1.5; }
.usage-actions, .connection-next { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.connection-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.connection-card p { margin: 4px 0; color: var(--muted); }
.connection-card .connection-error { color: #76372b; }
.connection-card > .secondary-button, .signed-in { margin-left: auto; }
.auth-instructions, .auth-code-form, .install-help, .connection-next, .connection-next p { width: 100%; }
.auth-instructions { white-space: pre-wrap; overflow-wrap: anywhere; }
.provider-glyph, .signed-in { color: var(--accent); }
.context-kicker { margin-top: 12px; color: var(--muted); }
.goal { white-space: pre-line; }
.idea-workspace { width: min(650px, 100%); padding: 24px; margin-inline: auto; }
.idea-intro { font-size: 14px; color: var(--muted); }
#idea-text { width: 100%; min-height: 90px; }
.idea-form-footer { display: flex; justify-content: flex-end; margin-top: 5px; }
.idea-item { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.idea-item p { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
#toast { position: fixed; z-index: 30; bottom: 16px; left: 50%; transform: translateX(-50%); max-width: 90%; background: var(--ink); color: white; padding: 8px 13px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; }
#toast.visible { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 750px) {
  .project-switch kbd { display: none; }
  .thread { scrollbar-gutter: auto; }
  .conversation { padding-block: 10px; }
  .composer-wrap { padding-block: 7px calc(8px + env(safe-area-inset-bottom)); }
  .reply-box { padding: 5px 7px; }
  #prompt { min-height: 40px; height: 44px; max-height: 24dvh; padding: 6px 8px; }
  @supports (field-sizing: content) { #prompt { height: auto; } }
}
