:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --ink: #18181b;
  --muted: #63636b;
  --faint: #a1a1aa;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-ink: #ffffff;
  --accent-soft: #f0fdfa;
  --accent-line: #99f6e4;
  --good: #15803d;
  --good-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(24 24 27 / 5%);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; font-weight: 650; margin: 0 0 6px; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 28px 0 10px; }
h3 { font-size: 0.98rem; font-weight: 600; margin: 0 0 6px; }
p { line-height: 1.55; }
.lead { color: var(--muted); margin: 0 0 24px; max-width: 62ch; }
.hint { color: var(--muted); font-size: 0.86rem; margin: 6px 0 0; line-height: 1.5; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
.ico { flex: none; vertical-align: -3px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px;
  background: rgb(255 255 255 / 92%); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brandmark { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 0.98rem; }
.brandmark .mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; }
.project-name { flex: 1; color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 16px; border-left: 1px solid var(--line); }
.top-actions { display: flex; gap: 8px; }

/* Layout */
.layout { display: grid; grid-template-columns: 224px minmax(0, 1fr) 360px; min-height: calc(100vh - 56px); }
.steps { border-right: 1px solid var(--line); padding: 20px 12px; }
.steps button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 9px 10px; margin-bottom: 2px; border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--muted); font-weight: 500;
}
.steps button:hover { background: #efeff1; color: var(--ink); }
.steps button[aria-current='step'] { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.steps .num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); font-size: 0.75rem; flex: none; color: var(--muted);
}
.steps button[aria-current='step'] .num { border-color: var(--accent); color: var(--accent); }
.steps .done .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps .todo-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.content { padding: 32px 40px 80px; outline: none; max-width: 920px; }
.preview { border-left: 1px solid var(--line); background: var(--panel); padding: 20px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; }
.preview-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 0.9rem; margin-bottom: 14px; }
.switch { font-weight: 400; color: var(--muted); font-size: 0.86rem; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.phone { width: 300px; height: 600px; margin: 0 auto; border: 8px solid #27272a; border-radius: 32px; overflow: hidden; background: #fff; box-shadow: 0 12px 32px rgb(0 0 0 / 12%); }
.phone iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-note { color: var(--muted); font-size: 0.8rem; text-align: center; margin: 12px 8px 0; line-height: 1.45; }

/* Buttons */
button.primary, button.ghost, button.secondary, button.danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 8px; cursor: pointer; font-weight: 550; font-size: 0.92rem; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
button.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); box-shadow: var(--shadow); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
button.secondary:hover { border-color: var(--faint); }
button.ghost { background: var(--panel); border: 1px solid var(--line); color: var(--ink); }
button.ghost:hover { background: #f4f4f5; }
button.ghost.small { height: 30px; padding: 0 10px; font-size: 0.84rem; }
button.danger { background: none; border: 1px solid transparent; color: var(--bad); }
button.danger:hover { background: var(--bad-soft); }
button.big { height: 44px; padding: 0 20px; font-size: 0.98rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Fields */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field { margin: 0 0 20px; }
.field:last-child { margin-bottom: 0; }
.field > label, .label { display: block; font-weight: 550; font-size: 0.9rem; margin-bottom: 7px; }
.field .opt { color: var(--faint); font-weight: 400; }
input[type='text'], input[type='url'], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow);
}
input[type='text'], select { height: 40px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type='text']:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(15 118 110 / 15%); }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
textarea.code { font-family: var(--mono); font-size: 0.8rem; min-height: 220px; white-space: pre; }
textarea.brief { min-height: 240px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type='color'] { width: 44px; height: 40px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); cursor: pointer; }
.color-row input[type='text'] { width: 120px; font-family: var(--mono); text-transform: uppercase; }
.swatch-big { width: 28px; height: 28px; border-radius: 7px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%); }

/* Colour chart */
.chart-wrap { margin-top: 10px; }
.chart-wrap > summary { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; color: var(--accent); font-weight: 550; padding: 4px 0; list-style: none; }
.chart-wrap > summary::-webkit-details-marker { display: none; }
.chart { margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-width: 420px; }
.chart-grid { display: grid; gap: 3px; align-items: center; }
.chart-shade { font-size: 0.66rem; color: var(--faint); text-align: center; }
.chart-hue { font-size: 0.74rem; color: var(--muted); }
.chart-cell { height: 22px; border: 0; border-radius: 4px; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 6%); }
.chart-cell:hover { transform: scale(1.18); position: relative; z-index: 1; box-shadow: 0 2px 6px rgb(0 0 0 / 25%); }
.chart-cell.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ink); position: relative; z-index: 2; }

.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 8px; }
.palette div { border-radius: 6px; padding: 18px 6px 5px; font-size: 0.66rem; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 7%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 7px; align-items: center; height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); cursor: pointer; user-select: none; font-size: 0.9rem; }
.chip input { margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 9px; background: #efeff1; }
.seg button { border: 0; background: none; height: 32px; padding: 0 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 550; font-size: 0.9rem; }
.seg button[aria-pressed='true'] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.icons { display: grid; grid-template-columns: repeat(auto-fill, 40px); gap: 6px; }
.icons button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; color: var(--muted); }
.icons button:hover { color: var(--ink); border-color: var(--line-strong); }
.icons button[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.logo-drop { display: flex; gap: 16px; align-items: center; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: #fcfcfc; }
.logo-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.logo-drop img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: var(--bg); }
.logo-drop .ph { width: 56px; height: 56px; border-radius: 8px; background: #f4f4f5; display: grid; place-items: center; color: var(--faint); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--ink); }
.card.pick { cursor: pointer; text-align: left; transition: border-color 0.12s, box-shadow 0.12s; }
.card.pick:hover { border-color: var(--line-strong); box-shadow: 0 4px 12px rgb(24 24 27 / 6%); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.disabled { opacity: 0.6; cursor: default; box-shadow: none; background: transparent; border-style: dashed; }
.card h3 { margin: 10px 0 2px; }
.card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.cicon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; background: #f4f4f5; color: var(--ink); }
.card.selected .cicon { background: var(--accent-soft); color: var(--accent); }
.ficon { --fc: var(--accent); display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 8px; color: var(--fc); background: color-mix(in srgb, var(--fc) 11%, white); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel > h3:first-child { margin-bottom: 14px; }
.step-label { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.step-label .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 0.78rem; }

/* Forms step */
.forms-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 20px; align-items: start; }
.form-list { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 76px; }
.form-list > button.secondary, .form-list > button.ghost { width: 100%; }
.form-list > button.secondary { margin-top: 6px; }
.form-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: left; box-shadow: var(--shadow); }
.form-item:hover { border-color: var(--line-strong); }
.form-item[aria-current='true'] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.form-item .t { flex: 1; min-width: 0; }
.form-item .t b { display: block; font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 0.76rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; line-height: 1.6; }
.status.ok { background: var(--good-soft); color: var(--good); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.none { background: #f4f4f5; color: var(--muted); }
p.status { display: inline-flex; }
.snippets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.snippets button { font-size: 0.82rem; height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line); background: #fafafa; cursor: pointer; color: var(--muted); }
.snippets button:hover { border-color: var(--line-strong); color: var(--ink); background: var(--panel); }
.ai-links { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ai-links a { display: inline-flex; align-items: center; gap: 5px; font-size: 0.84rem; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink); background: var(--panel); }
.ai-links a:hover { border-color: var(--line-strong); }
.problems { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.problems li { padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; line-height: 1.5; border: 1px solid transparent; }
.problems li.error { background: var(--bad-soft); border-color: #fecaca; }
.problems li.warning { background: var(--warn-soft); border-color: #fde68a; }
.problems li.info { background: #fafafa; color: var(--muted); border-color: var(--line); }
.problems li b { margin-right: 6px; }
.summary-line { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 0.88rem; margin: 6px 0; }
.summary-line b { color: var(--ink); }
details { margin-top: 12px; }
details > summary { cursor: pointer; font-weight: 550; font-size: 0.9rem; color: var(--muted); padding: 6px 0; }
details > summary:hover { color: var(--ink); }

/* Form outline */
.outline .page { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.outline .page-h { background: #fafafa; border-bottom: 1px solid var(--line); padding: 8px 12px; font-weight: 600; font-size: 0.86rem; display: flex; justify-content: space-between; gap: 10px; }
.outline ol { margin: 0; padding: 6px 12px 10px 34px; }
.outline li { padding: 6px 0; line-height: 1.45; font-size: 0.92rem; }
.outline .type { display: inline-block; font-size: 0.72rem; color: var(--muted); background: #f4f4f5; border-radius: 5px; padding: 1px 6px; margin-left: 8px; vertical-align: 1px; }
.outline .req { color: var(--bad); margin-left: 3px; }
.outline .cond { display: block; font-size: 0.8rem; color: var(--accent); margin-top: 2px; }
.outline .choices { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* Download */
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.check-list li { display: flex; gap: 12px; align-items: center; padding: 11px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.check-list .ic { flex: none; display: inline-grid; }
.dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; align-items: center; }
.dl + .dl { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.dl .fname { font-family: var(--mono); font-size: 0.8rem; color: var(--faint); margin-top: 6px; }
.steps-how { margin: 6px 0 0; padding-left: 20px; }
.steps-how li { margin: 6px 0; line-height: 1.55; }
.nav-foot { display: flex; justify-content: space-between; margin-top: 32px; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); box-shadow: 0 24px 64px rgb(0 0 0 / 22%); }
dialog::backdrop { background: rgb(24 24 27 / 40%); }
#dialogBody { padding: 24px; }
#dialogBody h2 { margin-top: 0; gap: 10px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 500; font-size: 0.9rem; z-index: 50; box-shadow: 0 8px 24px rgb(0 0 0 / 20%); max-width: calc(100vw - 32px); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  .preview { grid-column: 1 / -1; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .steps { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; gap: 4px; }
  .steps button { width: auto; white-space: nowrap; margin: 0; }
  .content { padding: 22px 16px 60px; }
  .grid2, .forms-layout { grid-template-columns: 1fr; }
  .form-list { position: static; }
  .topbar { padding: 0 16px; }
  .project-name { display: none; }
  .top-actions button { padding: 0 10px; }
  .phone { width: 280px; height: 540px; }
  .dl { grid-template-columns: 1fr; }
}
