/* Forge design system */
:root {
  --bg: #0a0b10; --bg-2: #0e1017; --panel: #12151d; --panel-2: #171b25; --hover: #1e2330; --active: #252b3b;
  --border: rgba(255,255,255,.065); --border-2: rgba(255,255,255,.11);
  --text: #eceef4; --text-2: #c3c8d4; --muted: #8a92a6; --faint: #5c6478;
  --accent: #8b7cff; --accent-2: #4fd1c5; --accent-soft: rgba(139,124,255,.14);
  --grad: linear-gradient(135deg, #8b7cff 0%, #5fa8ff 55%, #4fd1c5 100%);
  --ok: #3ddc97; --warn: #ffc65c; --danger: #ff6b81;
  --r-lg: 18px; --r: 12px; --r-sm: 8px;
  --shadow: 0 10px 40px -12px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.25);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --rail: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14.5px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { font: inherit; color: var(--text); }
::selection { background: rgba(139,124,255,.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,.16); }
::-webkit-scrollbar-track { background: transparent; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; } svg.i.lg { width: 22px; height: 22px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text); font-weight: 500; transition: .15s; white-space: nowrap; }
.btn:hover { background: var(--hover); border-color: rgba(255,255,255,.18); }
.btn.primary { background: var(--grad); border: 0; color: #0b0c12; font-weight: 600; box-shadow: 0 6px 20px -8px rgba(139,124,255,.7); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: rgba(255,107,129,.12); border-color: rgba(255,107,129,.35); color: #ff9aaa; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--muted); transition: .15s; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.field { width: 100%; height: 40px; padding: 0 12px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--r); outline: none; transition: .15s; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { appearance: none; -webkit-appearance: none; height: 36px; padding: 0 34px 0 12px; background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a92a6' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; border: 1px solid var(--border-2); border-radius: 10px; outline: none; min-width: 0; cursor: pointer; }
.select:focus { border-color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,151,.15); }
.dot.busy { background: var(--warn); box-shadow: 0 0 0 3px rgba(255,198,92,.15); animation: pulse 1.4s infinite; }
.dot.off { background: var(--danger); }
@keyframes pulse { 50% { opacity: .45; } }
.logo { width: 34px; height: 34px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; color: #0b0c12; box-shadow: 0 6px 18px -6px rgba(139,124,255,.8); flex: none; }
.logo svg { width: 18px; height: 18px; stroke-width: 2.4; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* app shell */
.shell { display: flex; height: 100vh; height: 100dvh; }
.rail { width: var(--rail); flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; background: var(--bg-2); border-right: 1px solid var(--border); z-index: 40; }
.rail .logo { margin-bottom: 14px; }
.rail-link { position: relative; width: 46px; height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 14px; color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 500; transition: .15s; }
.rail-link:hover { background: var(--hover); color: var(--text); }
.rail-link.active { background: var(--accent-soft); color: #c8c0ff; }
.rail-link.active::before { content: ""; position: absolute; left: -11px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.rail-link .label { display: none; }
.rail .status-dot { margin: 8px 0 4px; }
.page { flex: 1; min-width: 0; display: flex; position: relative; }
.scrim { position: fixed; inset: 0; background: rgba(4,5,9,.6); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: .2s; z-index: 35; }
body.nav-open .scrim, body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.mobile-only { display: none !important; }

/* chat page */
.drawer { width: 288px; flex: none; display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--border); transition: margin .25s, transform .25s; z-index: 36; }
body.drawer-collapsed .drawer { margin-left: -288px; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 16px 14px 10px; }
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.search { position: relative; margin: 0 14px 8px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 34px; height: 36px; font-size: 13.5px; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.group-label { font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); padding: 14px 10px 6px; }
.conv { display: flex; align-items: center; gap: 4px; height: 38px; padding: 0 6px 0 12px; border-radius: 10px; cursor: pointer; color: var(--text-2); transition: background .12s; }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--active); color: var(--text); }
.conv .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.conv .acts { display: none; }
.conv:hover .acts, .conv.active .acts { display: flex; }
.drawer-foot { padding: 10px 12px calc(12px + var(--safe-b)); border-top: 1px solid var(--border); display: flex; gap: 6px; }
.drawer-empty { color: var(--faint); font-size: 13px; padding: 24px 12px; text-align: center; }

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: radial-gradient(1200px 500px at 50% -200px, rgba(139,124,255,.08), transparent 60%), var(--bg); }
.topbar { height: 58px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); background: rgba(10,11,16,.7); backdrop-filter: blur(12px); }
.topbar .title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.transcript { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 28px 18px 12px; scroll-behavior: auto; }
.transcript .inner { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

/* messages */
.row { display: flex; gap: 14px; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.row.user { justify-content: flex-end; }
.bubble { max-width: min(78%, 640px); background: linear-gradient(180deg, #232838, #1d2230); border: 1px solid var(--border-2); padding: 11px 16px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #0b0c12; flex: none; margin-top: 2px; }
.avatar svg { width: 16px; height: 16px; stroke-width: 2.4; }
.row.assistant .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.md { overflow-wrap: anywhere; color: var(--text); }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; } .md ul, .md ol { padding-left: 22px; margin: 0 0 12px; } .md li { margin: 3px 0; }
.md h1, .md h2, .md h3 { line-height: 1.3; margin: 18px 0 10px; } .md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15.5px; }
.md a { color: #a99eff; }
.md blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--text-2); }
.md :not(pre) > code { font-family: var(--mono); font-size: .86em; background: rgba(139,124,255,.12); color: #d4ceff; padding: 2px 6px; border-radius: 6px; }
.md table { border-collapse: collapse; margin: 0 0 12px; display: block; overflow-x: auto; } .md th, .md td { border: 1px solid var(--border-2); padding: 6px 10px; } .md th { background: var(--panel-2); }
.codeblock { margin: 0 0 12px; border: 1px solid var(--border-2); border-radius: var(--r); overflow: hidden; background: #07080c; }
.codeblock .cb-head { display: flex; align-items: center; height: 34px; padding: 0 6px 0 14px; background: var(--panel); border-bottom: 1px solid var(--border); font: 12px var(--mono); color: var(--muted); }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.codeblock code, .codeblock code.hljs { font: 12.8px/1.6 var(--mono); background: transparent; padding: 0; }
.cursor-blink::after { content: ""; display: inline-block; width: 8px; height: 16px; margin-left: 2px; vertical-align: -3px; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; height: 30px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; background: #6f9dff; } .dots i:nth-child(3) { animation-delay: .3s; background: var(--accent-2); }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
.thinking .timer { font-variant-numeric: tabular-nums; color: var(--faint); }
.msg-meta { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; }
.msg-meta .icon-btn { width: 28px; height: 28px; }
.notice { align-self: center; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; padding: 6px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); }
.notice.err { color: #ff9aaa; border-color: rgba(255,107,129,.3); }

/* tool cards */
.tool { border: 1px solid var(--border-2); border-radius: var(--r); background: var(--panel); overflow: hidden; transition: border-color .15s; }
.tool:hover { border-color: rgba(255,255,255,.16); }
.tool summary { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; cursor: pointer; list-style: none; user-select: none; }
.tool summary::-webkit-details-marker { display: none; }
.tool .ticon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: #b9b0ff; flex: none; }
.tool .ticon svg { width: 14px; height: 14px; }
.tool .tlabel { font-weight: 500; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.tool .targ { flex: 1; min-width: 0; font: 12px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool .tstate { flex: none; display: inline-flex; }
.tool .tstate.ok { color: var(--ok); } .tool .tstate.err { color: var(--danger); }
.tool .chev { color: var(--faint); transition: transform .2s; }
.tool[open] .chev { transform: rotate(90deg); }
.tool pre { margin: 0; padding: 12px 14px; border-top: 1px solid var(--border); max-height: 340px; overflow: auto; font: 12px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); background: #0b0c11; }
.spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,198,92,.25); border-top-color: var(--warn); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* empty state */
.hero { margin: auto; width: 100%; max-width: 680px; text-align: center; padding: 6vh 4px 20px; }
.hero .logo { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 22px; } .hero .logo svg { width: 28px; height: 28px; }
.hero h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 0 0 10px; font-weight: 700; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 30px; text-align: left; }
.card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--border); color: var(--text-2); transition: .15s; text-align: left; font-size: 13.5px; line-height: 1.45; }
.card:hover { border-color: rgba(139,124,255,.5); background: var(--panel-2); color: var(--text); transform: translateY(-1px); }
.card svg { color: var(--accent); margin-top: 1px; }

/* composer */
.composer { flex: none; padding: 10px 18px calc(18px + var(--safe-b)); }
.composer .box { max-width: 800px; margin: 0 auto; background: var(--panel); border: 1px solid var(--border-2); border-radius: 22px; padding: 12px 12px 10px 18px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer .box:focus-within { border-color: rgba(139,124,255,.55); box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; background: transparent; resize: none; padding: 2px 0; max-height: 220px; line-height: 1.55; font-size: 15px; }
.composer textarea::placeholder { color: var(--faint); }
.composer .row2 { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.composer .hint { color: var(--faint); font-size: 12px; }
.send { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; background: var(--grad); color: #0b0c12; transition: .15s; flex: none; }
.send svg { stroke-width: 2.5; }
.send:disabled { background: var(--hover); color: var(--faint); cursor: default; }
.send.stop { background: var(--text); }
.ctx { display: inline-flex; align-items: center; gap: 7px; color: var(--faint); font-size: 12px; }
.ctx svg { width: 18px; height: 18px; transform: rotate(-90deg); }
.ctx circle { fill: none; stroke-width: 3.5; }
.composer .disclaimer { max-width: 800px; margin: 8px auto 0; text-align: center; color: var(--faint); font-size: 11.5px; }

/* dialogs & toasts */
.dialog-back { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(4,5,9,.65); backdrop-filter: blur(4px); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: 440px; max-width: 100%; max-height: 86vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow); animation: pop .18s ease-out; }
.dialog.wide { width: 620px; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.dialog header { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.dialog header h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.dialog .content { padding: 8px 20px 16px; overflow-y: auto; color: var(--text-2); }
.dialog footer { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; }
.mem { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.mem:last-child { border-bottom: 0; }
.mem .scope { font: 11px var(--mono); padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: #c8c0ff; white-space: nowrap; margin-top: 2px; }
.mem .text { flex: 1; color: var(--text); font-size: 14px; }
.mem-add { display: flex; gap: 8px; padding: 14px 20px 20px; border-top: 1px solid var(--border); }
.toasts { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px; background: #20263a; border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 13.5px; animation: pop .2s ease-out; }
.toast.err { border-color: rgba(255,107,129,.4); } .toast.ok svg { color: var(--ok); } .toast.err svg { color: var(--danger); }

/* login */
.login-page { height: 100dvh; display: grid; place-items: center; padding: 20px; overflow: auto; background: radial-gradient(700px 400px at 20% 10%, rgba(139,124,255,.18), transparent 60%), radial-gradient(600px 400px at 85% 90%, rgba(79,209,197,.13), transparent 60%), var(--bg); }
.login-card { width: 400px; max-width: 100%; padding: 36px 32px 30px; border-radius: 24px; background: rgba(18,21,29,.8); border: 1px solid var(--border-2); box-shadow: var(--shadow); backdrop-filter: blur(16px); display: flex; flex-direction: column; gap: 16px; }
.login-card .logo { width: 52px; height: 52px; border-radius: 16px; } .login-card .logo svg { width: 26px; height: 26px; }
.login-card h1 { margin: 6px 0 0; font-size: 26px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 6px; color: var(--muted); }
.login-card .field { height: 46px; font-size: 15px; }
.login-card .btn { height: 46px; font-size: 15px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }

/* code page */
.ide { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ide-top { height: 54px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.ide-top .proj { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ide-top .proj .select { max-width: 220px; font-weight: 600; }
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; color: var(--muted); font: 12.5px var(--mono); overflow: hidden; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 500; }
.seg { display: flex; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.seg button { height: 32px; padding: 0 12px; border-radius: 9px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.seg button.on { background: var(--active); color: var(--text); }
.ide-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr) 5px var(--agent-w, 430px); }
body.no-agent .ide-body { grid-template-columns: 260px minmax(0, 1fr) 0 0; }
body.no-agent .agent, body.no-agent .vsplit { display: none; }
.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.panel-head { height: 40px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--border); font-size: 11.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.explorer { background: var(--bg-2); border-right: 1px solid var(--border); }
.tree { flex: 1; overflow: auto; padding: 6px 6px 20px; font-size: 13.5px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.node { display: flex; align-items: center; gap: 6px; height: 30px; padding-right: 4px; border-radius: 8px; cursor: pointer; white-space: nowrap; color: var(--text-2); }
.node:hover { background: var(--hover); }
.node.active { background: var(--accent-soft); color: var(--text); }
.node .tw { width: 16px; display: grid; place-items: center; color: var(--faint); flex: none; }
.node .tw svg { width: 13px; height: 13px; transition: transform .15s; }
.node.open .tw svg { transform: rotate(90deg); }
.node .fi { flex: none; } .node .fi.folder { color: #8fb3ff; } .node .fi.file { color: var(--faint); }
.node .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.node .acts { display: none; }
.node:hover .acts { display: flex; }
.tree-empty { color: var(--faint); padding: 20px 12px; font-size: 13px; text-align: center; }
.work { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.etabs { height: 40px; flex: none; display: flex; overflow-x: auto; background: var(--bg-2); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.etabs::-webkit-scrollbar { display: none; }
.etab { display: flex; align-items: center; gap: 7px; padding: 0 6px 0 14px; border-right: 1px solid var(--border); color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 13px; position: relative; }
.etab:hover { color: var(--text-2); background: var(--panel); }
.etab.active { background: var(--bg); color: var(--text); }
.etab.active::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--grad); }
.etab .dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.editor { flex: 1; min-height: 80px; position: relative; background: var(--bg); }
.editor .CodeMirror { position: absolute; inset: 0; height: auto; font: 13.5px/1.6 var(--mono); background: var(--bg); }
.editor .CodeMirror-gutters { background: var(--bg); border-right: 1px solid var(--border); }
.editor .CodeMirror-linenumber { color: #3f465a; }
.editor .CodeMirror-activeline-background { background: rgba(255,255,255,.025); }
.welcome { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; padding: 24px; }
.welcome .logo { width: 48px; height: 48px; border-radius: 15px; margin-bottom: 6px; }
.welcome h3 { margin: 0; color: var(--text); font-size: 17px; }
.welcome kbd { font: 12px var(--mono); padding: 2px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text-2); }
.hsplit { height: 5px; flex: none; cursor: row-resize; background: var(--border); transition: background .15s; }
.vsplit { cursor: col-resize; background: var(--border); transition: background .15s; }
.hsplit:hover, .vsplit:hover { background: var(--accent); }
.termpane { height: var(--term-h, 32%); min-height: 90px; flex: none; display: flex; flex-direction: column; background: #07080c; }
body.no-term .termpane, body.no-term .hsplit { display: none; }
.termpane .panel-head { background: var(--bg-2); }
.term { flex: 1; min-height: 0; padding: 8px 0 0 12px; }
.term .xterm-viewport { background: transparent !important; }
.agent { border-left: 1px solid var(--border); }
.agent .panel-head { text-transform: none; letter-spacing: 0; font-size: 13px; gap: 8px; padding: 0 8px; height: 52px; }
.agent .panel-head .select { flex: 1; height: 34px; font-size: 13px; }
.agent .transcript { padding: 18px 14px 8px; }
.agent .transcript .inner { gap: 18px; }
.agent .row { gap: 10px; } .agent .avatar { width: 26px; height: 26px; border-radius: 9px; }
.agent .bubble { max-width: 88%; }
.agent .composer { padding: 8px 12px calc(12px + var(--safe-b)); }
.agent .composer .box { border-radius: 18px; padding: 10px 10px 8px 14px; }
.agent .hero { padding: 4vh 6px 10px; } .agent .hero h1 { font-size: 22px; } .agent .cards { grid-template-columns: 1fr; gap: 8px; margin-top: 20px; }
.mtabs { display: none; }

/* responsive */
@media (max-width: 1180px) { .ide-body { grid-template-columns: 220px minmax(0, 1fr) 5px var(--agent-w, 380px); } }
@media (max-width: 860px) {
  html, body { font-size: 15px; }
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .rail { position: fixed; top: 0; bottom: 0; left: 0; width: 270px; align-items: stretch; padding: 18px 14px calc(18px + var(--safe-b)); transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow); }
  body.nav-open .rail { transform: none; }
  .rail .logo { margin: 0 6px 18px; }
  .rail-link { width: auto; height: 46px; flex-direction: row; justify-content: flex-start; gap: 14px; padding: 0 14px; font-size: 14.5px; }
  .rail-link .label { display: inline; }
  .rail-link.active::before { left: -14px; }
  .rail .status-dot { align-self: flex-start; margin: 10px 18px; }
  .drawer { position: fixed; top: 0; bottom: 0; left: 0; width: 86vw; max-width: 330px; transform: translateX(-100%); box-shadow: var(--shadow); }
  body.drawer-open .drawer { transform: none; }
  body.drawer-collapsed .drawer { margin-left: 0; }
  .conv .acts { display: flex; }
  .topbar { padding: 0 8px; height: 54px; }
  .transcript { padding: 18px 14px 8px; }
  .bubble { max-width: 88%; }
  .row { gap: 10px; } .avatar { width: 26px; height: 26px; border-radius: 9px; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .hero { padding-top: 3vh; }
  .composer { padding: 6px 10px calc(10px + var(--safe-b)); }
  .composer .box { border-radius: 20px; padding: 10px 10px 8px 14px; }
  .composer .hint, .composer .disclaimer { display: none; }
  .ide-top { height: auto; flex-wrap: wrap; padding: 8px 8px 0; gap: 6px; border-bottom: 0; }
  .ide-top .proj { flex: 1; } .ide-top .proj .select { max-width: none; flex: 1; }
  .mtabs { display: flex; width: 100%; padding: 4px 0 8px; }
  .mtabs.seg { background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 4px 0 8px; }
  .mtabs button { flex: 1; justify-content: center; }
  .ide-body, body.no-agent .ide-body { display: block; position: relative; }
  .ide-body > .panel, .ide-body > .work { position: absolute; inset: 0; display: none; border: 0; }
  .ide-body > .show { display: flex !important; }
  .vsplit, .hsplit { display: none !important; }
  .work .termpane { display: none; }
  .work.term-mode .editor, .work.term-mode .etabs { display: none; }
  .work.term-mode .termpane { display: flex; flex: 1; height: auto; }
  body.no-agent .agent { display: none; }
  .node { height: 40px; } .node .acts { display: flex; }
}
@media (min-width: 861px) { .work.term-mode .termpane { display: flex; } }
