:root {
  --ink: #172321;
  --muted: #66736f;
  --faint: #8c9793;
  --line: #dce3e0;
  --line-soft: #e9eeec;
  --surface: #ffffff;
  --surface-soft: #f5f7f6;
  --sidebar: #f1f5f3;
  --teal-950: #123f3b;
  --teal-800: #17665f;
  --teal-600: #1e8a7e;
  --teal-100: #d9f0eb;
  --coral: #ef755f;
  --blue: #5b83d8;
  --gold: #d8a22e;
  --violet: #8d6bc4;
  --danger: #b94747;
  --shadow: 0 18px 50px rgba(31, 57, 52, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { overflow: hidden; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, a, input, textarea, select { outline-color: var(--teal-600); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.auth-gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 18px; background: #eef3f1; }
.auth-panel { width: min(430px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 38px; color: var(--teal-950); font-size: 20px; }.auth-brand .brand-mark { width: 25px; height: 25px; }.auth-brand .brand-mark span { width: 11px; height: 11px; }.auth-brand .brand-mark span:nth-child(3) { left: 7px; }
.auth-panel h1 { margin: 0; color: var(--teal-950); font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 500; }.auth-copy { margin: 10px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.55; }.auth-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }.auth-tab { padding: 9px 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; }.auth-tab.active { color: var(--teal-800); border-bottom-color: var(--teal-600); }.auth-form { display: grid; gap: 15px; }.auth-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }.auth-form input { width: 100%; height: 43px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; }.auth-form .primary-button { width: 100%; }.otp-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: end; }.text-button { height: 43px; border: 0; background: transparent; color: var(--teal-800); cursor: pointer; font-size: 11px; font-weight: 700; }.auth-note { margin: 0; padding: 10px; border-left: 2px solid var(--gold); color: var(--muted); background: #fcf8ed; font-size: 11px; line-height: 1.5; }.auth-error { min-height: 17px; margin: 14px 0 0; color: var(--danger); font-size: 11px; }.auth-footnote { margin: 25px 0 0; color: var(--faint); font-size: 10px; line-height: 1.5; }
.icon { width: 19px; height: 19px; display: block; flex: 0 0 auto; }

.app-shell { height: 100dvh; display: grid; grid-template-columns: 268px minmax(0, 1fr); background: var(--surface); }
.sidebar { display: flex; min-width: 0; flex-direction: column; padding: 18px 14px 12px; border-right: 1px solid var(--line); background: var(--sidebar); z-index: 20; }
.brand-row { height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.brand { display: flex; align-items: center; gap: 10px; border: 0; padding: 0; background: transparent; font-size: 20px; font-weight: 750; cursor: pointer; }
.brand-mark { position: relative; width: 27px; height: 27px; display: inline-block; transform: rotate(45deg); }
.brand-mark span { position: absolute; display: block; width: 12px; height: 12px; border-radius: 2px 8px 2px 8px; background: var(--teal-600); }
.brand-mark span:nth-child(1) { left: 0; top: 0; background: var(--teal-950); }
.brand-mark span:nth-child(2) { right: 0; top: 0; background: var(--coral); }
.brand-mark span:nth-child(3) { left: 7px; bottom: 0; background: var(--teal-600); }
.brand-mark.large { width: 45px; height: 45px; }
.brand-mark.large span { width: 21px; height: 21px; border-radius: 4px 11px 4px 11px; }
.brand-mark.large span:nth-child(3) { left: 12px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 6px; display: inline-grid; place-items: center; background: transparent; cursor: pointer; transition: background .16s, color .16s, transform .16s; }
.icon-button:hover { background: #e3e9e6; }
.icon-button:active { transform: translateY(1px); }
.icon-button.subtle { width: 30px; height: 30px; color: var(--muted); }
.sidebar-close, .mobile-menu { display: none; }
.new-chat-button { height: 44px; margin: 18px 0 14px; padding: 0 11px; display: flex; align-items: center; gap: 10px; border: 1px solid #cdd9d5; border-radius: 7px; background: var(--surface); font-weight: 650; cursor: pointer; box-shadow: 0 1px 0 rgba(18,63,59,.04); }
.new-chat-button:hover { border-color: #aebfba; background: #fbfcfc; }
.new-chat-button kbd { margin-left: auto; padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--faint); background: var(--surface-soft); font-size: 10px; font-family: inherit; }
.primary-nav { display: grid; gap: 3px; }
.nav-item { width: 100%; min-height: 41px; padding: 0 11px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 6px; background: transparent; color: #40504c; cursor: pointer; text-align: left; }
.nav-item span:nth-child(2) { flex: 1; }
.nav-item:hover { background: #e4ebe8; }
.nav-item.active { color: var(--teal-950); background: #dce8e4; font-weight: 700; }
.count-badge { min-width: 22px; height: 20px; border-radius: 10px; display: grid; place-items: center; background: #ccd9d5; color: var(--teal-950); font-size: 11px; font-weight: 700; }
.history-section { flex: 1; min-height: 0; margin-top: 22px; display: flex; flex-direction: column; }
.section-label-row { height: 34px; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; color: var(--faint); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.history-list { display: grid; gap: 2px; overflow-y: auto; scrollbar-width: thin; }
.history-item { position: relative; width: 100%; min-height: 38px; border: 0; border-radius: 5px; padding: 8px 34px 8px 9px; overflow: hidden; background: transparent; text-align: left; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; color: #47534f; font-size: 13px; }
.history-item:hover, .history-item.active { background: #e2e9e6; color: var(--ink); }
.history-item .delete-chat { position: absolute; right: 4px; top: 3px; width: 30px; height: 30px; display: none; border: 0; background: transparent; color: var(--faint); cursor: pointer; }
.history-item:hover .delete-chat { display: grid; place-items: center; }
.history-empty { color: var(--faint); padding: 10px 8px; font-size: 12px; line-height: 1.5; }
.sidebar-footer { padding-top: 10px; border-top: 1px solid #d9e1de; }
.profile-button { width: 100%; padding: 8px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; text-align: left; }
.profile-button:hover { background: #e3e9e6; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-950); color: white; font-weight: 750; }
.profile-copy { min-width: 0; flex: 1; display: grid; }
.profile-copy strong { font-size: 13px; }
.profile-copy small { color: var(--faint); font-size: 11px; }
.profile-button > .icon { color: var(--faint); width: 17px; }
.scrim { display: none; }

.main { min-width: 0; height: 100dvh; display: flex; flex-direction: column; background: #fbfcfb; }
.topbar { height: 63px; flex: 0 0 auto; padding: 0 24px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.94); }
.topbar-title { display: flex; align-items: center; gap: 10px; }
.topbar-title > div { display: grid; }
.topbar-title strong { font-size: 14px; }
.topbar-title small { color: var(--faint); font-size: 11px; }
.mobile-brand-mark { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { height: 28px; padding: 0 10px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: var(--surface); font-size: 11px; font-weight: 650; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.status-pill.online .status-dot { background: #3a9a62; box-shadow: 0 0 0 3px #ddefe4; }

.view { display: none; min-height: 0; flex: 1; }
.view.active { display: flex; }
#chatView { position: relative; flex-direction: column; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.welcome { width: min(780px, calc(100% - 40px)); min-height: calc(100dvh - 250px); margin: 0 auto; padding: 64px 0 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.welcome-mark { margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--teal-600); text-transform: uppercase; font-size: 11px; font-weight: 800; }
.welcome h1, .page-heading h1 { margin: 0; color: var(--teal-950); font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: 0; }
.welcome h1 { font-size: 38px; text-align: center; }
.welcome-copy { max-width: 490px; margin: 12px auto 30px; color: var(--muted); text-align: center; line-height: 1.6; }
.quick-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-actions button { min-width: 0; height: 72px; padding: 11px 13px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; text-align: left; transition: border-color .16s, transform .16s, box-shadow .16s; }
.quick-actions button:hover { transform: translateY(-1px); border-color: #b9c8c4; box-shadow: 0 7px 22px rgba(32,69,62,.08); }
.quick-actions button > span:nth-child(2) { min-width: 0; flex: 1; display: grid; gap: 2px; }
.quick-actions strong { font-size: 13px; }
.quick-actions small { overflow: hidden; color: var(--faint); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.quick-actions button > .icon { width: 16px; color: var(--faint); }
.quick-icon { width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; color: white; }
.quick-icon.coral { background: var(--coral); }.quick-icon.blue { background: var(--blue); }.quick-icon.gold { background: var(--gold); }.quick-icon.violet { background: var(--violet); }
.quick-icon .icon { width: 18px; }

.messages { width: min(810px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 60px; display: grid; gap: 26px; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 13px; animation: appear .22s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } }
.message.user { grid-template-columns: minmax(0, 1fr) 34px; }
.message-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--teal-950); color: white; font-size: 12px; font-weight: 750; }
.message.assistant .message-avatar { border-radius: 7px; background: var(--teal-100); color: var(--teal-800); }
.message.user .message-avatar { grid-column: 2; }
.message.user .message-body { grid-column: 1; grid-row: 1; justify-self: end; max-width: 82%; padding: 11px 14px; border-radius: 8px 2px 8px 8px; background: #e2eeeb; }
.message-body { min-width: 0; color: #2d3936; line-height: 1.65; font-size: 14px; }
.message-body p { margin: 0 0 12px; }.message-body p:last-child { margin-bottom: 0; }
.message-body ul, .message-body ol { padding-left: 22px; }
.message-body code { padding: 2px 5px; border-radius: 4px; background: var(--surface-soft); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.message-body pre { padding: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; background: #f4f7f5; }
.message-meta { margin-top: 8px; display: flex; gap: 10px; align-items: center; color: var(--faint); font-size: 10px; }
.message.error .message-body { color: var(--danger); }
.message-attachments { margin-bottom: 10px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.message-attachments img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid #cbd8d4; }
.file-chip { max-width: 240px; padding: 7px 9px; display: flex; align-items: center; gap: 7px; border: 1px solid #cbd8d4; border-radius: 6px; background: rgba(255,255,255,.6); font-size: 11px; }
.tool-traces { margin-top: 12px; }
.tool-traces summary { cursor: pointer; color: var(--teal-800); font-size: 11px; font-weight: 700; }
.tool-trace { margin-top: 7px; padding: 8px 10px; border-left: 2px solid var(--teal-100); color: var(--muted); background: #f7f9f8; font-size: 11px; }
.typing-dots { display: flex; gap: 5px; padding-top: 9px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--teal-600); animation: pulse 1s infinite alternate; }.typing-dots i:nth-child(2){animation-delay:.2s}.typing-dots i:nth-child(3){animation-delay:.4s}
@keyframes pulse { to { opacity: .25; transform: translateY(-3px); } }

.composer-wrap { flex: 0 0 auto; padding: 0 24px 14px; background: linear-gradient(0deg, #fbfcfb 72%, rgba(251,252,251,0)); }
.composer, .attachment-tray { width: min(810px, 100%); margin: 0 auto; }
.composer { border: 1px solid #bccbc7; border-radius: 8px; background: white; box-shadow: 0 8px 28px rgba(38,66,60,.08); transition: border-color .16s, box-shadow .16s; }
.composer:focus-within { border-color: var(--teal-600); box-shadow: 0 0 0 3px rgba(30,138,126,.1), 0 8px 28px rgba(38,66,60,.08); }
.composer textarea { width: 100%; max-height: 180px; min-height: 53px; padding: 16px 16px 8px; resize: none; border: 0; outline: 0; color: var(--ink); background: transparent; line-height: 1.5; }
.composer textarea::placeholder { color: #9aa5a1; }
.composer-toolbar { padding: 5px 8px 8px; display: flex; justify-content: space-between; align-items: center; }
.composer-toolbar > div { display: flex; align-items: center; }
.composer-toolbar .icon-button { width: 34px; height: 34px; color: var(--muted); }
.composer-right { gap: 10px; }
.composer-hint { color: var(--faint); font-size: 10px; }
.send-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 6px; background: var(--teal-950); color: white; cursor: pointer; }
.send-button:disabled { opacity: .45; cursor: default; }
.attachment-tray { min-height: 0; display: flex; flex-wrap: wrap; gap: 7px; }
.attachment-tray:not(:empty) { padding-bottom: 8px; }
.attachment-preview { position: relative; max-width: 220px; height: 42px; padding: 0 34px 0 8px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: white; box-shadow: 0 4px 14px rgba(28,56,50,.06); }
.attachment-preview img { width: 30px; height: 30px; border-radius: 4px; object-fit: cover; }
.attachment-preview span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.attachment-preview button { position: absolute; right: 3px; width: 28px; height: 28px; border: 0; background: transparent; cursor: pointer; }
.voice-active { color: var(--danger) !important; background: #fbe8e8 !important; }
.disclaimer { margin: 7px 0 0; color: var(--faint); text-align: center; font-size: 9px; }

.content-view { overflow-y: auto; padding: 48px clamp(24px, 5vw, 72px) 70px; flex-direction: column; }
.page-heading { width: min(1040px, 100%); margin: 0 auto 28px; display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.page-heading h1 { font-size: 34px; }
.page-heading p:not(.eyebrow) { max-width: 620px; margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.primary-button, .secondary-button { min-height: 40px; padding: 0 14px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: 13px; }
.primary-button { border: 1px solid var(--teal-950); background: var(--teal-950); color: white; }.primary-button:hover { background: #0d332f; }
.secondary-button { border: 1px solid var(--line); background: white; }.secondary-button:hover { background: var(--surface-soft); }
.primary-button .icon, .secondary-button .icon { width: 16px; }
.filter-row { width: min(1040px, 100%); margin: 0 auto 14px; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.filter { padding: 9px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.filter.active { color: var(--teal-950); border-bottom-color: var(--teal-600); font-weight: 750; }
.task-list, .activity-list { width: min(1040px, 100%); margin: 0 auto; display: grid; }
.task-row { min-height: 78px; padding: 14px 4px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 13px; border-bottom: 1px solid var(--line-soft); }
.task-type-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; background: var(--teal-100); color: var(--teal-800); }
.task-type-icon .icon { width: 17px; }
.task-copy { min-width: 0; display: grid; gap: 5px; }
.task-copy strong { overflow-wrap: anywhere; font-size: 13px; }.task-copy small { color: var(--faint); font-size: 11px; }
.task-status { padding: 4px 8px; border-radius: 4px; background: #e4f1eb; color: #33704e; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.task-status.paused { background: #f3ead5; color: #85651f; }.task-status.completed { background: #e7e9e8; color: #6f7774; }
.task-actions { display: flex; }
.task-actions .icon-button { width: 34px; height: 34px; color: var(--muted); }
.empty-state { padding: 54px 20px; border-bottom: 1px solid var(--line); text-align: center; color: var(--muted); }
.empty-state .icon { width: 26px; height: 26px; margin: 0 auto 12px; color: var(--teal-600); }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 5px; }

.activity-item { position: relative; min-height: 70px; padding: 13px 0 13px 45px; border-bottom: 1px solid var(--line-soft); }
.activity-item::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.activity-icon { position: absolute; left: 1px; top: 16px; width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fbfcfb; color: var(--teal-600); }
.activity-icon .icon { width: 14px; }
.activity-item strong { display: block; margin-bottom: 4px; font-size: 13px; text-transform: capitalize; }
.activity-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.activity-item time { display: block; margin-top: 5px; color: var(--faint); font-size: 10px; }

.connection-grid { width: min(1040px, 100%); margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.connection-card { min-height: 176px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: white; display: flex; flex-direction: column; }
.connection-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.connection-logo { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 6px; color: white; font-weight: 800; font-size: 13px; }
.connection-status { padding: 4px 7px; border-radius: 4px; background: #eef1f0; color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.connection-status.local, .connection-status.connected { background: #e2f1ea; color: #33704e; }
.connection-card h2 { margin: 18px 0 5px; font-size: 14px; }.connection-card p { flex: 1; margin: 0 0 16px; color: var(--muted); line-height: 1.45; font-size: 11px; }
.connection-card button { align-self: start; border: 0; padding: 0; background: transparent; color: var(--teal-800); font-size: 11px; font-weight: 750; cursor: pointer; }

.settings-form { width: min(820px, 100%); margin: 0 auto; display: grid; gap: 18px; }
.settings-section { padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.settings-section h2 { margin: 0 0 18px; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-form label:not(.toggle-row), .dialog-card label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.settings-form input:not([type="checkbox"]), .dialog-card input, .dialog-card select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: white; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 13px 0; border-top: 1px solid var(--line-soft); cursor: pointer; }
.toggle-row:first-of-type { border-top: 0; }
.toggle-row > span { display: grid; gap: 4px; }.toggle-row strong { font-size: 13px; }.toggle-row small { color: var(--muted); font-size: 11px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { position: relative; flex: 0 0 auto; width: 42px; height: 23px; border-radius: 12px; background: #c9d1ce; transition: background .2s; }
.toggle-row i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.16); transition: transform .2s; }
.toggle-row input:checked + i { background: var(--teal-600); }.toggle-row input:checked + i::after { transform: translateX(19px); }
.model-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; }.model-card h2 { margin-bottom: 5px; }.model-card p { margin: 0; color: var(--muted); font-size: 11px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }.form-actions span { color: #33704e; font-size: 11px; }

dialog { padding: 0; border: 0; border-radius: 8px; background: transparent; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(13, 33, 30, .46); backdrop-filter: blur(2px); }
.dialog-card { width: min(520px, calc(100vw - 28px)); padding: 22px; display: grid; gap: 17px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; }.dialog-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 26px; font-weight: 500; color: var(--teal-950); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; pointer-events: none; }
.toast { width: min(340px, calc(100vw - 36px)); padding: 12px 14px; border: 1px solid #c8d7d2; border-radius: 7px; display: grid; grid-template-columns: auto 1fr; gap: 10px; background: white; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast .icon { color: var(--teal-600); }.toast strong { display: block; margin-bottom: 3px; font-size: 12px; }.toast p { margin: 0; color: var(--muted); font-size: 11px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 232px minmax(0, 1fr); }
  .sidebar { padding-left: 10px; padding-right: 10px; }
  .connection-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  body { overflow: hidden; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%); box-shadow: 18px 0 50px rgba(15,43,38,.16); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .mobile-menu { display: inline-grid; }
  .scrim { position: fixed; inset: 0; z-index: 15; background: rgba(12,31,28,.36); }
  .scrim.open { display: block; }
  .main { width: 100%; }
  .topbar { height: 58px; padding: 0 10px; }
  .topbar-title { flex: 1; }
  .topbar-title > div { display: none; }
  .mobile-brand-mark { display: inline-block; margin-left: 2px; transform: rotate(45deg) scale(.82); }
  .status-pill { max-width: 124px; }.status-pill span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .welcome { width: min(100% - 26px, 580px); min-height: calc(100dvh - 230px); padding: 28px 0 20px; justify-content: center; }
  .welcome-mark { margin-bottom: 18px; transform: rotate(45deg) scale(.85); }
  .welcome h1 { max-width: 330px; font-size: 30px; }
  .welcome-copy { margin: 10px auto 22px; font-size: 13px; }
  .quick-actions { grid-template-columns: 1fr; gap: 7px; }
  .quick-actions button { height: 58px; }
  .quick-icon { width: 34px; height: 34px; }
  .messages { width: calc(100% - 24px); padding: 22px 0 42px; gap: 22px; }
  .message { grid-template-columns: 29px minmax(0, 1fr); gap: 9px; }.message.user { grid-template-columns: minmax(0, 1fr) 29px; }
  .message-avatar { width: 28px; height: 28px; }
  .message.user .message-body { max-width: 91%; }
  .composer-wrap { padding: 0 9px 8px; }
  .composer-hint { display: none; }
  .content-view { padding: 32px 16px 60px; }
  .page-heading { align-items: start; }.page-heading h1 { font-size: 30px; }.page-heading p:not(.eyebrow) { font-size: 13px; }
  .page-heading .primary-button { flex: 0 0 auto; width: 40px; padding: 0; font-size: 0; }.page-heading .primary-button .icon { width: 18px; }
  .task-row { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 9px; }.task-status { grid-column: 2; justify-self: start; }.task-actions { grid-column: 3; grid-row: 1 / 3; }
  .connection-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-section { padding: 17px; }
  .model-card { align-items: start; flex-direction: column; }
}

@media (max-height: 700px) and (min-width: 721px) {
  .welcome { min-height: 510px; padding-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.help-grid { width: min(1040px, 100%); margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-grid section { padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.help-grid h2 { margin: 0 0 8px; font-size: 14px; }.help-grid p, .setting-copy { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.inline-form { display: flex; gap: 8px; margin-top: 14px; }.inline-form input, .settings-section select { min-width: 0; flex: 1; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface-soft); }
.pairing-code { margin: 14px 0 0; padding: 14px; border: 1px solid var(--teal-600); border-radius: 6px; color: var(--ink); background: var(--teal-100); font: 700 20px ui-monospace, monospace; text-align: center; }
.pairing-code img { display: block; width: min(280px, 100%); height: auto; margin: 0 auto; }
.invite-list { display: grid; margin-top: 12px; }.invite-list > div { min-height: 42px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); font-size: 12px; }
.onboarding ol { margin: 0; padding-left: 22px; color: var(--muted); line-height: 1.8; font-size: 13px; }.onboarding .primary-button { margin-top: 8px; }

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f5f4; --muted: #a9b2af; --faint: #737d79; --line: #2a3431; --line-soft: #222b28;
  --surface: #151b19; --surface-soft: #101513; --sidebar: #0d1210; --teal-950: #e8f6f2; --teal-800: #77d3c5; --teal-600: #41b8a7; --teal-100: #173b35; --shadow: none;
}
html[data-theme="dark"] body, html[data-theme="dark"] .main, html[data-theme="dark"] .content-view { background: #0a0e0d; }
html[data-theme="dark"] .topbar, html[data-theme="dark"] .composer-wrap { background: #0a0e0d; }
html[data-theme="dark"] .composer, html[data-theme="dark"] .quick-actions button, html[data-theme="dark"] .connection-card, html[data-theme="dark"] .settings-section, html[data-theme="dark"] .dialog-card, html[data-theme="dark"] .auth-panel, html[data-theme="dark"] .toast, html[data-theme="dark"] .attachment-preview { background: var(--surface); }
html[data-theme="dark"] .new-chat-button, html[data-theme="dark"] .secondary-button, html[data-theme="dark"] .status-pill { background: var(--surface-soft); }
html[data-theme="dark"] .message.user .message-body { background: #17332e; }
html[data-theme="dark"] .tool-trace, html[data-theme="dark"] .message-body code, html[data-theme="dark"] .message-body pre { background: #101513; }
html[data-theme="dark"] .auth-gate { background: #090d0c; }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { color: var(--ink); }

@media (max-width: 720px) { .help-grid { grid-template-columns: 1fr; }.inline-form { flex-wrap: wrap; }.inline-form input { flex-basis: 100%; } }

/* DESIGN.md: Linear-inspired product canvas */
:root {
  --ink: #f7f8f8;
  --muted: #d0d6e0;
  --faint: #8a8f98;
  --line: #23252a;
  --line-soft: #191b1e;
  --surface: #0f1011;
  --surface-soft: #141516;
  --sidebar: #090a0b;
  --teal-950: #f7f8f8;
  --teal-800: #828fff;
  --teal-600: #5e6ad2;
  --teal-100: #191b2b;
  --coral: #5e6ad2;
  --blue: #5e6ad2;
  --gold: #5e6ad2;
  --violet: #5e6ad2;
  --danger: #f07178;
  --shadow: none;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #010102;
}

html, body { background: #010102; color: var(--ink); }
body { letter-spacing: 0; }
button, input, textarea, select { letter-spacing: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--teal-600); outline-offset: 2px; }

.auth-gate { background: #010102; }
.auth-panel { width: min(420px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: none; }
.auth-brand { color: var(--ink); margin-bottom: 48px; }
.auth-panel h1, .dialog-heading h2, .welcome h1, .page-heading h1 { color: var(--ink); font-family: inherit; font-weight: 600; letter-spacing: 0; }
.auth-copy, .page-heading p:not(.eyebrow), .welcome-copy { color: var(--muted); }
.auth-tabs { border-color: var(--line); }
.auth-tab { color: var(--faint); }
.auth-tab.active { color: var(--ink); border-color: var(--teal-600); }
.auth-form label, .settings-form label:not(.toggle-row), .dialog-card label { color: var(--muted); }
.auth-form input, .settings-form input:not([type="checkbox"]), .dialog-card input, .dialog-card select { border-color: var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--ink); }
.auth-note { border-color: var(--teal-600); background: var(--teal-100); color: var(--muted); }
.text-button, .connection-card button, .tool-traces summary { color: var(--teal-800); }

.app-shell { grid-template-columns: 248px minmax(0, 1fr); background: #010102; }
.sidebar { padding: 16px 12px 12px; border-color: var(--line); background: var(--sidebar); }
.brand { color: var(--ink); font-size: 17px; }
.brand-mark span:nth-child(1) { background: var(--teal-600); }
.brand-mark span:nth-child(2) { background: #828fff; }
.brand-mark span:nth-child(3) { background: #b7bdff; }
.icon-button { color: var(--faint); }
.icon-button:hover, .profile-button:hover, .nav-item:hover, .history-item:hover { background: var(--surface-2, #141516); }
.new-chat-button { height: 40px; margin: 16px 0 12px; border-color: var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: none; font-size: 13px; }
.new-chat-button:hover { border-color: var(--line-strong, #34343a); background: var(--surface-soft); }
.new-chat-button kbd { border-color: var(--line); background: var(--surface-soft); color: var(--faint); }
.nav-item { min-height: 36px; color: var(--faint); font-size: 13px; }
.nav-item.active { color: var(--ink); background: #191b2b; font-weight: 600; }
.count-badge { background: var(--surface-soft); color: var(--muted); }
.section-label-row { color: var(--faint); }
.history-item { color: var(--faint); }
.history-item:hover, .history-item.active { background: var(--surface-soft); color: var(--ink); }
.sidebar-footer { border-color: var(--line); }
.profile-button { color: var(--ink); }
.avatar { background: var(--teal-600); color: white; }
.profile-copy small { color: var(--faint); }

.main, .topbar, .content-view, .composer-wrap { background: #010102; }
.topbar { height: 57px; padding: 0 24px; border-color: var(--line); }
.topbar-title strong { color: var(--ink); font-size: 13px; }
.topbar-title small { color: var(--faint); }
.status-pill { border-color: var(--line); background: var(--surface); color: var(--muted); }
.status-pill.online .status-dot { box-shadow: 0 0 0 3px #172819; }

.welcome { min-height: calc(100dvh - 220px); padding-top: 44px; }
.welcome-mark { opacity: .9; }
.eyebrow { color: var(--teal-800); font-size: 12px; letter-spacing: .4px; }
.welcome h1 { font-size: 38px; }
.quick-actions button { height: 68px; border-color: var(--line); border-radius: 8px; background: var(--surface); box-shadow: none; }
.quick-actions button:hover { border-color: #34343a; background: var(--surface-soft); box-shadow: none; }
.quick-actions strong { color: var(--ink); }
.quick-actions small { color: var(--faint); }
.quick-icon, .quick-icon.coral, .quick-icon.blue, .quick-icon.gold, .quick-icon.violet { background: #191b2b; color: var(--teal-800); }
.quick-actions button > .icon { color: var(--faint); }

.messages { width: min(860px, calc(100% - 40px)); gap: 30px; }
.message-avatar { background: var(--teal-600); }
.message.assistant .message-avatar { border: 1px solid var(--line); background: var(--surface); color: var(--teal-800); }
.message-body { color: var(--muted); line-height: 1.6; }
.message.user .message-body { background: var(--surface-soft); border: 1px solid var(--line); color: var(--ink); }
.message-body code, .message-body pre { border-color: var(--line); background: #0a0b0c; color: var(--muted); }
.message-meta { color: var(--faint); }
.message-attachments img, .file-chip { border-color: var(--line); background: var(--surface-soft); }
.file-chip { color: var(--ink); text-decoration: none; }
.tool-trace { border-color: var(--teal-600); background: var(--surface); color: var(--faint); }
.typing-dots i { background: var(--teal-600); }

.composer-wrap { padding: 0 24px 18px; }
.composer { border-color: var(--line-strong, #34343a); border-radius: 10px; background: var(--surface); box-shadow: none; }
.composer:focus-within { border-color: var(--teal-600); box-shadow: 0 0 0 2px rgba(94,106,210,.22); }
.composer textarea { color: var(--ink); }
.composer textarea::placeholder { color: var(--faint); }
.composer-toolbar .icon-button { color: var(--faint); }
.composer-toolbar .icon-button:hover { background: var(--surface-soft); color: var(--ink); }
.send-button { border-radius: 7px; background: var(--teal-600); color: white; }
.attachment-preview { border-color: var(--line); background: var(--surface); box-shadow: none; }
.disclaimer { color: var(--faint); }

.content-view { padding: 40px clamp(24px, 5vw, 72px) 64px; }
.page-heading { margin-bottom: 32px; }
.page-heading h1 { font-size: 32px; }
.primary-button { border-color: var(--teal-600); border-radius: 8px; background: var(--teal-600); font-weight: 500; }
.primary-button:hover { background: #828fff; }
.secondary-button { border-color: var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-weight: 500; }
.secondary-button:hover { background: var(--surface-soft); }
.filter-row { border-color: var(--line); }
.filter { color: var(--faint); }
.filter.active { color: var(--ink); border-color: var(--teal-600); }
.task-row, .activity-item { border-color: var(--line); }
.task-type-icon { background: #191b2b; color: var(--teal-800); }
.task-status { border-radius: 9999px; background: #16251b; color: #73d69a; }
.task-status.paused { background: #282316; color: #e0bc65; }
.task-status.completed { background: var(--surface-soft); color: var(--faint); }
.empty-state { border-color: var(--line); color: var(--faint); }
.empty-state .icon { color: var(--teal-800); }
.activity-item::before { background: var(--line); }
.activity-icon { border-color: var(--line); background: var(--surface); color: var(--teal-800); }
.connection-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.connection-card, .settings-section, .help-grid section { border-color: var(--line); border-radius: 12px; background: var(--surface); }
.connection-card:hover, .help-grid section:hover { border-color: #34343a; }
.connection-logo { border-radius: 8px; background: #191b2b !important; color: var(--teal-800); }
.connection-status { border-radius: 9999px; background: var(--surface-soft); color: var(--muted); }
.connection-status.local, .connection-status.connected { background: #16251b; color: #73d69a; }
.settings-form { gap: 16px; }
.settings-section { padding: 24px; }
.settings-section h2, .help-grid h2 { color: var(--ink); }
.settings-section input:not([type="checkbox"]), .settings-section select, .inline-form input { border-color: var(--line); background: var(--surface-soft); }
.toggle-row { border-color: var(--line); }
.toggle-row i { background: #34343a; }
.toggle-row input:checked + i { background: var(--teal-600); }
.form-actions span { color: #73d69a; }
.pairing-code { border-color: var(--teal-600); background: #191b2b; }

dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.dialog-card { border-color: var(--line); border-radius: 12px; background: var(--surface); }
.toast { border-color: var(--line); border-radius: 8px; background: var(--surface); box-shadow: none; }
.toast .icon { color: var(--teal-800); }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 224px minmax(0, 1fr); }
  .connection-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .sidebar { background: var(--sidebar); box-shadow: 18px 0 50px rgba(0,0,0,.45); }
  .scrim { background: rgba(0,0,0,.62); }
  .topbar { padding: 0 12px; }
  .welcome { min-height: calc(100dvh - 224px); padding-top: 26px; }
  .welcome h1 { font-size: 30px; }
  .quick-actions button { background: var(--surface); }
  .messages { width: calc(100% - 24px); }
  .composer-wrap { padding: 0 10px 10px; }
  .content-view { padding: 28px 16px 52px; }
  .settings-section { padding: 18px; }
}
