/* =====================================================================
   Hero Page Builder — app chrome (the builder UI around the preview).
   The GENERATED pages carry their own styles; this only styles the tool.
   System fonts only — no network requests.
   ===================================================================== */
:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1d2430;
  --line: #29313f;
  --text: #e8edf4;
  --muted: #93a0b2;
  --accent: #4f8cff;
  --accent-2: #6ea3ff;
  --ok: #4ec98a;
  --err: #ff6b6b;
  --radius: 12px;
  --f: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --fm: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
}

* , *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #131924, #0e1117);
}
.app-brand { display: flex; align-items: center; gap: 0.7rem; }
.app-badge {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 800; letter-spacing: .02em;
}
.app-brand strong { display: block; font-size: 1.02rem; }
.app-sub { display: block; color: var(--muted); font-size: 0.82rem; }
.app-header-meta { color: var(--muted); font-size: 0.8rem; font-family: var(--fm); }

/* ---------- layout ---------- */
.builder {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  gap: 1rem; padding: 1rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
}
.controls { padding: 1.25rem; overflow-y: auto; }

/* ---------- fields ---------- */
.field { margin-bottom: 1.4rem; }
.field label, .label-lite {
  display: block; font-weight: 700; font-size: 0.92rem; margin-bottom: 0.25rem;
}
.label-lite { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; }
.hint { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.84rem; }
textarea {
  width: 100%; resize: vertical; min-height: 3.2rem;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.8rem; font: inherit; line-height: 1.5;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea:disabled { opacity: 0.55; cursor: not-allowed; }

.row { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.7rem; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 0.65rem 1.2rem; font: inherit; font-weight: 700; cursor: pointer;
  transition: transform .1s, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }

.status { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

/* ---------- example chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.4rem 0.85rem; font: inherit; font-size: 0.86rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-2); }

/* ---------- change box (plain-English edits) ---------- */
.change-box { border-top: 1px solid var(--line); padding-top: 0.9rem; }
.cap-list {
  margin: 0.7rem 0 0; padding: 0.7rem 0.85rem;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; color: var(--text); font-size: 0.84rem; line-height: 1.5;
  white-space: pre-line;
}

/* ---------- readout ---------- */
.readout { border-top: 1px solid var(--line); padding-top: 0.9rem; }
.readout summary { cursor: pointer; font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.readout-grid { margin: 0.8rem 0 0; display: grid; gap: 0.5rem; }
.readout-grid > div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--line); padding-bottom: 0.4rem; }
.readout-grid dt { margin: 0; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: .06em; }
.readout-grid dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- preview ---------- */
.preview { display: flex; flex-direction: column; overflow: hidden; }
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line);
}
.preview-title { font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.widths { display: inline-flex; gap: 0.25rem; background: var(--panel-2); border-radius: 8px; padding: 0.2rem; }
.wbtn {
  border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.82rem; font-weight: 600; padding: 0.3rem 0.7rem;
  border-radius: 6px; cursor: pointer;
}
.wbtn.is-active { background: var(--accent); color: #fff; }

.preview-stage {
  flex: 1; min-height: 0; overflow: auto;
  background:
    repeating-linear-gradient(45deg, #0c0f14 0 12px, #0e1117 12px 24px);
  display: grid; place-items: start center;
}
.preview-stage.is-device { padding: 1.25rem; place-items: start center; }
#preview {
  width: 100%; height: 100%; border: 0; background: #fff;
  display: block;
}
.preview-stage.is-device #preview {
  height: calc(100% - 2.5rem); min-height: 640px;
  border-radius: 10px; box-shadow: 0 20px 50px -20px rgba(0,0,0,.7);
  border: 1px solid var(--line);
}

/* app-chrome ghost button (used by Reset + checkout "Done") */
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-2); }

/* ---------- preview bar actions + Publish CTA ---------- */
.preview-actions { display: inline-flex; align-items: center; gap: 0.7rem; }
.btn-publish { padding: 0.5rem 1rem; font-size: 0.88rem; white-space: nowrap; }

/* ---------- checkout modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 9, 14, 0.72);
  display: grid; place-items: center; padding: 1.25rem;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative; width: min(100%, 440px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.5rem 1.5rem 1.6rem; box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
}
.modal-x {
  position: absolute; top: 0.6rem; right: 0.7rem;
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.modal-x:hover { background: var(--panel-2); color: var(--text); }
.modal h2 { margin: 0 0 0.3rem; font-size: 1.35rem; }
.modal .price { color: var(--accent-2); }
.modal-sub { margin: 0 0 1rem; color: var(--muted); font-size: 0.88rem; }
.test-banner {
  margin: 0 0 1rem; padding: 0.6rem 0.75rem;
  background: rgba(224, 138, 30, 0.12); border: 1px solid #7a5a1e; border-radius: 8px;
  color: #f0c479; font-size: 0.8rem; line-height: 1.45;
}
.test-banner code { font-family: var(--fm); color: #ffd89a; }

.co-field { margin-bottom: 0.85rem; }
.co-field label { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 0.25rem; }
.co-field input {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 0.6rem 0.7rem; font: inherit;
}
.co-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.co-field input.is-invalid { border-color: var(--err); outline-color: var(--err); }
.co-err { display: block; min-height: 1.1em; margin-top: 0.2rem; color: var(--err); font-size: 0.78rem; }
.co-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.btn-block { width: 100%; margin-top: 0.4rem; }
.btn-block + .btn-block { margin-top: 0.6rem; }

/* confirmation view */
.co-check {
  width: 54px; height: 54px; margin: 0 auto 0.6rem; border-radius: 50%;
  display: grid; place-items: center; background: rgba(78, 201, 138, 0.15);
  color: var(--ok); font-size: 1.8rem; font-weight: 800;
}
#co-done { text-align: center; }
#co-done h2 { text-align: center; }
.co-summary {
  text-align: left; margin: 1rem 0; padding: 0.8rem 0.9rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  display: grid; gap: 0.45rem;
}
.co-summary > div { display: flex; justify-content: space-between; gap: 1rem; }
.co-summary dt { margin: 0; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .05em; }
.co-summary dd { margin: 0; font-weight: 700; font-family: var(--fm); font-size: 0.86rem; text-align: right; }
.co-hint { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.8rem; }

/* ---------- responsive: stack on narrow screens ---------- */
@media (max-width: 880px) {
  .builder { grid-template-columns: 1fr; }
  .controls { max-height: 46vh; }
  .preview { min-height: 60vh; }
  .app-header-meta { display: none; }
  .preview-actions { gap: 0.45rem; }
  .btn-publish { padding: 0.45rem 0.7rem; font-size: 0.8rem; }
}
