/* AgentDeck — demo workspace */

.app-body { height: 100vh; height: 100dvh; overflow: hidden; }
.app {
  display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
}
.mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Spinner */
.spinner {
  display: inline-block; width: 13px; height: 13px; flex: none;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Top bar ---------- */
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--bg-elev);
}
.topbar .brand { font-size: 17px; }
.topbar .brand-mark { width: 26px; height: 26px; }
.demo-badge { flex: none; }
.project-switch { min-width: 0; margin-left: 8px; }
.project-switch select {
  max-width: 220px; height: 32px; padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg);
  font-family: var(--font-mono); font-size: 13px; color: var(--text);
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px; background-repeat: no-repeat;
}
.project-switch select:disabled { opacity: .6; }
.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.ctx { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.ctx .meter { width: 96px; height: 5px; border-radius: 99px; background: var(--bg-sunk); overflow: hidden; }
.ctx .meter > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .5s ease, background .3s; }
.ctx .meter > span[data-level="mid"] { background: var(--warn); }
.ctx .meter > span[data-level="high"] { background: var(--bad); }
.ctx-val { font-family: var(--font-mono); color: var(--text-2); white-space: nowrap; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px;
  border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap;
  background: var(--bg-sunk); color: var(--muted);
}
.status-pill[data-state="idle"] { background: var(--ok-soft); color: var(--ok); }
.status-pill[data-state="working"], .status-pill[data-state="reconnecting"] { background: var(--accent-soft); color: var(--accent); }
.status-pill[data-state="working"] .dot, .status-pill[data-state="reconnecting"] .dot { animation: pulse 1s ease-in-out infinite; }
.status-pill[data-state="waiting"] { background: var(--warn-soft); color: var(--warn); }
@keyframes pulse { 50% { opacity: .3; } }
.exit-link:hover { text-decoration: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column; gap: 22px; min-height: 0; overflow-y: auto;
  padding: 14px 10px; border-right: 1px solid var(--line); background: var(--bg-elev);
}
.side-nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-2); font-size: 14px; font-weight: 500; text-align: left;
}
.nav-item:hover { background: var(--bg-sunk); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}
.side-head { padding: 0 10px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.project-list { display: grid; gap: 2px; }
.project-item {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); font-size: 13.5px; text-align: left;
}
.project-item:hover { background: var(--bg-sunk); color: var(--text); }
.project-item.active { background: var(--bg-sunk); color: var(--text); font-weight: 500; }
.pi-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.project-item.active .pi-dot { background: var(--ok); }
.pi-name { font-family: var(--font-mono); font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-src { margin-left: auto; font-size: 11px; color: var(--muted); }
.side-empty { margin: 0; padding: 0 10px; font-size: 13px; color: var(--muted); }
.add-project { color: var(--muted); height: 34px; font-size: 13.5px; }
.agent-card {
  margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); font-size: 12.5px;
}
.agent-row { display: flex; align-items: center; gap: 8px; }
.agent-row .icon { width: 16px; height: 16px; color: var(--accent); }
.agent-state { margin-left: auto; color: var(--muted); }
.agent-state[data-state="idle"] { color: var(--ok); }
.agent-state[data-state="working"], .agent-state[data-state="reconnecting"] { color: var(--accent); }
.agent-state[data-state="waiting"] { color: var(--warn); }
.agent-meta { margin-top: 6px; color: var(--muted); }
.agent-meta code { color: var(--text-2); }

/* ---------- Main + views ---------- */
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }

.empty-view { margin: auto; padding: 40px 24px; max-width: 420px; text-align: center; }
.empty-view .ev-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 14px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.empty-view .ev-icon .icon { width: 24px; height: 24px; }
.empty-view h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 22px; letter-spacing: -.02em; }
.empty-view p { margin: 0 0 18px; color: var(--muted); }

/* ---------- Chat ---------- */
.chat-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 28px 0 12px; }
.chat-thread { width: 100%; max-width: 800px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; gap: 18px; }

.msg { display: flex; gap: 12px; }
.msg-user { justify-content: flex-end; }
.msg-user .bubble {
  max-width: 78%; padding: 9px 14px; border-radius: 16px 16px 4px 16px;
  background: var(--accent); color: var(--accent-ink); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-agent .avatar { width: 30px; height: 30px; flex: none; margin-top: 1px; }
.msg-agent .avatar .brand-mark { width: 30px; height: 30px; }
.msg-agent .content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.msg-name { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: -4px; }

.md { color: var(--text); line-height: 1.62; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md code { padding: 1px 5px; border-radius: 4px; background: var(--bg-sunk); border: 1px solid var(--line); font-size: .86em; }
.md strong { font-weight: 600; }
.md em { color: var(--text-2); }
.md h3, .md h4, .md h5, .md h6 { margin: 16px 0 8px; font-size: 15px; font-weight: 600; }
.md-pre { margin: 0 0 10px; padding: 10px 12px; border-radius: 8px; background: var(--bg-sunk); overflow-x: auto; }
.md-pre code { padding: 0; border: 0; background: none; }
.md.streaming > :last-child::after { content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Tool cards */
.tool { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); overflow: hidden; }
.tool-head {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 7px 12px;
  border: 0; background: transparent; text-align: left; font-size: 13px; color: var(--text-2);
}
.tool-head:hover { background: var(--bg-sunk); }
.tool-head > .icon:first-child { color: var(--muted); }
.tool-kind { font-weight: 600; color: var(--text); }
.tool-target { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); }
.tool-meta { margin-left: auto; padding-left: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.tool-meta .add, .code .add .sign { color: var(--ok); }
.tool-meta .del, .code .del .sign { color: var(--bad); }
.tool-state { display: inline-grid; place-items: center; width: 18px; flex: none; }
.tool.is-ok .tool-state { color: var(--ok); }
.tool.is-bad .tool-state { color: var(--bad); }
.tool.is-bad .tool-meta { color: var(--bad); }
.tool-state .dash { color: var(--muted); }
.tool-chev { color: var(--muted); transition: transform .15s; }
.tool.is-open .tool-chev { transform: rotate(180deg); }
.tool-body { max-height: 340px; overflow: auto; border-top: 1px solid var(--line); background: var(--bg-sunk); }
.tool-note { margin: 0; padding: 10px 12px; color: var(--muted); font-size: 13px; }

pre.out {
  margin: 0; padding: 10px 14px; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--text);
}
.tool-bash .tool-body { background: var(--term-bg); border-top-color: transparent; }
.tool-bash pre.out { color: var(--term-text); }
pre.out .ok, .tl.ok { color: #34d399; }
pre.out .bad, .tl.bad { color: #f47171; }
pre.out .dim, .tl.dim { color: var(--term-muted); }
.tool:not(.tool-bash) pre.out .ok { color: var(--ok); }
.tool:not(.tool-bash) pre.out .bad { color: var(--bad); }
.tool:not(.tool-bash) pre.out .dim { color: var(--muted); }

.code { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; padding: 6px 0; min-width: max-content; }
.cl { display: flex; }
.cl .ln { flex: none; width: 44px; padding-right: 12px; text-align: right; color: var(--muted); user-select: none; opacity: .75; }
.cl .sign { flex: none; width: 16px; user-select: none; }
.cl .lc { white-space: pre; padding-right: 16px; }
.cl.add { background: var(--ok-soft); }
.cl.del { background: var(--bad-soft); }
.cl.hunk { color: var(--muted); }
.cl.more .lc { color: var(--muted); font-style: italic; }

/* Approval */
.approval {
  padding: 16px 18px; border: 1px solid var(--line-strong); border-left: 3px solid var(--warn);
  border-radius: 12px; background: var(--bg-elev); box-shadow: var(--shadow-md);
}
.approval .ap-head { display: flex; align-items: center; gap: 8px; color: var(--warn); font-weight: 600; font-size: 14px; }
.approval .ap-text { margin: 6px 0 10px; }
.approval .ap-cmd { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--term-bg); color: var(--term-text); font-size: 12.5px; line-height: 1.6; overflow-x: auto; white-space: pre; }
.approval .ap-meta { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 14px; }
.approval .ap-meta dt { font-size: 12px; color: var(--muted); }
.approval .ap-meta dd { margin: 0; font-size: 14px; font-weight: 500; }
.approval .ap-actions { display: flex; justify-content: flex-end; gap: 8px; }
.approval .ap-result { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 13px; font-weight: 500; }
.approval.is-approved { border-left-color: var(--ok); }
.approval.is-approved .ap-result { color: var(--ok); }
.approval.is-denied { border-left-color: var(--muted); }
.approval.is-denied .ap-result { color: var(--muted); }

.run-note, .sys-note {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
}
.run-note.is-bad { color: var(--bad); }
.sys-note { align-self: center; padding: 6px 14px; border: 1px dashed var(--line-strong); border-radius: 999px; }
.sys-note code { font-size: 12px; }

/* Composer */
.composer-wrap { padding: 4px 24px 18px; }
.composer-inner { position: relative; max-width: 800px; margin: 0 auto; padding: 0; }
.chips-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none;
  mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
}
.chips-row::after { content: ""; flex: none; width: 32px; }
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-elev); color: var(--text-2); font-size: 13px;
}
.chip:hover:not(:disabled) { border-color: var(--accent-line); color: var(--accent); }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.composer {
  border: 1px solid var(--line-strong); border-radius: 16px; background: var(--bg-elev);
  box-shadow: var(--shadow-sm); padding: 10px 10px 8px 14px;
}
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  display: block; width: 100%; min-height: 26px; max-height: 180px; padding: 2px 0; margin: 0;
  border: 0; outline: 0; resize: none; background: transparent; line-height: 1.5; font-size: 15px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:disabled { cursor: not-allowed; }
.composer-bar { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.composer-bar .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.composer-hint { margin-left: 8px; font-size: 12px; color: var(--muted); }
.send-btn {
  display: grid; place-items: center; width: 34px; height: 34px; margin-left: auto;
  border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }
.send-btn.is-stop { background: var(--text); color: var(--bg); }
.send-btn.is-stop .icon { fill: currentColor; }

.slash-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% - 38px); z-index: 5;
  display: grid; padding: 6px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--bg-elev); box-shadow: var(--shadow-lg);
}
.slash-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 13.5px; color: var(--text-2); }
.slash-item code { min-width: 84px; color: var(--accent); }
.slash-item.active, .slash-item:hover { background: var(--bg-sunk); color: var(--text); }

/* Plan panel */
.plan-panel {
  width: 300px; flex: none; overflow-y: auto; padding: 20px 18px;
  border-left: 1px solid var(--line); background: var(--bg-elev);
}
.panel-head { margin: 0 0 10px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel-head:not(:first-child) { margin-top: 26px; }
.plan-list, .mem-mini { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.plan-empty { color: var(--muted); font-size: 13px; }
.plan-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); }
.pl-state { display: inline-grid; place-items: center; width: 18px; height: 20px; flex: none; }
.pl-dot { width: 9px; height: 9px; border: 1.5px solid var(--line-strong); border-radius: 50%; }
.plan-item.is-done { color: var(--muted); }
.plan-item.is-done .pl-state { color: var(--ok); }
.plan-item.is-doing { color: var(--text); font-weight: 500; }
.plan-item.is-skipped { color: var(--muted); text-decoration: line-through; }
.plan-item code, .mem-mini code, .facts code, .task-text code { padding: 0 4px; border-radius: 4px; background: var(--bg-sunk); font-size: .85em; }
.mem-mini li { display: grid; gap: 1px; font-size: 13px; color: var(--text-2); }
.fact-kind { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.panel-link { margin-top: 12px; padding-left: 0; color: var(--accent); }

/* ---------- Terminal ---------- */
.view-terminal { background: var(--term-bg); }
.term-out {
  flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px 22px;
  color: var(--term-text); font-family: var(--font-mono); font-size: 13px; line-height: 1.65;
}
.tl { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.65em; }
.tl.strong { color: #fff; font-weight: 500; }
.tl.agent { color: #8f83ff; margin-top: 6px; }
.tl.cmdline { color: #fff; }
.tl.dir { color: #7cc4ff; }
.tl.warn { color: #f5b84b; }
.term-input-row { display: flex; align-items: baseline; gap: 8px; }
.term-prompt { color: #34d399; white-space: nowrap; }
.term-input {
  flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent;
  color: #fff; font: inherit; caret-color: #34d399;
}
.term-input:disabled { opacity: .4; }

/* ---------- Pages (memory, tasks) ---------- */
.page { flex: 1; min-width: 0; overflow-y: auto; padding: 28px 28px 40px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-family: var(--font-display); font-size: 24px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); }
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-elev); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 46px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.card-head .muted { font-size: 12.5px; }
.card-body { padding: 16px 18px; }

.mem-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.mem-side { display: grid; gap: 18px; }
.seg { display: inline-flex; margin-left: auto; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; font-size: 12.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }
.md-doc h3 { font-family: var(--font-display); font-size: 22px; margin: 0 0 8px; letter-spacing: -.02em; }
.md-doc h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }
pre.raw { margin: 0; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.facts li { display: grid; gap: 2px; padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.facts li:last-child { border-bottom: 0; }
#instr {
  display: block; width: 100%; margin: 10px 0 12px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); font-size: 13.5px; line-height: 1.55;
}
#instr:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-body .muted.small { margin: 0; }
.row-end { display: flex; justify-content: flex-end; }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.col { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-sunk); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-size: 13.5px; font-weight: 600; }
.col-head .count { background: var(--bg-elev); color: var(--text-2); border: 1px solid var(--line); }
.col-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.col-doing .col-dot { background: var(--accent); }
.col-done .col-dot { background: var(--ok); }
.col-body { display: grid; gap: 8px; padding: 0 10px 12px; }
.col-empty { margin: 0; padding: 10px 4px; font-size: 13px; color: var(--muted); }
.task-card { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); box-shadow: var(--shadow-sm); }
.task-text { font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.task-text { font-weight: 500; }
.task-src { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.task-steps { display: grid; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.task-steps li { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--text-2); }
.task-steps .pl-state { height: 18px; }
.task-steps .spinner { width: 11px; height: 11px; }
.task-steps li.is-done { color: var(--muted); }
.task-steps li.is-done .pl-state { color: var(--ok); }
.task-steps li.is-skipped { color: var(--muted); text-decoration: line-through; }

/* ---------- Files ---------- */
.files-wrap { flex: 1; min-width: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; padding: 20px; overflow: hidden; }
.tree { overflow-y: auto; padding: 8px; font-size: 13.5px; }
.tree-root { display: flex; align-items: center; gap: 8px; padding: 6px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.tree-root b { font-family: var(--font-mono); font-size: 13px; }
.tree-root .muted { margin-left: auto; font-size: 12px; }
.tree-children { display: grid; }
.tree-dir > .tree-children { padding-left: 14px; }
.tree-dir summary {
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px; border-radius: 6px;
  cursor: pointer; list-style: none; color: var(--text-2);
}
.tree-dir summary::-webkit-details-marker { display: none; }
.tree-dir summary:hover { background: var(--bg-sunk); color: var(--text); }
.tree-dir summary .icon:nth-child(2) { color: var(--accent); }
.tree-chev { transition: transform .15s; color: var(--muted); }
.tree-dir[open] > summary .tree-chev { transform: rotate(90deg); }
.tree-file {
  display: flex; align-items: center; gap: 6px; height: 30px; width: 100%; padding: 0 6px 0 27px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-2); text-align: left; font-size: 13.5px;
}
.tree-file span:not(.chg) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-file .icon { color: var(--muted); }
.tree-file:hover { background: var(--bg-sunk); color: var(--text); }
.tree-file.active { background: var(--accent-soft); color: var(--accent); }
.chg { margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.chg-A { color: var(--ok); }
.chg-M { color: var(--warn); }
.tree-skip { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 27px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.tree-skip .muted { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.viewer { display: flex; flex-direction: column; min-height: 0; }
.viewer-body { flex: 1; min-height: 0; overflow: auto; background: var(--bg-sunk); }
.viewer-note { display: flex; align-items: center; gap: 8px; margin: 0; padding: 16px; color: var(--muted); font-size: 13.5px; }

/* ---------- Onboarding dialog ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal {
  position: relative; width: 100%; max-width: 620px; max-height: calc(100dvh - 32px); overflow-y: auto;
  border: 1px solid var(--line-strong); border-radius: 20px; background: var(--bg-elev); box-shadow: var(--shadow-lg);
}
.modal-close { position: absolute; top: 12px; right: 12px; }
.stepper { display: flex; gap: 6px; margin: 0; padding: 18px 22px; list-style: none; border-bottom: 1px solid var(--line); }
.stepper li { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 13px; font-weight: 500; color: var(--muted); }
.st-n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--line-strong); font-size: 12px;
}
.stepper li.active { color: var(--text); }
.stepper li.active .st-n { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.stepper li.done { color: var(--ok); }
.stepper li.done .st-n { border-color: var(--ok); background: var(--ok-soft); }
.modal-body { padding: 24px 26px 26px; }
.modal-body h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 24px; letter-spacing: -.02em; }
.lead-sm { margin: 0 0 20px; color: var(--text-2); }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.key-field {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--muted);
}
.key-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-family: var(--font-mono); font-size: 13.5px; color: var(--text); }
.hint { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.hint .icon { margin-top: 2px; }
.pick-error { color: var(--bad); }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 22px; }
.btn.is-ok { background: var(--ok); border-color: var(--ok); color: #fff; opacity: 1; }
.btn .spinner { border-color: color-mix(in srgb, currentColor 35%, transparent); border-top-color: currentColor; }

.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px;
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--bg); text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.pick:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pick:active { transform: translateY(1px); }
.pick b { font-size: 15px; }
.pick-top { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 6px; }
.pick-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.pick-tag { font-size: 11.5px; font-weight: 600; color: var(--ok); background: var(--ok-soft); padding: 2px 8px; border-radius: 99px; }
.pick-text { font-size: 13px; color: var(--muted); line-height: 1.5; }

.build-log { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.bl-item { display: grid; grid-template-columns: 22px auto 1fr; align-items: center; gap: 10px; min-height: 36px; font-size: 14px; animation: rise .25s ease both; }
.bl-state { display: inline-grid; place-items: center; }
.bl-item.is-done .bl-state { color: var(--ok); }
.bl-label { font-weight: 500; white-space: nowrap; }
.bl-res { justify-self: end; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 8px);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: fixed; inset: auto 16px 16px; padding: 12px 16px; border-radius: 10px; background: var(--warn-soft); color: var(--text); }

/* Mobile nav (hidden on desktop) */
.mobile-nav { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .plan-panel { display: none; }
}
@media (max-width: 1100px) {
  .ctx-label { display: none; }
  .mem-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .hide-sm { display: none; }
  .composer-hint { display: none; }
  .files-wrap { grid-template-columns: 1fr; grid-template-rows: minmax(0, 38%) minmax(0, 1fr); padding: 12px; gap: 12px; }
  .board { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .sidebar { display: none; }
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 8px 12px; }
  .topbar .brand-name { display: none; }
  .project-switch { margin-left: 0; flex: 1; }
  .project-switch select { width: 100%; max-width: none; }
  .top-right { width: 100%; gap: 8px; margin-left: 0; }
  .ctx { flex: 1; min-width: 0; }
  .ctx .meter { flex: 1; width: auto; }
  .exit-link { padding: 0 8px; }
  .chat-thread { padding: 0 16px; }
  .composer-wrap { padding: 4px 12px 10px; }
  .msg-user .bubble { max-width: 88%; }
  .msg-agent .avatar { display: none; }
  .page { padding: 20px 16px 32px; }
  .term-out { padding: 14px 16px 18px; font-size: 12.5px; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--line); background: var(--bg-elev);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 56px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 500;
  }
  .mobile-nav button.active { color: var(--accent); }
  .mobile-nav .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }
  .pick-grid { grid-template-columns: 1fr; }
  .stepper { padding: 14px 16px; }
  .stepper li { font-size: 12px; gap: 6px; }
  .modal-body { padding: 20px 18px 20px; }
  .bl-item { grid-template-columns: 22px 1fr; }
  .bl-res { grid-column: 2; justify-self: start; margin-top: -8px; margin-bottom: 4px; }
}
@media (max-width: 420px) {
  .demo-badge { display: none; }
  .status-pill { padding: 0 9px; }
  .stepper li { font-size: 0; }
  .stepper li .st-n { font-size: 12px; }
  .stepper li.active { font-size: 12px; }
}
