:root {
  color-scheme: light;
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --sunk: #F1EEE8;
  --line: #E6E1D8;
  --line-2: #D6D0C4;
  --ink: #2F3437;
  --muted: #646B70;
  --faint: #8C9296;
  --sage: #8FA68A;
  --sage-ink: #4E6A48;
  --sage-soft: #EAF0E8;
  --terra: #D08C6A;
  --terra-ink: #9C5634;
  --terra-soft: #F8E9E1;
  --amber-ink: #8A5E12;
  --amber-soft: #FBF1DC;
  --red-ink: #A2342A;
  --red-soft: #FBE7E4;
  --focus: #3D6FB6;
  --radius: 12px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
a { color: var(--sage-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font: 13px var(--mono); background: var(--sunk); padding: 1px 5px; border-radius: 5px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand b { font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.saved { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.saved::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sage); }
.saved.busy::before { background: var(--terra); }
.demo-banner {
  background: var(--terra-soft); color: var(--terra-ink); text-align: center; font-size: 14px;
  padding: 8px 16px; border-bottom: 1px solid #EED6C9;
}
.demo-banner a { color: var(--terra-ink); font-weight: 700; }
body:not(.is-demo) .demo-only { display: none !important; }

/* ---------- layout ---------- */
.app {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "steps stage" "panel stage";
}
@media (min-width: 901px) {
  body { height: 100vh; height: 100dvh; overflow: hidden; }
}
.steps { grid-area: steps; display: flex; gap: 4px; padding: 12px 16px 0; background: var(--bg); border-right: 1px solid var(--line); }
.steps button {
  flex: 1; border: 0; background: transparent; color: var(--muted); font: 600 14px var(--font);
  padding: 10px 6px; border-bottom: 3px solid transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.steps button span {
  width: 22px; height: 22px; border-radius: 50%; background: var(--sunk); display: inline-grid; place-items: center; font-size: 12px;
}
.steps button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--sage); }
.steps button[aria-selected="true"] span { background: var(--sage-ink); color: #fff; }
.mobile-only { display: none !important; }
.show-sm { display: none; }

.panel { grid-area: panel; overflow-y: auto; padding: 8px 20px 40px; border-right: 1px solid var(--line); min-height: 0; }
.step h2 { font-size: 21px; margin: 14px 0 4px; }
.step h3 { font-size: 16px; margin: 0 0 6px; }
.step h3 small { color: var(--muted); font-weight: 500; font-size: 13px; }
.lead { color: var(--muted); margin: 0 0 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row.tight { margin: 8px 0; }
.row.end { justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: 600 14px var(--font); padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none;
  min-height: 40px;
}
.btn:hover { border-color: var(--sage); }
.btn.primary { background: var(--sage-ink); border-color: var(--sage-ink); color: #fff; }
.btn.primary:hover { background: #435C3E; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--sage-ink); }
.btn.ghost:hover { background: var(--sage-soft); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.link { background: none; border: 0; padding: 0; color: var(--sage-ink); font: 600 13px var(--font); text-decoration: underline; cursor: pointer; }
.backup { gap: 18px; margin-top: 18px; }

textarea#guests {
  width: 100%; min-height: 330px; resize: vertical;
  font: 14px/1.55 var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 12px 14px;
}
textarea#guests:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px var(--sage-soft); }

.summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip { background: var(--sage-soft); color: var(--sage-ink); font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 99px; }
.chip.warn { background: var(--amber-soft); color: var(--amber-ink); }

.notes { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.notes li { font-size: 13.5px; padding: 8px 12px; border-radius: 10px; background: var(--sunk); color: var(--ink); }
.notes li.ok { background: var(--sage-soft); color: var(--sage-ink); }
.notes li.warn { background: var(--amber-soft); color: var(--amber-ink); }
.notes li.bad { background: var(--red-soft); color: var(--red-ink); }
.notes li.info { background: var(--sunk); color: var(--muted); }

details.help { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
details.help summary { cursor: pointer; font-weight: 700; color: var(--sage-ink); }
details.help ul { margin: 8px 0 2px; padding-left: 18px; font-size: 13.5px; }
details.help li { margin: 5px 0; }

fieldset { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
fieldset.tight { margin-top: 14px; }
legend { font-weight: 700; font-size: 14px; margin-bottom: 8px; padding: 0; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field.inline input { width: 80px; }
input[type="text"], input[type="number"], select {
  font: 15px var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; min-height: 40px; width: 100%;
}
.row select { width: auto; flex: 1 1 160px; }
input:focus, select:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px var(--sage-soft); }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme {
  border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; font: 600 12.5px var(--font); color: var(--ink); text-align: left;
}
.theme[aria-pressed="true"] { border-color: var(--sage-ink); box-shadow: 0 0 0 3px var(--sage-soft); }
.theme .sw { height: 46px; border-radius: 8px; display: flex; overflow: hidden; border: 1px solid var(--line); }
.theme .sw i { flex: 1; }
.theme .sw i:first-child { flex: 2; }

.choice2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice2 label { cursor: pointer; position: relative; }
.choice2 input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; }
.choice2 span {
  display: flex; flex-direction: column; gap: 2px; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; background: var(--surface); height: 100%;
}
.choice2 small { color: var(--muted); font-size: 12.5px; }
.choice2 input:checked + span { border-color: var(--sage-ink); box-shadow: 0 0 0 3px var(--sage-soft); }
.choice2 input:focus-visible + span { outline: 3px solid var(--focus); }

.seg { display: inline-flex; background: var(--sunk); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg label { cursor: pointer; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; }
.seg span, .seg button {
  display: inline-block; padding: 7px 12px; border-radius: 8px; font: 600 13px var(--font); color: var(--muted);
  border: 0; background: transparent; cursor: pointer;
}
.seg input:checked + span, .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); }

.checks { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; font-size: 14px; }
.checks label, .check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check { margin-top: 10px; font-size: 14px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--sage-ink); width: 17px; height: 17px; margin: 2px 0 0; flex: none; }
body.layout-table .for-alpha, body.layout-alpha .for-table { display: none; }

.dl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.dl .btn.primary { margin-top: 4px; }

/* ---------- stage ---------- */
.stage { grid-area: stage; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #ECE8E1; }
.stage-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px 6px; flex-wrap: wrap; }
.products { flex: 0 1 auto; }
.zoom { margin-left: auto; display: inline-flex; gap: 4px; }
.zoom button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; min-width: 36px; height: 34px; font: 600 14px var(--font); cursor: pointer; color: var(--ink); }
.fitline { padding: 0 16px; font-size: 13px; color: var(--muted); min-height: 20px; }
.canvas-wrap { flex: 1; min-height: 0; overflow: auto; position: relative; padding: 16px; display: grid; place-items: center; }
.canvas-wrap.zoomed { place-items: start; }
#preview { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 28px rgba(60,50,30,.16); display: block; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 4px 0; font-size: 13px; color: var(--muted); }
.pager button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; width: 34px; height: 30px; font-size: 18px; cursor: pointer; }
.stage .notes { padding: 0 16px 12px; margin: 0; max-height: 30vh; overflow: auto; }

/* ---------- dialog / toast ---------- */
dialog { border: 0; border-radius: 16px; padding: 22px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(30, 30, 25, 0.45); }
dialog h2 { margin: 0 0 6px; font-size: 20px; }
dialog fieldset { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
dialog label { display: flex; gap: 8px; align-items: flex-start; font-size: 14.5px; }
dialog small { color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 10; max-width: calc(100% - 32px);
}
.noscript { padding: 20px; text-align: center; }

/* ---------- phones and small tablets ---------- */
@media (max-width: 900px) {
  .app { display: block; }
  .steps { position: sticky; top: 0; z-index: 5; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px 8px 0; }
  .steps button { font-size: 13px; padding: 9px 2px; gap: 5px; }
  .mobile-only { display: flex !important; }
  .steps .n-dl { font-size: 0; }
  .steps .n-dl::after { content: "4"; font-size: 12px; }
  .panel { border-right: 0; padding: 4px 16px 32px; overflow: visible; }
  .stage { display: none; min-height: calc(100vh - 110px); }
  body.step-preview .stage { display: flex; }
  body.step-preview .panel { display: none; }
  .canvas-wrap { min-height: 60vh; padding: 12px; }
  .stage-bar { padding: 10px 12px 4px; }
  .products { width: 100%; }
  .products button { flex: 1; padding: 7px 6px; font-size: 12.5px; }
  .zoom { margin-left: 0; }
  .top { padding: 8px 14px; gap: 8px; }
  .brand small, .hide-sm { display: none; }
  .show-sm { display: inline; }
  .top .btn { white-space: nowrap; }
  .saved { font-size: 0; }
  .saved::before { width: 10px; height: 10px; }
  .themes { grid-template-columns: repeat(3, 1fr); }
  .choice2 { grid-template-columns: 1fr; }
  .stage .notes { max-height: none; }
}
@media (max-width: 380px) {
  .theme { font-size: 11.5px; }
}
