:root {
  color-scheme: light;
  --bg: #f7f5f0;
  --surface: #fffdf8;
  --surface-2: #efeae0;
  --sidebar: #ece7dc;
  --text: #20211f;
  --muted: #6f6b62;
  --border: #ddd6c8;
  --accent: #176b4d;
  --accent-hover: #12573e;
  --accent-soft: #dcebe3;
  --danger: #a33b32;
  --warning: #9a5b12;
  --user-bubble: #e7e1d4;
  --shadow: 0 18px 50px rgba(49, 43, 31, .14);
  --radius: 18px;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171816;
  --surface: #20211f;
  --surface-2: #292a27;
  --sidebar: #1d1e1c;
  --text: #f0eee8;
  --muted: #aaa69c;
  --border: #383a36;
  --accent: #55b98d;
  --accent-hover: #6cc79d;
  --accent-soft: #213b30;
  --danger: #ef8a80;
  --warning: #e0aa5e;
  --user-bubble: #30312e;
  --shadow: 0 18px 50px rgba(0,0,0,.38);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.app-shell { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 276px; flex: 0 0 276px; display: flex; flex-direction: column;
  padding: 18px 14px 14px; background: var(--sidebar); border-right: 1px solid var(--border);
  z-index: 30;
}
.brand-row { display: flex; align-items: center; gap: 11px; padding: 2px 6px 18px; }
.brand-mark, .empty-mark {
  display: grid; place-items: center; background: var(--text); color: var(--bg);
  font-weight: 750; letter-spacing: -.04em;
}
.brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 20px; }
.brand-name { font-weight: 720; letter-spacing: -.02em; line-height: 1.15; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.sidebar-close { display: none; margin-left: auto; }
.new-chat {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 13px; padding: 11px 13px; text-align: left; font-weight: 650;
}
.new-chat:hover { border-color: var(--accent); }
.main-nav { display: grid; gap: 3px; margin: 18px 0 22px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px;
  border: 0; border-radius: 10px; background: transparent; text-align: left; color: var(--muted);
}
.nav-item span { width: 20px; text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); font-weight: 650; }
.recent-head { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 7px; color: var(--muted); font-size: 12.5px; font-weight: 650; }
.text-button { border: 0; background: none; color: var(--muted); padding: 2px; font-size: 12px; }
.text-button:hover { color: var(--accent); }
.session-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.session-item {
  width: 100%; border: 0; background: transparent; border-radius: 10px; padding: 9px 10px;
  text-align: left; color: var(--text);
}
.session-item:hover, .session-item.active { background: var(--surface-2); }
.session-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.session-preview { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.empty-list { color: var(--muted); font-size: 13px; padding: 8px 10px; }
.sidebar-footer { border-top: 1px solid var(--border); padding: 13px 8px 0; margin-top: 12px; }
.connection-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); flex: 0 0 auto; }
.status-dot.online { background: var(--accent); }
.status-dot.offline { background: var(--danger); }
.key-status { border: 0; background: none; padding: 4px 0 0 16px; color: var(--muted); font-size: 12.5px; text-align: left; }
.key-status:hover { color: var(--accent); }
.sidebar-scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: 0 0 58px; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.menu-button { display: none; }
.icon-button {
  width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; font-size: 20px;
}
.icon-button:hover { background: var(--surface-2); }
.model-picker select {
  max-width: min(360px, 58vw); border: 0; background: transparent; font-weight: 680;
  padding: 8px 26px 8px 8px; border-radius: 9px; text-overflow: ellipsis;
}
.model-picker select:hover { background: var(--surface-2); }
.effort-picker { display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 13px; }
.effort-picker select {
  border: 0; background: transparent; color: var(--text); font-weight: 650;
  padding: 8px 24px 8px 7px; border-radius: 9px;
}
.effort-picker select:hover { background: var(--surface-2); }
.topbar-spacer, .composer-spacer { flex: 1; }
.quiet-button {
  border: 0; background: transparent; color: var(--muted); border-radius: 10px; padding: 8px 11px;
}
.quiet-button:hover { background: var(--surface-2); color: var(--text); }
.quiet-button.bordered { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.link-button { display: inline-block; text-decoration: none; }
.view { display: none; min-height: 0; flex: 1; }
.view.active { display: flex; flex-direction: column; }
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.empty-state { max-width: 760px; margin: 0 auto; padding: clamp(56px, 13vh, 128px) 24px 40px; text-align: center; }
.empty-mark { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 22px; font-size: 28px; }
.empty-state h1 { font-size: clamp(32px, 5vw, 46px); line-height: 1.08; letter-spacing: -.045em; margin: 0 0 12px; }
.empty-state p { color: var(--muted); max-width: 560px; margin: 0 auto; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 30px; }
.suggestions button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 9px 15px;
}
.suggestions button:hover { border-color: var(--accent); color: var(--accent); }
.setup-callout {
  margin: 34px auto 0; max-width: 620px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  text-align: left; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius); padding: 16px 18px;
}
.setup-callout strong, .setup-callout span { display: block; }
.setup-callout span { color: var(--muted); font-size: 13.5px; }
.setup-callout button, .primary-button {
  border: 0; background: var(--accent); color: white; border-radius: 11px; padding: 10px 15px; font-weight: 680;
}
html[data-theme="dark"] .setup-callout button, html[data-theme="dark"] .primary-button { color: #102018; }
.setup-callout button:hover, .primary-button:hover { background: var(--accent-hover); }
.messages { max-width: 820px; margin: 0 auto; padding: 28px 24px 44px; }
.message { margin: 0 0 28px; }
.message.user { display: flex; justify-content: flex-end; }
.message-bubble { max-width: 78%; background: var(--user-bubble); border-radius: 20px 20px 6px 20px; padding: 12px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.assistant .message-content { overflow-wrap: anywhere; }
.message.assistant .message-content > *:first-child { margin-top: 0; }
.message.assistant .message-content > *:last-child { margin-bottom: 0; }
.message-content pre {
  overflow-x: auto; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 13px; padding: 14px; font-size: 13px; line-height: 1.5;
}
.message-content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.message-content :not(pre) > code { background: var(--surface-2); border-radius: 5px; padding: 1px 5px; }
.message-content a { color: var(--accent); }
.message-content blockquote { border-left: 3px solid var(--border); margin-left: 0; padding-left: 14px; color: var(--muted); }
.message-actions { display: flex; gap: 4px; margin-top: 8px; }
.message-actions button { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 5px 8px; font-size: 12.5px; }
.message-actions button:hover { background: var(--surface-2); color: var(--text); }
.activity-list { display: grid; gap: 7px; margin: 12px 0; }
.activity {
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 9px 12px;
  color: var(--muted); font-size: 13px;
}
.activity summary { cursor: pointer; color: var(--text); }
.activity pre { white-space: pre-wrap; max-height: 260px; overflow: auto; }
.typing { color: var(--muted); display: flex; gap: 8px; align-items: center; }
.typing::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite alternate; }
@keyframes pulse { from { opacity: .35; transform: scale(.8); } to { opacity: 1; transform: scale(1.15); } }
.composer-wrap { flex: 0 0 auto; padding: 8px 18px 14px; }
.attachment-chip {
  max-width: 820px; margin: 0 auto 8px; display: flex; justify-content: space-between; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 8px 12px; font-size: 13px;
}
.attachment-chip button { border: 0; background: none; }
.composer {
  max-width: 820px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; box-shadow: 0 10px 34px rgba(49,43,31,.09); padding: 12px 12px 9px;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
#composerInput {
  width: 100%; border: 0; resize: none; background: transparent; padding: 4px 7px 8px;
  max-height: 190px; outline: none;
}
.composer-row { display: flex; align-items: center; gap: 8px; }
.round-button, .send-button {
  width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: 0 0 auto;
}
.round-button { background: transparent; font-size: 21px; color: var(--muted); }
.round-button:hover { background: var(--surface-2); color: var(--text); }
.mode-picker { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.mode-picker button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 10px; font-size: 12.5px; }
.mode-picker button.active { background: var(--surface); color: var(--text); font-weight: 680; box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.send-button { background: var(--text); color: var(--bg); font-size: 19px; font-weight: 750; }
.send-button:disabled { opacity: .35; cursor: default; }
.stop-button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 13px; }
.composer-hint { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 7px; }
.page-view { overflow-y: auto; }
.page-inner { width: min(920px, 100%); margin: 0 auto; padding: 42px 28px 70px; }
.page-inner.narrow { width: min(720px, 100%); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h1 { font-size: 36px; letter-spacing: -.04em; line-height: 1.1; margin: 0 0 7px; }
.page-head p { color: var(--muted); margin: 0; }
.goal-form, .settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.goal-form { display: grid; gap: 11px; }
.goal-form .primary-button { justify-self: start; }
input[type="text"], input[type="password"], input[type="search"], textarea {
  border: 1px solid var(--border); background: var(--bg); border-radius: 12px; padding: 11px 13px;
}
.goal-form textarea { resize: vertical; }
.goal-list, .tool-list { display: grid; gap: 10px; }
.goal-card, .tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 15px; padding: 15px 16px;
}
.goal-card-head, .tool-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.goal-card h3, .tool-card h3 { margin: 0; font-size: 15px; }
.goal-card p, .tool-card p { color: var(--muted); margin: 5px 0 0; font-size: 13.5px; }
.status-pill { flex: 0 0 auto; border-radius: 999px; background: var(--surface-2); color: var(--muted); padding: 3px 9px; font-size: 12px; }
.status-pill.running, .status-pill.review { background: var(--accent-soft); color: var(--accent); }
.status-pill.blocked { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.card-actions button {
  border: 1px solid var(--border); background: var(--bg); border-radius: 9px; padding: 6px 10px; font-size: 12.5px;
}
.card-actions button:hover { border-color: var(--accent); color: var(--accent); }
.card-actions .danger { color: var(--danger); }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.tabs button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 15px; }
.tabs button.active { background: var(--surface); color: var(--text); font-weight: 680; }
.search-input { width: 100%; margin-bottom: 16px; }
.tool-panel { display: none; }
.tool-panel.active { display: block; }
.switch { position: relative; width: 44px; height: 25px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); transition: .18s; }
.switch span::before { content: ""; position: absolute; width: 19px; height: 19px; left: 2px; top: 2px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .18s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(19px); }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.mcp-form { display: grid; grid-template-columns: 180px 1fr auto; gap: 10px; margin-bottom: 16px; }
.settings-card h2 { margin: 0 0 7px; font-size: 18px; letter-spacing: -.02em; }
.settings-card p { color: var(--muted); margin: 0 0 16px; }
.api-key-form { display: flex; gap: 10px; }
.api-key-form input { flex: 1; min-width: 0; }
.settings-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.danger-button { border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); background: transparent; color: var(--danger); border-radius: 10px; padding: 8px 12px; }
.account-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.account-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.password-form { display: grid; gap: 10px; }
.password-form button { justify-self: start; }
.auth-backdrop {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px);
}
.auth-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 30px; box-shadow: var(--shadow);
}
.auth-mark {
  width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px;
  background: var(--text); color: var(--bg); font-size: 25px; font-weight: 800; margin-bottom: 20px;
}
.auth-card h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.035em; }
.auth-card p { color: var(--muted); margin: 0 0 22px; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 7px; font-weight: 650; font-size: 13.5px; }
.auth-form input { width: 100%; }
.auth-error {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--danger); border-radius: 11px; padding: 10px 12px; font-size: 13.5px;
}
.auth-submit { width: 100%; padding: 12px 16px; }
.auth-note { text-align: center; font-size: 13px; margin: 18px 0 0 !important; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 11px 16px; box-shadow: var(--shadow);
  transition: .2s; z-index: 80; max-width: min(560px, calc(100vw - 32px)); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,18,.48); display: grid; place-items: center; padding: 18px; z-index: 70;
}
.modal-backdrop[hidden] { display: none; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 36px); overflow-y: auto; background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 12px; letter-spacing: -.025em; }
.modal pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 13px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.modal-actions button { border: 1px solid var(--border); background: var(--bg); border-radius: 10px; padding: 9px 13px; }
.modal-actions button.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 680; }
.clarify-question { margin: 16px 0; }
.clarify-question label { display: block; font-weight: 650; margin-bottom: 8px; }
.clarify-question input { width: 100%; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-row button.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
@media (max-width: 820px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: grid; place-items: center; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(20,20,18,.42); z-index: 20; }
  .sidebar-scrim.show { display: block; }
  .topbar { padding: 0 10px; gap: 4px; }
  .model-picker select { max-width: 36vw; padding-inline: 4px 20px; }
  .effort-picker span { display: none; }
  .effort-picker select { max-width: 29vw; padding-inline: 4px 20px; }
  #themeButton { padding-inline: 7px; }
  .messages { padding: 22px 17px 36px; }
  .message-bubble { max-width: 90%; }
  .composer-wrap { padding: 6px 10px 10px; }
  .mode-picker button { padding-inline: 7px; }
  .page-inner { padding: 30px 17px 60px; }
  .page-head { flex-direction: column; }
  .mcp-form { grid-template-columns: 1fr; }
  .api-key-form { flex-direction: column; }
  .setup-callout { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
