:root {
  --bg: #f6f6f2;
  --surface: #ffffff;
  --surface-2: #efefea;
  --ink: #0e1411;
  --muted: #5a645e;
  --faint: #8a938d;
  --line: #e2e3dc;
  --accent: #087f44;
  --accent-hover: #066a39;
  --accent-ink: #ffffff;
  --accent-soft: #dff3e6;
  --ok: #087f44;
  --ok-soft: #dff3e6;
  --warn-bg: #fff4dd;
  --warn-line: #f1d9a5;
  --warn-ink: #7d4b00;
  --error-bg: #fdecea;
  --error-ink: #a1271b;
  --mark-bg: #0e1411;
  --mark-fg: #3ddc84;
  --glow: rgba(8, 127, 68, .13);
  --dots: rgba(14, 20, 17, .09);
  --shadow: 0 1px 2px rgba(14, 20, 17, .05), 0 10px 30px rgba(14, 20, 17, .07);
  --radius: 14px;
  --font: "Geist", "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #090b0a;
  --surface: #111413;
  --surface-2: #181c1a;
  --ink: #ecf0ed;
  --muted: #98a29c;
  --faint: #6b756f;
  --line: #242a27;
  --accent: #3ddc84;
  --accent-hover: #5ee79b;
  --accent-ink: #04140a;
  --accent-soft: #11301f;
  --ok: #3ddc84;
  --ok-soft: #11301f;
  --warn-bg: #2a2110;
  --warn-line: #4a3a18;
  --warn-ink: #efc46e;
  --error-bg: #331715;
  --error-ink: #ff9c90;
  --mark-bg: #3ddc84;
  --mark-fg: #04140a;
  --glow: rgba(61, 220, 132, .12);
  --dots: rgba(236, 240, 237, .08);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  height: 100dvh; margin: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font: 15.5px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* --- Top bar --- */
.topbar {
  flex: none; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px clamp(14px, 2vw, 22px); background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; letter-spacing: -.015em; }
.brand b { color: var(--accent); font-weight: 600; }
.brand-mark { flex: none; }
.topbar-actions { display: flex; gap: 8px; align-items: center; min-width: 0; }

/* --- Controls --- */
select, textarea, input, button { font: inherit; color: var(--ink); }
select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  max-width: 210px; min-width: 0; text-overflow: ellipsis; font-size: 13.5px; cursor: pointer;
}
select:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn {
  font-weight: 550; font-size: 14px; padding: 8px 15px; border-radius: 10px; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 28%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 18px var(--glow); }
.btn.success { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 10px 18px; font-size: 15px; border-radius: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn .arrow { transition: transform .15s; }
.btn:hover .arrow { transform: translateX(2px); }
[dir="rtl"] .arrow { scale: -1 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.link { color: var(--accent); font-size: 13.5px; text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
:root[data-theme="dark"] .icon-btn .moon, :root:not([data-theme="dark"]) .icon-btn .sun { display: none; }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.seg button {
  font-size: 12.5px; font-weight: 600; padding: 3px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }

.field { display: flex; align-items: center; gap: 8px; min-width: 0; }
.field label { font-size: 13px; color: var(--muted); white-space: nowrap; }
kbd {
  font: 500 11px/1 var(--mono); padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted);
}

.notice {
  flex: none; margin: 10px clamp(14px, 2vw, 22px) 0; padding: 7px 14px; border-radius: 10px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); font-size: 13.5px;
}
.muted { color: var(--muted); font-size: 13.5px; }

.spinner {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
.caret {
  display: inline-block; width: 7px; height: 1.05em; margin-inline-start: 2px; vertical-align: text-bottom;
  background: var(--accent); border-radius: 1px; animation: blink 1s steps(1) infinite;
}

/* --- Home --- */
.home {
  flex: 1; min-height: 0; overflow-y: auto;
  background:
    radial-gradient(900px 420px at 50% -80px, var(--glow), transparent 70%),
    radial-gradient(var(--dots) 1px, transparent 1px) 0 0 / 22px 22px;
}
.home-inner { width: min(1000px, 100% - 32px); margin: 0 auto; padding: clamp(36px, 9vh, 96px) 0 40px; }
.hero { text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-size: 12.5px; font-weight: 550; margin-bottom: 22px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.8s ease-out infinite; }
.hero h1 {
  font-size: clamp(38px, 7vw, 68px); line-height: 1.03; letter-spacing: -.045em; font-weight: 650;
  text-wrap: balance;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.lead { color: var(--muted); font-size: clamp(16px, 2vw, 18px); margin: 20px auto 34px; max-width: 56ch; text-wrap: pretty; }
.composer {
  text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 16px 16px 12px; box-shadow: var(--shadow); max-width: 740px; margin-inline: auto;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow), var(--shadow); }
.composer textarea {
  width: 100%; border: 0; background: transparent; resize: none; padding: 4px 6px; font-size: 16.5px;
  min-height: 104px; line-height: 1.5;
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder, .edit-box textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.composer-go { display: flex; align-items: center; gap: 5px; }
.composer-go .btn { margin-inline-start: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px auto 0; max-width: 740px; }
.chip {
  font-size: 13px; padding: 5px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }
.proof { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; margin-top: 26px; color: var(--muted); font-size: 13.5px; }
.proof li { display: inline-flex; align-items: center; gap: 7px; }
.proof li::before {
  content: ""; width: 14px; height: 14px; flex: none; background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' stroke='%23000' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.section-title { font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 14px; }
.apps, .how { margin-top: clamp(40px, 8vh, 76px); }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.app-card {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); text-align: start;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; min-width: 0;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.app-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.app-card span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; font-size: 14.5px; }
.app-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: hsl(var(--hue, 150) 55% 42%); color: #fff; font-weight: 650; font-size: 16px;
}
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.step-n { display: block; font: 500 12.5px var(--mono); color: var(--accent); margin-bottom: 14px; }
.step h3 { font-size: 16.5px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 5px; }
.step p { color: var(--muted); font-size: 14.5px; }
.foot { text-align: center; color: var(--faint); font-size: 13px; margin-top: 52px; }

/* --- Workspace --- */
.workspace {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(330px, 410px) minmax(0, 1fr); gap: 14px;
  padding: 14px clamp(14px, 2vw, 22px);
}
.chat {
  display: flex; flex-direction: column; min-height: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
}
/* The quick chips draw the divider above the composer; without them the composer gets its own gap. */
.quick[hidden] + .edit-box { margin-top: 12px; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; flex: none;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}
.app-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-head .app-icon { width: 32px; height: 32px; border-radius: 9px; font-size: 14.5px; }
.app-title { min-width: 0; line-height: 1.25; }
.app-title h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-meta { font-size: 12px; color: var(--faint); }
.chat-head select { max-width: 150px; font-size: 12.5px; padding: 5px 8px; flex: none; }

/* App logo button (letter avatar or the uploaded logo) and the editable name */
.logo-btn { position: relative; border: 0; padding: 0; cursor: pointer; }
.logo-btn:disabled, .logo-btn.static { cursor: default; }
/* App icon card */
.icon-row { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.icon-preview {
  width: 56px; height: 56px; border-radius: 16px; font-size: 22px; overflow: hidden; flex: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.icon-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.icon-card .build-actions .btn { flex: 1; }
.logo-btn img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
.logo-badge {
  position: absolute; inset-block-end: -3px; inset-inline-end: -3px; width: 15px; height: 15px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  opacity: 0; transition: opacity .15s;
}
.logo-btn:hover .logo-badge, .logo-btn:focus-visible .logo-badge { opacity: 1; }
.logo-btn:disabled .logo-badge { display: none; }
.app-name { display: flex; min-width: 0; }
.name-btn {
  font: inherit; letter-spacing: inherit; border: 0; background: none; padding: 1px 4px; margin-inline-start: -4px;
  border-radius: 6px; cursor: text; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; text-align: start;
}
.name-btn:hover:not(:disabled) { background: var(--surface-2); }
.name-btn:disabled { cursor: default; }
.name-input {
  font: inherit; width: 100%; min-width: 0; padding: 0 4px; margin-inline-start: -4px; border: 1px solid var(--accent);
  border-radius: 6px; background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--glow);
}
.link.logo-link { display: inline-block; margin-top: 8px; padding: 0; border: 0; background: none; cursor: pointer; }
.link.logo-link:disabled { color: var(--faint); cursor: default; text-decoration: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 18px 16px 22px; display: flex; flex-direction: column; gap: 14px; min-height: 160px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent; overscroll-behavior: contain; scroll-padding-bottom: 22px;
}
/* Children of a scrolling flex column must keep their full height, or their bottom gets cut off. */
.messages > * { flex-shrink: 0; }
.msg-list { display: flex; flex-direction: column; gap: 14px; }
.msg-list:empty { display: none; }
.msg { max-width: 88%; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .25s ease-out; }
.msg.user {
  align-self: flex-end; background: var(--accent); color: var(--accent-ink); padding: 9px 14px;
  border-radius: 18px; border-end-end-radius: 6px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.msg.assistant {
  align-self: flex-start; position: relative; background: var(--bg); border: 1px solid var(--line);
  padding: 10px 14px; padding-inline-start: 40px; border-radius: 18px; border-end-start-radius: 6px;
}
/* The assistant's mark: a small spark in an accent circle. */
.msg.assistant::before {
  content: ""; position: absolute; inset-inline-start: 11px; top: 11px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2l1.5 4.5L14 8l-4.5 1.5L8 14l-1.5-4.5L2 8l4.5-1.5z' fill='%23087f44'/%3E%3C/svg%3E") center / 12px no-repeat;
}
:root[data-theme="dark"] .msg.assistant::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2l1.5 4.5L14 8l-4.5 1.5L8 14l-1.5-4.5L2 8l4.5-1.5z' fill='%233ddc84'/%3E%3C/svg%3E");
}
.msg.system { align-self: stretch; max-width: none; color: var(--muted); font-size: 13px; padding: 0 4px; line-height: 1.5; }
.msg.system.error, .msg.system.success, .msg.system.fix, .msg.system.build { padding: 9px 12px; border-radius: 12px; }
.msg.system.build { background: var(--surface-2); }
.msg.system.error { background: var(--error-bg); color: var(--error-ink); }
.msg.system.success { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.msg.system.fix { background: var(--warn-bg); color: var(--warn-ink); }
.msg.system.done { display: flex; align-items: center; gap: 10px; font: 500 12px var(--mono); color: var(--faint); }
.msg.system.done::before, .msg.system.done::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg details { margin-top: 6px; }
.msg summary { cursor: pointer; font-size: 12.5px; }
.msg pre, .card pre {
  margin: 6px 0 0; padding: 9px 11px; background: rgba(0, 0, 0, .07); border-radius: 8px; font: 12px/1.55 var(--mono);
  direction: ltr; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto;
}
.msg.ghost { color: var(--muted); }
.msg.assistant.ghost { background: transparent; border-style: dashed; }

/* Live run card */
.run {
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; background: var(--bg);
  animation: rise .25s ease-out; position: relative; overflow: hidden;
}
.run::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent) 0 0 / 200% 100%; animation: shimmer 2.2s linear infinite;
}
.run-head { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.run-head strong { flex: 1; min-width: 0; font-weight: 600; }
.run-head time { font: 500 12.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.orb { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-out infinite; flex: none; }
.run-steps { margin-top: 13px; display: flex; flex-direction: column; }
.run-steps > li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding-bottom: 11px; position: relative; color: var(--faint); font-size: 13.5px; }
.run-steps > li:last-child { padding-bottom: 0; }
.run-steps > li:not(:last-child)::before {
  content: ""; position: absolute; inset-inline-start: 8.5px; top: 20px; bottom: 1px; width: 1px; background: var(--line);
}
.run-steps > li.done::before { background: var(--accent); opacity: .5; }
.tick { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line); margin-top: 1px; display: grid; place-items: center; }
.run-steps > li.active { color: var(--ink); }
.run-steps > li.active .step-label { font-weight: 550; }
.run-steps > li.active .tick { border-color: color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.run-steps > li.done { color: var(--muted); }
.run-steps > li.done .tick { border-color: var(--accent); background: var(--accent); }
.run-steps > li.done .tick::after {
  content: ""; width: 10px; height: 10px; background: var(--accent-ink);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' stroke='%23000' stroke-width='2.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.step-stat { font: 500 11.5px var(--mono); color: var(--faint); margin-inline-start: 8px; }
.thought {
  margin-top: 7px; max-height: 92px; overflow: hidden; font-size: 12.5px; line-height: 1.55; color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere; font-style: italic;
  mask-image: linear-gradient(transparent, #000 34px);
}
.run-steps > li:not(.active) .thought { display: none; }
.run-files { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.run-files:empty { display: none; }
.run-files li {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 7px; background: var(--surface);
  border: 1px solid var(--line); font: 12px var(--mono); color: var(--muted); animation: rise .2s ease-out; text-align: left;
}
.run-files li::before { display: none; }
.run-files .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.run-files .fstate { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.run-files li.writing .fstate { animation: pulse 1.2s ease-out infinite; }
.run-files li:not(.writing) .fstate { opacity: .45; }
.run-hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

.quick { display: flex; gap: 6px; padding: 10px 12px 8px; overflow-x: auto; scrollbar-width: none; flex: none; border-top: 1px solid var(--line); }
.quick .chip { white-space: nowrap; font-size: 12.5px; padding: 4px 11px; }
.edit-box {
  flex: none; display: flex; gap: 8px; align-items: flex-end; margin: 0 12px 12px; padding: 7px; padding-inline-start: 13px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); transition: border-color .15s, box-shadow .15s;
}
.edit-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.edit-box textarea { flex: 1; border: 0; background: transparent; resize: none; padding: 6px 0; max-height: 150px; font-size: 14.5px; line-height: 1.45; }
.edit-box textarea:focus { outline: none; }
.send {
  width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer; flex: none; transition: background .15s, transform .08s;
}
.send:hover { background: var(--accent-hover); }
.send:active { transform: scale(.94); }
.send:disabled { background: var(--surface-2); color: var(--faint); cursor: not-allowed; }

/* --- Stage --- */
.stage { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.tabs button {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 550; padding: 5px 16px; border: 0;
  border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-out infinite; display: none; }
.tabs button.live .live-dot { display: block; }
.stage-tools { display: flex; gap: 6px; align-items: center; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; background: transparent; color: var(--muted); }
[dir="rtl"] .flip-rtl { scale: -1 1; }
#editModeBtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Inspector: the element selected in visual edit mode */
.inspector { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; animation: rise .2s ease-out; }
.insp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.insp-head strong { font: 600 13.5px var(--mono); color: var(--accent); }
.insp-head .icon-btn { width: 28px; height: 28px; }
.insp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; color: var(--muted); }
.insp-row > label, .insp-row > span:first-child { white-space: nowrap; }
.insp-text { flex-direction: column; align-items: stretch; gap: 4px; }
.inspector input[type="text"], .inspector input[type="number"] {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); min-width: 0; font-size: 13.5px;
}
.inspector input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.inspector input[type="color"] {
  width: 38px; height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer;
}
.insp-num { width: 74px; }
.insp-pair { display: inline-flex; align-items: center; gap: 6px; }
.insp-pos { font: 12.5px var(--mono); color: var(--ink); white-space: nowrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { width: 28px; height: 28px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 15px; color: var(--ink); }
.stepper button:hover { background: var(--line); }
.inspector .stepper input { width: 52px; border: 0; border-radius: 0; text-align: center; background: var(--surface); }
.tog {
  width: 30px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.tog[aria-pressed="true"], .inspector .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.inspector .seg { padding: 2px; }
.inspector .seg button { display: grid; place-items: center; padding: 4px 7px; border: 1px solid transparent; }
.insp-actions { display: flex; gap: 4px; padding-top: 9px; border-top: 1px solid var(--line); }
.insp-actions .icon-btn { border-color: var(--line); color: var(--ink); }
.insp-actions .icon-btn.danger:hover { color: var(--error-ink); background: var(--error-bg); }
.insp-ask { align-self: stretch; }
.insp-hint { font-size: 12.5px; }
.stage-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
.stage-main { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.canvas {
  flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; padding: 16px;
  border: 1px solid var(--line); border-radius: 18px;
  background:
    radial-gradient(520px 360px at 50% 40%, var(--glow), transparent 70%),
    radial-gradient(var(--dots) 1px, transparent 1px) 0 0 / 18px 18px, var(--surface);
}
.phone {
  width: min(360px, 100cqw, (100cqh - 2px) * 9 / 18.6); aspect-ratio: 9 / 18.6; padding: 9px; border-radius: 44px;
  background: linear-gradient(145deg, #23282a, #0b0d0c 40%);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .3), 0 0 0 1px rgba(255, 255, 255, .04), inset 0 0 0 1.5px #343a37;
}
.phone-screen {
  --sb: 7.6cqw; --nav: 6cqw;
  position: relative; width: 100%; height: 100%; border-radius: 36px; overflow: hidden; background: #000;
  direction: ltr; container-type: size; isolation: isolate;
}
/* Camera punch hole, centered in the status bar. */
.phone-screen::after {
  content: ""; position: absolute; top: calc(var(--sb) / 2 - 1.6cqw); left: 50%; width: 3.2cqw; height: 3.2cqw; margin-left: -1.6cqw;
  border-radius: 50%; background: #050606; box-shadow: inset 0 0 0 .5px #222; z-index: 9; pointer-events: none;
}
.app-view {
  position: absolute; inset: var(--sb) 0 var(--nav); overflow: hidden; background: #fff;
  transition: transform .26s cubic-bezier(.3, 0, .2, 1), opacity .26s, border-radius .26s;
}
.app-view.closing { transform: scale(.12); opacity: 0; border-radius: 40%; }
.phone-screen[data-mode="home"] .app-view { visibility: hidden; }
.phone-screen iframe { position: absolute; top: 0; left: 0; width: 360px; height: 100%; border: 0; transform-origin: 0 0; }

/* Status bar and gesture bar */
.sb {
  position: absolute; inset: 0 0 auto; height: var(--sb); z-index: 8; display: flex; align-items: center; justify-content: space-between;
  padding: 0 6.5cqw; color: #fff; font: 600 3.4cqw/1 var(--font); letter-spacing: .02em; pointer-events: none;
}
.sb-icons { display: flex; align-items: center; gap: 1.4cqw; }
.sb-icons svg { height: 3.3cqw; width: auto; }
.sb-icons svg:last-child { height: 3.6cqw; }
.navbar {
  position: absolute; inset: auto 0 0; height: var(--nav); z-index: 8; display: grid; place-items: center;
  border: 0; padding: 0; background: transparent; cursor: pointer;
}
.navbar i { width: 30cqw; height: 1.3cqw; border-radius: 1cqw; background: rgba(255, 255, 255, .85); transition: width .15s, background .15s; }
.navbar:hover:not(:disabled) i { width: 36cqw; background: #fff; }
.navbar:disabled { cursor: default; }
.navbar:disabled i { opacity: .4; }

/* Home screen */
.launcher {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; color: #fff;
  padding: calc(var(--sb) + 7cqw) 5cqw calc(var(--nav) + 3cqw);
  background:
    radial-gradient(90% 55% at 15% 10%, rgba(120, 220, 170, .55), transparent 70%),
    radial-gradient(80% 60% at 95% 85%, rgba(80, 120, 255, .55), transparent 70%),
    linear-gradient(160deg, #0f3d34, #102a4a 55%, #1b1440);
  animation: home-in .3s ease-out;
}
@keyframes home-in { from { opacity: 0; transform: scale(1.06); } }
.l-clock { display: flex; flex-direction: column; align-items: center; gap: 1cqw; margin-bottom: auto; text-shadow: 0 1px 8px rgba(0, 0, 0, .25); }
.l-clock time { font: 300 17cqw/1 var(--font); letter-spacing: -.03em; }
.l-clock span { font-size: 3.8cqw; font-weight: 500; opacity: .9; }
.l-grid, .l-dock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5cqw 2cqw; }
.l-app {
  display: flex; flex-direction: column; align-items: center; gap: 1.6cqw; min-width: 0; padding: 0; border: 0;
  background: none; color: #fff; cursor: pointer; font: inherit;
}
.l-icon {
  position: relative; width: 14.5cqw; height: 14.5cqw; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: var(--c, #555); box-shadow: 0 1.2cqw 3cqw rgba(0, 0, 0, .25); transition: transform .12s;
}
.l-icon svg { width: 52%; height: 52%; }
.l-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.l-icon.letter { background: hsl(var(--hue, 150) 55% 42%); font: 650 6.4cqw/1 var(--font); }
.l-app:active .l-icon { transform: scale(.9); }
.l-app.mine .l-icon { box-shadow: 0 0 0 .8cqw rgba(255, 255, 255, .9), 0 1.2cqw 3.5cqw rgba(0, 0, 0, .35); }
.l-label {
  max-width: 100%; font-size: 3.1cqw; font-weight: 500; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}
.l-search {
  display: flex; align-items: center; gap: 2.4cqw; margin: 6cqw 1cqw 4.5cqw; padding: 3cqw 4.5cqw; border-radius: 99px;
  background: rgba(255, 255, 255, .88); color: #4b5550; font-size: 3.6cqw;
}
.l-search svg { width: 4.4cqw; height: 4.4cqw; }
.l-dock { padding: 3cqw 1cqw; border-radius: 7cqw; background: rgba(255, 255, 255, .14); backdrop-filter: blur(8px); }
.l-dock .l-label { display: none; }
.l-toast {
  position: absolute; left: 50%; bottom: calc(var(--nav) + 30cqw); transform: translateX(-50%); z-index: 2;
  padding: 2.2cqw 4cqw; border-radius: 99px; background: rgba(20, 22, 21, .9); color: #fff; font-size: 3.3cqw; white-space: nowrap;
  animation: rise .2s ease-out;
}

/* Splash screen: grows from the icon, shows the logo, then fades into the app */
.splash {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: var(--splash-bg, #fff);
  animation: splash-open .32s cubic-bezier(.2, 0, 0, 1);
}
.splash.leaving { opacity: 0; transition: opacity .28s ease-in; }
@keyframes splash-open { from { transform: scale(.12); border-radius: 40%; opacity: .6; } }
.splash-icon {
  width: 34cqw; height: 34cqw; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  box-shadow: 0 2cqw 6cqw rgba(0, 0, 0, .12); animation: splash-icon .9s ease-out;
}
.splash-icon img { width: 100%; height: 100%; object-fit: cover; }
.splash-icon.letter { background: hsl(var(--hue, 150) 55% 42%); color: #fff; font: 650 15cqw/1 var(--font); }
@keyframes splash-icon { from { transform: scale(.8); opacity: 0; } 40% { opacity: 1; } }
/* --- iPhone: same app, iOS frame, Dynamic Island, rounded-square icons, home indicator --- */
.phone[data-os="ios"] {
  padding: 10px; border-radius: 54px;
  background: linear-gradient(145deg, #3a3d40, #121314 45%, #2a2c2e);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .3), 0 0 0 1px rgba(255, 255, 255, .06), inset 0 0 0 2px #4a4e52;
}
.phone[data-os="ios"] .phone-screen { --sb: 12.5cqw; --nav: 7cqw; border-radius: 45px; }
.phone[data-os="ios"] .phone-screen::after {
  top: 3cqw; width: 30cqw; height: 8.4cqw; margin-left: -15cqw; border-radius: 99px; background: #000; box-shadow: none;
}
.phone[data-os="ios"] .sb { padding: 0 8cqw 0 10cqw; font: 600 4.2cqw/1 -apple-system, "SF Pro Text", var(--font); letter-spacing: 0; }
.phone[data-os="ios"] .sb-icons { gap: 1.6cqw; }
.phone[data-os="ios"] .sb-icons svg { height: 3.6cqw; }
.phone[data-os="ios"] .sb-icons svg:last-child { height: 4.2cqw; }
.phone[data-os="ios"] .navbar i { width: 36cqw; height: 1.4cqw; }
.phone[data-os="ios"] .launcher {
  padding: calc(var(--sb) + 4cqw) 5.5cqw calc(var(--nav) + 2cqw); font-family: -apple-system, "SF Pro Text", var(--font);
  background:
    radial-gradient(80% 50% at 20% 15%, rgba(255, 170, 120, .7), transparent 70%),
    radial-gradient(90% 60% at 90% 80%, rgba(170, 90, 255, .6), transparent 70%),
    linear-gradient(170deg, #ff7e5f, #b6447d 50%, #3b2a8c);
}
/* iOS has no clock on the home screen: show it as a widget instead. */
.phone[data-os="ios"] .l-clock {
  align-items: flex-start; align-self: stretch; margin-bottom: 7cqw; padding: 4.5cqw 5cqw; border-radius: 6cqw;
  background: rgba(255, 255, 255, .2); backdrop-filter: blur(10px); text-shadow: none;
}
.phone[data-os="ios"] .l-clock time { font: 600 11cqw/1 -apple-system, "SF Pro Display", var(--font); }
.phone[data-os="ios"] .l-clock span { font-size: 3.5cqw; text-transform: uppercase; letter-spacing: .04em; opacity: .85; order: -1; }
.phone[data-os="ios"] .l-grid { margin-bottom: auto; }
.phone[data-os="ios"] .l-icon { border-radius: 23%; width: 15cqw; height: 15cqw; box-shadow: none; }
.phone[data-os="ios"] .l-app.mine .l-icon { box-shadow: 0 0 0 .7cqw rgba(255, 255, 255, .85); }
.phone[data-os="ios"] .l-label { font-size: 3cqw; text-shadow: none; }
.phone[data-os="ios"] .l-search {
  align-self: center; margin: 4cqw 0 3.5cqw; padding: 1.8cqw 4cqw; background: rgba(255, 255, 255, .25); color: #fff; font-size: 3.3cqw;
  backdrop-filter: blur(8px);
}
.phone[data-os="ios"] .l-dock { padding: 3.5cqw 3cqw; border-radius: 9cqw; background: rgba(255, 255, 255, .25); }
.phone[data-os="ios"] .splash-icon { border-radius: 23%; }
.seg-os { flex: none; }
.badge.soon { background: var(--surface-2); color: var(--muted); }
.ios-card .build-actions .btn { flex: 1; }
.seg-os button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }

#homeBtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.phone-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 18px; align-items: center; justify-content: center;
  text-align: center; padding: 28px; color: #6c7570; background: #f5f6f3; font-size: 13.5px; direction: inherit;
}
.skeleton { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.skeleton i { height: 14px; border-radius: 7px; background: #e3e5df; }
.skeleton i:nth-child(1) { width: 55%; height: 22px; }
.skeleton i:nth-child(3) { width: 80%; }
.skeleton i:nth-child(4) { width: 65%; }
.phone-empty.loading .skeleton i {
  background: linear-gradient(90deg, #e3e5df 25%, #f1f2ee 50%, #e3e5df 75%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite;
}
.phone-chip {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: rgba(11, 13, 12, .86); color: #fff; font-size: 12.5px; white-space: nowrap;
  backdrop-filter: blur(6px);
}

.code-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid #1f2522; border-radius: 16px; overflow: hidden; background: #0b0e0d; }
.file-tabs { display: flex; gap: 2px; padding: 6px 6px 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid #1f2522; flex: none; }
.file-tabs button {
  display: inline-flex; align-items: center; gap: 7px; font: 12.5px var(--mono); padding: 7px 12px; border: 0; cursor: pointer;
  background: transparent; color: #7d8882; border-radius: 8px 8px 0 0; white-space: nowrap; border-bottom: 2px solid transparent;
}
.file-tabs button:hover { color: #c9d1cc; }
.file-tabs button[aria-selected="true"] { color: #ecf0ed; background: #141917; border-bottom-color: #3ddc84; }
.file-tabs .live-dot { display: block; background: #3ddc84; }
#codeView {
  flex: 1; min-height: 0; margin: 0; padding: 16px 18px; color: #d3dad5; font: 12.5px/1.65 var(--mono);
  text-align: left; overflow: auto; tab-size: 2; scrollbar-width: thin; scrollbar-color: #2b322e transparent;
}
#codeView:empty::before { content: attr(data-empty); color: #5f6b65; }
/* Line numbers: a gutter in the same scrolling box, pinned while scrolling sideways. */
#codeView:not(:empty) { display: grid; grid-template-columns: auto 1fr; align-items: start; padding-inline-start: 0; }
#codeView .gutter {
  position: sticky; left: 0; z-index: 1; min-height: 100%; padding: 0 14px 0 16px; margin-right: 16px; text-align: right;
  color: #46524c; background: #0b0e0d; border-right: 1px solid #1a201d; user-select: none; white-space: pre;
}
#codeView code { font: inherit; white-space: pre; }

/* --- Patches in the chat: files changed, then the lines in green and red --- */
.diff-card {
  align-self: stretch; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface);
  font-size: 13px; animation: rise .25s ease-out; margin-top: -6px;
}
.diff-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: var(--muted); font-weight: 550;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.diff-title { flex: 1; min-width: 0; color: var(--ink); }
.diff-num { font: 600 12px var(--mono); font-variant-numeric: tabular-nums; }
.diff-num.add { color: #1a9a4b; }
.diff-num.del { color: #d0373b; }
:root[data-theme="dark"] .diff-num.add { color: #4ade80; }
:root[data-theme="dark"] .diff-num.del { color: #f87171; }
.diff-file + .diff-file { border-top: 1px solid var(--line); }
.diff-row {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 12px; border: 0; background: transparent;
  cursor: pointer; text-align: start; font-size: 13px;
}
.diff-row:hover { background: var(--surface-2); }
.diff-path { flex: 1; min-width: 0; font: 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.diff-tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); }
.diff-tag.deleted { background: var(--error-bg); color: var(--error-ink); }
.chev {
  width: 8px; height: 8px; flex: none; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s; margin-inline-end: 2px;
}
[dir="rtl"] .chev { transform: rotate(135deg); }
.diff-row[aria-expanded="true"] .chev { transform: rotate(45deg); }
.diff-note { padding: 8px 12px; color: var(--muted); font-size: 12.5px; }
/* The patch itself keeps the code view's dark look in both themes. */
.diff-lines { max-height: 340px; overflow: auto; background: #0b0e0d; scrollbar-width: thin; scrollbar-color: #2b322e transparent; }
.diff-grid { display: grid; min-width: max-content; font: 12px/1.6 var(--mono); color: #d3dad5; padding: 4px 0; }
.dl { display: grid; grid-template-columns: 36px 36px 18px auto; white-space: pre; }
.dl .ln { padding-right: 8px; text-align: right; color: #46524c; user-select: none; }
.dl .sg { text-align: center; user-select: none; color: #7d8882; }
.dl .tx { padding-right: 16px; }
.dl.add { background: rgba(46, 160, 67, .17); }
.dl.add .ln, .dl.add .sg { color: #4ade80; background: rgba(46, 160, 67, .14); }
.dl.del { background: rgba(248, 81, 73, .15); }
.dl.del .ln, .dl.del .sg { color: #f87171; background: rgba(248, 81, 73, .13); }
.dl.hunk { grid-template-columns: 1fr; color: #7cc4f7; background: rgba(56, 139, 253, .1); padding-left: 12px; margin-top: 4px; }
.dl.hunk:first-child { margin-top: 0; }
#codeView .caret { background: #3ddc84; }
.hl-c { color: #5f6b65; font-style: italic; }
.hl-s { color: #a8e07a; }
.hl-k { color: #c49bf0; }
.hl-n { color: #f2a97c; }
.hl-t { color: #7cd3f7; }
.hl-f { color: #8fb4ff; }

.rail { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.card.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); font-size: 14px; }
.card.warn .btn { margin-top: 10px; }
.build-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: 14.5px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.badge.run { background: var(--accent-soft); color: var(--accent); }
.badge.failed { background: var(--error-bg); color: var(--error-ink); }
.badge.stale { background: var(--warn-bg); color: var(--warn-ink); }
.bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 12px 0 2px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .6s ease; }
.ci-steps { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--faint); }
.ci-steps li { display: flex; align-items: center; gap: 9px; }
.ci-steps li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; }
.ci-steps li.done { color: var(--muted); }
.ci-steps li.done::before { background: var(--accent); border-color: var(--accent); }
.ci-steps li.active { color: var(--ink); font-weight: 550; }
.ci-steps li.active::before { background: var(--accent); border-color: var(--accent); animation: pulse 1.2s ease-out infinite; }
.build-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 13px; }
.build-actions .btn.primary, .build-actions .btn.success { flex: 1; }
.qr { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.qr img, .qr canvas { display: block; border-radius: 8px; background: #fff; padding: 5px; }

/* --- Dialog --- */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(360px, 92vw); background: var(--surface); color: var(--ink); box-shadow: 0 24px 70px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(6, 8, 7, .6); backdrop-filter: blur(3px); }
dialog h3 { margin-bottom: 4px; }
dialog input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; margin: 12px 0; background: var(--surface-2); }
.dialog-actions { display: flex; justify-content: flex-end; }
.logo-dialog { width: min(440px, 94vw); }
.logo-dialog p { margin-top: 2px; }
.logo-previews { --logo-bg: #ffffff; display: flex; gap: 22px; justify-content: center; margin: 18px 0 14px; }
.logo-mask {
  position: relative; width: 96px; height: 96px; overflow: hidden; background: var(--logo-bg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.logo-mask.circle { border-radius: 50%; }
.logo-mask.squircle { border-radius: 26%; }
.logo-mask img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* An adaptive icon shows the middle two thirds of its layers; the foreground is scaled up the same way. */
.logo-dialog[data-mode="new"] .logo-mask img { inset: -25%; width: 150%; height: 150%; }
.logo-bg { justify-content: center; margin-bottom: 6px; }
.logo-bg input { width: 44px; height: 30px; padding: 2px; margin: 0; border-radius: 8px; cursor: pointer; }
.logo-error { color: var(--error-ink); background: var(--error-bg); padding: 7px 10px; border-radius: 8px; font-size: 13.5px; margin-top: 8px; }
.logo-actions { gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.logo-actions .spacer { flex: 1; }
#logoRemove { color: var(--error-ink); }

/* --- Responsive --- */
@media (max-width: 1240px) {
  .stage-body { grid-template-columns: 1fr; overflow-y: auto; align-content: start; }
  .stage-main { height: clamp(460px, 100dvh - 150px, 760px); flex: none; }
  .rail { overflow: visible; }
}
@media (max-width: 860px) {
  /* Rows take their content's height and the page scrolls; without max-content the grid squeezed
     the stage row to fit the window and the phone spilled over the chat. */
  .workspace { grid-template-columns: 1fr; grid-auto-rows: max-content; overflow-y: auto; align-content: start; }
  .stage { order: -1; }
  .stage-body { overflow: visible; flex: none; }
  .stage-main { height: min(640px, 82dvh); }
  .chat { height: min(640px, 85dvh); }
  .stage-bar { flex-wrap: wrap; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .brand span { display: none; }
  .topbar-actions select { max-width: 120px; }
  .composer-bar { flex-direction: column; align-items: stretch; }
  .composer-bar .field { justify-content: space-between; }
  .composer-bar .field select { flex: 1; max-width: none; }
  .composer-go kbd { display: none; }
  .composer-go .btn { flex: 1; margin: 0; }
  #reloadPreview span, #copyCode span, #editModeBtn span, #homeBtn span { display: none; }
  .msg { max-width: 94%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .spinner, .run-steps > li.active .tick { animation: spin 2.4s linear infinite !important; }
}
