:root {
  --bg: #f7f7f5; --panel: #ffffff; --side: #f1f0ec; --ink: #1c1c1a; --muted: #6b6a64; --line: #e4e2dc;
  --accent: #c96442; --accent-hover: #b4563a; --accent-ink: #ffffff; --accent-soft: #f6e8e1; --accent-text: #a54a2c;
  --user: #ece9e1; --err: #b3261e; --ok: #2e7d4f; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1f1e1d; --panel: #2a2927; --side: #181716; --ink: #ecebe6; --muted: #a09f97; --line: #3a3835;
          --accent: #d97757; --accent-hover: #e48a6c; --accent-ink: #1a0f0a; --accent-soft: #3a2a23; --accent-text: #e9967a;
          --user: #34322f; --err: #ff8a80; --ok: #6bd68f; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15.5px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.error { color: var(--err); min-height: 1.4em; margin: .5rem 0 0; font-size: .9rem; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* buttons */
.btn, button.primary { font-size: .88rem; font-weight: 500; padding: .45rem .9rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; white-space: nowrap; }
.btn.ghost:hover { background: var(--side); }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.wide { width: 100%; padding: .7rem; font-size: 1rem; margin-top: .5rem; }
.icon-btn { background: transparent; border: 0; padding: .4rem; border-radius: 8px; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: var(--line); color: var(--ink); }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 390px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 2rem 1.75rem; box-shadow: var(--shadow); }
.login-card h1 { font-size: 1.45rem; margin: .75rem 0 .25rem; }
.login-card .muted { margin: 0 0 1rem; font-size: .93rem; }
label { display: block; margin: .8rem 0 0; font-size: .85rem; font-weight: 500; }
label input { margin-top: .3rem; }
input, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .65rem .75rem; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 1.25rem; }
.logo.sm { width: 24px; height: 24px; border-radius: 8px; font-size: .8rem; display: inline-grid; vertical-align: middle; }
.logo.has-img { background: transparent; width: auto; height: 40px; border-radius: 0; display: flex; justify-content: flex-start; align-items: center; }
.logo.sm.has-img { width: auto; border-radius: 0; display: inline-flex; height: 24px; margin-right: .35rem; }
.logo.big.has-img { width: auto; border-radius: 0; height: 56px; justify-content: center; margin: 0 auto 1rem; }
.logo > svg { width: 64%; height: 64%; display: block; }
.logo.sm > svg { width: 76%; height: 76%; }
.msg.assistant .avatar-a > svg { width: 70%; height: 70%; display: block; }
.logo > img { height: 100%; width: auto; max-width: 220px; object-fit: contain; display: block; }
.logo.big { width: 52px; height: 52px; border-radius: 16px; font-size: 1.6rem; margin: 0 auto 1rem; }

/* layout */
#app { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100vh; height: 100dvh; }
#sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1rem .75rem; gap: .5rem; min-height: 0; }
.brand { font-weight: 650; padding: .25rem .5rem .75rem; display: flex; gap: .5rem; align-items: center; }
.new { display: flex; gap: .5rem; align-items: center; justify-content: center; padding: .6rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 500; }
.new:hover { border-color: var(--accent); }
.section-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .5rem .2rem; }
#session-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
#session-list button { width: 100%; text-align: left; background: transparent; border: 0; padding: .55rem .6rem; border-radius: 8px; display: flex; gap: .55rem; align-items: center; min-width: 0; }
#session-list button:hover { background: var(--line); }
#session-list li.active button { background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
#session-list .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: none; }
.dot.working { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dot.review { background: var(--ok); }
.dot.failed { background: var(--err); }
.dot.news { background: var(--accent); }
.rstat { margin-left: auto; flex: none; font-size: .68rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 .4rem; white-space: nowrap; }
.rstat.working { color: var(--accent-text); border-color: var(--accent); }
.user-row { display: flex; align-items: center; gap: .6rem; padding: .6rem .5rem 0; border-top: 1px solid var(--line); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 650; font-size: .8rem; text-transform: uppercase; }
#whoami { flex: 1; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }

#chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar { display: flex; flex-wrap: wrap; row-gap: .4rem; align-items: center; gap: .6rem; padding: .7rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--bg); }
.topbar h2 { margin: 0; font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; min-width: 8rem; max-width: 100%; }
.pill { font-size: .75rem; padding: .15rem .55rem; border-radius: 999px; background: var(--user); color: var(--muted); white-space: nowrap; }
.pill.working { background: var(--accent-soft); color: var(--accent-text); }
.pill.review { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.banner { margin: .75rem auto 0; width: calc(100% - 2.5rem); max-width: 760px; padding: .65rem .9rem; border-radius: 12px; background: color-mix(in srgb, var(--ok) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line)); font-size: .92rem; }
.banner a { color: var(--ok); font-weight: 600; }

#scroller { flex: 1; overflow-y: auto; min-height: 0; }
#thread { max-width: 760px; margin: 0 auto; padding: 1.5rem 1.25rem 1rem; min-height: 100%; display: flex; flex-direction: column; }
#messages { display: flex; flex-direction: column; gap: 1.25rem; }
.jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .9rem; font-size: .82rem; box-shadow: var(--shadow); }

/* empty state */
.empty { text-align: center; margin: auto; padding: 2rem 0; max-width: 520px; }
.empty h3 { font-size: 1.5rem; margin: 0 0 .4rem; font-weight: 650; }
.empty .muted { margin: 0 0 1.25rem; }
#empty-start { margin: 0 0 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.chip { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; font-size: .84rem; color: var(--muted); }
.chip:hover { border-color: var(--accent-text); color: var(--accent-text); }

/* messages */
.msg { display: flex; gap: .75rem; }
.msg.user { justify-content: flex-end; }
.msg.user .body { background: var(--user); border-radius: 18px 18px 4px 18px; padding: .6rem 1rem; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant .avatar-a { flex: none; width: 28px; height: 28px; margin-top: 2px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .8rem; }
.msg.assistant .body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.body p { margin: 0 0 .7em; } .body p:last-child { margin-bottom: 0; }
.body h3, .body h4 { margin: 1em 0 .35em; font-size: 1.02rem; }
.body ul, .body ol { margin: 0 0 .7em; padding-left: 1.4rem; } .body li { margin: .15em 0; }
.body a { color: var(--accent-text); text-underline-offset: 2px; }
.body strong { font-weight: 650; }

/* steps (what the assistant is doing) */
.steps { margin-left: 2.5rem; display: flex; flex-direction: column; gap: .3rem; }
.step { display: flex; align-items: center; gap: .55rem; font-size: .88rem; color: var(--muted); padding: .3rem .65rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: fit-content; max-width: 100%; }
.step .ico { width: 14px; height: 14px; flex: none; display: grid; place-items: center; font-size: .8rem; line-height: 1; }
.step.running .ico { border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.step.done .ico { color: var(--ok); } .step.done .ico::before { content: "✓"; }
.step.failed .ico { color: var(--err); } .step.failed .ico::before { content: "✕"; }
.step.running { color: var(--ink); }

.typing { margin-left: 2.5rem; display: flex; gap: 4px; padding: .3rem 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }

/* composer */
.dock { max-width: 760px; width: 100%; margin: 0 auto; padding: .5rem 1.25rem calc(.75rem + env(safe-area-inset-bottom)); }
.composer { display: flex; flex-direction: column; gap: .15rem; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: .6rem .6rem .5rem 1rem; box-shadow: var(--shadow); }
.composer-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .35rem; margin-left: -.35rem; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { padding-right: .5rem; border: 0; background: transparent; resize: none; padding: .45rem 0; max-height: 200px; outline: none !important; }
.send { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send.stop { background: var(--ink); color: var(--bg); }
.hint { margin: .4rem .5rem 0; font-size: .75rem; color: var(--muted); text-align: center; }
#count { color: var(--err); margin-right: .6rem; }
.notice { margin-bottom: .5rem; padding: .55rem .85rem; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: .9rem; }
.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 12px; font-size: .9rem; box-shadow: var(--shadow); max-width: 90vw; z-index: 30; }

.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 19; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; scroll-behavior: auto !important; } }

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: 82vw; max-width: 320px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  #app.menu-open #sidebar { transform: none; }
  .only-mobile { display: inline-flex; }
  .topbar { padding: .6rem .75rem; }
  .topbar .btn.ghost { display: none; }
  #thread, .dock { padding-left: .9rem; padding-right: .9rem; }
  .steps, .typing { margin-left: 2.25rem; }
}

/* attachments */
.attach-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .1rem 0 .4rem; }
.file-chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .25rem .35rem .25rem .6rem; font-size: .82rem; max-width: 100%; }
.file-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.file-chip.up { opacity: .6; }
.file-chip button { border: 0; background: transparent; color: var(--muted); padding: 0 .25rem; font-size: .9rem; }
.drop { position: fixed; inset: 0; z-index: 25; background: color-mix(in srgb, var(--accent) 14%, transparent); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 1.3rem; font-weight: 600; color: var(--accent); pointer-events: none; }

/* model picker */
.model-wrap { position: relative; min-width: 0; }
.model-btn { background: transparent; border: 1px solid transparent; border-radius: 10px; padding: .3rem .55rem; font-size: .82rem; color: var(--muted); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn:hover { background: var(--bg); border-color: var(--line); color: var(--ink); }
.menu { position: absolute; bottom: calc(100% + 8px); left: 0; width: min(360px, 86vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: .5rem; z-index: 15; }
.menu input[type=search] { margin-bottom: .4rem; padding: .45rem .6rem; font-size: .88rem; }
#model-list { max-height: 280px; overflow-y: auto; }
.m-group { display: flex; align-items: center; gap: .4rem; width: 100%; border: 0; background: transparent; text-align: left; font-size: .78rem; font-weight: 600; color: var(--ink); padding: .45rem .5rem; border-radius: 8px; margin-top: .15rem; }
.m-group:hover { background: var(--bg); }
.m-group.locked { color: var(--muted); }
.m-group .chev { width: 1em; color: var(--muted); }
.m-group .gname { flex: 1; }
.m-group .gcount { font-weight: 400; color: var(--muted); font-size: .72rem; }
.m-item { padding-left: 1.6rem; }
.m-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: .4rem .5rem; border-radius: 8px; font-size: .88rem; }
.m-item:hover { background: var(--bg); }
.m-item.sel { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.effort { border-top: 1px solid var(--line); margin-top: .4rem; padding-top: .5rem; font-size: .82rem; }
.effort select { margin-left: .4rem; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: .2rem .4rem; }

/* accounts dialog */
.dialog { max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); width: min(560px, 94vw); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow: auto; overscroll-behavior: contain; padding: 1.25rem; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog h3 { margin: 0; font-size: 1.15rem; }
.small { font-size: .88rem; }
.prov { border: 1px solid var(--line); border-radius: 12px; padding: .75rem .9rem; margin-top: .6rem; }
.prov-head { display: flex; align-items: center; gap: .6rem; }
.prov-head strong { flex: 1; }
.badge { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.prov-body { margin-top: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.prov-body .row { display: flex; gap: .5rem; }
.prov-body select { width: 100%; padding: .55rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
.note { font-size: .85rem; color: var(--muted); }
.m-item.locked { color: var(--muted); }
.m-more { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--accent-text); padding: .35rem .5rem; font-size: .82rem; border-radius: 8px; }
.m-more:hover { background: var(--bg); }

/* mode switch */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: .28rem .6rem; font-size: .8rem; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.seg.plan button[aria-checked="true"], .seg.ask button[aria-checked="true"], .seg.team button[aria-checked="true"] { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }

/* usage */
.usage { border: 1px solid transparent; background: transparent; border-radius: 10px; padding: .25rem .5rem; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.usage:hover { background: var(--bg); border-color: var(--line); color: var(--ink); }
.usage-wrap .menu { left: auto; right: 0; width: min(300px, 86vw); padding: .75rem; }
.u-row { display: flex; justify-content: space-between; font-size: .85rem; padding: .15rem 0; }
.u-row span:first-child { color: var(--muted); }
.u-bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: .35rem 0 .15rem; }
.u-bar i { display: block; height: 100%; background: var(--accent); }
.u-bar i.high { background: var(--err); }
#compact-btn { margin-top: .6rem; width: 100%; justify-content: center; font-size: .8rem; }

/* model list extras */
.m-item { display: flex; justify-content: space-between; gap: .5rem; }
.m-item .via { color: var(--muted); font-size: .72rem; white-space: nowrap; align-self: center; }
.skill-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: .45rem .55rem; border-radius: 8px; }
.skill-item:hover, .skill-item.active { background: var(--bg); }
.skill-item small { display: block; color: var(--muted); font-size: .76rem; line-height: 1.3; }
.file-chip.skill { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }

.agent-select { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: .28rem .4rem; font-size: .8rem; max-width: 9rem; }
.skill-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .4rem .55rem .1rem; }

.steer { font-size: .78rem; padding: .3rem .65rem; }
.qtag { display: block; font-size: .7rem; color: var(--muted); margin-top: .15rem; text-align: right; }
.msg.user.queued .body { opacity: .65; }
a.new { text-decoration: none; color: inherit; }

.project-select { font: inherit; font-size: .85rem; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: .25rem .5rem; max-width: 14rem; }
#session-list .proj { font-size: .7rem; color: var(--muted); white-space: nowrap; }

.list-tools { display: flex; flex-direction: column; gap: .15rem; padding: .25rem .5rem; }
.link { background: transparent; border: 0; color: var(--muted); font-size: .78rem; text-align: left; padding: .15rem 0; text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--ink); }
#session-list li { position: relative; }
#session-list li button.arch { width: auto; display: inline-block; text-align: center; position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); opacity: 0; border: 0; background: var(--line); color: var(--muted); border-radius: 6px; padding: .1rem .4rem; font-size: .72rem; }
#session-list li:hover .arch, #session-list li:focus-within .arch, #session-list .arch:focus-visible { opacity: 1; }
@media (hover: hover) { #session-list li:hover .proj, #session-list li:hover .dot, #session-list li:hover .rstat { visibility: hidden; } }
@media (hover: none) { #session-list .arch { opacity: 1; } }
.empty-list { padding: .5rem; font-size: .85rem; color: var(--muted); }

/* call to action: send the changes for review */
.cta { margin-left: 2.5rem; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 14px; padding: .8rem 1rem; display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; }
.cta-text { flex: 1 1 260px; font-size: .92rem; }
.cta-actions { display: flex; gap: .5rem; }
.cta .btn.primary { font-size: .9rem; padding: .5rem 1rem; }
#review-btn.attention { animation: ring 1.8s ease-in-out infinite; }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
@media (max-width: 800px) { .cta { margin-left: 2.25rem; } }

/* attachment previews */
.thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; display: block; }
.thumb-big { max-width: 220px; max-height: 160px; border-radius: 10px; display: block; margin-top: .4rem; border: 1px solid var(--line); }
.filelabel { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.attach-warn { flex-basis: 100%; font-size: .82rem; color: var(--err); padding: .1rem 0 .2rem; }

.step.folded { display: none; }
.step { flex-wrap: wrap; cursor: pointer; }
.step-more { flex-basis: 100%; padding-left: 1.45rem; font-size: .8rem; line-height: 1.45; color: var(--muted); }
.steps-summary { align-self: flex-start; border: 0; background: transparent; color: var(--muted); font-size: .8rem; text-decoration: underline; text-underline-offset: 2px; padding: .1rem .2rem; }
.steps-summary:hover { color: var(--ink); }

.chat-search { margin: .15rem .5rem .35rem; width: calc(100% - 1rem); padding: .4rem .6rem; font-size: .85rem; }
#chat-title { cursor: text; }

.typing { align-items: center; }
.typing-time { font-style: normal; font-size: .78rem; color: var(--muted); margin-inline-start: .5rem; }

.device-code { display: flex; align-items: center; gap: .75rem; background: var(--accent-soft); border-radius: 12px; padding: .6rem .9rem; margin: .4rem 0; }
.dc-label { font-size: .8rem; color: var(--muted); }
.dc-value { font-size: 1.4rem; letter-spacing: .12em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; flex: 1; }

/* requests: the form and the header chip */
.dialog.wide { width: min(680px, 96vw); overflow: auto; }
#intake-form label { display: block; margin-top: .75rem; font-size: .88rem; font-weight: 600; }
#intake-form label input, #intake-form label select, #intake-form label textarea { display: block; width: 100%; margin-top: .25rem; font: inherit; font-weight: 400; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
#intake-form label textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.in-drop { margin-top: .85rem; padding: .7rem .8rem; border: 1.5px dashed var(--line); border-radius: 12px; display: flex; align-items: center; gap: .6rem .75rem; flex-wrap: wrap; }
.in-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.in-drop .attach-chips { flex-basis: 100%; padding: 0; }
.in-drop .attach-chips:empty { display: none; }
.dialog-actions { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; position: sticky; bottom: -1.25rem; background: var(--panel); padding: .6rem 0 calc(.6rem + env(safe-area-inset-bottom)); }
.req-chip { font: inherit; font-size: .78rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--accent-soft); color: var(--ink); cursor: pointer; }
.req-chip:hover { border-color: var(--accent); }
.req-chip .st { margin-left: .4rem; color: var(--muted); font-weight: 500; }
.rd-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0 .25rem; }
.rd-meta span { font-size: .78rem; padding: .1rem .55rem; border-radius: 999px; background: var(--accent-soft); }
#rd-body h4 { margin: 1rem 0 .25rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
#rd-body p, #rd-body ul { margin: .15rem 0; }
#rd-body ul { padding-left: 1.2rem; }

/* phones and tablets */
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; row-gap: .4rem; padding-top: max(.6rem, env(safe-area-inset-top)); padding-left: max(.75rem, env(safe-area-inset-left)); padding-right: max(.75rem, env(safe-area-inset-right)); }
  .topbar h2 { flex: 1 1 0; min-width: 6rem; }
  .topbar .spacer { display: none; }
  .topbar .btn.ghost { display: inline-flex; } /* Undo, Archive and the live link stay reachable on a phone */
  .topbar .btn, .pill, .req-chip { flex: none; }
  .topbar #review-btn { margin-left: auto; }
  #sidebar { visibility: hidden; transition: transform .2s, visibility 0s .2s; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); padding-left: max(.75rem, env(safe-area-inset-left)); }
  #app.menu-open #sidebar { visibility: visible; transition: transform .2s; }
  input, textarea, select { font-size: 16px !important; } /* iOS zooms into smaller fields */
  .jump { bottom: calc(8rem + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(7rem + env(safe-area-inset-bottom)); }
  .admin h2 { flex-wrap: wrap; }
  .table-wrap table { min-width: 640px; }
  .table-wrap td .btn { white-space: nowrap; }
}
@media (max-width: 560px) {
  .composer { position: relative; }
  .composer .model-wrap { position: static; }
  .composer .menu { left: .5rem; right: .5rem; width: auto; bottom: calc(100% + 6px); }
  .model-btn { max-width: 34vw; }
  .composer-bar .send, .composer-bar .steer { margin-left: auto; }
  .composer-bar .steer ~ .send { margin-left: 0; }
  #skill-btn { font-size: 0; padding: .3rem .6rem; }
  #skill-btn::before { content: "/"; font-size: .9rem; }
  .agent-select { max-width: 6.5rem; }
  .dock { padding-left: max(.9rem, env(safe-area-inset-left)); padding-right: max(.9rem, env(safe-area-inset-right)); }
}
@media (pointer: coarse) {
  .icon-btn { min-width: 44px; min-height: 44px; justify-content: center; }
  .seg button, .model-btn, .usage, .req-chip, .topbar .btn, .link { min-height: 40px; }
  #session-list li button.arch { min-height: 32px; padding: .3rem .65rem; }
  .hint { display: none; }
  #session-list .t { margin-right: 3.4rem; }
}

.support { margin: .5rem .5rem 0; font-size: .78rem; color: var(--muted); }
.support a { color: inherit; }

.rename { flex: none; color: var(--muted); }
.rename:hover { color: var(--ink); }
.title-edit { flex: 1 1 12rem; min-width: 0; font: inherit; font-weight: 600; padding: .25rem .5rem; }

#session-list li button.arch.del { right: 4.6rem; color: var(--err); }

.dev-note { margin-top: .35rem; font-size: .88rem; padding: .4rem .6rem; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 6px; white-space: pre-wrap; }

#preview-banner { display: flex; align-items: flex-start; gap: .5rem; }
#preview-banner.hidden { display: none; }
#preview-banner .banner-text { flex: 1; min-width: 0; }
.banner-close { flex: none; border: 0; background: transparent; color: var(--muted); font-size: 1rem; line-height: 1; padding: .25rem .4rem; border-radius: 8px; cursor: pointer; }
.banner-close:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
@media (pointer: coarse) { .banner-close { min-width: 40px; min-height: 40px; } }

/* the agent's own task list, inside the conversation */
.tasks-card { margin: .4rem 0 .4rem 2.25rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: .88rem; max-width: 34rem; }
.tasks-card summary { cursor: pointer; padding: .45rem .8rem; font-weight: 600; color: var(--muted); list-style: none; }
.tasks-card summary::-webkit-details-marker { display: none; }
.tasks-card summary::before { content: "▸ "; } .tasks-card[open] summary::before { content: "▾ "; }
.tasks-card ul { list-style: none; margin: 0; padding: 0 .8rem .55rem; }
.task { display: flex; gap: .5rem; padding: .12rem 0; align-items: baseline; }
.task .tk-ico { flex: none; width: 1.1em; color: var(--muted); text-align: center; }
.task.done { color: var(--muted); } .task.done .tk-text { text-decoration: line-through; }
.task.running { font-weight: 600; } .task.running .tk-ico { color: var(--accent-text); }
.task.cancelled { color: var(--muted); opacity: .7; }
.files-layout { display: grid; grid-template-columns: 13rem 1fr; gap: 1rem; margin-top: .5rem; min-height: 14rem; }
@media (max-width: 640px) { .files-layout { grid-template-columns: 1fr; } }
.files-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.files-list button { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: .45rem .6rem; font: inherit; font-size: .88rem; overflow-wrap: anywhere; }
.files-list button.sel { border-color: var(--accent); background: var(--accent-soft); }
.files-view { min-width: 0; }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.doc-body { max-height: 55dvh; overflow: auto; padding-right: .25rem; }
.doc-pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; }
.doc-scroll { overflow: auto; }
.doc-table { border-collapse: collapse; font-size: .85rem; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: .25rem .5rem; text-align: left; vertical-align: top; }
.doc-table th { background: var(--bg); }

.progress-chip { border: 0; cursor: pointer; flex: none; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--ink); }
.pill.working { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 800px) { .progress-chip { max-width: 12rem; } }

/* the less-used actions (What changed?, Undo, Archive) live in one menu */
.more-wrap { position: relative; }
.menu.down { bottom: auto; top: calc(100% + 6px); left: auto; right: 0; width: 220px; display: flex; flex-direction: column; gap: .15rem; }
.menu.down .skill-item.hidden { display: none; }
.topbar #more-btn { display: inline-flex; } /* stays reachable on a phone */

/* the assistant's question: tappable choices */
.qcard { margin-left: 2.5rem; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 14px; padding: .8rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.qcard.answered { opacity: .8; border-style: dashed; }
.q-head { font-weight: 600; font-size: .92rem; }
.q-item { display: flex; flex-direction: column; gap: .4rem; }
.q-title { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.q-text { font-size: .95rem; }
.q-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.q-opt.chosen { background: var(--accent); color: #fff; border-color: var(--accent); }
.q-other { max-width: 28rem; }
@media (max-width: 800px) { .qcard { margin-left: 0; } }

/* "Undo from here" on the person's own messages, and what an undo hides */
.msg.user { position: relative; }
.undo-here { display: block; margin: .2rem 0 0 auto; border: 0; background: transparent; color: var(--muted); font-size: .76rem; padding: .1rem .3rem; border-radius: 6px; opacity: 0; transition: opacity .15s; cursor: pointer; }
.msg.user:hover .undo-here, .undo-here:focus-visible { opacity: 1; }
@media (hover: none) { .undo-here { opacity: .7; } }
.msg.queued .undo-here { display: none; }
#messages .undone { display: none; }

.q-ctl { display: flex; gap: .6rem; justify-content: flex-end; font-size: .8rem; margin-top: .2rem; }

/* where the request is: a short line of steps */
.stepper { list-style: none; margin: 0; padding: .35rem 1.25rem; display: flex; gap: .35rem; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--bg); font-size: .78rem; scrollbar-width: none; }
.stepper li { flex: none; padding: .15rem .6rem; border-radius: 999px; color: var(--muted); border: 1px solid transparent; white-space: nowrap; }
.stepper li.done { color: var(--accent-text); }
.stepper li.active { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
@media (max-width: 800px) { .stepper { padding: .3rem .75rem; } }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* the live site beside the chat (wide screens only) */
#app.with-pane { grid-template-columns: 272px minmax(0, 1fr) minmax(360px, 46%); }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--line); background: var(--panel); }
.pane-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
.pane-actions { display: flex; gap: .3rem; }
#bell-btn.on { color: var(--accent); }
.pane-stage { position: relative; flex: 1; display: flex; min-height: 0; }
.pane iframe { flex: 1; width: 100%; border: 0; background: #fff; }
/* the live preview's status (starting, asleep, could not start) covers the frame until the app answers */
.pane-state { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 1.5rem; text-align: center; background: var(--panel); }
.pane-state p { margin: 0; max-width: 22rem; }
.pane-state .spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.pane-state .row { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.pane-note { margin: 0; padding: .35rem .75rem; border-top: 1px solid var(--line); }
@media (max-width: 1100px) { #app.with-pane { grid-template-columns: 272px minmax(0, 1fr); } .pane, #pane-btn { display: none !important; } }
@media (max-width: 800px) { #app.with-pane { grid-template-columns: 1fr; } }

/* the top bar's actions: on a wide screen they sit in the bar itself; on a phone they are one row (the first few scroll sideways, More and Send for review stay in reach) */
.actions, .actions-scroll { display: contents; }
@media (max-width: 800px) {
  .actions { display: flex; flex: 1 0 100%; order: 9; align-items: center; gap: .5rem; min-width: 0; }
  .actions-scroll { display: flex; flex: 1 1 0; min-width: 0; align-items: center; gap: .5rem; overflow-x: auto; scrollbar-width: none; padding: 2px; }
  .actions-scroll > * { flex: none; }
  .actions .more-wrap, .actions #review-btn { flex: none; }
  .topbar #review-btn { margin-left: 0; }
}
/* placeholders while a conversation loads */
.skeleton { display: grid; gap: .7rem; padding: 1.2rem 1.25rem; }
.skeleton i { display: block; height: 1rem; border-radius: 8px; background: linear-gradient(90deg, var(--line) 25%, var(--side) 37%, var(--line) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skeleton i:nth-child(1) { width: 40%; margin-left: auto; height: 2.2rem; } .skeleton i:nth-child(2) { width: 85%; } .skeleton i:nth-child(3) { width: 70%; } .skeleton i:nth-child(4) { width: 55%; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton i { animation: none; } }

/* help */
#help-btn { position: relative; font-weight: 700; }
.help-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.help-steps { padding-left: 1.2rem; display: grid; gap: .5rem; }
.help-news { padding-left: 1.2rem; display: grid; gap: .3rem; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35rem; font: inherit; font-size: .85em; background: var(--panel); }

/* helpers (sub-agents): a chip in the top bar, a panel with each helper's progress */
.helpers-wrap { position: relative; flex: none; }
.helpers-chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; padding: .15rem .65rem; border-radius: 999px; border: 1px solid var(--line); background: var(--accent-soft); color: var(--ink); cursor: pointer; }
.helpers-chip .spin { width: 10px; height: 10px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.helpers-chip.idle .spin { display: none; }
.helpers-pop.menu.down { left: 0; right: auto; width: min(26rem, 92vw); max-height: 60vh; overflow: auto; gap: .35rem; padding: .6rem; }
.helpers-pop h3 { margin: 0 0 .1rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.helper { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: .85rem; }
.helper > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; }
.helper > summary::-webkit-details-marker { display: none; }
.helper .h-ico { width: 14px; height: 14px; flex: none; display: grid; place-items: center; font-size: .8rem; line-height: 1; }
.helper.running .h-ico { border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.helper.done .h-ico { color: var(--ok); } .helper.done .h-ico::before { content: "✓"; }
.helper.failed .h-ico { color: var(--err); } .helper.failed .h-ico::before { content: "✕"; }
.helper .h-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.helper .h-kind { flex: none; color: var(--muted); font-size: .76rem; }
.helper .h-body { padding: 0 .6rem .5rem 1.9rem; display: flex; flex-direction: column; gap: .2rem; color: var(--muted); }
.helper .h-step.running { color: var(--ink); } .helper .h-step.failed { color: var(--err); }
.helper .h-sum { color: var(--ink); margin: .2rem 0 0; }
/* goal: what done means, checked after each turn */
.goal-chip.met { background: color-mix(in srgb, var(--ok) 14%, var(--panel)); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.goal-chip.attn { background: color-mix(in srgb, #c77d00 14%, var(--panel)); border-color: color-mix(in srgb, #c77d00 40%, var(--line)); }
.goal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; }
.goal-list li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .1rem .4rem; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.goal-list .g-ico { font-weight: 700; color: var(--muted); }
.goal-list li.met .g-ico { color: var(--ok); }
.goal-list .g-note { grid-column: 2; color: var(--muted); font-size: .8rem; }
.goal-state { margin: .2rem 0 0; font-size: .85rem; font-weight: 600; }
.goal-pop .note { margin: .1rem 0; font-size: .82rem; }
.goal-edit { width: 100%; font: inherit; font-size: .9rem; padding: .5rem .6rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); resize: vertical; }
.goal-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
@media (max-width: 800px) { .helpers-pop.menu.down { position: fixed; left: .5rem; right: .5rem; top: 3.6rem; width: auto; } }

.progress-pop ul { list-style: none; margin: 0 0 .4rem; padding: 0; font-size: .85rem; display: flex; flex-direction: column; gap: .15rem; }
.progress-pop li { overflow-wrap: anywhere; }
.progress-pop .note { font-size: .82rem; color: var(--muted); margin: 0 0 .4rem; }

/* "What changed?" tour: the summary, then the step, then its buttons, one under the other */
.summary-card .cta-text, .summary-card .tour, .summary-card .tour-nav { flex: 1 1 100%; }
.tour { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; font-size: .92rem; }
.tour p { margin: .25rem 0 0; }
.tour-count { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tour-title { display: block; margin-top: .1rem; }
.tour-nav { display: flex; flex-wrap: wrap; gap: .4rem; }
/* the goal panel opens toward the page, never past its right edge */
.goal-pop.menu.down { left: auto; right: 0; }
@media (max-width: 800px) { .goal-pop.menu.down { left: .5rem; right: .5rem; } }
