:root {
  --ink: #1d1d1f;
  --muted: #5f6368;
  --line: #e2ded6;
  --bg: #f6f4ef;
  --card: #ffffff;
  --gold: #a88d55;
  --gold-dark: #7d6637;
  --danger: #b3261e;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 18px; padding: 12px 24px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar-logo { height: 34px; width: auto; }
.topbar-text { color: var(--muted); font-size: 14px; }

/* ---------- step 1 ---------- */
.start { max-width: 720px; margin: 64px auto; padding: 0 16px; text-align: center; }
.start h1 { font-family: "Playfair Display", Georgia, serif; font-size: 40px; line-height: 1.15; margin: 0 0 14px; }
.lede { color: var(--muted); font-size: 17px; margin: 0 auto 28px; max-width: 560px; }
.lookup { display: flex; gap: 10px; }
.lookup input { flex: 1; font-size: 17px; padding: 14px 16px; }
.ac-wrap { position: relative; flex: 1; display: flex; text-align: left; }
.ac-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; margin: 0; padding: 4px 0; list-style: none;
  background: #fff; border: 1px solid #cfcac0; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.ac-list li { padding: 9px 14px; cursor: pointer; line-height: 1.3; }
.ac-list li b { font-weight: 600; display: block; }
.ac-list li span { font-size: 13px; color: var(--muted); }
.ac-list li[aria-selected="true"], .ac-list li:hover { background: #f4efe4; }
.hint { color: var(--muted); margin-top: 16px; }
.demo-note { background: #fff7e0; border: 1px solid #ecd9a0; border-radius: var(--radius); padding: 10px 14px; font-size: 14px; }
.msg { min-height: 1.4em; color: var(--muted); }
.msg.error { color: var(--danger); }

input, select, textarea {
  font: inherit; color: inherit; width: 100%; padding: 8px 10px; background: #fff;
  border: 1px solid #cfcac0; border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
}
.btn.primary { background: var(--gold); color: #fff; }
.btn.primary:hover { background: var(--gold-dark); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { background: #fff; border-color: #cfcac0; color: var(--ink); }
.btn.ghost:hover { border-color: var(--gold); }
.btn:disabled { opacity: .55; cursor: wait; }
.lookup .btn { padding: 14px 22px; font-size: 16px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--gold-dark); text-decoration: underline; cursor: pointer; }
.small { font-size: 13px; color: var(--muted); }

/* ---------- step 2 ---------- */
.studio { display: grid; grid-template-columns: 400px 1fr; gap: 24px; padding: 20px 24px 40px; align-items: start; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 16px 16px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto;
}
.panel-head { padding: 8px 0; }
.group { border-top: 1px solid var(--line); padding: 10px 0; }
.group summary { font-weight: 700; cursor: pointer; padding: 4px 0 8px; }
.group label { display: block; font-size: 13px; font-weight: 600; color: #3c4043; margin: 8px 0 0; }
.group label input, .group label select, .group label textarea { margin-top: 4px; font-weight: 400; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; }
.grid2 > *, .grid3 > * { min-width: 0; }
input[type=time], input[type=date] { padding: 8px 6px; }
.openhouse { border: 1px dashed #d6d0c4; border-radius: 8px; margin: 12px 0 4px; padding: 4px 10px 10px; }
.openhouse legend { font-size: 13px; font-weight: 600; color: #3c4043; padding: 0 4px; }
.field-label { font-size: 13px; font-weight: 600; color: #3c4043; margin: 12px 0 6px; }
.choice { display: flex; gap: 8px; }
.choice button {
  flex: 1; padding: 8px; border: 1px solid #cfcac0; border-radius: 8px; background: #fff; font: inherit; cursor: pointer;
}
.choice button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
  box-shadow: 0 0 0 1px #cfcac0; position: relative; overflow: hidden; padding: 0;
}
.swatch span { position: absolute; right: 0; bottom: 0; width: 50%; height: 50%; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.swatch.custom { background: conic-gradient(#e53935, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935); }
.custom-colors { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfaf7; }
.color-row + .color-row { margin-top: 10px; }
.color-label { font-size: 13px; font-weight: 600; color: #3c4043; }
.color-label .small { font-weight: 400; margin-left: 4px; }
.color-ctl { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.color-ctl .c-pick { width: 44px; height: 36px; padding: 2px; flex: none; cursor: pointer; }
.color-ctl .c-hex { width: 96px; flex: none; font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
.color-ctl .c-hex.bad { border-color: var(--danger); }
.logo-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.logo-chips button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #cfcac0; cursor: pointer; padding: 0; }
#color-tip { margin: 8px 0 0; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: auto; margin: 0; }

.photo-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.photo-item { cursor: grab; touch-action: manipulation; }
.photo-item.dragging { opacity: .35; }
.photo-item.chosen { outline: 2px solid var(--gold); }
.photo-item { position: relative; border-radius: 6px; overflow: hidden; background: #eee; aspect-ratio: 4 / 3; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item .badge {
  position: absolute; top: 4px; left: 4px; background: var(--ink); color: #fff; font-size: 11px;
  padding: 1px 6px; border-radius: 4px;
}
.photo-item .tools {
  position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between;
  background: linear-gradient(transparent, rgba(0,0,0,.65)); padding: 10px 4px 4px;
}
.photo-item .tools button {
  background: rgba(255,255,255,.92); border: 0; border-radius: 4px; width: 26px; height: 24px;
  cursor: pointer; font-size: 13px; line-height: 1;
}
.photo-item.broken { outline: 2px solid var(--danger); }
.upload { width: 100%; }
/* ✕ on every filled-in field: clears it, which leaves it off the flyer. */
.has-clear { position: relative; }
.has-clear > input, .has-clear > textarea { padding-right: 30px; }
.clear-btn {
  position: absolute; right: 6px; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: #e9e5dc; color: #5f6368; font-size: 12px; line-height: 22px; text-align: center; padding: 0; cursor: pointer;
}
.clear-btn:hover { background: #d9d3c6; color: var(--ink); }
.clear-btn[hidden] { display: none; }
.qr-choice { display: grid; gap: 6px; }
.qr-choice .radio { display: flex; gap: 8px; align-items: baseline; font-weight: 500; margin: 2px 0 0; }
.qr-choice .radio input { width: auto; margin: 0; }
.qr-choice .qr-input { margin: 0 0 4px 22px; width: calc(100% - 22px); font-size: 14px; }
.qr-choice .qr-input:disabled { background: #f3f1ec; color: #9a9384; }

.media-row { display: flex; gap: 14px; align-items: center; margin: 8px 0; }
.media-text { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.media-text .field-label { width: 100%; margin: 0; }
.logo-thumb {
  width: 96px; height: 64px; flex: none; border: 1px dashed #cfcac0; border-radius: 8px; background: #fff center / contain no-repeat;
  display: grid; place-items: center; color: #9a9384; font-size: 12px; background-origin: content-box; padding: 6px;
}
.logo-thumb.has { border-style: solid; }
.agent-thumb {
  width: 64px; height: 64px; border-radius: 50%; background: #ece8e0 center / cover no-repeat; flex: none;
  display: grid; place-items: center; color: #9a9384; font-size: 12px;
}
.small-btn { padding: 6px 10px; font-size: 13px; }
.lender-note {
  display: flex; gap: 12px; align-items: center; background: #f6f2e9; border-radius: 8px; padding: 10px 12px; margin-top: 10px;
}
.lender-note img { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.lender-note p { margin: 0; font-size: 13px; color: #4a4a4a; }

.previews { min-width: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button {
  font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 8px 8px 0 0; cursor: pointer;
  border: 1px solid var(--line); border-bottom: 0; background: #ebe7df; color: #5a5a5a;
}
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); }
.preview-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 0 var(--radius) 0 0; padding: 10px 14px;
}
.dl-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.stage {
  background: #dcd8cf; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius);
  padding: 24px; display: flex; justify-content: center;
}
.scaler { position: relative; box-shadow: 0 6px 30px rgba(0,0,0,.18); background: #fff; }
.scaler > .scale-inner { transform-origin: 0 0; position: absolute; top: 0; left: 0; }
.all-row { display: flex; justify-content: flex-end; margin-top: 8px; }

.site-foot { max-width: 980px; margin: 30px auto; padding: 0 16px 30px; font-size: 12px; color: #8a867c; text-align: center; }

@media (max-width: 960px) {
  .studio { grid-template-columns: 1fr; padding: 12px 16px 30px; }
  .panel { position: static; max-height: none; }
  .stage { padding: 12px; }
}
@media (max-width: 560px) {
  .topbar { flex-direction: column; gap: 4px; padding: 10px 16px; text-align: center; }
  .start { margin-top: 32px; }
  .start h1 { font-size: 30px; }
  .lookup { flex-direction: column; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .tabs button { padding: 7px 10px; font-size: 13px; }
  .dl-buttons .btn { flex: 1; }
}
