/* Xcoder web client — dark, modern, purple-accented. */
:root {
  --bg: #0a0a0f; --bg-2: #0e0e15; --panel: #14141c; --panel-2: #1a1a24;
  --border: #24242f; --border-2: #2f2f3d;
  --text: #e9e9f0; --muted: #8b8b99; --faint: #5f5f6e;
  --accent: #8b5cf6; --accent-2: #a78bfa; --accent-soft: rgba(139,92,246,.16);
  --green: #34d399; --amber: #fbbf24; --red: #f87171; --orange: #fb923c; --blue: #60a5fa;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 10px 40px rgba(0,0,0,.5);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #16121f 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
code, .mono, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.logo-mark { font-family: ui-monospace, monospace; font-weight: 700; color: #fff; }

/* screen toggling */
body.screen-connect #app { display: none; }
body.screen-app #connect { display: none; }

/* ---------------- buttons ---------------- */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 11px 18px; font-weight: 600; transition: filter .15s, transform .05s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 13px; transition: background .15s;
}
.btn-ghost:hover { background: #22222e; }
.btn-ghost.danger { color: var(--red); border-color: rgba(248,113,113,.3); }
.btn-mini { background: var(--accent-soft); color: var(--accent-2); border: 1px solid rgba(139,92,246,.3); border-radius: 8px; padding: 4px 10px; font-weight: 600; font-size: 12.5px; }
.btn-mini:hover { background: rgba(139,92,246,.26); }
.icon-btn { background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ---------------- connect screen ---------------- */
.connect { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.connect-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 34px; box-shadow: var(--shadow); text-align: center; }
.connect-logo { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-size: 28px; box-shadow: 0 8px 24px rgba(139,92,246,.4); }
.connect-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.connect-sub { color: var(--muted); margin: 0 0 24px; }
.connect-form { text-align: left; display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.connect-form .btn-primary { margin-top: 4px; }
.connect-error { color: var(--red); font-size: 13px; min-height: 16px; }
.connect-hint { color: var(--faint); font-size: 12px; margin: 18px 0 0; }
.connect-hint code { color: var(--muted); background: var(--bg-2); padding: 1px 6px; border-radius: 5px; }

/* ---------------- app shell ---------------- */
.app { height: 100vh; display: grid; grid-template-rows: 54px 1fr; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 14px; border-bottom: 1px solid var(--border); background: rgba(14,14,21,.8); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand .logo-mark.sm { background: linear-gradient(135deg, var(--accent), var(--accent-2)); width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab { background: transparent; border: none; color: var(--muted); padding: 7px 14px; border-radius: 8px; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.conn-status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); padding: 5px 10px; border-radius: 20px; background: var(--panel); border: 1px solid var(--border); }
.conn-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.conn-status.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn-status.offline .dot { background: var(--red); }
.conn-status.connecting .dot { background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.nav-toggle { display: none; }

.app { grid-template-columns: minmax(0, 1fr); }
.view { display: none; min-height: 0; min-width: 0; }
.view.active { display: grid; }
#view-sessions { grid-template-columns: 300px minmax(0, 1fr); }
/* Let the content chain shrink below children's min-content (long code lines
   in <pre> must scroll internally, not expand the layout). */
.detail { grid-template-columns: minmax(0, 1fr); }
.content, .detail, .transcript, .tool, .tool-body, .msg, .plan, .perm { min-width: 0; }

/* ---------------- sidebar ---------------- */
.sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px; font-weight: 700; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.session-list { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.session-item { padding: 11px 12px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; margin-bottom: 4px; transition: background .12s; }
.session-item:hover { background: var(--panel); }
.session-item.active { background: var(--panel); border-color: var(--border-2); }
.si-top { display: flex; align-items: center; gap: 7px; }
.agent-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.si-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-preview { color: var(--muted); font-size: 12.5px; margin: 4px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--faint); }
.si-time { margin-left: auto; }
.chip-branch { color: var(--muted); }
.session-empty-hint { color: var(--faint); padding: 20px 12px; font-size: 13px; }

/* status badges */
.status-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .03em; }
.status-badge.ready { color: var(--green); background: rgba(52,211,153,.12); }
.status-badge.working { color: var(--blue); background: rgba(96,165,250,.14); }
.status-badge.attention { color: var(--orange); background: rgba(251,146,60,.16); }
.status-badge.error { color: var(--red); background: rgba(248,113,113,.14); }
.status-badge.stopped { color: var(--faint); background: rgba(120,120,140,.12); }
.perm-badge { background: var(--orange); color: #1a1205; font-weight: 800; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: inline-grid; place-items: center; padding: 0 5px; }

/* ---------------- content / detail ---------------- */
.content { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 40px; }
.empty .empty-art { font-family: ui-monospace, monospace; font-size: 48px; color: var(--border-2); margin-bottom: 8px; }
.empty h2 { margin: 6px 0; color: var(--text); }
.empty.small { padding: 24px; font-size: 13px; }
.empty .btn-primary { margin-top: 14px; }

.detail { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; height: 100%; }
.detail-head { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dh-row { display: flex; align-items: flex-start; gap: 12px; }
.dh-left { min-width: 0; flex: 1; }
.dh-left h2 { margin: 0 0 4px; font-size: 17px; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta .mono { color: var(--faint); overflow: hidden; text-overflow: ellipsis; max-width: 320px; white-space: nowrap; }
.dot-sep { color: var(--border-2); }
.dh-actions { display: flex; gap: 8px; flex: none; }
/* git strip */
.git-strip { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.git-branch { color: var(--accent-2); font-weight: 600; }
.git-files { color: var(--muted); }
.git-strip .ins { color: var(--green); } .git-strip .del { color: var(--red); }
.git-clean { color: var(--faint); }
.btn-revert { margin-left: auto; background: var(--panel-2); color: var(--orange); border: 1px solid rgba(251,146,60,.3); border-radius: 7px; padding: 4px 11px; font-size: 12px; font-weight: 600; }
.btn-revert:hover { background: rgba(251,146,60,.14); }
/* file chips + clickable paths */
.tool-locs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 13px 10px; }
.file-chip, .diff-path { font-family: ui-monospace, monospace; font-size: 11.5px; }
.file-chip { background: var(--bg-2); border: 1px solid var(--border); color: var(--accent-2); border-radius: 6px; padding: 3px 8px; }
.file-chip:hover { border-color: var(--accent); }
button.diff-path { width: 100%; text-align: left; background: var(--bg-2); border: none; border-bottom: 1px solid var(--border); color: var(--muted); padding: 6px 10px; cursor: pointer; }
button.diff-path:hover { color: var(--accent-2); }
/* file viewer */
.file-modal { width: min(860px, 100%); height: 82vh; }
.file-body { padding: 0; flex: 1; }
.file-content { margin: 0; padding: 14px 0; font-family: ui-monospace, monospace; font-size: 12.5px; line-height: 1.55; white-space: pre; overflow: auto; height: 100%; }
.file-content .ln { display: inline-block; width: 3em; padding-right: 14px; margin-right: 12px; text-align: right; color: var(--faint); border-right: 1px solid var(--border); user-select: none; }
.file-loading { color: var(--muted); padding: 16px; }

/* ---------------- transcript ---------------- */
.transcript { overflow-y: auto; padding: 20px 18px 28px; display: flex; flex-direction: column; gap: 14px; }
/* Prevent flex-column from crushing items with overflow:hidden (min-height:auto -> 0). */
.transcript > * { flex: 0 0 auto; }
.msg { max-width: min(760px, 100%); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; padding: 9px 14px; border-radius: 16px 16px 4px 16px; }
.msg.user .bubble :first-child { margin-top: 0; } .msg.user .bubble :last-child { margin-bottom: 0; }
.msg.assistant { align-self: flex-start; color: var(--text); }
.msg.assistant p:first-child { margin-top: 0; }
.msg.error { align-self: stretch; color: var(--red); background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.25); padding: 10px 14px; border-radius: 10px; }
.msg pre, .tool-output { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; }
.msg code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.msg pre code { background: none; padding: 0; }
/* fenced code (highlight.js) */
.code-block { background: var(--bg-2) !important; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; margin: 8px 0; }
.code-block code.hljs { background: none; padding: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
/* GFM tables */
.msg table, .markdown table { border-collapse: collapse; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; max-width: 100%; }
.msg th, .msg td, .markdown th, .markdown td { border: 1px solid var(--border-2); padding: 6px 11px; text-align: left; }
.msg th, .markdown th { background: var(--panel-2); font-weight: 700; }
.msg tr:nth-child(2n), .markdown tr:nth-child(2n) { background: var(--panel); }
.msg blockquote { border-left: 3px solid var(--border-2); margin: 8px 0; padding: 2px 12px; color: var(--muted); }
/* mermaid diagrams */
.mermaid-block { display: flex; justify-content: center; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 10px 0; overflow-x: auto; }
.mermaid-block svg { max-width: 100%; height: auto; }
.mermaid-fallback { background: none !important; border: none !important; color: var(--muted); margin: 0; }

/* ---------------- live terminal pane ---------------- */
.terminal-pane { display: flex; flex-direction: column; min-height: 0; height: 340px; border-top: 1px solid var(--border); background: #0d0f14; }
.terminal-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--bg-2); border-bottom: 1px solid var(--border); font-size: 12px; }
.terminal-title { color: var(--accent-2); font-weight: 700; }
.terminal-cwd { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.terminal-spacer { flex: 1; }
.terminal-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.terminal-btn:hover { color: var(--text); }
.terminal-body { flex: 1; min-height: 0; padding: 6px 4px 6px 8px; overflow: hidden; }
.terminal-body .xterm { height: 100%; }
.terminal-missing { color: var(--muted); padding: 14px; font-size: 13px; }
.btn-ghost.on { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent); }

/* ---------------- files pane ---------------- */
#view-sessions.files-open { grid-template-columns: 300px minmax(0, 1fr) 300px; }
.files-pane { border-left: 1px solid var(--border); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }
.files-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-size: 13px; }
.files-title { color: var(--text); font-weight: 700; }
.files-spacer { flex: 1; }
.files-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 7px; border-radius: 6px; }
.files-btn:hover { color: var(--text); background: var(--panel); }
.files-cwd { padding: 0 14px 8px; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.file-row:hover { background: var(--panel); }
.fr-ico { flex: none; }
.fr-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-size { color: var(--faint); font-size: 11px; }
.fr-dl { background: none; border: none; color: var(--muted); cursor: pointer; opacity: 0; padding: 0 4px; font-size: 13px; }
.file-row:hover .fr-dl { opacity: 1; }
.fr-dl:hover { color: var(--accent-2); }
.file-row.up { color: var(--muted); }
.files-drop { display: block; margin: 8px 12px 10px; padding: 14px; border: 1.5px dashed var(--border-2); border-radius: 10px; text-align: center; color: var(--faint); font-size: 12px; cursor: pointer; }
.files-drop.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.files-status { padding: 0 14px 12px; font-size: 12px; color: var(--muted); min-height: 16px; }
.files-status.err { color: var(--red); }
.files-loading, .files-empty { color: var(--faint); padding: 12px; font-size: 13px; }

.thinking { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 4px 12px; max-width: 760px; color: var(--muted); }
.thinking summary { cursor: pointer; padding: 6px 0; font-size: 13px; color: var(--muted); }
.thinking-body { font-size: 13px; padding: 4px 0 8px; color: var(--muted); }

#transcript.hide-tools .tool { display: none; }
.tool { align-self: flex-start; width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tool-head { display: flex; align-items: center; gap: 9px; padding: 10px 13px; }
.tool-title { flex: 1; font-weight: 600; font-size: 13.5px; }
.tool-status { font-weight: 800; }
.tool-status.done { color: var(--green); } .tool-status.fail { color: var(--red); } .tool-status.run { color: var(--blue); }
.tool-body { border-top: 1px solid var(--border); padding: 10px 13px; display: grid; gap: 8px; }
.tool-output { margin: 0; max-height: 320px; }
.diff { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 12.5px; }
.diff-path { background: var(--bg-2); padding: 6px 10px; color: var(--muted); border-bottom: 1px solid var(--border); }
.dl { padding: 1px 10px; white-space: pre-wrap; font-family: ui-monospace, monospace; }
.dl.add { background: rgba(52,211,153,.1); color: #86efac; }
.dl.del { background: rgba(248,113,113,.09); color: #fca5a5; }

.plan { align-self: flex-start; width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.plan-head { font-weight: 700; font-size: 13px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.plan-count { color: var(--muted); font-weight: 600; }
.plan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.plan-row { display: flex; gap: 9px; font-size: 13.5px; }
.plan-row .plan-ico { width: 16px; color: var(--muted); }
.plan-row.completed { color: var(--muted); text-decoration: line-through; }
.plan-row.completed .plan-ico { color: var(--green); }
.plan-row.in_progress .plan-ico { color: var(--blue); }

.perm { align-self: stretch; max-width: 760px; width: 100%; background: rgba(251,146,60,.07); border: 1px solid rgba(251,146,60,.3); border-radius: 12px; padding: 13px 15px; }
.perm-head { font-weight: 700; color: var(--orange); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.perm-title { font-weight: 600; margin: 5px 0 8px; }
.perm-body { margin-bottom: 10px; }
.perm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-perm { border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.btn-perm.go { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-perm.danger { background: var(--panel-2); color: var(--red); border: 1px solid rgba(248,113,113,.3); }
.perm.resolved { background: var(--panel); border-color: var(--border); color: var(--muted); }
.perm.resolved.denied { color: var(--red); }

.typing { align-self: flex-start; display: flex; gap: 4px; padding: 8px 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------------- composer ---------------- */
#composer-wrap { border-top: 1px solid var(--border); background: var(--bg-2); }
.pills-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 16px 0; }
.pills-bar:empty { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 3px 6px 3px 11px; font-size: 12px; }
.pill-k { color: var(--faint); text-transform: uppercase; letter-spacing: .03em; font-size: 10.5px; }
.pill-sel { background: transparent; border: none; color: var(--accent-2); font-weight: 600; outline: none; cursor: pointer; padding: 2px; border-radius: 6px; }
.pill-sel option { background: var(--panel-2); color: var(--text); }
.composer { padding: 12px 16px 16px; position: relative; }
.composer-inner { display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 8px 8px 8px 14px; transition: border-color .15s; }
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#prompt-input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); resize: none; font: inherit; line-height: 1.45; max-height: 160px; padding: 4px 0; }
.send-btn { flex: none; width: 34px; height: 34px; border-radius: 10px; border: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 17px; font-weight: 700; display: grid; place-items: center; }
.send-btn:hover { filter: brightness(1.1); }
.slash-menu { position: absolute; bottom: 100%; left: 16px; right: 16px; margin-bottom: 6px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; z-index: 10; }
.slash-item { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 9px 13px; }
.slash-item:hover, .slash-item:focus { background: var(--accent-soft); }
.slash-name { color: var(--accent-2); font-weight: 600; font-family: ui-monospace, monospace; }
.slash-desc { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-list { margin-bottom: 8px; display: grid; gap: 5px; }
.queue-head { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.queue-item { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px dashed var(--border-2); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; color: var(--muted); }
.queue-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-del { background: none; border: none; color: var(--faint); }
.queue-del:hover { color: var(--red); }

/* ---------------- dashboard ---------------- */
.dashboard { padding: 20px 22px; overflow-y: auto; }
.dashboard-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.dashboard-head h2 { margin: 0; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.dash-card { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px; padding: 14px; cursor: pointer; transition: transform .1s, border-color .15s; }
.dash-card:hover { transform: translateY(-2px); border-color: var(--border-2); }
.dash-card.working { border-left-color: var(--blue); }
.dash-card.attention { border-left-color: var(--orange); box-shadow: 0 0 0 1px rgba(251,146,60,.25); }
.dc-head { display: flex; align-items: center; gap: 8px; }
.dc-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-status { margin: 8px 0; }
.dc-preview { color: var(--muted); font-size: 12.5px; height: 36px; overflow: hidden; }
.dc-meta { color: var(--faint); font-size: 11.5px; margin-top: 8px; }

/* ---------------- modal ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { width: min(560px, 100%); max-height: 88vh; overflow: hidden; background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: grid; gap: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.form-error { color: var(--red); font-size: 13px; min-height: 16px; }
.agent-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.agent-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 3px; text-align: left; color: var(--text); transition: border-color .15s; }
.agent-card:hover { border-color: var(--border-2); }
.agent-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.agent-card.unavailable { opacity: .45; cursor: not-allowed; }
.ac-dot { width: 10px; height: 10px; border-radius: 50%; }
.ac-name { font-weight: 600; }
.ac-sub { color: var(--faint); font-size: 11.5px; }
.folder-browser { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.folder-cwd { background: var(--bg-2); padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); overflow-x: auto; white-space: nowrap; }
.folder-list { list-style: none; margin: 0; padding: 6px; max-height: 240px; overflow-y: auto; }
.folder-row { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.folder-row:hover { background: var(--panel-2); }
.folder-row.up { color: var(--muted); }
.git-tag { margin-left: auto; font-size: 10px; color: var(--accent-2); background: var(--accent-soft); padding: 1px 6px; border-radius: 5px; }
.folder-empty, .folder-loading { color: var(--faint); padding: 12px; font-size: 13px; }
.field em { color: var(--faint); font-style: normal; font-weight: 400; }
.continue-list { display: grid; gap: 6px; }
.continue-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; text-align: left; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; color: var(--text); }
.continue-row:hover { border-color: var(--accent); }
.cr-title { font-weight: 600; font-size: 13px; }
.cr-cwd { grid-column: 1; color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-go { grid-row: 1 / span 2; grid-column: 2; color: var(--accent-2); font-weight: 600; font-size: 12px; }
.continue-loading, .continue-none { color: var(--faint); font-size: 12.5px; padding: 8px 2px; }

/* ---------------- toast + scrim ---------------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text); padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 100; }
.toast.error { border-color: rgba(248,113,113,.5); color: #fecaca; }
.toast.ok { border-color: rgba(52,211,153,.5); color: #bbf7d0; }
.scrim { display: none; }

/* ---------------- responsive ---------------- */
@media (max-width: 760px) {
  .tabs { margin-left: 0; }
  .conn-label { display: none; }
  .brand { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .nav-toggle { display: grid; }
  #view-sessions { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: 54px; bottom: 0; left: 0; width: 84%; max-width: 320px; z-index: 40; transform: translateX(-105%); transition: transform .2s; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; position: fixed; inset: 54px 0 0 0; background: rgba(0,0,0,.5); z-index: 30; }
  .meta .mono { max-width: 140px; }
  .dh-row { flex-wrap: wrap; }
  .dh-actions { flex-wrap: wrap; }
  .dh-actions .btn-ghost { padding: 6px 10px; font-size: 12.5px; }
  .git-strip { flex-wrap: wrap; gap: 8px; }
  .btn-revert { margin-left: 0; }
  .transcript { padding: 14px 12px 20px; }
  .tool, .plan, .perm, .thinking { max-width: 100%; }
  .dashboard { padding: 16px 14px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
