/* Craft phone app. Quiet, flat and monochrome, laid out like Codex on a
   phone: a title dropdown at the top, one rounded composer at the bottom,
   dropdown menus anchored to the button that opened them (the same menus
   Craft has on the PC), a "/" command menu, bottom sheets only for decisions.
   Dark and light come from the variables below; an explicit choice
   (data-theme on <html>) wins over the system setting. */
:root {
  --bg: #0d0d0d;
  --surface: #171717;
  --surface-2: #222222;
  --sheet: #161616;
  --pop: #1b1b1b;
  --border: #262626;
  --border-strong: #343434;
  --text: #ededed;
  --muted: #a3a3a3;
  --faint: #6e6e6e;
  --accent: #ededed;
  --accent-text: #0d0d0d;
  --link: #7fb2ff;
  --brand: #3d6af2;
  --circle: #151515;
  /* Edges: a thin rim all round and a brighter line along the top, like ChatGPT's buttons. */
  --rim: rgba(255,255,255,.10);
  --rim-top: rgba(255,255,255,.07);
  --edge: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top);
  --user-bg: #1f1f1f;
  --code-bg: #121212;
  --add: #4fbf7f;
  --del: #ef6f5e;
  --danger: #ef6f5e;
  --invert-bg: #ededed;
  --invert-text: #0d0d0d;
  --shadow: 0 12px 32px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.09), inset 0 1px 0 rgba(255,255,255,.06);
  --scrim: rgba(0,0,0,.25);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", Roboto, "Segoe UI", system-ui, sans-serif;
  --serif: var(--font);
  --mono: ui-monospace, "SF Mono", "Roboto Mono", "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(.2,.8,.2,1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff; --surface: #f4f4f4; --surface-2: #e9e9e9; --sheet: #ffffff; --pop: #ffffff; --border: #e6e6e6; --border-strong: #d6d6d6;
    --text: #0d0d0d; --muted: #5e5e5e; --faint: #9b9b9b; --accent: #0d0d0d; --accent-text: #ffffff; --link: #1667d9; --brand: #2f5fe8; --circle: #f4f4f4; --rim: rgba(0,0,0,.08); --rim-top: rgba(255,255,255,.9); --user-bg: #f1f1f1;
    --code-bg: #f6f6f6; --add: #23864a; --del: #c8432f; --danger: #c8432f; --invert-bg: #0d0d0d; --invert-text: #ffffff;
    --shadow: 0 12px 32px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.07); --scrim: rgba(0,0,0,.06);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #ffffff; --surface: #f4f4f4; --surface-2: #e9e9e9; --sheet: #ffffff; --pop: #ffffff; --border: #e6e6e6; --border-strong: #d6d6d6;
  --text: #0d0d0d; --muted: #5e5e5e; --faint: #9b9b9b; --accent: #0d0d0d; --accent-text: #ffffff; --link: #1667d9; --brand: #2f5fe8; --circle: #f4f4f4; --rim: rgba(0,0,0,.08); --rim-top: rgba(255,255,255,.9); --user-bg: #f1f1f1;
  --code-bg: #f6f6f6; --add: #23864a; --del: #c8432f; --danger: #c8432f; --invert-bg: #0d0d0d; --invert-text: #ffffff;
  --shadow: 0 12px 32px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.07); --scrim: rgba(0,0,0,.06);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
a { color: inherit; }
.hidden { display: none !important; }
.serif { font-family: var(--font); font-weight: 600; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.caret { flex: none; opacity: .7; }

.icon-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; color: var(--text); flex: none; transition: background .15s var(--ease); }
.icon-btn:active { background: var(--surface); }
.icon-btn.small { width: 34px; height: 34px; color: var(--muted); }
/* Round header buttons with a soft fill, like ChatGPT on iOS. */
.circle-btn, .round-btn, .box, .suggest button, .ctx-chip, .pop-tile, .drawer-search, .btn-quiet { box-shadow: var(--edge); }
.circle-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--circle); color: var(--text); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: transform .15s var(--ease), background .15s; }
.circle-btn:active { transform: scale(.94); }
.circle-btn.on { background: var(--surface-2); }

.btn { height: 46px; padding: 0 18px; border-radius: 999px; font-weight: 600; font-size: 15px; transition: opacity .15s var(--ease), transform .15s var(--ease); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-quiet { background: var(--surface); color: var(--text); }
.btn-primary { box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), inset 0 -1px 0 rgba(0,0,0,.18); }
.btn:disabled { opacity: .5; }
.link-btn { color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 8px 0; }
.form-error { color: var(--danger); font-size: 14px; margin: 0; }

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

/* ─── Sign in ─── */
.signin { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; }
.signin-inner { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.signin-mark { width: 40px; height: 40px; margin-bottom: 20px; border-radius: 10px; }
.signin h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 8px; }
.signin p { margin: 0 0 24px; font-size: 15px; line-height: 1.45; }
.signin-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.signin-form input { height: 48px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); padding: 0 15px; outline: none; transition: border-color .15s; }
.signin-form input:focus { border-color: var(--muted); }
.signin-form .btn { margin-top: 6px; }
.signin-form p.muted { margin: 0 0 6px; }
.signin-busy { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-top: 8px; }

/* ─── App shell ─── */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; }
/* Three equal parts: the title stays in the exact centre whatever sits on either side. */
.top { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: calc(6px + env(safe-area-inset-top)) 14px 8px; }
.top > :first-child { justify-self: start; }
.top > :last-child { justify-self: end; }
.top-right { display: flex; align-items: center; gap: 8px; }
.top-title { min-width: 0; max-width: calc(100vw - 230px); display: flex; align-items: center; justify-content: center; gap: 4px; height: 44px; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.top-title > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title:active > span { opacity: .6; }
div.top-title { display: block; text-align: center; line-height: 40px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 18px 16px; }

/* Empty state: one quiet line in the middle, like ChatGPT. */
.empty { min-height: 100%; display: flex; flex-direction: column; }
.empty-head { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 12px 40px; }
.greeting { font-size: 27px; line-height: 1.2; margin: 0; font-weight: 600; letter-spacing: -.035em; }
.empty-sub { color: var(--muted); font-size: 14.5px; margin: 10px 0 0; }
.empty-sub:empty { display: none; }
.empty-sub strong { color: var(--text); font-weight: 600; }

/* Starters: a sideways row of cards just above the composer. */
/* Edge to edge for swiping, but the first card lines up with the message box (snapping keeps the same 12px). */
.suggest { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 10px; padding: 0 12px; scroll-padding-inline: 12px; scroll-snap-type: x proximity; }
.suggest::after { content: ''; flex: none; width: 4px; }
.suggest::-webkit-scrollbar { display: none; }
.suggest button { flex: none; scroll-snap-align: start; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 14px; border-radius: 18px; background: var(--surface); text-align: left; max-width: 220px; transition: transform .15s var(--ease), background .15s; }
.suggest button:active { transform: scale(.97); background: var(--surface-2); }
.suggest button strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.suggest button span { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ─── Composer ─── */
.composer { flex: none; position: relative; padding: 6px 12px max(10px, calc(env(safe-area-inset-bottom) - 14px)); }
.ctx-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 0 8px; }
.ctx-chip { display: inline-flex; align-items: stretch; height: 30px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 500; max-width: 100%; min-width: 0; }
.ctx-main { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 10px; min-width: 0; border-radius: 999px 0 0 999px; }
.ctx-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-ico { display: inline-flex; flex: none; color: var(--muted); }
.ctx-ico svg { width: 14px; height: 14px; }
.ctx-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--faint); }
.ctx-dot.on { background: var(--add); }
.ctx-x { display: inline-flex; align-items: center; justify-content: center; width: 28px; color: var(--muted); border-radius: 0 999px 999px 0; }
.ctx-chip:has(.ctx-x.hidden) .ctx-main { padding-right: 11px; }
.ctx-main:active, .ctx-x:active { background: var(--border-strong); }
.ctx-status { display: none; }
.box { background: var(--surface); border-radius: 28px; padding: 10px 8px 8px 12px; transition: box-shadow .15s var(--ease); }
.box:focus-within { border-color: var(--border-strong); }
.box textarea { width: 100%; border: 0; outline: none; background: transparent; resize: none; font-size: 17px; letter-spacing: -.01em; line-height: 1.4; max-height: 160px; padding: 4px 6px 10px 4px; display: block; }
.box textarea::placeholder { color: var(--faint); }
.box-row { display: flex; align-items: center; gap: 6px; }
.round-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--circle); display: inline-flex; align-items: center; justify-content: center; color: var(--text); flex: none; margin-left: -2px; transition: background .15s; }
.round-btn:active, .pill-btn:active { background: var(--surface-2); }
.pill-btn { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px 0 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--muted); flex: none; min-width: 0; transition: background .15s; }
.pill-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#codeModeChip { border: 1px solid var(--border-strong); color: var(--text); }
.spacer { flex: 1; }
.send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-text); box-shadow: inset 0 -1.5px 0 rgba(0,0,0,.14), inset 0 0 0 1px rgba(0,0,0,.06); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: opacity .15s, transform .15s var(--ease); }
.send-btn:active { transform: scale(.92); }
.send-btn:disabled { opacity: .35; }
/* Empty composer: the voice button (Calls) instead of send, like ChatGPT. */
.voice-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-text); box-shadow: inset 0 -1.5px 0 rgba(0,0,0,.14), inset 0 0 0 1px rgba(0,0,0,.06); display: none; align-items: center; justify-content: center; flex: none; transition: transform .15s var(--ease); }
.voice-btn:active { transform: scale(.92); }
.composer.empty-input .voice-btn { display: inline-flex; }
.composer.empty-input .send-btn { display: none; }

/* "/" commands: rises above the composer while you type, like Craft's slash menu. */
.slash { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 2px); z-index: 20; max-height: min(52vh, 380px); overflow-y: auto; background: var(--pop); border-radius: 18px; box-shadow: var(--shadow); padding: 6px; animation: popIn .16s var(--ease); transform-origin: bottom center; }
.slash-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); padding: 6px 10px 4px; }
.slash-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 6px 10px; border-radius: 12px; text-align: left; }
.slash-item.active, .slash-item:active { background: var(--surface-2); }
.slash-ico { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--text); }
.slash-item.active .slash-ico { background: var(--bg); }
.slash-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.slash-txt strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.slash-txt small { color: var(--faint); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slash-tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 7px; flex: none; }

/* ─── Dropdown menus (anchored popovers) ─── */
.pop-layer { position: fixed; inset: 0; z-index: 80; }
.pop-catch { position: absolute; inset: 0; background: var(--scrim); animation: fade .16s ease; }
.pop { position: absolute; width: min(320px, calc(100vw - 24px)); overflow-y: auto; overscroll-behavior: contain; background: var(--pop); border-radius: 18px; box-shadow: var(--shadow); padding: 6px; animation: popIn .17s var(--ease); }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(var(--pop-dy, 4px)); } to { opacity: 1; transform: none; } }
.pop .sheet-title { font-size: 12.5px; font-weight: 500; color: var(--faint); margin: 0; padding: 8px 10px 4px; }
.pop .sheet-label { font-size: 12px; color: var(--faint); margin: 0; padding: 8px 10px 4px; }
.pop .sheet-text { font-size: 13.5px; margin: 0; padding: 2px 10px 8px; }
.pop .pick-row { min-height: 46px; padding: 7px 10px; border-radius: 12px; gap: 12px; font-size: 15.5px; letter-spacing: -.01em; }
.pop .pick-row:active, .pop .pick-row:focus-visible { background: var(--surface-2); outline: none; }
.pop .pick-row .pick-main small { font-size: 12px; white-space: normal; line-height: 1.35; }
.pop .pick-row > svg:first-child { width: 20px; height: 20px; }
.pop .pick-ico { width: 20px; height: 20px; color: var(--text); }
.pop .pick-ico svg { width: 20px; height: 20px; }
.pop .pick-divider { margin: 6px 4px; }
.pop .pick-note { font-size: 12px; margin: 6px 10px 6px; }
.pop-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 4px 8px; }
.pop-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; height: 76px; border-radius: 16px; background: var(--surface-2); font-size: 14px; font-weight: 500; color: var(--text); }
.pop-tile svg { color: var(--text); }
.pop-tile:active { background: var(--border-strong); }
.pick-kbd { font-size: 12.5px; color: var(--faint); flex: none; }
.pick-ico { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }

/* ─── Feed ─── */
.feed { display: flex; flex-direction: column; gap: 14px; padding-top: 10px; }
.msg { font-size: 17px; line-height: 1.5; letter-spacing: -.01em; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 82%; background: var(--user-bg); padding: 10px 16px; border-radius: 22px; white-space: pre-wrap; }
.msg.agent { align-self: stretch; }
.msg.error { color: var(--danger); font-size: 15px; white-space: pre-wrap; }
.msg.note { color: var(--muted); font-size: 14px; }
.msg p { margin: 0 0 10px; }
.msg p:last-child, .msg ul:last-child, .msg ol:last-child, .msg pre:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 0 0 10px; padding-left: 22px; }
.msg li { margin: 3px 0; }
.msg h3, .msg h4 { font-size: 16px; margin: 14px 0 6px; }
.msg code { font-family: var(--mono); font-size: 13.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.msg pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; overflow-x: auto; margin: 0 0 10px; }
.msg pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; white-space: pre; }
.msg a { color: var(--link); }

.working { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; }

.step { font-size: 14px; color: var(--muted); }
.step.tool + .step.tool { margin-top: -10px; }
.step.tool > summary { min-height: 30px; }
.step > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 26px; cursor: pointer; }
.step > summary::-webkit-details-marker { display: none; }
.step .chev { flex: none; transition: transform .15s; color: var(--faint); }
.step[open] .chev { transform: rotate(90deg); }
.step.no-body .chev { visibility: hidden; }
.step-verb { color: var(--text); font-weight: 500; flex: none; font-size: 13.5px; }
.step-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; color: var(--muted); }
.step-stats { flex: none; display: inline-flex; gap: 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.step.failed .step-verb { color: var(--danger); }
.step-body { margin: 6px 0 4px 2px; }
.step-body-label { font-size: 12px; color: var(--faint); margin: 4px 0; font-family: var(--mono); }
.step-text { color: var(--muted); line-height: 1.5; white-space: pre-wrap; padding: 4px 0 0 2px; }
.code { font-family: var(--mono); font-size: 12px; line-height: 1.5; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 0 0 6px; overflow-x: auto; white-space: pre; color: var(--text); }
.code.del { color: var(--del); }
.code.add { color: var(--add); }
.add { color: var(--add); }
.del { color: var(--del); }
/* A screenshot on its step: drawn at the page's own shape (--sw/--sh), never taller than --shot-h. */
.shot { --shot-h: 260px; position: relative; display: block; margin: 8px 0 4px; width: min(100%, calc(var(--shot-h) * var(--sw, 16) / var(--sh, 10))); aspect-ratio: var(--sw, 16) / var(--sh, 10); border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); -webkit-tap-highlight-color: transparent; }
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; animation: shotIn .28s var(--ease) both; }
.shot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--border); pointer-events: none; }
.shot[data-state="ready"] { cursor: zoom-in; }
.shot[data-state="ready"]:active { transform: scale(.985); transition: transform .12s var(--ease); }
.shot:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.shot-ph { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, var(--fill, rgba(255,255,255,.06)) 50%, transparent 70%) var(--surface); background-size: 220% 100%; animation: shotWait 1.4s linear infinite; }
.shot[data-state="ready"] .shot-ph { display: none; }
@keyframes shotWait { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes shotIn { from { opacity: 0; } }
.shot-fail { display: flex; align-items: flex-start; gap: 7px; margin: 6px 0 4px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.shot-fail svg { flex: none; width: 15px; height: 15px; margin-top: 1px; fill: none; stroke: var(--faint); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { .shot-ph, .shot img { animation: none; } }

.summary-card { border: 1px solid var(--border); background: var(--surface); border-radius: 16px; padding: 10px 12px; font-size: 13.5px; display: flex; flex-direction: column; gap: 5px; }
.summary-head { font-size: 12px; color: var(--faint); font-weight: 500; }
.summary-files { display: flex; flex-wrap: wrap; gap: 5px; }
.summary-files span, .file-list code { font-size: 12.5px; }
.summary-files span { background: var(--surface-2); padding: 2px 8px; border-radius: 7px; }
.check { font-size: 13px; }
.check.pass { color: var(--add); }
.check.fail { color: var(--del); }
.check span { color: var(--faint); }
.file-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.file-list li { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.file-list li code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list li span { font-family: var(--mono); }
.pushed-head { font-size: 13.5px; line-height: 1.45; }
.pushed-head code { font-family: var(--mono); font-size: 12.5px; }

.inline-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); border-radius: 14px; padding: 8px 8px 8px 12px; font-size: 14px; color: var(--muted); }
.inline-row button { height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; flex: none; }
.inline-row.undone { opacity: .7; }

.question { border: 1px solid var(--border); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.question .q-opts { display: flex; flex-direction: column; gap: 6px; }
.question .q-opts button { text-align: left; padding: 10px 13px; border-radius: 12px; background: var(--surface); font-size: 14px; }
.question form { display: flex; gap: 6px; }
.question input { flex: 1; min-width: 0; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: transparent; padding: 0 10px; outline: none; }
.question form button { padding: 0 12px; border-radius: 10px; background: var(--surface); font-size: 14px; }
.question .q-skip { align-self: flex-start; color: var(--muted); font-size: 13px; }
.question .q-answer { color: var(--muted); font-size: 14px; }

/* Steps the agent took, folded into one row (open it to see each one). */
.steps-group { font-size: 14px; color: var(--muted); }
.steps-group > summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 30px; max-width: 100%; cursor: pointer; color: var(--muted); }
.steps-group > summary::-webkit-details-marker { display: none; }
.steps-group > summary:active { opacity: .6; }
.steps-group .sg-ico:empty { display: none; }
.steps-group .sg-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps-group.live .sg-text { color: var(--text); background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.steps-group > summary > .chev { flex: none; transition: transform .18s var(--ease); color: var(--faint); }
.steps-group[open] > summary > .chev { transform: rotate(90deg); }
.steps-group.has-failed .sg-text { color: var(--muted); }
.sg-body { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 2px 6px; padding-left: 14px; border-left: 1px solid var(--border-strong); }
.sg-body .step.tool + .step.tool { margin-top: 0; }
.sg-body .msg.note { font-size: 13px; }

.verify { font-size: 13.5px; color: var(--muted); }
.verify > summary { list-style: none; display: inline-flex; align-items: center; gap: 7px; min-height: 28px; cursor: pointer; }
.verify > summary::-webkit-details-marker { display: none; }
.verify > summary > .chev { color: var(--faint); transition: transform .18s var(--ease); }
.verify[open] > summary > .chev { transform: rotate(90deg); }
.verify-mark { width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex: none; }
.verify.ok .verify-mark { background: color-mix(in srgb, var(--add) 22%, transparent); color: var(--add); }
.verify.warn .verify-mark { background: color-mix(in srgb, var(--del) 22%, transparent); color: var(--del); }
.verify .summary-card { margin-top: 6px; }

/* ─── Drawer (laid out like ChatGPT's) ─── */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; opacity: 0; transition: opacity .25s; }
.backdrop.open { opacity: 1; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(80vw, 330px); background: var(--bg); z-index: 41; display: flex; flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)); transform: translateX(-102%); transition: transform .28s var(--ease); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 0 6px 8px; }
.drawer-title { flex: 1; font-size: 25px; font-weight: 700; letter-spacing: -.025em; }
.drawer-search { flex: 1; display: flex; align-items: center; gap: 8px; height: 44px; border-radius: 999px; background: var(--surface); padding: 0 14px; color: var(--faint); margin-left: -8px; }
.drawer-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 16.5px; }
.drawer-search input::-webkit-search-cancel-button { display: none; }
.drawer-nav { display: flex; flex-direction: column; padding: 6px 0 4px; }
.drawer-item { display: flex; align-items: center; gap: 16px; height: 52px; padding: 0 8px; border-radius: 14px; font-size: 18px; font-weight: 500; letter-spacing: -.01em; text-align: left; color: var(--text); }
.drawer-item svg { flex: none; color: var(--text); }
.drawer-item:active, .chat-row:active { background: var(--surface); }
.drawer-sep { height: 1px; background: var(--border-strong); margin: 10px 8px 12px; flex: none; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; margin: 0 -2px; padding: 0 2px; }
.chat-row { display: flex; align-items: center; min-height: 48px; padding: 0 8px; border-radius: 14px; font-size: 17px; letter-spacing: -.01em; text-align: left; width: 100%; color: var(--text); flex: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.chat-row.active { background: var(--surface); }
.chat-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.see-all { color: var(--muted); }
.pick-row.danger strong, .pick-row.danger .pick-ico { color: var(--danger); }
.chat-empty { color: var(--faint); font-size: 15px; padding: 8px; }
.drawer-foot { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 0; }
.pill-new { display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 26px 0 22px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 18px; font-weight: 600; letter-spacing: -.01em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), inset 0 1px 0 rgba(255,255,255,.28); transition: transform .15s var(--ease); }
.pill-new:active { transform: scale(.97); }
.drawer-foot .circle-btn { width: 52px; height: 52px; }
.pop-account { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; font-size: 14.5px; font-weight: 500; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.pop-account span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: none; }

/* ─── Sheets ─── */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.5); animation: fade .18s ease; }
.sheet-card { position: relative; width: 100%; max-width: 720px; max-height: 86vh; overflow-y: auto; background: var(--sheet); border-radius: 26px 26px 0 0; box-shadow: inset 0 1px 0 var(--rim), inset 1px 0 0 var(--rim), inset -1px 0 0 var(--rim); padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); animation: rise .24s var(--ease); }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }
.sheet-handle { width: 36px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 14px; }
.sheet-title { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.sheet-text { color: var(--muted); font-size: 15px; margin: 0 0 18px; line-height: 1.45; overflow-wrap: anywhere; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }
.sheet-label { font-size: 12px; color: var(--faint); margin: 6px 2px 6px; }
.pick-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 10px; border-radius: 14px; text-align: left; font-size: 15px; }
.pick-row:active { background: var(--surface); }
.pick-row .pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pick-row .pick-main strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row .pick-main small { color: var(--faint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row svg { flex: none; color: var(--muted); }
.pick-row .check-mark { visibility: hidden; color: var(--text); }
.pick-row.on .check-mark { visibility: visible; }
.pick-tag { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: 1px; }
.pick-note { color: var(--faint); font-size: 13px; margin: 10px 4px 0; line-height: 1.45; }
.pick-divider { height: 1px; background: var(--border); margin: 8px 0; }
.image-pick { display: block; max-width: 100%; max-height: 220px; border-radius: 10px; margin: 0 auto 16px; }

/* ─── Full-screen panel (cloud setup) ─── */
.panel { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; animation: rise .24s var(--ease); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 18px calc(24px + env(safe-area-inset-bottom)); }
.panel-body h2 { font-size: 24px; margin: 8px 0 6px; }
.panel-body p { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 0 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 12px 13px; outline: none; font-size: 15px; }
.field textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.field small { color: var(--faint); font-size: 12.5px; line-height: 1.4; }
.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--surface); gap: 3px; }
.seg button { flex: 1; height: 36px; border-radius: 9px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--bg); color: var(--text); font-weight: 600; }
.repo-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 14px; }
.repo-row { display: flex; align-items: center; gap: 10px; padding: 12px 13px; text-align: left; font-size: 14.5px; border-bottom: 1px solid var(--border); }
.repo-row:last-child { border-bottom: 0; }
.repo-row:active { background: var(--surface); }
.repo-row span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; flex: none; }
.tag.ready { color: var(--add); border-color: currentColor; }
.connected { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.connected button { margin-left: auto; color: var(--muted); text-decoration: underline; font-size: 13px; }
.progress { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.progress li.done::before { content: "\2713  "; color: var(--add); }
.panel-body .btn { width: 100%; }

.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top, 0px) + 56px) 12px calc(env(safe-area-inset-bottom, 0px) + 24px); animation: fade .18s ease both; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 18px 48px rgba(0,0,0,.5); }
.lightbox-close { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 12px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.14); }
.lightbox-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Crew logo marks the bots (Calls) entry; the app itself uses the Codeply logo */
.drawer-crew { width: 18px; height: 18px; border-radius: 5px; flex: none; }

/* Tables in replies: a real table that scrolls sideways on a narrow screen. */
.md-table { overflow-x: auto; margin: 8px 0; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 12px; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 1.4; }
.md-table th, .md-table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border, rgba(127,127,127,.18)); min-width: 90px; }
.md-table tr:last-child td { border-bottom: 0; }
.md-table th { font-weight: 600; background: rgba(127,127,127,.08); white-space: nowrap; }

/* Attached files (attachments.js) */
.att-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 8px; }
.att-row.hidden { display: none; }
.att-note { width: 100%; font-size: 12.5px; color: #e5484d; }
.att-chip { display: inline-flex; align-items: center; gap: 9px; max-width: 100%; padding: 7px 12px 7px 8px; border-radius: 14px; background: var(--chip-bg, rgba(127,127,127,.1)); border: 1px solid var(--border, rgba(127,127,127,.2)); position: relative; }
.att-ico { width: 30px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 8px; background: rgba(75,149,255,.14); color: #3b82f6; }
.att-chip.pdf .att-ico { background: rgba(229,72,77,.14); color: #e5484d; }
.att-ico svg { width: 20px; height: 20px; }
.att-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.att-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.att-meta { font-size: 11.5px; opacity: .6; white-space: nowrap; }
.att-chip.reading .att-meta { animation: attPulse 1.4s ease-in-out infinite; }
@keyframes attPulse { 50% { opacity: .25; } }
.att-x { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; font-size: 15px; line-height: 20px; }
.msg-files { align-self: flex-end; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: 8px; max-width: 85%; margin-bottom: -2px; }

.att-img { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: visible; }
.att-img img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; display: block; border: 1px solid var(--border, rgba(127,127,127,.2)); }
.msg-thumb { width: 120px; height: 120px; object-fit: cover; border-radius: 14px; border: 1px solid var(--border, rgba(127,127,127,.2)); }

/* Long commands, paths and output wrap inside their box instead of widening the page */
.scroll { overflow-x: hidden; }
.feed, .feed > * { min-width: 0; max-width: 100%; }
.code { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; overflow-x: hidden; }
.step-text, .step-body-label, .summary-card, .check, .step-label { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }

/* a cloud run waiting for an OK */
.cloud-ask { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; font-size: 14px; min-width: 0; }
.cloud-ask span { color: var(--muted); overflow-wrap: anywhere; }
.cloud-ask .code { max-height: 160px; overflow-y: auto; }
.cloud-ask-btns { display: flex; gap: 8px; margin-top: 4px; }
/* setup: start a new repo */
.new-repo-row { display: flex; gap: 8px; }
.new-repo-row input { flex: 1; min-width: 0; }
.new-repo-row .btn { width: auto; flex: none; padding: 0 20px; }
.new-repo-row input { flex: 1 1 auto; width: auto; min-width: 0; }
.cloud-ask-btns .btn:not(.btn-primary) { border: 1px solid var(--border); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Craft's rich replies on the phone: coloured text, pills, documents, widget notes. */
.md-c-green { color: #3fb27f; } .md-c-red { color: #e5534b; } .md-c-blue { color: #3d8bfd; }
.md-c-amber { color: #e0892f; } .md-c-purple { color: #9a7cf0; } .md-c-gray { opacity: .7; }
.md-pill { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .82em; font-weight: 600; line-height: 1.6; border: 1px solid rgba(127,127,127,.3); background: rgba(127,127,127,.12); }
.md-pill.md-c-green { background: rgba(63,178,127,.14); border-color: rgba(63,178,127,.3); }
.md-pill.md-c-red { background: rgba(229,83,75,.14); border-color: rgba(229,83,75,.3); }
.md-pill.md-c-blue { background: rgba(61,139,253,.14); border-color: rgba(61,139,253,.3); }
.md-pill.md-c-amber { background: rgba(224,137,47,.14); border-color: rgba(224,137,47,.3); }
.md-pill.md-c-purple { background: rgba(154,124,240,.14); border-color: rgba(154,124,240,.3); }
.md-kbd { font: .82em ui-monospace, monospace; padding: 0 5px; border: 1px solid rgba(127,127,127,.35); border-bottom-width: 2px; border-radius: 5px; }
.md-doc { margin: 8px 0; padding: 12px 14px; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 14px; }
.md-widget-note { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; padding: 12px 14px; border: 1px dashed rgba(127,127,127,.4); border-radius: 14px; font-size: 13px; }
.md-widget-note span { opacity: .7; }
