/* The builder: the site sheet's tokens (white, four greys, one blue, General Sans, pills, no borders or shadows) laid out as a
   workspace: a bar, the chat on the left, the stage on the right. */
body.app { height: 100svh; overflow: hidden; display: grid; grid-template-rows: 64px 1fr; }
body.app.is-start { overflow: auto; height: auto; min-height: 100svh; }
.brand-logo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.bar { display: flex; align-items: center; gap: 16px; padding: 0 16px 0 20px; background: var(--bg); box-shadow: inset 0 -1px var(--surface-3); position: sticky; top: 0; z-index: 5; }
.bar-name { white-space: nowrap; }
.bar-title { flex: 1; min-width: 80px; max-width: 420px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: 15px; font-weight: 500; outline: none; text-overflow: ellipsis; }
.bar-title:hover, .bar-title:focus { background: var(--surface-2); }
.is-start .bar-title { visibility: hidden; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bar-right > span { display: contents; }
.bar-right > span[hidden] { display: none; }
.credits { font-size: 13px; color: var(--muted); margin-right: 6px; white-space: nowrap; }
.bar .btn-sm { height: 36px; padding: 0 16px; font-size: 14px; }
.bar-ca .ca { padding: 3px; } .bar-ca .ca-chain { height: 30px; } .bar-ca .ca-soon { height: 30px; font-size: 13px; }
.ca-btn { cursor: pointer; } .ca-btn .ca-addr { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px 0 2px; font-size: 13px; } .ca-btn svg { margin-right: 8px; color: var(--muted); }

/* ---------- start screen */
.start { padding: clamp(40px, 8vh, 96px) var(--gutter) 96px; }
.start-in { max-width: 980px; margin: 0 auto; }
.start-in .head { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.4rem); }
.start-sub { margin-top: 14px; max-width: 56ch; font-size: var(--step-lead); }
.s-err { margin-top: 16px; color: var(--down); }
.s-form { margin-top: 36px; padding: 20px; background: var(--surface-2); }
.s-form textarea { width: 100%; resize: vertical; min-height: 120px; background: none; border: 0; outline: none; font: inherit; font-size: 18px; line-height: 1.5; color: var(--ink); }
.s-form textarea::placeholder, .ask textarea::placeholder { color: var(--muted); }
.s-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.s-plan { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink-2); cursor: pointer; }
.s-h { font-size: 22px; margin-top: 72px; margin-bottom: 20px; }
.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px; }
.tpl { display: grid; align-content: start; gap: 8px; min-height: 180px; padding: 22px; text-align: left; background: var(--surface); cursor: pointer; transition: background .3s; }
.tpl:hover { background: var(--surface-3); }
.tpl b { font-size: 18px; font-weight: 500; letter-spacing: -0.01em; } .tpl span { font-size: 14px; color: var(--ink-2); } .tpl i { font-style: normal; font-size: 13px; color: var(--muted); margin-top: auto; }
.s-blank { margin-top: 20px; }
.link { cursor: pointer; }
.projs { display: grid; gap: 4px; }
.proj { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px; background: var(--surface); transition: background .3s; }
.proj:hover { background: var(--surface-3); } .proj b { font-weight: 500; }

/* ---------- the workspace */
.work { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; min-height: 0; }
.chat { display: grid; grid-template-rows: 1fr auto auto; min-height: 0; background: var(--surface); }
.msgs { overflow-y: auto; padding: 20px 18px 8px; display: flex; flex-direction: column; gap: 14px; }
.hello { margin: auto 0; padding: 12px 6px; } .hello h3 { font-size: 26px; margin-bottom: 10px; }
.msg { font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; letter-spacing: .02em; }
.msg.me { align-self: flex-end; max-width: 88%; padding: 12px 16px; background: var(--surface-3); border-radius: 18px 18px 4px 18px; }
.msg.ai { padding: 2px 4px; }
.msg.err p { color: var(--down); }
.msg p + p, .msg ul, .msg h4, .msg pre { margin-top: 8px; }
.msg ul { padding-left: 20px; list-style: disc; } .msg h4 { font-size: 15px; font-weight: 600; letter-spacing: 0; }
.msg code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.msg pre { background: var(--surface-3); padding: 10px 12px; overflow-x: auto; } .msg pre code { background: none; padding: 0; }
.chg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-f { padding: 4px 10px; border-radius: 999px; background: var(--surface-3); font-size: 12px; font-family: ui-monospace, monospace; cursor: pointer; }
.chip-f:hover { background: var(--surface-4); }
.vtag { margin-top: 8px; font-size: 13px; color: var(--accent); cursor: pointer; display: block; }
.build-plan { margin-top: 12px; }
.live { padding: 12px 18px; display: grid; gap: 8px; font-size: 14px; box-shadow: inset 0 1px var(--surface-3); max-height: 46vh; overflow-y: auto; }
.think { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.think span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.steps-l { display: grid; gap: 4px; }
.step { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.step b { font-weight: 500; font-family: ui-monospace, monospace; font-size: 12.5px; }
.step em { flex-basis: 100%; font-style: normal; color: var(--down); font-size: 12px; padding-left: 20px; }
.say { font-size: 15px; }
.say p + p { margin-top: 6px; }
i.spin { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface-4); border-top-color: var(--accent); animation: spin .8s linear infinite; }
i.ok { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--up); }
i.x { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--down); }
@keyframes spin { to { transform: rotate(360deg); } }
.ask { position: relative; margin: 10px; padding: 12px; background: var(--bg); border-radius: 20px; box-shadow: 0 0 0 1px var(--surface-3); }
.ask:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.ask textarea { width: 100%; resize: none; border: 0; outline: none; font: inherit; font-size: 15px; line-height: 1.5; background: none; color: var(--ink); max-height: 220px; }
.ask-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.ask-hint { flex: 1; }
.ask .btn-sm { height: 34px; padding: 0 16px; font-size: 14px; }
.is-running .ask textarea { opacity: .6; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.seg button { padding: 5px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: #fff; }
.model { margin-top: 6px; } .model:empty { display: none; }
.picked { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 6px 10px; border-radius: 10px; background: #eef2ff; color: var(--accent); font-size: 12.5px; font-family: ui-monospace, monospace; }
.picked span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked button { cursor: pointer; font-size: 16px; line-height: 1; }
.cmds { position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); background: var(--bg); border-radius: 14px; box-shadow: 0 0 0 1px var(--surface-3), 0 12px 32px rgba(17, 19, 24, .1); padding: 6px; display: grid; gap: 2px; max-height: 280px; overflow-y: auto; z-index: 3; }
.cmds button { display: grid; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.cmds button.on, .cmds button:hover { background: var(--surface-2); }
.cmds b { font-weight: 500; font-size: 14px; } .cmds span { font-size: 12.5px; color: var(--muted); }

.stage { display: grid; grid-template-rows: auto 1fr; min-height: 0; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 14px; box-shadow: inset 0 -1px var(--surface-3); overflow-x: auto; }
.tabs button { padding: 7px 14px; border-radius: 999px; font-size: 14px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.tabs button:hover { background: var(--surface-2); }
.tabs button.on { background: var(--surface-3); color: var(--ink); }
.tabs button[hidden] { display: none; }
.pane { min-height: 0; overflow: hidden; }
.pane-preview { display: grid; grid-template-rows: auto 1fr auto; }
.pv-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; }
.pv-url { flex: 1; min-width: 0; height: 32px; display: flex; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ib, .pv-btn { height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ib { width: 32px; padding: 0; justify-content: center; }
.ib:hover, .pv-btn:hover { background: var(--surface-2); color: var(--ink); }
.pv-btn.on { background: var(--accent); color: #fff; }
.pv-btn:disabled { opacity: .4; cursor: default; }
.pv-frame { position: relative; min-height: 0; margin: 0 12px; background: var(--surface-2); display: grid; place-items: stretch; overflow: hidden; }
.pv-frame iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.pv-frame.phone { place-items: center; padding: 16px; }
.pv-frame.phone iframe { width: 390px; max-width: 100%; height: min(844px, 100%); border-radius: 28px; box-shadow: 0 0 0 8px var(--ink); }
.pv-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.console { margin: 0 12px 12px; background: var(--surface); }
.console-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.con-t { flex: 1; text-align: left; font-size: 13px; color: var(--muted); cursor: pointer; height: 30px; }
.console.has-err .con-t { color: var(--down); }
.console #fix { height: 30px; font-size: 13px; padding: 0 14px; }
.console-body { display: none; max-height: 180px; overflow-y: auto; padding: 4px 12px 10px; font: 12.5px/1.5 ui-monospace, monospace; }
.console.open .console-body { display: block; }
.log { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); padding: 2px 0; }
.log.error { color: var(--down); } .log.warn { color: var(--flat); }

.pane-code { display: grid; grid-template-columns: 240px 1fr; }
.tree { overflow-y: auto; padding: 10px 8px; background: var(--surface); display: grid; align-content: start; gap: 2px; }
.tf { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px 7px calc(10px + var(--lvl) * 12px); border-radius: 8px; font: 13px ui-monospace, monospace; text-align: left; cursor: pointer; overflow: hidden; }
.tf span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.tf:hover { background: var(--surface-2); } .tf.on { background: var(--surface-3); }
.editor { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.ed-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; flex-wrap: wrap; }
.ed-bar #ed-path { flex: 1; font-size: 13px; color: var(--ink-2); font-family: ui-monospace, monospace; }
.ed-bar > span { display: contents; } .ed-bar > span[hidden] { display: none; }
#ed { width: 100%; height: 100%; resize: none; border: 0; outline: none; padding: 14px 18px; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); background: var(--bg); tab-size: 2; white-space: pre; overflow: auto; }
#ed-img { max-width: 100%; max-height: 100%; object-fit: contain; margin: 16px; }

.pane-versions { display: grid; grid-template-columns: 340px 1fr; }
.vlist { overflow-y: auto; padding: 12px; display: grid; align-content: start; gap: 4px; background: var(--surface); }
.vrow { display: grid; gap: 8px; padding: 12px 14px; background: var(--bg); }
.vrow b { font-weight: 600; } .vrow p { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.vbtns { display: flex; gap: 6px; flex-wrap: wrap; } .vbtns .btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.vdiff { overflow: auto; padding: 16px 20px; }
.vdiff h4 { font-size: 16px; margin-bottom: 14px; letter-spacing: 0; }
.dfile { margin-bottom: 20px; } .dfile > b { font: 600 13px ui-monospace, monospace; }
.dbody { margin-top: 6px; background: var(--surface); padding: 8px 0; overflow-x: auto; }
.dl { font: 12.5px/1.55 ui-monospace, monospace; white-space: pre; padding: 0 12px; }
.dl.add { background: #e3f6ee; color: #0b6a48; } .dl.del { background: #fde8e7; color: #a4302a; } .dl.gap { color: var(--muted); }

.pane-images { overflow-y: auto; padding: 16px 20px; }
.img-form { padding: 16px; background: var(--surface-2); }
.img-form textarea { width: 100%; border: 0; background: none; outline: none; resize: vertical; font: inherit; font-size: 15px; }
.img-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 6px; }
.img-row input, .img-row select { height: 34px; padding: 0 12px; border-radius: 999px; background: var(--bg); font: inherit; font-size: 14px; border: 0; }
.img-row label { display: flex; gap: 6px; align-items: center; color: var(--ink-2); }
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 16px; }
.imgs figure { background: var(--surface); padding: 8px; } .imgs img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--surface-2); }
.imgs figcaption { font: 12px ui-monospace, monospace; margin-top: 6px; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }

.pane-plan { display: grid; grid-template-rows: auto 1fr auto; padding: 16px 20px; gap: 12px; }
#plan { width: 100%; height: 100%; resize: none; border: 0; outline: none; padding: 16px; background: var(--surface); font: 14px/1.6 ui-monospace, monospace; color: var(--ink); }
.plan-row { display: flex; gap: 8px; justify-content: flex-end; } .plan-row[hidden] { display: none; }

.pane-report { overflow-y: auto; padding: 20px 24px 40px; }
.report { max-width: 860px; } .report > p { margin: 14px 0; }
.rep-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.rep-head h3 { font-size: 26px; }
.sev-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 18px; }
.sev { display: grid; min-width: 110px; padding: 12px 14px; background: var(--surface); font-size: 13px; color: var(--ink-2); }
.sev b { font-size: 26px; font-weight: 500; color: var(--ink); }
.sev-critical b, .sev-tag.sev-critical { color: #b42318; } .sev-high b, .sev-tag.sev-high { color: var(--down); }
.sev-medium b, .sev-tag.sev-medium { color: var(--flat); } .sev-low b, .sev-tag.sev-low { color: var(--accent); }
.finding { padding: 16px 18px; background: var(--surface); margin-top: 4px; }
.finding p { margin-top: 6px; font-size: 15px; } .finding > b { font-weight: 500; }
.sev-tag { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-right: 10px; }
.report h4 { margin-top: 26px; font-size: 16px; letter-spacing: 0; } .report ul { list-style: disc; padding-left: 20px; margin-top: 8px; color: var(--ink-2); }

.dlg { margin: auto; border: 0; padding: 28px; width: min(520px, calc(100vw - 32px)); background: var(--bg); color: var(--ink); border-radius: 20px; box-shadow: 0 24px 80px rgba(17, 19, 24, .2); }
.dlg::backdrop { background: rgba(17, 19, 24, .35); }
.dlg h3 { font-size: 24px; margin-bottom: 8px; }
.fld { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 16px; }
.fld > input { height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 15px; outline: none; }
.slug { display: flex; align-items: center; height: 40px; border-radius: 999px; background: var(--surface-2); padding-left: 14px; margin-top: 12px; overflow: hidden; }
.fld .slug { margin-top: 0; }
.slug span { color: var(--muted); font-size: 14px; white-space: nowrap; } .slug input { flex: 1; min-width: 0; height: 100%; padding: 0 10px 0 2px; font-size: 15px; color: var(--ink); outline: none; }
.chk { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--ink-2); }
.pb-live { margin-top: 14px; font-size: 15px; } .pb-live a { color: var(--accent); }
.pb-err { margin-top: 10px; color: var(--down); font-size: 14px; min-height: 1em; }
.dlg-row { display: flex; gap: 8px; align-items: center; margin-top: 18px; } .dlg-row > span { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; transition: all .4s var(--ease); z-index: 20; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.bad { background: var(--down); }

.is-view .chat .msgs { padding-bottom: 20px; }
@media (max-width: 980px) {
  body.app { overflow: auto; height: auto; }
  .work { grid-template-columns: 1fr; }
  .chat { max-height: none; } .msgs { max-height: 50vh; }
  .stage { min-height: 80vh; }
  .pane-preview .pv-frame { min-height: 70vh; }
  .pane-code, .pane-versions { grid-template-columns: 1fr; } .tree, .vlist { max-height: 30vh; }
  .credits, .bar-ca, .bar-name { display: none; }
  .bar { gap: 8px; padding: 0 10px; } .bar .btn-sm { padding: 0 12px; }
}
