/* One-prompt builder (app.html). Uses the tokens in theme.css only: one accent, one radius, two shadows. */

*,*::before,*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans, system-ui, -apple-system, "Segoe UI", sans-serif);
  color: var(--bx-ink);
  background-color: var(--bx-bg);
  background-image: radial-gradient(ellipse 80% 45% at 50% 0%, var(--bx-accent-soft), transparent 70%);
  background-repeat: no-repeat;
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 1200px; margin: 0 auto; padding: 1.1rem 1.5rem;
}
.logo { font-weight: 600; font-size: 1.35rem; letter-spacing: -0.02em; color: var(--bx-ink); text-decoration: none; }
.logo b { color: var(--bx-accent); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 0.5rem; }
.top-tools { display: flex; align-items: center; gap: 0.25rem; }

.icon-btn {
  min-height: 44px; min-width: 44px; padding: 0 0.6rem;
  border: 0; border-radius: var(--bx-radius); background: transparent; color: var(--bx-ink);
  font: inherit; font-size: 1.15rem; cursor: pointer;
  transition: background 0.2s ease-out, transform 0.2s ease-out;
}
.icon-btn:hover { background: var(--bx-accent-soft); transform: translateY(-1px); }
.icon-btn:focus-visible, .ghost:focus-visible, .btn-primary:focus-visible, .example:focus-visible, .dev:focus-visible, .chip:focus-visible, .menu button:focus-visible {
  outline: 3px solid var(--bx-accent); outline-color: color-mix(in srgb, var(--bx-accent) 30%, transparent); outline-offset: 2px;
}

.more { position: relative; }
.menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 0.4rem); z-index: 5;
  min-width: 12.5rem; padding: 0.35rem; display: grid; gap: 0.15rem;
  background: var(--bx-surface); border: 1px solid var(--bx-line); border-radius: var(--bx-radius); box-shadow: var(--bx-shadow-lift);
}
.menu button {
  min-height: 44px; padding: 0 0.85rem; text-align: start; border: 0; border-radius: 10px;
  background: transparent; color: var(--bx-ink); font: inherit; cursor: pointer;
}
.menu button:hover { background: var(--bx-accent-soft); }

/* ---------- layout ---------- */
.main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }
.stage { animation: rise 0.2s ease-out both; }
.stage.narrow { max-width: 720px; margin: 0 auto; padding-top: 2.5rem; }
.stage.wide { max-width: 1200px; margin: 0 auto; padding-top: 1.5rem; }

@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.kicker { margin: 0 0 0.5rem; color: var(--bx-accent-hi); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.02em; }
h1 { margin: 0 0 0.75rem; font-size: clamp(2rem, 5vw, 2.75rem); font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; text-wrap: balance; }
h2 { margin: 0 0 1rem; font-size: 1.25rem; font-weight: 600; }
.lede { margin: 0 0 2rem; color: var(--bx-muted); font-size: 1.125rem; max-width: 40rem; }
.hint, .small { color: var(--bx-muted); font-size: 0.9rem; margin: 0.5rem 0 0; }
.small a, .hint a { color: var(--bx-accent-hi); }
.msg { min-height: 1.2rem; margin: 0.75rem 0 0; font-weight: 600; color: var(--bx-danger); }
.msg.ok { color: var(--bx-accent-hi); }

/* ---------- surfaces ---------- */
.card {
  background: var(--bx-surface); border: 1px solid var(--bx-line); border-radius: var(--bx-radius);
  box-shadow: var(--bx-shadow-soft); padding: 1.5rem;
}
.lift { box-shadow: var(--bx-shadow-lift); }
.gate { max-width: 440px; margin: 2rem auto 0; }
.gate .lede { margin-bottom: 1.25rem; font-size: 1rem; }
.gate label { display: block; margin: 0 0 0.4rem; font-weight: 600; font-size: 0.9375rem; color: var(--bx-muted); }

/* ---------- inputs ---------- */
textarea, input[type="text"], input[type="url"], input[type="password"], input[type="tel"] {
  width: 100%; font: inherit; color: var(--bx-ink);
  background: var(--bx-input); border: 1px solid var(--bx-input-line); border-radius: 12px;
  padding: 0.75rem 0.9rem; transition: border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}
textarea:focus, input:focus {
  outline: none; border-color: var(--bx-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bx-accent) 30%, transparent);
}
.gate input { margin-bottom: 1rem; }
.prompt { min-height: 120px; resize: vertical; font-size: 1.0625rem; line-height: 1.55; }
#buildForm .prompt { margin: 0; }

.attach-block { margin-top: 0.9rem; }
.attach { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.9rem; color: var(--bx-muted); font-size: 0.9rem; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { min-height: 44px; border: 0; background: transparent; color: var(--bx-accent-hi); font: inherit; cursor: pointer; padding: 0 0.5rem; }

.secondary { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

/* ---------- buttons ---------- */
.btn-primary, .ghost {
  min-height: 44px; padding: 0 1.25rem; border-radius: var(--bx-radius);
  font: inherit; font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: background 0.2s ease-out, transform 0.2s ease-out, box-shadow 0.2s ease-out;
}
.btn-primary {
  border: 0; background: var(--bx-accent); color: #fff; box-shadow: var(--bx-shadow-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary:hover { background: var(--bx-accent-hi); transform: translateY(-1px); box-shadow: var(--bx-shadow-lift); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }
.btn-primary.wide { width: 100%; margin-top: 1rem; }
.ghost {
  border: 1px solid var(--bx-line); background: var(--bx-surface); color: var(--bx-ink);
}
.ghost:hover { background: var(--bx-accent-soft); transform: translateY(-1px); }
.send { min-width: 44px; padding: 0; font-size: 1.15rem; }

/* ---------- examples ---------- */
.examples { display: grid; gap: 0.5rem; margin-top: 1.75rem; }
.example {
  min-height: 44px; padding: 0.6rem 0.9rem; text-align: start;
  background: transparent; border: 1px dashed var(--bx-line); border-radius: 12px;
  color: var(--bx-muted); font: inherit; cursor: pointer; transition: color 0.2s ease-out, border-color 0.2s ease-out;
}
.example:hover { color: var(--bx-ink); border-color: var(--bx-accent); }

/* ---------- prompt pill ---------- */
.pill {
  display: inline-block; max-width: 100%; margin-bottom: 1.5rem; padding: 0.35rem 0.85rem;
  border-radius: 999px; background: var(--bx-accent-soft); color: var(--bx-ink);
  font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- phase 2: the log ---------- */
.log { list-style: none; margin: 0.5rem 0 2rem; padding: 0; display: grid; gap: 0.7rem; }
.log li { animation: rise 0.2s ease-out both; font-size: 1.0625rem; color: var(--bx-ink); }
.log li .dia { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; color: var(--bx-accent); margin-inline-end: 0.6rem; }
.log li.done .dia { color: var(--bx-accent-hi); }
.log li.err { color: var(--bx-danger); }
.log li.muted { color: var(--bx-muted); }
.pulse { display: flex; gap: 0.4rem; margin-bottom: 2rem; }
.pulse span { width: 8px; height: 8px; border-radius: 50%; background: var(--bx-accent); opacity: 0.25; animation: pulse 1.2s ease-out infinite; }
.pulse span:nth-child(2) { animation-delay: 0.2s; }
.pulse span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.stop { margin-top: 0.5rem; }

/* ---------- phase 3: preview ---------- */
.devices { display: flex; justify-content: center; gap: 0.35rem; margin-bottom: 1rem; }
.g { display: inline-block; border: 2px solid currentColor; border-radius: 3px; vertical-align: middle; }
.g-desk { width: 20px; height: 13px; border-radius: 3px; }
.g-tab { width: 13px; height: 17px; border-radius: 3px; }
.g-phone { width: 11px; height: 19px; border-radius: 3px; }
.dev {
  min-height: 44px; min-width: 44px; border: 1px solid transparent; border-radius: var(--bx-radius);
  background: transparent; color: var(--bx-muted); font-size: 1.05rem; cursor: pointer;
  transition: background 0.2s ease-out, color 0.2s ease-out;
}
.dev[aria-pressed="true"] { background: var(--bx-surface); border-color: var(--bx-line); color: var(--bx-ink); box-shadow: var(--bx-shadow-soft); }

.frame-wrap { display: flex; justify-content: center; }
.frame {
  width: 100%; max-width: 1200px; height: min(72vh, 780px); min-height: 360px;
  background: var(--bx-surface); border: 1px solid var(--bx-line); border-radius: 18px;
  box-shadow: var(--bx-shadow-lift); overflow: hidden; transition: max-width 0.2s ease-out;
}
.frame-wrap[data-dev="tablet"] .frame { max-width: 780px; }
.frame-wrap[data-dev="phone"] .frame { max-width: 390px; }
.preview { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

.live { min-height: 1.4rem; margin: 1rem 0 0; color: var(--bx-muted); text-align: center; font-size: 0.95rem; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin: 1rem 0 0.75rem; }
.chip {
  min-height: 44px; padding: 0 0.95rem; border-radius: 999px;
  border: 1px solid var(--bx-line); background: var(--bx-surface); color: var(--bx-ink);
  font: inherit; font-size: 0.95rem; cursor: pointer; transition: background 0.2s ease-out, transform 0.2s ease-out;
}
.chip:hover { background: var(--bx-accent-soft); transform: translateY(-1px); }

.composer { display: block; }
.composer.small { display: flex; align-items: flex-end; gap: 0.6rem; }
.composer.small { max-width: 720px; margin: 0 auto; padding: 0.6rem; box-shadow: var(--bx-shadow-soft); }
.composer.small .change { border: 0; background: transparent; box-shadow: none; resize: none; min-height: 44px; padding: 0.6rem 0.4rem; }
.composer.small .change:focus { box-shadow: none; }
.composer.small .send { flex: 0 0 auto; }
#changeForm .hint { display: none; }

/* ---------- publish dialog ---------- */
.modal {
  width: min(92vw, 440px); padding: 1.5rem; border: 1px solid var(--bx-line); border-radius: var(--bx-radius);
  background: var(--bx-surface); color: var(--bx-ink); box-shadow: var(--bx-shadow-lift);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.35); }
.modal form { display: grid; gap: 0.5rem; }
.modal label { font-weight: 600; font-size: 0.9rem; color: var(--bx-muted); margin-top: 0.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
.modal-actions .btn-primary, .modal-actions .ghost { min-width: 110px; }

/* ---------- phone and tablet ---------- */
@media (max-width: 40rem) {
  .top { padding: 0.85rem 1rem; }
  .main { padding: 1rem 1rem 3rem; }
  .stage.narrow { padding-top: 1.5rem; }
  h1 { font-size: 1.85rem; }
  .lede { font-size: 1rem; margin-bottom: 1.5rem; }
  .card { padding: 1.1rem; }
  .secondary .ghost { flex: 1 1 100%; }
  .frame { height: 60vh; }
  .composer.small { position: sticky; bottom: max(0.75rem, env(safe-area-inset-bottom)); background: var(--bx-surface); border-radius: var(--bx-radius); z-index: 3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--bx-muted);
}
.consent input { margin-top: 2px; }
.consent span { flex: 1; }
