/* Customization studio */
.studio-hero { padding: 36px 0 22px; }
.studio-hero-row { display: flex; justify-content: space-between; align-items: end; gap: 28px; }
.ent-banner { display: flex; align-items: center; gap: 14px; margin-top: 22px; padding: 16px 20px; font-size: 15px; line-height: 1.5; }
.ent-banner > svg { width: 22px; height: 22px; flex: none; }
.ent-banner > div { flex: 1; min-width: 0; }
.ent-banner .btn { flex: none; }
.studio { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 28px; align-items: start; padding-bottom: 40px; }

.controls { display: grid; gap: 14px; min-width: 0; }
.ctl-group { margin: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: 18px 18px 20px; display: grid; gap: 16px; min-width: 0; }
.ctl-group legend { float: left; width: 100%; padding: 0; margin-bottom: 2px; font: 600 15px/1 var(--f-display); letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.ctl-group legend + * { clear: both; }
.cg-n { font: 600 10.5px/1 var(--f-mono); letter-spacing: .1em; color: var(--lime-ink); padding: 4px 6px; border-radius: 5px; background: var(--lime-soft); }
.grid-2.tight { gap: 12px; }
.field .hint.ok { color: var(--lime-ink); }
.field .hint.err { color: var(--danger); }
.field .label .tag { height: 18px; font-size: 9.5px; margin-left: 6px; margin-right: auto; }
.seg { width: 100%; }
.seg button { flex: 1 1 auto; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 8px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text-2); font: 500 12.5px/1 var(--f-ui); cursor: pointer; transition: border-color .2s, color .2s, transform .15s; }
.preset:hover { border-color: var(--line-3); color: var(--text); }
.preset:active { transform: scale(.97); }
.preset i { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--p1) 0 50%, var(--p2) 50% 100%); box-shadow: 0 0 0 2px var(--pb), 0 0 0 3px var(--line-2); }

.saved-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.saved-row .icon-btn { width: 38px; height: 38px; }

.word-buckets { display: grid; gap: 6px; }
.word-buckets:empty { display: none; }
.bucket { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; }
.b-label { font: 600 9.5px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); width: 78px; }
.word { height: 24px; padding: 0 8px; border-radius: 6px; border: 1px solid; font: 500 11.5px/1 var(--f-mono); cursor: pointer; background: transparent; }
.w-adj { color: var(--cyan-ink); border-color: color-mix(in srgb, var(--cyan-ink) 35%, transparent); background: var(--cyan-soft); }
.w-noun { color: var(--lime-ink); border-color: color-mix(in srgb, var(--lime-ink) 35%, transparent); background: var(--lime-soft); }
.word:hover { filter: brightness(1.2); }

.tokens { display: flex; flex-wrap: wrap; gap: 5px; }
.token { height: 26px; padding: 0 8px; border-radius: 6px; border: 1px dashed var(--line-3); background: transparent; color: var(--muted); font: 500 11.5px/1 var(--f-mono); cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.token:hover { color: var(--lime-ink); border-color: var(--lime-ink); border-style: solid; background: var(--lime-soft); }

.check { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--lime); }

.swatches { display: flex; gap: 8px; }
.swatch { position: relative; width: 44px; height: 44px; border-radius: 11px; cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.swatch span { display: block; width: 100%; height: 100%; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 0 0 1px var(--line-2); transition: transform .15s; }
.swatch:hover span { transform: scale(1.06); }
.swatch:focus-within span { box-shadow: 0 0 0 2px var(--lime-ink); }

.colors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.color-input { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 6px; }
.color-input input[type=color] { width: 38px; height: 38px; padding: 0; border: 1px solid var(--line-2); border-radius: 9px; background: var(--bg-2); cursor: pointer; }
.color-input input[type=color]::-webkit-color-swatch-wrapper { padding: 4px; }
.color-input input[type=color]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-input input[type=color]::-moz-color-swatch { border: 0; border-radius: 5px; }
.input.bad { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255,107,90,.12); }

.uploads { display: flex; flex-wrap: wrap; gap: 8px; }
.upload-add { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 64px; height: 64px; padding: 0 12px; border-radius: 11px; border: 1px dashed var(--line-3); color: var(--muted); font: 500 11px/1 var(--f-mono); cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.upload-add:hover, .upload-add:focus-within { color: var(--lime-ink); border-color: var(--lime-ink); background: var(--lime-soft); }
.upload-add svg { width: 18px; height: 18px; }
.upload-thumb { position: relative; width: 64px; height: 64px; border-radius: 11px; background: repeating-conic-gradient(var(--raised) 0 25%, var(--bg-2) 0 50%) 0 0 / 12px 12px; border: 1px solid var(--line-2); }
.upload-thumb img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.thumb-x { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-3); background: var(--raised-2); color: var(--text); display: grid; place-items: center; cursor: pointer; padding: 0; }
.thumb-x svg { width: 12px; height: 12px; }
.thumb-x:hover { background: var(--danger); color: #fff; border-color: transparent; }
body.locked [data-premium], body.locked [data-export] { position: relative; opacity: .45; filter: grayscale(.85); }
body.locked [data-premium] :disabled, body.locked [data-export] :disabled { cursor: not-allowed; }
.pro-lock { position: absolute; top: 10px; right: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font: 600 10.5px/1 var(--f-mono); letter-spacing: .08em; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); filter: none; }
.pro-lock svg { width: 11px; height: 11px; }

/* preview column */
.preview-col { min-width: 0; align-self: stretch; }
/* No inner scrollbar: the preview scrolls with the page, and only sticks once its bottom is in view
   (top = whichever is higher: under the header, or "bottom edge 16px above the fold"). --pv-h set in studio.js. */
.preview-sticky { position: sticky; top: min(calc(var(--header-h) + 16px), calc(100vh - var(--pv-h, 0px) - 16px)); display: grid; gap: 12px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pv-note { font-size: 11px; }
.preview-stage { --st-bg: #0a0c0f; --st-accent: #c6ff3d; --st-accent2: #2ee6ff; position: relative; border-radius: var(--r-lg); border: 1px solid var(--line-2); padding: 22px 18px; min-height: 0; display: grid; place-items: center; overflow: hidden; background: var(--st-bg); transition: background .3s; isolation: isolate; }
.preview-stage::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.preview-stage[data-backdrop="blur"]::before { background: radial-gradient(400px 260px at 20% 10%, color-mix(in srgb, var(--st-accent) 22%, transparent), transparent 70%), radial-gradient(420px 280px at 90% 90%, color-mix(in srgb, var(--st-accent2) 18%, transparent), transparent 70%); filter: blur(10px); }
.preview-stage[data-backdrop="grid"]::before { background-image: linear-gradient(color-mix(in srgb, var(--st-accent) 14%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--st-accent) 14%, transparent) 1px, transparent 1px); background-size: 28px 28px; mask-image: radial-gradient(circle at 50% 40%, #000 30%, transparent 85%); }
.preview-stage[data-backdrop="stars"]::before { background-image: radial-gradient(1.2px 1.2px at 12% 18%, #fff, transparent), radial-gradient(1px 1px at 72% 12%, #fff, transparent), radial-gradient(1.4px 1.4px at 40% 70%, #fff, transparent), radial-gradient(1px 1px at 88% 62%, #fff, transparent), radial-gradient(1px 1px at 22% 86%, #fff, transparent), radial-gradient(1.3px 1.3px at 58% 34%, var(--st-accent2), transparent), radial-gradient(1px 1px at 94% 88%, #fff, transparent), radial-gradient(1px 1px at 6% 52%, #fff, transparent); background-size: 220px 220px; opacity: .7; }
.preview-picker { width: 100%; max-width: 440px; zoom: .82; } /* about the size it pops up at in a real app */
.preview-picker .demo-loading { color: #8a919a; font-size: 12px; text-align: center; padding: 60px 0; }
.demo-fallback { display: flex; gap: 12px; padding: 16px; border-radius: var(--r); border: 1px dashed rgba(255,255,255,.2); color: #b7bdb8; font-size: 13.5px; }
.demo-fallback svg { width: 18px; height: 18px; flex: none; color: #ffb547; }
.demo-fallback b { display: block; color: #e8ece6; margin-bottom: 4px; }

.preview-samples { padding: 14px 16px 16px; }
.ps-head { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.ps-avatars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.ps-avatars span { aspect-ratio: 1; display: block; animation: card-in .35s var(--ease) both; }
.ps-avatars svg { width: 100%; height: 100%; }
.ps-names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ps-names span { padding: 6px 10px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }

.export { padding: 14px 16px 16px; display: grid; gap: 12px; }
.export-head { display: flex; align-items: center; gap: 8px; }
.ex-status { margin-left: auto; font-size: 11px; }
.ex-status.ok { color: var(--lime-ink); }
.ex-status.warn { color: var(--amber-ink); cursor: help; }
.export-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.export-btns .btn .dim { font-size: 11px; font-weight: 400; }
.ex-reset { justify-self: start; border: 0; background: none; padding: 0; font: 500 11.5px/1 var(--f-mono); color: var(--dim); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.ex-reset:hover { color: var(--text); }

@media (max-width: 1080px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .preview-col { order: -1; }
  .preview-sticky { position: static; }
  .studio-hero-row { flex-direction: column; align-items: stretch; }
  .ent-banner { max-width: none; }
}
@media (max-width: 720px) {
  .preview-stage { padding: 14px; min-height: 0; }
  .ps-avatars { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .colors { grid-template-columns: minmax(0, 1fr); }
  .ctl-group { padding: 16px 14px; }
  .export-btns .btn { flex: 1 1 100%; }
  .export-btns .btn .dim { display: none; }
}
.studio .seg { flex-wrap: nowrap; }
.studio .seg button { padding: 0 6px; min-width: 0; }
@media (max-width: 520px) { .studio .seg { flex-wrap: wrap; } .studio .seg button { padding: 0 9px; } }

/* ---------- polish ---------- */
.studio-hero .lead { text-wrap: balance; }
.colors > .field:last-child:nth-child(odd) { grid-column: 1 / -1; }
.colors > .field:last-child:nth-child(odd) .color-input { grid-template-columns: 38px minmax(0, calc(50% - 50px)); }
.word-buckets:empty + .hint { display: none; }
.studio .seg button { transition: background .2s, color .2s, transform .12s; }
.studio .seg button:active { transform: scale(.96); }
.word, .token { transition: color .2s, border-color .2s, background .2s, transform .12s; }
.word:active, .token:active { transform: scale(.95); }
.preset[aria-pressed="true"], .preset:focus-visible { border-color: var(--lime-ink); color: var(--text); }
.export-head .tag { height: 20px; }
.ex-reset { margin-top: 2px; padding: 4px 0; }
.ex-reset:focus-visible { outline-offset: 3px; }
.ps-avatars span { border-radius: 10px; transition: transform .2s var(--ease); }
.ps-avatars span:hover { transform: translateY(-2px) scale(1.06); }
.ps-names span { transition: border-color .2s; }
.ps-names span:hover { border-color: var(--line-3); }
@media (max-width: 1080px) {
  .preview-head { justify-content: flex-start; }
}
@media (max-width: 720px) {
  .studio-hero { padding: 26px 0 16px; }
  .studio { gap: 18px; }
  /* tap targets >= 40px */
  .studio .input, .studio .select { height: 44px; }
  .color-input { grid-template-columns: 44px minmax(0, 1fr); }
  .color-input input[type=color] { width: 44px; height: 44px; }
  .colors > .field:last-child:nth-child(odd) .color-input { grid-template-columns: 44px minmax(0, 1fr); }
  .preset { height: 40px; }
  .saved-row .btn-sm { --h: 44px; }
  .saved-row .icon-btn { width: 44px; height: 44px; }
  .studio .seg button { height: 40px; }
  .word { height: 32px; }
  .token { height: 40px; padding: 0 10px; }
  .studio .range { height: 40px; }
  .check { min-height: 40px; }
  .check input { width: 20px; height: 20px; }
  .export-btns .btn { --h: 44px; }
  .ps-head .btn-xs { --h: 40px; }
  .ex-reset { min-height: 40px; padding: 0 4px 0 0; }
  .colors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  /* five-option groups: an even 3-column grid instead of a ragged wrap */
  .studio .seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); flex-wrap: nowrap; }
  .studio .seg:has(> :nth-child(5)) { grid-auto-flow: row; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .studio .seg:has(> :nth-child(5)) > button { grid-column: span 2; }
  .studio .seg:has(> :nth-child(5)) > button:nth-child(n+4) { grid-column: span 3; }
  .studio .seg button { padding: 0 4px; }
}

/* Light / dark switch beside the presets */
.preset-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mode-seg { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--bg-2); letter-spacing: 0; text-transform: none; }
.mode-seg button { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: 500 12px/1 var(--f-ui); cursor: pointer; transition: background .2s, color .2s; }
.mode-seg button svg { width: 13px; height: 13px; }
.mode-seg button:hover { color: var(--text); }
.mode-seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--cyan-ink) 16%, transparent); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan-ink) 45%, transparent); }

/* The PRO tag sits in the export header's corner: keep the validity status clear of it */
body.locked .export .ex-status { margin-right: 64px; }
