:root {
  color-scheme: light;
  --bg: #fcfbf8;
  --sidebar: #f1f0eb;
  --surface: #fffefa;
  --text: #242725;
  --muted: #636960;
  --line: #e3e4dd;
  --hover: #e8e9e2;
  --accent: #286653;
  --accent-soft: #e2ebe3;
  --bubble: #eeeee7;
  --button: #292e2a;
  --button-text: #fffefa;
  --danger: #a53a2c;
  --shadow: 0 2px 5px #202a2004, 0 12px 40px #202a2006;
  --sidebar-width: 272px;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #1b1e1c;
  --sidebar: #151816;
  --surface: #242824;
  --text: #edeee8;
  --muted: #a1a89f;
  --line: #363d35;
  --hover: #2b302a;
  --accent: #a6c8af;
  --accent-soft: #2c3d31;
  --bubble: #2c322c;
  --button: #e6eadd;
  --button-text: #212820;
  --danger: #f3ab9a;
  --shadow: 0 2px 5px #00000008, 0 12px 40px #00000012;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button, select, input { min-height: 44px; }
button { cursor: pointer; border: 1px solid transparent; background: transparent; border-radius: 12px; padding: 8px 14px; transition: background-color .16s, border-color .16s, color .16s, transform .16s; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:not(:disabled):active { transform: translateY(1px); }
button:not(:disabled):hover { background: var(--hover); }
input, textarea, select { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; max-width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
a, button, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; flex: 0 0 auto; color: var(--muted); }
.skip { position: fixed; top: -100px; left: 12px; z-index: 20; padding: 12px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.skip:focus { top: 8px; }
.topbar { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); flex: 0 0 76px; transition: grid-template-columns .2s ease; }
.brand-bar { display: flex; align-items: center; justify-content: space-between; padding: 0 18px 0 24px; background: var(--sidebar); overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 23px; font-weight: 650; letter-spacing: -.8px; }
.brand img { border-radius: 9px; }
.brand-dot { color: var(--accent); }
.contact-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; padding: 0 28px; }
.contact { min-width: 0; }
.contact h1 { font-size: 16px; font-weight: 600; letter-spacing: -.25px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact p { font-size: 12px; color: var(--muted); margin: 1px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 54vw; }
.header-actions { display: flex; gap: 12px; align-items: center; }
.account-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--bubble); color: var(--text); }
#connection { flex: 0 0 auto; margin: 0; padding: 0; color: var(--danger); font-size: 13px; }
#connection:not(:empty) { padding: 10px 24px; border-block: 1px solid var(--line); background: var(--surface); }
#workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); transition: grid-template-columns .2s ease; }
#sidebar { min-width: 0; display: flex; flex-direction: column; background: var(--sidebar); overflow: hidden; }
.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px 14px; scrollbar-width: thin; }
.section-label, #discovery > summary { font-size: 12px; font-weight: 550; color: var(--muted); letter-spacing: .02em; }
.section-label { margin: 0 12px 10px; }
aside nav { display: grid; gap: 5px; }
aside nav a { position: relative; display: flex; align-items: center; gap: 11px; min-height: 70px; padding: 12px; border-radius: 12px; transition: background-color .16s; }
aside nav a:hover { background: var(--hover); }
aside nav a[aria-current=page] { background: var(--accent-soft); }
aside nav a[aria-current=page]::after { content: ""; position: absolute; right: 13px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.agent-avatar { display: flex; align-items: center; justify-content: center; flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; font-size: 14px; font-weight: 550; color: var(--accent); }
.agent-info { min-width: 0; padding-right: 7px; }
.agent-title { display: block; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.agent-info small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.45; margin-top: 2px; font-size: 11px; color: var(--muted); }
#discovery { margin: 12px 0 0; }
summary { cursor: pointer; list-style: none; min-height: 44px; display: flex; align-items: center; gap: 10px; border-radius: 10px; }
summary::-webkit-details-marker { display: none; }
#discovery > summary { padding: 8px 12px; justify-content: space-between; }
summary .icon:last-child { width: 15px; height: 15px; transition: transform .16s; }
details[open] > summary .icon:last-child { transform: rotate(90deg); }
.search-field { display: flex; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.search-field:focus-within { border-color: var(--accent); }
.search-field input { flex: 1; width: 100%; background: transparent; border: 0; font-size: 13px; }
#agent-search-form { margin: 2px 8px 10px; }
#no-agents { padding: 0 12px; }
.sidebar-footer { padding: 12px 20px 16px; border-top: 1px solid var(--line); }
#resources > summary { font-size: 13px; padding: 4px 6px; }
#resources > summary:hover { background: var(--hover); }
#resources .chevron { margin-left: auto; }
#resources p { margin: 6px; font-size: 12px; }
.legacy-link { display: block; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; padding: 12px 6px; }
.private-note { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; margin: 16px 6px 0; }
.private-note .icon { width: 12px; height: 12px; }
.drawer-heading { display: none; }
body.nav-collapsed { --sidebar-width: 0px; }
body.nav-collapsed .topbar { grid-template-columns: 76px minmax(0, 1fr); }
body.nav-collapsed .brand-bar { background: var(--bg); padding: 0 16px; }
body.nav-collapsed .brand { display: none; }
body.nav-collapsed #sidebar { visibility: hidden; }
main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 32px; }
#history-search-form { display: flex; align-items: center; gap: 4px; width: min(100%, 760px); margin: 0 auto 12px; }
#history-search-form .search-field { flex: 1; }
#history { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--line) transparent; overflow-anchor: none; scroll-padding: 24px; }
.reading-column { width: min(100%, 760px); margin: 0 auto; padding: 24px 4px 40px; }
#messages { display: flex; flex-direction: column; gap: 36px; }
.message { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.message > strong { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.message .text { white-space: pre-wrap; tab-size: 2; line-height: 1.85; font-size: 15px; }
.message .text.formatted { white-space: normal; }
.formatted > :first-child { margin-top: 0; }
.formatted > :last-child { margin-bottom: 0; }
.formatted p { white-space: pre-wrap; margin: 0 0 16px; }
.formatted h2, .formatted h3, .formatted h4 { font-size: 18px; font-weight: 600; letter-spacing: -.3px; line-height: 1.4; margin: 26px 0 12px; }
.formatted h3 { font-size: 16px; }
.formatted h4 { font-size: 15px; }
.formatted strong { font-weight: 600; }
.formatted ul, .formatted ol { padding-left: 25px; margin: 14px 0 20px; }
.formatted li { padding-left: 5px; margin-block: 5px; }
.formatted li::marker { color: var(--muted); }
.formatted code { font: .87em/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--bubble); padding: 2px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.formatted blockquote { white-space: pre-wrap; border-left: 3px solid var(--accent); margin: 20px 0; padding: 2px 18px; color: var(--muted); }
.code-block { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 20px 0; background: var(--surface); }
.code-caption { padding: 9px 16px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--sidebar); }
.code-block pre { overflow: auto; margin: 0; padding: 16px; white-space: pre; }
.code-block code { padding: 0; background: none; border-radius: 0; overflow-wrap: normal; }
.table-block { max-width: 100%; overflow-x: auto; margin: 20px 0; border: 1px solid var(--line); border-radius: 12px; }
.table-block table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-block th, .table-block td { text-align: left; min-width: 120px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table-block th { background: var(--sidebar); font-weight: 550; }
.table-block tr:last-child td { border-bottom: 0; }
.message.user { align-self: flex-end; max-width: 85%; padding: 14px 20px 10px; background: var(--bubble); border-radius: 22px 22px 5px 22px; }
.message.user > strong { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.message.assistant { align-self: stretch; padding: 0 2px; }
.message.assistant > strong { display: flex; align-items: center; gap: 9px; }
.message.assistant > strong::before { content: ""; width: 8px; height: 8px; background: var(--accent); border-radius: 3px; transform: rotate(-12deg); }
.message footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.message footer button { color: var(--danger); border: 1px solid var(--line); min-height: 44px; padding: 4px 12px; }
.message[data-status=running] footer > span::before, .message[data-status=queued] footer > span::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 7px; animation: breathe 1.6s ease-in-out infinite; }
.message[data-status=failed] footer, .message[data-status=error] footer, .message[data-status=interrupted] footer { color: var(--danger); }
#older { display: block; margin: 0 auto 28px; }
.quiet-button { border: 1px solid var(--line); font-size: 12px; }
#latest { position: absolute; bottom: 174px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 7px; white-space: nowrap; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); z-index: 1; }
#latest .icon { transform: rotate(180deg); width: 16px; }
#empty { text-align: center; padding: 40px 0 14px; }
.welcome-mark { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; background: var(--accent-soft); color: var(--accent); border-radius: 19px; margin-bottom: 24px; transform: rotate(-6deg); }
.welcome-mark .icon { width: 28px; height: 28px; transform: rotate(6deg); stroke-width: 1.3; }
.eyebrow { font-size: 12px; font-weight: 500; letter-spacing: .025em; color: var(--muted); margin: 0 0 14px; }
#empty h2 { font-size: clamp(26px, 3.2vw, 40px); font-weight: 500; line-height: 1.18; letter-spacing: -1.5px; margin: 0 0 18px; text-wrap: balance; }
#empty-description { font-size: 14px; color: var(--muted); margin: 0 auto; max-width: 440px; text-wrap: balance; }
#history-retry { margin-top: 18px; }
main.is-empty { justify-content: center; padding-bottom: min(7dvh, 60px); overflow-y: auto; }
main.is-empty #history { flex: 0 0 auto; overflow: visible; }
main.is-empty .reading-column { padding: 0 0 28px; }
main:not(.is-welcome) .welcome-mark, main:not(.is-welcome) #empty .eyebrow { display: none; }
.composer-area { flex: 0 0 auto; width: min(100%, 760px); margin: 0 auto; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
#notice { color: var(--muted); font-size: 13px; margin: 0; }
#notice:not(:empty) { margin: 0 0 10px; padding: 10px 14px; border-left: 2px solid var(--accent); background: var(--sidebar); border-radius: 0 8px 8px 0; }
#compose { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 9px 10px 10px; box-shadow: var(--shadow); transition: border-color .16s, box-shadow .16s; }
#compose:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
#composer { display: block; resize: none; width: 100%; min-height: 52px; max-height: min(240px, 30dvh); border: 0; border-radius: 14px; background: transparent; padding: 12px 12px 8px; line-height: 1.65; font-size: 16px; overflow-y: auto; outline: none; }
.compose-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding-left: 10px; }
.composer-scope { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; color: var(--muted); font-size: 11px; }
.composer-scope .icon { width: 13px; height: 13px; }
.keyboard-hint { font-size: 11px; color: var(--muted); margin-right: 7px; }
#send { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--button); color: var(--button-text); flex: 0 0 auto; }
#send:not(:disabled):hover { background: var(--accent); color: var(--bg); }
#send .icon { stroke-width: 2; }
.stop-button { display: flex; align-items: center; gap: 8px; border-color: var(--line); font-size: 12px; }
.stop-square { width: 9px; height: 9px; background: currentColor; border-radius: 2px; }
#starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
#starters button { display: flex; align-items: flex-start; text-align: left; gap: 10px; padding: 16px 12px; border: 1px solid var(--line); border-radius: 14px; }
#starters button:hover { background: var(--surface); border-color: var(--accent); transform: translateY(-2px); }
#starters button > .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--accent); }
#starters strong { display: block; font-size: 12px; font-weight: 550; }
#starters small { display: block; font-size: 11px; line-height: 1.5; color: var(--muted); margin-top: 4px; }
#starters .starter-arrow { display: none; }
.disclaimer { text-align: center; font-size: 10px; color: var(--muted); margin: 12px 0 0; }
.muted { font-size: 13px; color: var(--muted); }
dialog { width: min(380px, calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px 24px 24px; box-shadow: 0 24px 90px #0003; }
dialog::backdrop { background: #0b130d55; backdrop-filter: blur(4px); }
dialog[open] { animation: appear .18s ease-out; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dialog-heading h2 { margin: 0; font-size: 19px; font-weight: 550; }
#account-name { overflow-wrap: anywhere; color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.preference { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; font-size: 13px; }
.preference select { width: 145px; }
.account-note { margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.settings-link { display: flex; align-items: center; min-height: 44px; font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
#logout { display: block; width: 100%; margin-top: 12px; color: var(--danger); }
#login { flex: 1; min-height: 0; overflow: auto; padding: 8dvh 24px 24px; }
#login form { width: min(100%, 360px); margin: 0 auto; }
.login-mark { border-radius: 15px; margin-bottom: 28px; }
#login h1 { font-size: 32px; line-height: 1.2; font-weight: 500; letter-spacing: -1px; margin: 0 0 16px; }
#login .muted { margin-bottom: 32px; }
#login label { display: grid; gap: 7px; margin-top: 18px; font-size: 13px; }
.primary-button { background: var(--button); color: var(--button-text); width: 100%; margin-top: 24px; }
.primary-button:not(:disabled):hover { background: var(--accent); color: var(--bg); }
#login-error { color: var(--danger); font-size: 13px; }
body:not(.authenticated) .brand-bar { background: transparent; }
body:not(.authenticated) .contact { visibility: hidden; }
@keyframes breathe { 50% { opacity: .35; } }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 761px) and (max-width: 1100px) {
  :root { --sidebar-width: 238px; }
  main { padding-inline: 24px; }
  #starters { gap: 8px; }
  #starters button { flex-direction: column; padding: 12px; }
}
@media (max-width: 760px) {
  :root { --sidebar-width: 0px; }
  .topbar, body.nav-collapsed .topbar { grid-template-columns: 60px minmax(0, 1fr); flex-basis: 64px; }
  .brand-bar, body.nav-collapsed .brand-bar { background: var(--bg); padding: 0 8px; }
  .brand { display: none; }
  body:not(.authenticated) .brand { display: flex; }
  body:not(.authenticated) .brand > span { display: none; }
  .contact-bar { padding: 0 12px 0 4px; gap: 4px; }
  .contact h1 { font-size: 15px; }
  .contact p { font-size: 10px; max-width: 45vw; }
  .header-actions { gap: 4px; }
  .account-button { width: 44px; height: 44px; }
  #workspace { display: block; position: relative; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, calc(100% - 48px)); z-index: 11; visibility: hidden; transform: translateX(-100%); transition: transform .2s ease, visibility .2s; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); box-shadow: 8px 0 60px #0002; }
  body.nav-open #sidebar { visibility: visible; transform: translateX(0); }
  .drawer-heading { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px 0 24px; }
  .drawer-brand { font-size: 23px; font-weight: 600; letter-spacing: -.8px; }
  #nav-backdrop { position: fixed; inset: 0; z-index: 10; border: 0; border-radius: 0; background: #0b130d66; backdrop-filter: blur(3px); }
  #nav-backdrop:active { transform: none; }
  main { padding: 0 16px; height: 100%; }
  main.is-empty { padding-bottom: 12px; }
  .reading-column { padding-top: 20px; padding-bottom: 30px; }
  #messages { gap: 28px; }
  .message.user { max-width: 92%; padding: 12px 16px 8px; }
  .message .text { font-size: 15px; line-height: 1.75; }
  #empty { padding-top: 20px; }
  .welcome-mark { width: 48px; height: 48px; border-radius: 16px; margin-bottom: 20px; }
  #empty h2 { font-size: 30px; letter-spacing: -1px; }
  #empty-description { font-size: 13px; max-width: 290px; }
  .eyebrow { font-size: 10px; margin-bottom: 12px; }
  .composer-area { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #compose { border-radius: 22px; padding: 7px 8px 8px; }
  #composer { padding: 10px; }
  .compose-actions { padding-left: 8px; gap: 6px; }
  .keyboard-hint { display: none; }
  #starters { grid-template-columns: 1fr; gap: 7px; margin-top: 16px; }
  #starters button { align-items: center; padding: 10px 14px; gap: 12px; }
  #starters button > span { flex: 1; }
  #starters small { margin-top: 0; }
  #starters .starter-arrow { display: block; width: 14px; color: var(--muted); }
  .disclaimer { font-size: 9px; margin-top: 10px; }
  #connection:not(:empty) { padding: 8px 16px; font-size: 12px; }
  #latest { bottom: 164px; }
}
@media (max-height: 700px) {
  main.is-empty { justify-content: flex-start; padding-bottom: 0; }
  #empty { padding-top: 12px; }
  .welcome-mark { display: none; }
  main.is-empty .reading-column { padding-bottom: 16px; }
  #starters { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  #send, .account-button, aside nav a[aria-current=page] { border: 2px solid ButtonText; }
  .agent-avatar { border-color: ButtonText; }
}
