:root {
  color-scheme: dark;
  font: 15px/1.55 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #e9edf0;
  background: #101417;
  --panel: #171d21;
  --surface: #1d252a;
  --surface-hover: #273238;
  --line: #30393f;
  --muted: #a6b0b8;
  --accent: #a5efda;
  --error: #ffb2ad;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, .button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; text-decoration: none; border: 0; border-radius: 9px; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.primary, .secondary { padding: 8px 13px; white-space: nowrap; font-weight: 650; }
.primary { background: var(--accent); color: #102520; }
.primary:not(:disabled):hover { background: #c7ffef; }
.secondary { background: var(--surface-hover); color: inherit; }
.icon { display: inline-grid; place-items: center; width: 34px; height: 34px; background: transparent; color: var(--muted); font-size: 19px; }
.icon:not(:disabled):hover, .icon[aria-pressed=true] { background: var(--surface-hover); color: var(--accent); }
.layout { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 278px minmax(0,1fr); }
aside { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
.brand { padding: 20px 16px; display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.brand-icon { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; color: var(--accent); background: #213c36; border-radius: 9px; font-weight: 600; font-size: 20px; }
.sidebar-content { overflow: auto; padding: 0 10px 12px; flex: 1; }
.nav-title { padding: 6px 5px 3px 9px; display: flex; justify-content: space-between; align-items: center; }
.nav-title h2 { margin: 0; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.chats-title { margin-top: 17px; }
#projects, #chats { display: grid; gap: 3px; }
.nav-button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; color: #d8e0e6; background: transparent; padding: 8px 10px; min-width: 0; }
.nav-button span:first-child { color: var(--muted); flex: none; }
.nav-button span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nav-button:hover, .nav-button[aria-current=true] { background: var(--surface-hover); }
.nav-button[aria-current=true] { color: var(--accent); }
.search { display: flex; align-items: center; gap: 6px; color: var(--muted); border-radius: 9px; background: var(--surface); padding: 3px 9px; margin-bottom: 6px; }
.search input { width: 100%; border: 0; background: transparent; color: inherit; padding: 5px 0; }
.account { display: flex; justify-content: space-between; align-items: center; gap: 5px; border-top: 1px solid var(--line); padding: 10px; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); padding-left: 9px; font-size: .85rem; }
.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.topbar { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.breadcrumb { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); }
.breadcrumb span, .breadcrumb strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.breadcrumb strong { color: #e9edf0; }
.connection { color: var(--muted); min-width: max-content; font-size: .8rem; }
.connection::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #daa768; }
.connection[data-online=true]::before { background: var(--accent); }
.chat-actions { position: relative; }
.chat-actions summary { cursor: pointer; list-style: none; padding: 7px; }
.actions-menu { z-index: 3; position: absolute; top: 100%; right: 0; display: grid; gap: 4px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; min-width: 160px; }
.actions-menu button { text-align: left; background: transparent; color: inherit; padding: 6px 9px; }
.actions-menu button:hover { background: var(--surface-hover); }
.menu { display: none; }
.messages { overflow: auto; padding: 25px max(20px, calc((100% - 860px) / 2)); }
.welcome { display: grid; justify-items: center; align-content: center; height: 100%; min-height: 150px; text-align: center; }
.welcome h1, .login-card h1 { margin: 14px 0 0; font-size: clamp(1.8rem, 4vw, 2.65rem); letter-spacing: -.045em; }
.welcome p, .login-card p { color: var(--muted); margin: 8px 0 18px; }
.welcome .brand-icon, .login .brand-icon { width: 53px; height: 53px; font-size: 30px; border-radius: 14px; }
.chat-row { display: grid; margin: 0 0 21px; min-width: 0; overflow-wrap: anywhere; }
.chat-row.user { justify-items: end; }
.user .chat-text { max-width: min(92%, 680px); background: #23302f; border: 1px solid #304641; padding: 9px 14px; border-radius: 14px 14px 3px 14px; white-space: pre-wrap; }
.agent .chat-text > :first-child { margin-top: 0; }
.agent .chat-text > :last-child { margin-bottom: 0; }
.chat-text pre, details.item pre, .approval pre { overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); margin: 8px 0; }
.chat-text code, pre { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: .9em; }
.chat-text img { max-width: 100%; }
.chat-text table { border-collapse: collapse; }
.chat-text td, .chat-text th { border: 1px solid var(--line); padding: 6px; }
details.item { margin-bottom: 9px; border: 1px solid var(--line); border-radius: 9px; padding: 5px 9px; color: var(--muted); font-size: .9rem; }
details.item summary { cursor: pointer; overflow-wrap: anywhere; }
details.item pre, .approval pre { max-height: 300px; }
.bottom { margin: 0 auto; width: min(100%, 904px); padding: 0 22px 19px; }
.composer { background: var(--panel); border: 1px solid var(--line); padding: 11px; border-radius: 15px; }
.composer textarea { width: 100%; min-height: 69px; max-height: 35vh; padding: 5px; resize: vertical; background: transparent; color: inherit; border: 0; }
.composer textarea::placeholder, .search input::placeholder { color: var(--muted); }
.composer-actions, .input-tools, .model-tools, .send-tools { display: flex; align-items: center; gap: 6px; }
.composer-actions { justify-content: space-between; flex-wrap: wrap; }
.model-tools { flex: 1; }
select { max-width: 160px; color: var(--muted); border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 4px; }
.attachments { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 0 6px; }
.attachments button { background: var(--surface-hover); color: inherit; padding: 3px 8px; max-width: min(100%, 240px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#activity { color: var(--accent); padding: 4px 0; }
#approvals { max-height: 35vh; overflow: auto; }
.approval { background: var(--panel); border: 1px solid var(--line); padding: 12px; border-radius: 10px; margin-bottom: 6px; }
.approval strong, .approval label { display: block; margin-bottom: 6px; }
.approval input, .approval textarea, dialog input { display: block; width: 100%; color: inherit; background: #111719; border: 1px solid var(--line); border-radius: 7px; padding: 6px; }
.approval button { margin: 3px; }
#notice, #dialog-error { margin: 5px 0 0; color: var(--error); }
.muted, .empty-list { color: var(--muted); font-size: .87rem; padding: 4px 8px; }
dialog { color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: min(350px, 90vw); padding: 20px; }
dialog::backdrop { background: #070b0dbb; }
dialog h2 { margin: 0 0 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 14px; }
.login { display: grid; align-items: center; justify-items: center; min-height: 100dvh; padding: 20px; }
.login-card { max-width: 440px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 38px; text-align: center; }
.login-card .button { display: inline-block; }
.login-card .setup { margin-bottom: 0; color: var(--accent); }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  aside { display: none; position: fixed; top: 62px; bottom: 0; width: min(300px, 90vw); z-index: 5; box-shadow: 8px 0 35px #0007; }
  aside.open { display: flex; }
  .menu { display: inline-grid; flex: none; }
  .topbar { padding: 11px 8px; gap: 6px; }
  .breadcrumb { gap: 4px; }
  .connection { display: none; }
  .messages { padding: 16px 12px; }
  .bottom { padding: 0 9px 12px; }
  .model-tools select { max-width: 110px; }
}
.streaming { white-space: pre-wrap; }
#load-older { display: block; margin: 0 auto 18px; }
