:root {
  color-scheme: dark;
  --bg: #101317;
  --side: #14181d;
  --surface: #1b2127;
  --surface-raised: #222a30;
  --line: #2d3840;
  --text: #eff4f3;
  --muted: #acb9ba;
  --subtle: #89999c;
  --accent: #a6eed7;
  --accent-ink: #0d2921;
  --danger: #ffb0a8;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-width: 290px; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
svg { display: block; width: 19px; height: 19px; flex: 0 0 auto; }
.screen-reader { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.boot, .login { min-height: 100dvh; display: grid; place-content: center; padding: 24px; }
.boot { place-items: center; gap: 14px; color: var(--muted); }
.login { background: radial-gradient(ellipse at 50% 28%, #1c2c2c 0, var(--bg) 63%); }
.login-card { width: min(410px, calc(100vw - 32px)); padding: clamp(22px, 6vw, 38px); background: var(--side); border: 1px solid var(--line); border-radius: 22px; display: grid; gap: 16px; box-shadow: 0 28px 90px #0005; }
.login-card h1 { font-size: clamp(1.5rem, 5vw, 1.85rem); letter-spacing: -.04em; margin-top: 8px; }
.login-card p { color: var(--muted); }
.login-card label, .field { display: grid; gap: 7px; color: var(--muted); font-size: .875rem; }
.login-card input, .field input, .field select, .field textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; font-size: 1rem; width: 100%; min-width: 0; }
.login-card .form-error, .form-error { color: var(--danger); font-size: .875rem; }
.login-submit { margin-top: 4px; justify-content: center; }

.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); height: 100dvh; width: 100%; }
.shell.inspector-open { grid-template-columns: 248px minmax(0, 1fr) clamp(290px, 28vw, 410px); }
.sidebar, .inspector { display: flex; min-height: 0; min-width: 0; flex-direction: column; background: var(--side); }
.sidebar { border-right: 1px solid var(--line); gap: 13px; padding: 19px 13px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 13px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: .97rem; letter-spacing: -.015em; }
.brand div span { color: var(--subtle); font-size: .75rem; }
.primary, .quiet, .icon-button, .plan-mode, .send-button, .suggestion { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; font-weight: 600; }
.primary { background: var(--accent); color: var(--accent-ink); padding: 10px 13px; min-height: 42px; }
.primary:hover { background: #c6f6e5; }
.new-session { justify-content: flex-start; }
.quiet, .icon-button, .plan-mode { background: transparent; color: var(--muted); }
.quiet { min-height: 38px; padding: 6px 10px; font-size: .875rem; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; flex: 0 0 auto; }
.quiet:hover, .icon-button:hover, .plan-mode:hover { background: var(--surface-raised); color: var(--text); }
.icon-button[aria-pressed="true"], .quiet[aria-pressed="true"], .plan-mode[aria-pressed="true"] { color: var(--accent); background: #263b37; }
.filter-label { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; color: var(--subtle); }
.filter-label svg { width: 16px; height: 16px; }
.filter-label input { min-width: 0; width: 100%; border: 0; background: transparent; font-size: .875rem; padding: 8px 0; color: var(--text); }
kbd { color: var(--subtle); font-size: .75rem; border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 7px; }
.sidebar-label h2 { font-size: .84rem; font-weight: 600; color: var(--muted); }
.sidebar-label .icon-button { height: 30px; width: 32px; }
.sidebar-label .icon-button svg { width: 16px; height: 16px; }
.sessions { overflow-y: auto; flex: 1; min-height: 0; display: flex; align-content: start; flex-direction: column; gap: 3px; scrollbar-width: thin; }
.session-row { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; border: 1px solid transparent; border-radius: 9px; background: transparent; padding: 9px 7px; color: var(--muted); min-height: 44px; }
.session-row:hover { background: var(--surface); }
.session-row[aria-current="true"] { color: var(--text); background: #25312f; border-color: #354844; }
.session-row > span { display: grid; gap: 3px; min-width: 0; flex: 1; }
.session-row strong, .session-row small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.session-row strong { font-size: .86rem; font-weight: 550; }
.session-row small { color: var(--subtle); font-size: .75rem; }
.session-row svg { width: 16px; height: 16px; }
.more { justify-content: center; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 10px; }
.profile { display: flex; align-items: center; gap: 9px; width: 100%; padding: 5px; text-align: left; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.profile:hover { background: var(--surface); }
.profile strong, .profile small { display: block; max-width: 149px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.profile strong { font-size: .875rem; color: var(--text); }
.profile small { font-size: .73rem; }
.profile > span:last-child { margin-left: auto; }
.avatar { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; border-radius: 50%; background: #2a4a44; color: var(--accent); font-size: .85rem; font-weight: 650; }

.conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.topbar, .inspector-header { min-height: 67px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px clamp(12px, 3vw, 24px); border-bottom: 1px solid var(--line); }
.project-picker, .top-tools { display: flex; align-items: center; gap: 9px; min-width: 0; }
.project-icon { display: grid; place-items: center; width: 34px; height: 34px; background: #233530; border: 1px solid #304641; color: var(--accent); border-radius: 9px; flex: 0 0 34px; }
.project-label { display: grid; gap: 2px; min-width: 0; }
.project-label select, .select-chip select { appearance: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' stroke='%23acb9ba' stroke-width='1.3' fill='none'/%3E%3C/svg%3E") right 6px center / 12px no-repeat; color: var(--text); border: 0; padding: 2px 22px 2px 0; font-size: .9rem; font-weight: 600; min-width: 0; max-width: min(280px, 42vw); text-overflow: ellipsis; }
select option { background: var(--surface); }
#thread-title { color: var(--subtle); font-size: .75rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: min(360px, 45vw); }
.connection { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: .78rem; }
.connection i, .active-task i { display: block; width: 7px; height: 7px; background: #e5bd78; border-radius: 50%; }
.connection[data-status="online"] i { background: #8fdfbe; }
.connection[data-status="offline"] i { background: var(--danger); }
.chat { overflow: auto; overscroll-behavior-y: contain; scrollbar-width: thin; min-height: 0; }
.welcome { min-height: 100%; width: min(100%, 850px); margin: auto; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 34px 16px 28px; text-align: center; }
.hero-mark { display: grid; place-items: center; height: 92px; width: 92px; background: radial-gradient(ellipse at 40% 28%, #284841, #182725 76%); border: 1px solid #324943; border-radius: 25px; box-shadow: 0 10px 36px #01090865, inset 0 1px #48615860; margin-bottom: 23px; }
.welcome h1 { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 640; line-height: 1.08; letter-spacing: -.06em; }
.welcome p { color: var(--muted); margin-top: 12px; font-size: .96rem; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 25px; }
.suggestion { color: var(--muted); background: var(--side); border-color: var(--line); padding: 8px 10px; min-height: 40px; font-size: .83rem; }
.suggestion:hover { border-color: #60887b; color: var(--text); }
.suggestion svg { width: 16px; height: 16px; color: var(--accent); }
.history { width: min(100%, 850px); margin: auto; padding: 20px clamp(12px, 3vw, 26px) 10px; }
.older { display: flex; width: max-content; margin: 0 auto 18px; }
.messages { display: grid; gap: 18px; min-width: 0; }
.message { min-width: 0; overflow-wrap: anywhere; }
.message.user { justify-self: end; max-width: min(90%, 630px); padding: 12px 15px; background: #253630; border: 1px solid #354c43; border-radius: 15px 15px 4px 15px; white-space: pre-wrap; line-height: 1.55; }
.message.agent { display: grid; gap: 8px; }
.message-agent-label { display: flex; align-items: center; gap: 7px; color: var(--accent); font-size: .78rem; font-weight: 650; }
.message-agent-label img { width: 19px; height: 19px; }
.message-text { display: grid; gap: 7px; contain: inline-size; line-height: 1.56; white-space: pre-wrap; }
.message-text p, .message-text li { min-width: 0; }
.message-text ul, .message-text ol { margin: 0; padding-left: 22px; white-space: normal; }
.message-text h3 { font-size: 1.03rem; }
code, pre, kbd { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.message-text :not(pre) > code { background: var(--surface-raised); padding: 1px 4px; border-radius: 4px; font-size: .9em; }
pre { overflow: auto; min-width: 0; max-width: 100%; margin: 0; padding: 12px; background: #0d1013; border: 1px solid var(--line); border-radius: 9px; font-size: .82rem; line-height: 1.5; white-space: pre; tab-size: 2; }
.code-frame { position: relative; min-width: 0; }
.code-frame .quiet { position: absolute; right: 4px; top: 3px; min-height: 28px; background: var(--surface); }
.activity { border: 1px solid var(--line); border-radius: 10px; background: var(--side); color: var(--muted); }
.activity summary { padding: 10px; overflow-wrap: anywhere; font-size: .86rem; cursor: pointer; }
.activity .activity-body { display: grid; gap: 7px; padding: 0 9px 9px; }
.message-attachments { font-size: .8rem; color: var(--accent); }
.active-task { color: var(--muted); display: flex; align-items: center; gap: 8px; font-size: .875rem; padding: 14px 1px; }
.active-task i { animation: pulse 1.3s ease-in-out infinite; background: var(--accent); }
@keyframes pulse { 50% { opacity: .32; } }

.composer-area { width: min(100%, 850px); margin: 0 auto; padding: 0 clamp(12px, 3vw, 26px) 11px; }
.composer { padding: 10px 9px 8px; border-radius: 16px; background: var(--surface); border: 1px solid #3a484e; box-shadow: 0 10px 30px #05070864; }
.composer:focus-within { border-color: #64877d; }
.composer textarea { width: 100%; min-height: 53px; max-height: min(170px, 27dvh); resize: none; field-sizing: content; background: transparent; border: 0; padding: 5px 8px 8px; line-height: 1.45; font-size: 1rem; color: var(--text); }
.composer textarea:focus { outline: 0; }
.composer textarea::placeholder { color: var(--subtle); }
.composer-bar, .composer-group { display: flex; align-items: center; gap: 4px; min-width: 0; }
.composer-bar { justify-content: space-between; }
.composer-options { flex: 1; }
.select-chip { min-width: 40px; max-width: 168px; border: 1px solid var(--line); border-radius: 8px; }
.select-chip select { width: 100%; padding: 6px 21px 6px 8px; font-size: .8rem; }
.plan-mode { min-height: 34px; padding: 5px 7px; font-size: .79rem; }
.plan-mode svg { width: 15px; height: 15px; }
.send-button { display: grid; place-items: center; width: 38px; height: 38px; background: var(--accent); color: var(--accent-ink); padding: 0; }
.send-button:hover:not(:disabled) { background: #c6f6e5; }
.stop-button, .microphone[aria-pressed="true"] { color: var(--danger) !important; background: #472d31 !important; }
.composer-note { display: flex; justify-content: center; gap: 8px; color: var(--subtle); padding-top: 8px; font-size: .73rem; }
.attachments { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 6px 6px; }
.attachment-tag { border: 1px solid #446259; background: #233630; color: var(--accent); border-radius: 8px; padding: 4px 7px; font-size: .8rem; max-width: 100%; overflow-wrap: anywhere; }
.draft-status { padding: 7px 2px; color: var(--muted); font-size: .85rem; }
.requests { display: grid; gap: 6px; max-height: 31dvh; overflow: auto; }
.request { border: 1px solid #625339; background: #25231f; border-radius: 12px; padding: 10px; margin-bottom: 5px; display: grid; gap: 8px; color: var(--text); }
.request h3 { font-size: .92rem; color: #ffe3a9; }
.request p { color: var(--muted); font-size: .87rem; overflow-wrap: anywhere; }
.action-row { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }

.inspector { display: none; border-left: 1px solid var(--line); }
.inspector-open .inspector { display: flex; }
.inspector-header h2 { font-size: .96rem; font-weight: 630; }
.inspector-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
.inspector-tabs .quiet { justify-content: center; white-space: nowrap; }
.inspector-body { padding: 12px; overflow: auto; display: grid; align-content: start; gap: 10px; }
.inspector-body .path-label { font-size: .8rem; color: var(--subtle); overflow-wrap: anywhere; }
.inspector-body .quiet { justify-content: flex-start; text-align: left; overflow-wrap: anywhere; }
.inspector-body .quiet svg { color: var(--accent); }
.empty-label { line-height: 1.5; padding: 8px 4px; color: var(--subtle); font-size: .875rem; }
.diff-line { display: block; min-width: max-content; min-height: 1.5em; }
.diff-line.add { background: #20382c; color: #b4f2c5; }
.diff-line.remove { background: #3c272d; color: #ffc6bd; }
.diff-line.header { color: #9de0ee; }
.plan-step { display: flex; align-items: center; gap: 9px; padding: 7px 2px; font-size: .9rem; }
.plan-step[data-status="completed"] { color: var(--accent); }
.plan-step[data-status="inProgress"] { color: #f0cd94; }

.mobile-nav { display: none; }
.sheet { background: var(--side); color: var(--text); border: 1px solid var(--line); border-radius: 17px; padding: 0; width: min(560px, calc(100vw - 28px)); max-height: min(88dvh, 720px); box-shadow: 0 25px 100px #0008; }
.sheet::backdrop { background: #080a0bc9; }
.sheet-header { position: sticky; top: 0; z-index: 1; background: var(--side); display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 10px 14px; }
.sheet-header h2 { font-size: 1.13rem; }
.sheet-body { display: grid; align-content: start; gap: 10px; padding: 14px; }
.sheet-body form { display: grid; gap: 11px; min-width: 0; }
.sheet-body p { color: var(--muted); line-height: 1.5; font-size: .92rem; }
.menu-button { display: flex; width: 100%; align-items: center; gap: 9px; min-height: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; text-align: left; overflow-wrap: anywhere; }
.menu-button:hover { border-color: #6e9085; }
.menu-button.danger { color: var(--danger); }
.menu-button + .menu-button { margin-top: 1px; }
.check-label { padding: 7px 0; display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.check-label input { accent-color: #90dcc3; width: 19px; height: 19px; }
.toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 10; transform: translateX(-50%); max-width: min(480px, calc(100vw - 24px)); padding: 11px 16px; background: #243531; color: var(--text); border: 1px solid #52786d; border-radius: 12px; line-height: 1.45; font-size: .875rem; box-shadow: 0 8px 22px #0006; overflow-wrap: anywhere; }

@media (max-width: 1030px) and (min-width: 721px) {
  .shell { grid-template-columns: 217px minmax(0, 1fr); }
  .shell.inspector-open { grid-template-columns: 198px minmax(0, 1fr); }
  .inspector-open .inspector { position: absolute; top: 0; bottom: 0; right: 0; width: min(355px, 42vw); z-index: 3; box-shadow: -10px 0 30px #0008; }
  .connection > span { display: none; }
}
@media (max-width: 720px) {
  .shell, .shell.inspector-open { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; padding-top: env(safe-area-inset-top); }
  .shell .sidebar, .shell .conversation, .shell .inspector { display: none; }
  .shell[data-page="sessions"] .sidebar, .shell[data-page="workspace"] .inspector { display: flex; }
  .shell[data-page="chat"] .conversation { display: grid; }
  .sidebar, .inspector { border: 0; }
  .sidebar { padding: 12px 14px 9px; }
  .brand { padding-top: 5px; }
  .filter-label, .new-session, .session-row, .icon-button, .send-button { min-height: 44px; }
  .session-row { padding: 10px; }
  .icon-button, .send-button { width: 42px; }
  .topbar, .inspector-header { min-height: 59px; padding: 5px 10px; }
  .inspector-toggle, #close-inspector, .composer-note, #search-shortcut { display: none; }
  .connection > span { display: none; }
  #thread-title, .project-label select { max-width: 64vw; }
  .welcome { padding: 19px 12px; }
  .hero-mark { height: 68px; width: 68px; border-radius: 19px; margin-bottom: 16px; }
  .hero-mark img { width: 47px; height: 47px; }
  .welcome p { margin-top: 9px; font-size: .875rem; }
  .suggestions { margin-top: 15px; gap: 6px; }
  .suggestion { min-height: 44px; }
  .composer-area { padding: 0 8px 7px; }
  .composer { border-radius: 13px; padding: 5px; }
  .composer textarea { min-height: 46px; }
  .composer-bar, .composer-group { gap: 1px; }
  .composer .icon-button, .send-button { width: 39px; }
  .select-chip { max-width: 108px; }
  .plan-mode { min-height: 44px; width: 35px; padding: 0; justify-content: center; }
  .plan-mode span { display: none; }
  .mobile-nav { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--side); border-top: 1px solid var(--line); padding: 4px max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .mobile-nav button { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 45px; border: 0; background: transparent; color: var(--muted); font-size: .76rem; border-radius: 9px; }
  .mobile-nav button[aria-current="page"] { color: var(--accent); background: #223530; }
  .sheet { width: 100%; max-width: none; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 85dvh; padding-bottom: env(safe-area-inset-bottom); }
  .toast { bottom: calc(60px + env(safe-area-inset-bottom)); }
  html.keyboard-open .mobile-nav { display: none; }
}
@media (max-width: 380px) {
  .composer .icon-button, .send-button { width: 33px; }
  .select-chip { max-width: 79px; }
  .plan-mode { width: 31px; }
}
@media (max-height: 540px) and (max-width: 920px) {
  .hero-mark { display: none; }
  .welcome p { margin-top: 7px; }
  .welcome { padding: 8px; }
  .suggestions { margin-top: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; scroll-behavior: auto !important; }
}
.menu-button[aria-pressed="true"] { color: var(--accent); border-color: #52786d; background: #233630; }
@media (max-width: 420px) {
  #skills-button, #plan-mode { display: none; }
}
