/* Layout and app components. Tokens and shared components live in theme.css. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 13px/1.5 var(--sans); }
button, select, input, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.grow { flex: 1; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-columns: 240px minmax(0, 1fr) 360px; height: 100vh; }

/* Sidebar */
#side { border-right: 1px solid var(--line2); display: flex; flex-direction: column; background: var(--side); min-width: 0; }
.side-top { display: flex; align-items: center; gap: 2px; padding: 12px 10px 6px 14px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; flex: 1; font-size: 17px; letter-spacing: -0.01em; }
.brand .logo { flex: none; }
.side-filter { display: flex; align-items: center; gap: 4px; margin: 4px 10px 6px; }
.side-filter input { flex: 1; min-width: 0; height: 26px; border: 1px solid transparent; background: var(--side-hover); border-radius: var(--r-sm); padding: 0 8px; font-size: 12.5px; outline: 0; }
.side-filter input:focus { border-color: var(--line2); background: var(--bg); }
.side-filter input::placeholder { color: var(--dim); }
#groupBtn[aria-pressed="true"] { color: var(--accent); background: var(--accent-bg); }
#side .iconbtn:hover { background: var(--side-hover); }
#threads { flex: 1; overflow: auto; padding: 2px 6px 6px; }
.proj { padding: 2px 0 8px; }
.proj.dragging { opacity: 0.4; }
.proj-h { display: flex; align-items: center; position: relative; }
.proj-n { all: unset; flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px; border-radius: var(--r-sm); cursor: pointer; font-weight: 550; font-size: 13px; }
.proj-n.repo { cursor: default; font-weight: 500; color: var(--muted); font-size: 12px; }
.proj-n .pmark { display: inline-grid; color: var(--dim); }
.proj-n .pmark .ic { width: 14px; height: 14px; }
.proj-n .tt, .thread .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.proj-n:hover { background: var(--side-hover); }
.proj-n[aria-current="true"] { background: var(--side-sel); }
.proj-h .padd { margin-right: 4px; opacity: 0; }
.proj-h:hover .padd, .proj-h .padd:focus-visible { opacity: 1; }
.proj-h:hover .proj-n > .dot { visibility: hidden; }
.thread { all: unset; display: flex; align-items: center; gap: 8px; height: 26px; padding: 0 8px 0 15px; border-radius: var(--r-sm); cursor: pointer; width: 100%; box-sizing: border-box; font-size: 12px; color: #4f4c46; }
.thread:hover { background: var(--side-hover); }
.thread[aria-current="true"] { background: var(--side-sel); color: var(--fg); }
.thread .ptag { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; flex: none; }
.fold { all: unset; display: flex; align-items: center; gap: 8px; height: 26px; padding: 0 8px 0 15px; font-size: 12px; color: var(--muted); cursor: pointer; border-radius: var(--r-sm); box-sizing: border-box; width: 100%; }
.fold:hover { color: var(--fg); background: var(--side-hover); }
.fold .dot.none { background: none; }
.thread .t { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread .t span { overflow: hidden; text-overflow: ellipsis; }
.thread .s { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.side-bottom { border-top: 1px solid var(--line); padding: 8px; display: grid; gap: 2px; }
.link { all: unset; cursor: pointer; padding: 6px 8px; border-radius: 6px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.link:hover { background: var(--bg3); color: var(--fg); }
.link:disabled { opacity: 0.4; cursor: default; background: none; color: var(--muted); }
.count { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.link .count:not(:empty) { background: var(--bg3); padding: 0 6px; border-radius: 9px; }


.btn:focus-visible, .thread:focus-visible, .link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Main */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 49px; }
.bar-title { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; overflow: hidden; white-space: nowrap; }
#title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
#cwd { flex: none; display: inline-flex; align-items: center; }
.envchip { display: inline-flex; align-items: center; gap: 5px; font-family: var(--sans); font-size: 12px; line-height: 18px; color: var(--muted); border: 1px solid var(--line2); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.envchip .ic { width: 12px; height: 12px; }
.envchip span:last-child { overflow: hidden; text-overflow: ellipsis; }
.envchip.failed { color: var(--bad); border-color: var(--stuck-ring); }
.envopt { display: flex; gap: 10px; align-items: flex-start; }
.envopt .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--muted); }
.radio label.off { opacity: 0.5; cursor: not-allowed; }
.bar-right { display: flex; align-items: center; gap: 10px; }
select { background: var(--bg3); border: 1px solid var(--line2); border-radius: 6px; padding: 3px 6px; font-size: 12px; max-width: 220px; }

#scroll { flex: 1; overflow: auto; }
#log { max-width: 780px; margin: 0 auto; padding: 20px 20px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.empty { color: var(--muted); padding: 60px 0; display: grid; gap: 10px; justify-items: start; }
.empty h2 { color: var(--fg); font-size: 15px; font-weight: 500; margin: 0; }

.msg-user { justify-self: end; max-width: 85%; background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; word-break: break-word; }
.msg-assistant { word-break: break-word; }
.msg-assistant > :first-child { margin-top: 0; } .msg-assistant > :last-child { margin-bottom: 0; }
.thinking { color: var(--muted); font-size: 12px; border-left: 2px solid var(--line2); padding-left: 10px; white-space: pre-wrap; max-height: 120px; overflow: auto; }
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; } .md li > ul, .md li > ol { margin: 2px 0; }
.md li { margin: 2px 0; } .md li::marker { color: var(--dim); }
.md li.task { list-style: none; margin-left: -18px; display: flex; gap: 8px; align-items: baseline; }
.md .tick { flex: none; width: 13px; height: 13px; border: 1px solid var(--line2); border-radius: 3px; display: inline-grid; place-items: center; position: relative; top: 2px; }
.md .tick.on { background: var(--ok); border-color: var(--ok); color: #fff; } .md .tick .ic { width: 10px; height: 10px; stroke-width: 3; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 600; margin: 14px 0 6px; line-height: 1.3; }
.md h1 { font-size: 17px; } .md h2 { font-size: 15px; } .md h3 { font-size: 13.5px; } .md h4 { font-size: 13px; color: var(--muted); }
.md :not(pre) > code { font-family: var(--mono); font-size: 0.92em; background: var(--bg3); border: 1px solid var(--line); padding: 0 4px; border-radius: 4px; }
.md a { color: var(--accent); text-decoration: none; } .md a:hover { text-decoration: underline; }
.md blockquote { margin: 0 0 8px; padding: 2px 12px; border-left: 3px solid var(--line2); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md img { max-width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.md del { color: var(--dim); }
.md .tbl { overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 6px; }
.md table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md th, .md td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { background: var(--bg3); font-weight: 500; color: var(--muted); } .md tr:last-child td { border-bottom: 0; }
.md .code { margin: 0 0 10px; }
.md.doc { font-size: 13.5px; line-height: 1.6; max-width: 76ch; }

/* Code and text blocks */
.code { border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); overflow: hidden; }
.code-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 2px 10px; font: 11px/22px var(--sans); color: var(--dim); border-bottom: 1px solid var(--line); min-height: 26px; }
.code pre { margin: 0; padding: 10px 12px; overflow: auto; font: 12px/1.55 var(--mono); color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }

/* Media */
figure.media { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg2); }
.media .stage { display: grid; place-items: center; min-height: 80px; }
.media .stage.checker { background-color: #f3f2ee; background-image: linear-gradient(45deg, #e9e7e2 25%, transparent 25%, transparent 75%, #e9e7e2 75%), linear-gradient(45deg, #e9e7e2 25%, transparent 25%, transparent 75%, #e9e7e2 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; cursor: zoom-in; }
.media .stage.dark { background: #000; }
.media .stage.audio { padding: 14px; }
.media img, .media video { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; }
.media video { width: 100%; }
.media audio { width: 100%; }
.media .pdf { display: block; width: 100%; height: 70vh; border: 0; background: #fff; }
.media figcaption { display: flex; align-items: center; gap: 10px; padding: 3px 4px 3px 10px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.media .dims { color: var(--dim); }

.linkcard { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); color: var(--fg); text-decoration: none; }
.linkcard:hover { border-color: var(--line2); background: var(--bg3); }
.linkcard .li { width: 32px; height: 32px; border-radius: 7px; background: var(--bg3); border: 1px solid var(--line); display: grid; place-items: center; flex: none; }
.linkcard .lt { flex: 1; min-width: 0; display: grid; }
.linkcard .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.linkcard .d { font-size: 11.5px; color: var(--muted); }
.linkcard > .ic { color: var(--dim); }
.linkcard .li .ic { width: 16px; height: 16px; }
.filecard { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); }
.filecard > .ic { width: 22px; height: 22px; color: var(--muted); }
.filecard .lt { flex: 1; min-width: 0; display: grid; font-size: 12px; }
.filecard .btn { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; color: var(--fg); }

.tool { min-width: 0; }
.tool > summary { list-style: none; cursor: pointer; display: flex; gap: 8px; align-items: center; padding: 1px 0; font-size: 12px; min-width: 0; color: var(--muted); }
.tool > summary::-webkit-details-marker { display: none; }
.tool > summary:hover { color: var(--fg); }
.tool .name { font-family: var(--mono); flex: none; color: var(--muted); }
.tool > summary:hover .name { color: var(--fg); }
.tool .arg { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; color: var(--dim); }
.tool > summary:hover .arg { color: var(--muted); }
.tool .st { flex: none; font-size: 11px; color: var(--dim); }
.tool.err .st, .tool.err .name { color: var(--bad); }
.tool.wf .name { color: var(--accent); }
.tool pre { margin: 6px 0 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); font: 11.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; color: var(--ink2); }
.tool + .tool { margin-top: -10px; }
.event { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.event::before, .event::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.event b { font-weight: 500; color: var(--fg); }
.event.approved b { color: var(--ok); } .event.rejected b { color: var(--bad); } .event.moved b { color: var(--accent); }

/* Dock */
#dock { padding: 6px 16px 16px; }
#dock > * { max-width: 780px; margin-left: auto; margin-right: auto; }
#banner:empty { display: none; }
#banner { margin-bottom: 10px; }
.ready { border: 1px solid var(--dim); background: var(--bg2); border-radius: 10px; padding: 8px 8px 8px 12px; display: flex; align-items: center; gap: 10px; }
.rv-art { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.rv-h { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg3); }
.rv-b { padding: 12px; font-size: 13px; }

.rv-f { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 8px; }
.rv-f textarea { background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; resize: vertical; font-size: 13px; }
.rv-f .row { display: flex; gap: 8px; align-items: center; }
.fail { border: 1px solid var(--stuck-ring); background: var(--stuck-bg); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.fail .grow { color: var(--muted); }

#composer { border: 1px solid var(--line2); border-radius: 12px; background: var(--bg2); padding: 12px 14px 10px; }
#composer:focus-within { border-color: var(--dim); }
#input { width: 100%; border: 0; background: none; resize: none; outline: none; max-height: 260px; padding: 2px 0 6px; font-size: 14px; line-height: 1.5; min-height: 48px; }
.composer-row { display: flex; gap: 6px; align-items: center; font-size: 12px; }
/* The model picker reads as quiet text next to Send; it only looks interactive on hover. */
.modelpick { position: relative; display: inline-flex; align-items: center; gap: 2px; color: var(--dim); border-radius: 6px; padding: 2px 4px 2px 6px; margin-left: -6px; cursor: pointer; min-width: 0; }
.modelpick:hover, .modelpick:focus-within { color: var(--fg); background: var(--bg3); }
.modelpick select { appearance: none; -webkit-appearance: none; background: transparent; border: 0; padding: 0; margin: 0; font-size: 12px; color: inherit; max-width: 200px; cursor: pointer; outline: none; text-overflow: ellipsis; }
.modelpick select:disabled { cursor: default; }
.modelpick:has(select:disabled) { display: none; }
.modelpick .ic { width: 12px; height: 12px; pointer-events: none; }
.modelpick option, .modelpick optgroup { background: var(--bg2); color: var(--fg); }


/* Panel */
#panel { border-left: 1px solid var(--line2); background: var(--side); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel-h { padding: 14px 14px 0; font-size: 12px; color: var(--muted); }
.tabpane { flex: 1; overflow: auto; padding: 14px; }

.wf-head { display: grid; gap: 2px; margin-bottom: 14px; }
.wf-head .name { font-weight: 500; display: flex; gap: 8px; align-items: center; }
.wf-head .goal { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 9px; border: 1px solid var(--line2); color: var(--muted); }
.badge.active { color: var(--accent); border-color: var(--accent-line); }
.badge.awaiting_approval { color: var(--yours-ink); border-color: var(--yours-line); }
.badge.done { color: var(--ok); border-color: rgba(63, 138, 90, 0.35); }

.graph { position: relative; display: grid; }
.node { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 0 10px; align-items: start; padding: 6px 6px 14px; border-radius: 8px; position: relative; }
.node .ring { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line2); display: grid; place-items: center; font-size: 11px; color: var(--muted); background: var(--bg2); position: relative; z-index: 1; }
.node::before { content: ""; position: absolute; left: 16.5px; top: 30px; bottom: -6px; width: 1.5px; background: var(--line2); }
.node:last-child::before { display: none; }
.node.past::before { background: var(--ok); }
.node.past .ring { border-color: var(--ok); color: var(--ok); }
.node.current .ring { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); }
.node.current.wait .ring { border-color: var(--yours); color: var(--yours-ink); box-shadow: 0 0 0 4px var(--yours-bg); }
.node.done-all .ring { border-color: var(--ok); background: var(--ok); color: #fff; }
.node .nt { display: flex; gap: 6px; align-items: center; min-width: 0; }
.node .nt span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node.current .nt { font-weight: 500; }
.node:not(.current):not(.past) .nt { color: var(--muted); }
.node .meta { grid-column: 2 / 4; font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 2px; }
.node .meta .req.ok { color: var(--ok); }
.exit { grid-column: 2 / 4; margin-top: 6px; display: grid; gap: 3px; }
.chk { display: flex; gap: 6px; align-items: center; font-size: 12px; min-width: 0; }
.chk .why { color: var(--muted); }
.chk.miss { color: var(--warn); } .chk.ok > .ic, .chk.ok > .mono { color: var(--ok); }
.chk.wait { color: var(--fg); }
.art-link { all: unset; cursor: pointer; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 2px; }
.art-link:hover { color: var(--fg); text-decoration-color: var(--fg); }
.ic { width: 13px; height: 13px; flex: none; }
.req { display: inline-flex; align-items: center; gap: 3px; }
.req.ok { color: var(--ok); }
[data-tip] { cursor: default; }
#tip { position: fixed; z-index: 20; max-width: 260px; background: var(--bg3); border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; font-size: 12px; color: var(--fg); white-space: pre-line; pointer-events: none; box-shadow: var(--shadow-float); }
.gatec { display: inline-flex; color: var(--muted); padding-top: 3px; }
.steps .gatec { padding: 0 0 0 3px; vertical-align: -2px; }
.node .visits { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.node .loop { color: var(--muted); }

.hist { display: grid; gap: 4px; font-size: 12px; }
.hist div { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; color: var(--muted); }

.art { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 8px; overflow: hidden; }
.art .ah { display: flex; gap: 8px; align-items: center; padding: 8px 10px; cursor: pointer; }
.art .ah:hover { background: var(--bg3); }
.art .ah .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art .body { border-top: 1px solid var(--line); padding: 10px; max-height: 340px; overflow: auto; }
.art .body .md.doc { font-size: 12.5px; }
.art .body .media img, .art .body .media video { max-height: 220px; }
.art .body .media .pdf { height: 260px; }
.art .kind { display: grid; place-items: center; color: var(--muted); }
.group-h { font-size: 11px; color: var(--muted); margin: 14px 0 6px; display: flex; justify-content: space-between; }
.dlg-b > div:first-child .group-h { margin-top: 0; }

.start { display: grid; gap: 10px; }
.wfcard { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 6px; background: var(--bg); }
.wfcard .row { display: flex; gap: 8px; align-items: center; }
.wfcard .row .n { font-weight: 500; flex: 1; }
.steps { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 11.5px; color: var(--muted); }
.steps .arrow { color: var(--dim); }

/* Dialogs */
dialog { background: var(--bg2); color: var(--fg); border: 1px solid var(--line2); border-radius: 12px; padding: 0; width: min(560px, 92vw); max-height: 86vh; box-shadow: 0 24px 60px -12px rgba(40, 36, 28, 0.3); }
dialog::backdrop { background: rgba(40, 36, 28, 0.28); }
#viewer { width: min(960px, 94vw); }
/* Header and the review form stay put; only the artifacts scroll. */
#viewerBody { display: flex; flex-direction: column; max-height: 86vh; }
#viewerBody .dlg-b { flex: 1; min-height: 0; max-height: none; align-content: start; grid-auto-rows: max-content; }
.dlg-h { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 10px; }
.dlg-h .t { flex: 1; font-weight: 500; }
.dlg-b { padding: 16px; display: grid; gap: 12px; overflow: auto; max-height: calc(86vh - 110px); }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea { background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; max-width: none; font-size: 13px; }
.radio { display: grid; gap: 6px; }
.radio label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.radio label:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }
.radio .d { font-size: 12px; color: var(--muted); }
.subs { display: grid; gap: 10px; }
.sub { border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); transition: border-color 0.15s; }
.sub.on { border-color: rgba(63, 138, 90, 0.35); }
.sub-h { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.sub-h .nm { font-weight: 500; }
.sub-h .muted { font-size: 12px; }
.sub .mark { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--bg3); border: 1px solid var(--line2); font-weight: 600; color: var(--fg); flex: none; }
.sub-ok { display: inline-flex; align-items: center; gap: 5px; color: var(--ok); font-size: 12px; }
.flow-b { border-top: 1px solid var(--line); padding: 12px 14px; display: grid; gap: 10px; font-size: 12px; }
.flow-step { display: flex; align-items: center; gap: 10px; }
.flow-step .k { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line2); display: grid; place-items: center; font-size: 11px; color: var(--muted); flex: none; }
.flow-step input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 8px; }
.flow-step input:focus { outline: none; border-color: var(--accent); }
.flow-step a.btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--fg); }
.usercode { font-size: 16px; letter-spacing: 0.12em; color: var(--fg); background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 3px 10px; }
.flow-wait { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.flow-err { display: flex; align-items: center; gap: 8px; color: var(--bad); word-break: break-word; }

#onboard { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: grid; place-items: center; padding: 24px; overflow: auto; }
.ob { width: min(820px, 100%); display: grid; grid-template-columns: 200px minmax(0, 1fr); border: 1px solid var(--line2); border-radius: 14px; background: var(--bg2); overflow: hidden; box-shadow: 0 30px 80px -20px rgba(40, 36, 28, 0.25); }
.ob-side { padding: 28px 22px; border-right: 1px solid var(--line); background: var(--bg); display: grid; align-content: start; gap: 28px; }
.ob-side .brand { font-size: 17px; font-weight: 600; }
.ob-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; position: relative; }
.ob-steps li { display: flex; gap: 10px; align-items: flex-start; color: var(--dim); }
.ob-steps li .num { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line2); display: grid; place-items: center; font-size: 11px; flex: none; }
.ob-steps li .muted { font-size: 12px; }
.ob-steps li.cur { color: var(--fg); }
.ob-steps li.cur .num { border-color: var(--fg); color: var(--fg); }
.ob-steps li.done { color: var(--muted); }
.ob-steps li.done .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.ob-steps li.done .num .ic { width: 12px; height: 12px; stroke-width: 3; }
.ob-main { padding: 32px 32px 26px; display: grid; gap: 14px; align-content: start; }
.ob-main h1 { margin: 0; font-size: 20px; font-weight: 600; }
.ob-main p { margin: 0 0 6px; }
.ob-main .sub-h { padding: 16px; }
.ob-main .sub .mark { width: 38px; height: 38px; font-size: 15px; }
.ob-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 820px) {
  #onboard { place-items: start stretch; padding: 16px; }
  .ob { grid-template-columns: 1fr; }
  .ob-side { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px; gap: 14px; }
  .ob-steps { display: flex; gap: 14px; flex-wrap: wrap; }
  .ob-main { padding: 20px 18px; }
}

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--bad); color: var(--fg); border-radius: 8px; padding: 8px 14px; font-size: 12px; z-index: 10; max-width: 80vw; }

@media (max-width: 1100px) { #app { grid-template-columns: 200px minmax(0, 1fr) 300px; } }
.mob, #scrim { display: none; }
/* Phones: the chat fills the screen; threads slide in from the left, the workflow from the right. */
@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); height: 100dvh; }
  .mob { display: inline-grid; }
  .mob .ic { width: 18px; height: 18px; }
  .iconbtn.mob { width: 34px; height: 34px; position: relative; }
  #flowBtn .badge-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--yours); }
  #side, #panel { position: fixed; top: 0; bottom: 0; z-index: 30; width: min(320px, 86vw); transition: transform 0.2s ease; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  #side { left: 0; transform: translateX(-100%); }
  #panel { right: 0; transform: translateX(100%); overflow: auto; }
  body.side-open #side, body.panel-open #panel { transform: none; box-shadow: 0 0 40px rgba(40, 36, 28, 0.25); }
  #scrim { position: fixed; inset: 0; z-index: 25; background: rgba(40, 36, 28, 0.3); }
  body.side-open #scrim, body.panel-open #scrim { display: block; }
  #bar { padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); gap: 6px; min-height: 48px; }
  #title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
  #cwd, #cost { display: none; }
  #log { padding: 14px 14px 24px; }
  #dock { padding: 4px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #input { font-size: 16px; min-height: 40px; }
  dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 14px 14px 0 0; }
  #viewer { width: 100vw; }
}
@media (max-width: 820px) and (prefers-reduced-motion: reduce) { #side, #panel { transition: none; } }


/* Repository */
.repochip { text-decoration: none; }
.repochip:hover { color: var(--fg); border-color: var(--dim); }
.repochip .br { display: inline-flex; align-items: center; gap: 3px; color: var(--dim); }
.repochip.warn { border-color: var(--yours-line); } .repochip.warn > .ic:last-child { color: var(--warn); }
#cwd { gap: 6px; }
.field label .as { color: var(--dim); margin-left: 4px; }
.link.sm { display: inline; padding: 0; font-size: 12px; margin-left: 8px; color: var(--muted); }
.repopick { border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; background: var(--bg); }
.rsearch { display: flex; align-items: center; gap: 8px; padding: 0 10px; border-bottom: 1px solid var(--line); color: var(--dim); }
.rsearch input { flex: 1; background: transparent; border: 0; outline: 0; padding: 8px 0; font-size: 13px; }
.rlist { max-height: 196px; overflow: auto; padding: 4px; }
.rlist .pad { padding: 8px; font-size: 12px; }
label.repo { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }
label.repo:hover { background: var(--bg3); }
label.repo:has(input:checked) { background: var(--accent-bg); color: var(--fg); }
label.repo input { position: absolute; opacity: 0; pointer-events: none; }
label.repo .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
label.repo .d { font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.ghcode { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line2); border-radius: 8px; padding: 6px 8px 6px 12px; background: var(--bg); min-height: 44px; }
.ghcode .code { font-size: 18px; letter-spacing: 0.08em; color: var(--fg); }
.ghcode .btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.ghcode .link.sm { margin-left: 0; }

/* Threads: archive */
.trow { position: relative; }
.trow .tarch { position: absolute; top: 1px; right: 4px; opacity: 0; }
.trow:hover .tarch, .trow .tarch:focus-visible { opacity: 1; }
.trow:hover .thread { padding-right: 30px; }
.archived-h { all: unset; display: flex; align-items: center; gap: 6px; width: 100%; box-sizing: border-box; padding: 10px 10px 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.archived-h:hover { color: var(--fg); }
.archived .thread { opacity: 0.7; }

/* Account */
.me { margin-top: 4px; }
.me img, .me .ph { width: 20px; height: 20px; border-radius: 50%; flex: none; }
.me .ph { display: grid; place-items: center; background: var(--bg3); font-size: 11px; }
.signin { min-height: 100vh; display: grid; place-items: center; }
.signin .card { width: min(380px, 90vw); display: grid; gap: 14px; justify-items: center; text-align: center; padding: 32px 28px; border: 1px solid var(--line2); border-radius: 12px; background: var(--bg2); }
.signin .brand { font-size: 22px; font-weight: 600; flex: none; }
.signin .brand .logo { width: 26px; height: 26px; }
.signin .err { color: var(--bad); font-size: 12px; }
.btn.big { text-decoration: none; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; font-size: 14px; }
.btn.big .ic { width: 16px; height: 16px; }
.profile .who { display: flex; gap: 14px; align-items: flex-start; }
.profile .who img { width: 56px; height: 56px; border-radius: 50%; }
.profile .row { display: flex; gap: 8px; align-items: center; }
.profile .row input { flex: 1; }
.profile .btn { display: inline-flex; align-items: center; gap: 6px; }
.sec-h { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sess { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.sess > .ic { width: 16px; height: 16px; color: var(--muted); }
.sess .muted { font-size: 12px; }
.toast.ok { border-color: var(--ok); }

/* Touch screens have no hover: keep the archive button visible. */
@media (hover: none) { .proj-h .padd { opacity: 0.7; } }

/* Breadcrumb, sandbox state, project tabs */
.crumb { all: unset; cursor: pointer; color: var(--muted); flex: none; display: inline-flex; align-items: center; gap: 7px; }
.crumb:empty { display: none; }
.crumb:hover { color: var(--fg); }
.crumb::after { content: "/"; color: var(--dim); margin-left: 10px; }
.envstate { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.envstate.failed { color: var(--bad); }
#ptabs { padding: 0 20px; }
#ptabs > button:first-child { margin-left: max(0px, calc((100% - 780px) / 2 + 20px)); }
#main.tabbed #dock { display: none; }

/* A plain thread, or a project's other views, use the full width. */
@media (min-width: 821px) {
  body.no-recipe #app { grid-template-columns: 240px minmax(0, 1fr); }
  body.no-recipe #panel { display: none; }
}
@media (max-width: 820px) { #ptabs { padding: 0 14px; } #ptabs > button:first-child { margin-left: 0; } }

/* Sub-thread notes in a project thread */
.note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding-left: 2px; }
.note .dot { width: 6px; height: 6px; }
.thread-link { all: unset; cursor: pointer; color: var(--fg); font-weight: 500; }
.thread-link:hover { text-decoration: underline; text-decoration-color: var(--dim); }

/* Project artifacts */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.pcard { all: unset; cursor: pointer; display: grid; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line); background: var(--bg); overflow: hidden; }
.pcard:hover { box-shadow: inset 0 0 0 1px var(--line2), 0 4px 14px -6px rgba(40, 36, 28, 0.18); }
.pthumb { height: 110px; display: grid; place-items: center; background: var(--bg2); color: var(--dim); border-bottom: 1px solid var(--line); overflow: hidden; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.pthumb .ic { width: 22px; height: 22px; }
.pmeta { display: grid; gap: 1px; padding: 8px 10px; min-width: 0; }
.pmeta .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmeta .muted { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Project about */
.about { display: grid; gap: 18px; padding-top: 8px; }
.about-h { display: flex; align-items: center; gap: 12px; }
.about h1 { margin: 0; font-size: 26px; font-weight: 500; flex: 1; }
.about-s { display: grid; gap: 6px; }
.about-s .lbl { font-size: 12px; color: var(--muted); }
.repoline { display: flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; padding: 4px 0; font-family: var(--mono); font-size: 12.5px; }
.repoline .ic { width: 14px; height: 14px; color: var(--dim); }
.repoline:hover { color: var(--accent); }
.stats { display: flex; gap: 14px; }
.stat { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.about .row { display: flex; gap: 8px; }

/* Repository checkboxes */
label.repo .box { width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--line2); display: inline-grid; place-items: center; flex: none; background: var(--bg); }
label.repo .box .ic { width: 10px; height: 10px; opacity: 0; color: #fff; }
label.repo:has(input:checked) .box { background: var(--accent); box-shadow: none; }
label.repo:has(input:checked) .box .ic { opacity: 1; }
.note > .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note > .dot, .note > .thread-link, .note > span:not(.muted) { flex: none; }
.mark { flex: none; display: block; }
/* Dots sit on the middle of the lowercase letters, which in Inter is about 1px below the line box's center. */
.thread > .dot, .proj-n > .dot, .fold > .dot, .note > .dot { transform: translateY(1px); }
