:root {
  --brand: #7a4699;
  --brand-ink: #5c3175;
  --brand-soft: #f3ecf7;
  --ink: #24202a;
  --muted: #6d6675;
  --line: #e4dfe9;
  --bg: #faf8fb;
  --card: #ffffff;
  --stage: #ece7f0;
  --danger: #b3261e;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #b58ad1;
    --brand-ink: #d3b4e8;
    --brand-soft: #2c2234;
    --ink: #eee9f2;
    --muted: #a79fb0;
    --line: #383040;
    --bg: #17141b;
    --card: #201c25;
    --stage: #110f14;
    --danger: #f2b8b5;
    --warn: #f3d28b;
    --warn-bg: #3a2f17;
  }
  .logo { filter: brightness(1.6) saturate(.8); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Poppins", system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.5;
}
.layout { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; min-height: 100vh; }
aside {
  background: var(--card); border-right: 1px solid var(--line);
  padding: 24px 28px 40px; overflow-y: auto; max-height: 100vh; position: sticky; top: 0;
}
.logo { width: 210px; height: auto; display: block; margin-bottom: 4px; }

/* Collapsible sections */
.section { border-top: 1px solid var(--line); padding: 4px 0 8px; }
.section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after { content: "+"; font-size: 18px; font-weight: 400; letter-spacing: 0; }
.section[open] > summary::after { content: "–"; }
.section > summary .step {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 11px; margin-right: 8px; letter-spacing: 0;
}
.section > summary .done { color: var(--brand); text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: auto; margin-right: 10px; font-size: 12px; }

label, .label { display: block; font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.field { margin-bottom: 14px; position: relative; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 42px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
input:disabled { opacity: .5; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 6px 0; font-weight: 400; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.note { font-size: 12px; border-radius: 8px; padding: 8px 10px; margin-top: 8px; background: var(--brand-soft); color: var(--ink); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.counter { position: absolute; right: 0; top: 0; font-size: 11px; color: var(--muted); }

/* Autocomplete */
.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 4px 0 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); list-style: none; padding: 4px; max-height: 280px; overflow-y: auto;
}
.suggest li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.suggest li small { color: var(--muted); display: block; font-size: 12px; }
.suggest li[aria-selected=true], .suggest li:hover { background: var(--brand-soft); }

/* Segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 8px 4px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--brand); color: #fff; }

/* Style swatches */
.group-title { font-size: 12px; color: var(--muted); margin: 10px 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatch {
  position: relative; aspect-ratio: 3 / 4; border-radius: 8px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); outline: 2px solid transparent; outline-offset: 2px;
  display: grid; place-items: center; overflow: hidden;
}
.swatch[aria-pressed=true] { outline-color: var(--brand); }
.swatch .ring { width: 70%; aspect-ratio: 1; border-radius: 50%; border: 2px solid; display: grid; place-items: center; }
.swatch .core { width: 72%; aspect-ratio: 1; border-radius: 50%; position: relative; }
.swatch .core::before, .swatch .core::after {
  content: ""; position: absolute; width: 3px; height: 3px; border-radius: 50%; background: var(--star); opacity: var(--star-o);
  top: 30%; left: 28%; box-shadow: 9px 6px 0 var(--star), 4px 14px 0 var(--star), 14px -2px 0 var(--star);
}
.swatch .core::after { top: 55%; left: 55%; }
.swatch .tline { position: absolute; top: 9%; left: 25%; right: 25%; height: 3px; border-radius: 2px; opacity: .8; }
.swatch .name {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 9.5px; line-height: 1.2; padding: 3px 2px;
  background: rgba(0,0,0,.45); color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.swatch .del {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 18px; cursor: pointer; display: none;
}
.swatch:hover .del, .swatch:focus-within .del { display: block; }

/* Colour editor */
.editor { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 12px; background: var(--bg); }
.colour-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; margin-bottom: 10px; }
.colour-row label { margin: 0; font-weight: 400; }
.colour-row small { display: block; color: var(--muted); font-size: 11px; }
input[type=color] { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: var(--card); cursor: pointer; }
.stops { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mini { font: inherit; font-size: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 6px; padding: 5px 9px; cursor: pointer; }
.mini:hover { border-color: var(--brand); }
.mini.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
input[type=range] { width: 100%; accent-color: var(--brand); }

.btn {
  width: 100%; font: inherit; font-weight: 600; font-size: 15px; border: 0; border-radius: 10px;
  padding: 13px 16px; background: var(--brand); color: #fff; cursor: pointer; margin-top: 16px;
}
.btn:hover { background: var(--brand-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.spec { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Stage */
main { background: var(--stage); display: grid; place-items: center; padding: 40px; min-height: 100vh; }
.stage-wrap { display: flex; flex-direction: column; align-items: center; max-width: 100%; }
.paper {
  position: relative; height: min(84vh, 1100px); max-width: 100%;
  box-shadow: 0 20px 60px rgba(30, 10, 40, .25), 0 2px 6px rgba(0,0,0,.15);
  display: grid; place-items: center; transition: background-color .25s; background: #162035;
}
.paper img { position: absolute; display: block; transition: opacity .2s; }
.paper.loading img { opacity: .5; }
.bleed-line { position: absolute; border: 1px dashed rgba(127,127,127,.8); pointer-events: none; display: none; }
.empty { text-align: center; color: #cfc6db; max-width: 340px; padding: 20px; }
.empty svg { opacity: .5; }
.caption { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }
.spinner {
  position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; display: none;
}
.paper.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px;
  display: none; max-width: 90vw; z-index: 20;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 16px 28px; }
  main { min-height: auto; padding: 20px 16px; order: -1; }
  .stage-wrap { width: 100%; }
  .paper { height: 60vh; width: auto; max-width: 100%; }
  .swatches { grid-template-columns: repeat(5, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Which version this is: Studio (no limits) or Shop */
.edition-badge { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; vertical-align: middle;
  margin: 2px 0 8px; }
.edition-badge.edition-studio { background: #e6f4ea; color: #1e6b35; border: 1px solid #b9e0c4; }
.edition-badge.edition-shop { background: #f3ecf7; color: #5c3175; border: 1px solid #dccbe8; }
@media (prefers-color-scheme: dark) {
  .edition-badge.edition-studio { background: #1f3a28; color: #9fe0b1; border-color: #2f5a3c; }
  .edition-badge.edition-shop { background: #33233f; color: #e1c8f0; border-color: #4b3460; }
}
/* Shop previews: harder to save or drag out */
.protect img { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---------------------------------------------------------------- phones (all pages) */
/* iPhones zoom into any text box with lettering under 16px; and they shrink
   empty date/time boxes unless they have a height of their own. */
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-height: 42px; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; }
@media (max-width: 900px) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px !important; }
}

/* Shop: optional account offer on the download page */
.account-offer { margin-top: 20px; padding: 16px 18px; border: 1px solid var(--line, rgba(0,0,0,.12)); border-radius: 12px; }
.account-offer p { margin: 0 0 12px; }
