:root {
  --cream: #f6f1ea;
  --ink: #140c09;
  --blue: #1d46a3;
  --blue-soft: #e9eef9;
  --orange: #e2702f;
  --orange-dark: #ac4e18;
  --paper: #fff;
  --field: #fffdfa;
  --line: rgba(20, 12, 9, 0.11);
  --muted: rgba(20, 12, 9, 0.62);
  --ok: #1f7a4d;
  --warn: #9a5a00;
  --radius: 20px;
  --display: 'Jost', ui-sans-serif, system-ui, sans-serif;
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.wordmark { font: 600 24px/1 var(--display); letter-spacing: -0.01em; }
.slash { color: var(--orange); }

.hero { padding-top: 22px; padding-bottom: 18px; }
.hero h1 { margin: 0; font: 700 clamp(36px, 6vw, 64px)/0.98 var(--display); letter-spacing: -0.02em; }
.hero h1 span { color: var(--orange); }
.hero p { margin: 14px 0 0; max-width: 520px; color: var(--muted); font-size: 16px; }

/* content types */
.types { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 14px; scrollbar-width: none; }
.types::-webkit-scrollbar { display: none; }
.types button {
  flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 8px 15px; font-weight: 500; font-size: 14px; cursor: pointer; transition: background .15s, color .15s;
}
.types button:hover { border-color: rgba(20, 12, 9, 0.3); }
.types button[aria-selected='true'] { background: var(--ink); border-color: var(--ink); color: var(--cream); }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 12, 9, 0.04), 0 18px 40px -24px rgba(20, 12, 9, 0.25);
}
.preview { position: sticky; top: 16px; padding: 20px; }
.editor { overflow: hidden; }

/* accordion */
.acc + .acc { border-top: 1px solid var(--line); }
.acc-head {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.acc-head:hover { background: rgba(246, 241, 234, 0.6); }
.acc-icon {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px;
  background: var(--blue-soft); color: var(--blue); transition: background .15s, color .15s;
}
.acc-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.acc-title { flex: 1; font: 500 17px/1.2 var(--display); letter-spacing: 0.04em; text-transform: uppercase; }
.acc-sign { width: 14px; height: 14px; position: relative; }
.acc-sign::before, .acc-sign::after { content: ''; position: absolute; left: 0; top: 6px; width: 14px; height: 2px; border-radius: 2px; background: var(--muted); transition: transform .2s; }
.acc-sign::after { transform: rotate(90deg); }
.acc-head[aria-expanded='true'] .acc-icon { background: var(--blue); color: #fff; }
.acc-head[aria-expanded='true'] .acc-sign::after { transform: rotate(0deg); }
.acc-body { padding: 4px 18px 22px; }
.acc-head[aria-expanded='false'] + .acc-body { display: none; }

/* fields */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.field.half { grid-column: span 1; }
.field > label, .label, .labelled > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.label { margin: 18px 0 8px; }
.acc-body > .label:first-child { margin-top: 6px; }
input[type='text'], input[type='url'], input[type='email'], input[type='tel'], input[type='datetime-local'], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--field);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 84px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(226, 112, 47, 0.18); }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.hint.indent { margin: -4px 0 10px 52px; }
.error { margin: 10px 0 0; color: #b42318; font-size: 13px; font-weight: 500; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 10px 0; }
.labelled { display: flex; flex-direction: column; gap: 6px; }

/* colour picker */
.color { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--field); overflow: hidden; width: 170px; }
.color input[type='color'] { width: 46px; height: 42px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.color input[type='color']::-webkit-color-swatch-wrapper { padding: 6px; }
.color input[type='color']::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 8px; }
.color input[type='color']::-moz-color-swatch { border: 1px solid var(--line); border-radius: 8px; }
.color .hex { border: 0; border-left: 1px solid var(--line); border-radius: 0; padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; font-size: 14px; }
.color .hex:focus-visible { box-shadow: none; }

/* segmented radio */
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--cream); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 14px; border-radius: 9px; font-weight: 500; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 12, 9, 0.12); }
.seg input:focus-visible + span { outline: 2px solid var(--orange); }
.seg.small span { padding: 6px 12px; font-size: 13px; }

/* switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; margin: 14px 0 8px; user-select: none; }
.switch.inline { margin: 4px 0; align-self: end; min-height: 44px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.knob { width: 40px; height: 24px; flex: none; border-radius: 999px; background: rgba(20, 12, 9, 0.18); position: relative; transition: background .15s; }
.knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform .15s; }
.switch input:checked + .knob { background: var(--orange); }
.switch input:checked + .knob::after { transform: translateX(16px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--orange); outline-offset: 2px; }

/* sliders */
.slider { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.slider input[type='range'] { flex: 1; accent-color: var(--orange); min-width: 120px; }
.slider output { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.slider.size output { min-width: 112px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-dark); }
.btn.ghost { background: var(--paper); border-color: var(--line); }
.btn.ghost:hover { border-color: rgba(20, 12, 9, 0.35); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--muted); cursor: pointer; font-weight: 500; }

/* logo */
.logo-row { display: flex; gap: 16px; align-items: center; margin-top: 6px; }
.logo-thumb {
  width: 108px; height: 108px; flex: none; border-radius: 16px; border: 1.5px dashed rgba(20, 12, 9, 0.25);
  display: grid; place-items: center; color: var(--muted); font-size: 13px; background: var(--cream);
}
.logo-thumb.has {
  border-style: solid; border-color: var(--line);
  background: repeating-conic-gradient(#ece6dd 0 25%, #fff 0 50%) 0 0 / 14px 14px;
}
.logo-thumb img { max-width: 84%; max-height: 84%; }
.logo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.logo-actions .hint { width: 100%; }
.icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.icon-pick { aspect-ratio: 1; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.icon-pick:hover { border-color: var(--orange); }
.icon-pick img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* design tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.tile { aspect-ratio: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; transition: border-color .15s, background .15s; }
.tile:hover { border-color: rgba(20, 12, 9, 0.35); }
.tile svg { width: 100%; height: 100%; }
.tile[aria-pressed='true'] { border: 2px solid var(--blue); background: var(--blue-soft); color: var(--blue); padding: 9px; }

/* preview */
.stage { aspect-ratio: 1; border-radius: 16px; background: var(--cream); padding: 16px; display: grid; place-items: center; }
.stage.checker { background: repeating-conic-gradient(#ece6dd 0 25%, #fff 0 50%) 0 0 / 18px 18px; }
.stage canvas { width: 100%; height: 100%; border-radius: 6px; display: block; }
.placeholder { margin: 0; color: var(--muted); text-align: center; }
.scan { margin: 14px 0 6px; padding: 10px 12px 10px 36px; border-radius: 12px; font-size: 13px; font-weight: 500; position: relative; min-height: 40px; }
.scan::before { content: ''; position: absolute; left: 12px; top: 12px; width: 14px; height: 14px; border-radius: 50%; }
.scan[data-state='ok'] { background: #e8f5ee; color: var(--ok); }
.scan[data-state='ok']::before { background: var(--ok); box-shadow: inset 0 0 0 3px #e8f5ee; }
.scan[data-state='warn'] { background: #fdf1e2; color: var(--warn); }
.scan[data-state='warn']::before { background: var(--orange); }
.scan[data-state='error'] { background: #fdecea; color: #b42318; }
.scan[data-state='error']::before { background: #b42318; }
.scan[data-state='checking'], .scan[data-state='empty'] { background: var(--cream); color: var(--muted); }
.scan[data-state='checking']::before { border: 2px solid var(--muted); border-top-color: transparent; animation: spin .8s linear infinite; }
.scan[data-state='empty']::before { background: rgba(20, 12, 9, 0.2); }
@keyframes spin { to { transform: rotate(360deg); } }

.downloads { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.downloads .big { grid-column: 1 / -1; min-height: 52px; font-size: 16px; }
.fine { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* footer */
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 28px; padding-bottom: 32px; color: var(--muted); font-size: 13px; }
.foot p { margin: 0; }
.pif-pill {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); cursor: pointer; font: 600 12px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.08em; text-transform: uppercase;
}
.pif-pill:hover { border-color: var(--orange); color: var(--orange-dark); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }

/* dialogs */
.sheet { border: 0; border-radius: 24px; padding: 22px; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(20, 12, 9, 0.45); }
.sheet::backdrop { background: rgba(20, 12, 9, 0.45); backdrop-filter: blur(3px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font: 600 26px/1.1 var(--display); }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.template { padding: 8px 8px 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--cream); cursor: pointer; display: flex; flex-direction: column; gap: 8px; font-weight: 600; font-size: 13px; }
.template:hover { border-color: var(--orange); }
.template canvas { width: 100%; height: auto; border-radius: 10px; background: #fff; }

.pif { width: min(460px, calc(100vw - 32px)); padding: 28px; background: var(--cream); position: relative; }
.pif .close { position: absolute; top: 16px; right: 16px; }
.pif h2 { font-size: 34px; font-weight: 700; padding-right: 44px; }
.seriously { margin: 2px 0 16px; color: var(--orange); font: 600 18px/1 var(--display); }
.pif-line { margin: 0 0 16px; font-size: 16px; line-height: 1.55; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 22px; }
.chips li { padding: 5px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font: 600 11px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.06em; text-transform: uppercase; }
.pif-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; order: -1; }
  .stage { max-width: 380px; margin: 0 auto; }
}

@media (max-width: 520px) {
  .fields { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
  .hero { padding-top: 12px; }
  .acc-body { padding: 4px 14px 18px; }
  .acc-head { padding: 12px 14px; }
  .template-grid { grid-template-columns: repeat(2, 1fr); }
  .hint.indent { margin-left: 0; }
  .color { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
