/* m4ster-sprite-gen v3 — "alive" edition.
 * Theme system in the tracker's Customize spirit: html[data-theme] + CSS vars,
 * animated background aura (theme-aware orbs), alive micro-interactions.
 * No frameworks, no webfonts, no build step. */

:root {
  --bg: #0c0916;
  --ink: #12101f;
  --panel: #151223;
  --line: #2a2440;
  --text: #ede9fe;
  --mute: #a89fc7;
  --dim: #7c739e;
  --violet: #a78bfa;
  --violet-deep: #7c3aed;
  --violet-soft: #c4b5fd;
  --on-accent: #0c0916;
  --amber: #fbbf24;
  --danger: #f43f5e;
  --orb-1: #8b5cf6;
  --orb-2: #d946ef;
  --orb-3: #6366f1;
  --orb-opacity: .5;
  --aura-intensity: .7;
  --glow: rgba(139, 92, 246, .35);
  --vignette: rgba(0, 0, 0, .22);
  --r: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

/* v6.3: default 115% zoom — the site is designed to be viewed slightly
 * enlarged (his call: "looks good zoomed in, make it default").
 * zoom re-lays-out like browser zoom, so media queries still respond. */
html { zoom: 1.15; }

/* ---------- themes: one data-theme per tracker swatch, full token sets ---------- */
html[data-theme="violet"] {
  --bg: #0c0916; --ink: #12101f; --panel: #151223; --line: #2a2440;
  --text: #ede9fe; --mute: #a89fc7; --dim: #7c739e;
  --violet: #a78bfa; --violet-deep: #7c3aed; --violet-soft: #c4b5fd; --on-accent: #0c0916;
  --amber: #fbbf24; --danger: #f43f5e;
  --orb-1: #8b5cf6; --orb-2: #d946ef; --orb-3: #6366f1; --orb-opacity: .5;
  --glow: rgba(139, 92, 246, .35); --vignette: rgba(0, 0, 0, .22);
}
html[data-theme="midnight"] {
  --bg: #1d2125; --ink: #282e33; --panel: #22272b; --line: #3d474f;
  --text: #e6edf3; --mute: #8c9bab; --dim: #626f86;
  --violet: #0c66e4; --violet-deep: #0055cc; --violet-soft: #579dff; --on-accent: #ffffff;
  --amber: #fbbf24; --danger: #e5493a;
  --orb-1: #0c66e4; --orb-2: #7c3aed; --orb-3: #0ea5e9; --orb-opacity: .5;
  --glow: rgba(12, 102, 228, .35); --vignette: rgba(0, 0, 0, .22);
}
html[data-theme="ocean"] {
  --bg: #0a1428; --ink: #0d1830; --panel: #0f1c33; --line: #24406b;
  --text: #e8f1ff; --mute: #8ba3c7; --dim: #5f7396;
  --violet: #0ea5e9; --violet-deep: #0369a1; --violet-soft: #38bdf8; --on-accent: #06283a;
  --amber: #fbbf24; --danger: #f87171;
  --orb-1: #0ea5e9; --orb-2: #2563eb; --orb-3: #2dd4bf; --orb-opacity: .5;
  --glow: rgba(14, 165, 233, .35); --vignette: rgba(0, 0, 0, .25);
}
html[data-theme="ember"] {
  --bg: #1f1512; --ink: #241914; --panel: #271b16; --line: #4d382c;
  --text: #f7ece4; --mute: #b2947f; --dim: #7d6355;
  --violet: #f97316; --violet-deep: #c2410c; --violet-soft: #fb923c; --on-accent: #2a1400;
  --amber: #fbbf24; --danger: #ef4444;
  --orb-1: #f97316; --orb-2: #dc2626; --orb-3: #f59e0b; --orb-opacity: .45;
  --glow: rgba(249, 115, 22, .35); --vignette: rgba(0, 0, 0, .25);
}
html[data-theme="forest"] {
  --bg: #101a14; --ink: #121e17; --panel: #15211a; --line: #2f4a3a;
  --text: #e9f5ec; --mute: #8cae95; --dim: #5f7d68;
  --violet: #22c55e; --violet-deep: #15803d; --violet-soft: #4ade80; --on-accent: #062312;
  --amber: #fbbf24; --danger: #f87171;
  --orb-1: #22c55e; --orb-2: #0d9488; --orb-3: #84cc16; --orb-opacity: .45;
  --glow: rgba(34, 197, 94, .35); --vignette: rgba(0, 0, 0, .25);
}
html[data-theme="porcelain"] {
  --bg: #f1f2f4; --ink: #e9ebef; --panel: #ffffff; --line: #c1c7d0;
  --text: #172b4d; --mute: #626f86; --dim: #8993a4;
  --violet: #0c66e4; --violet-deep: #0055cc; --violet-soft: #388bff; --on-accent: #ffffff;
  --amber: #b45309; --danger: #e5493a;
  --orb-1: #bae6fd; --orb-2: #ddd6fe; --orb-3: #fed7aa; --orb-opacity: .7;
  --glow: rgba(12, 102, 228, .22); --vignette: rgba(23, 43, 77, .08);
}

/* ---------- animated background aura (theme-aware orbs, transform-only) ---------- */
.aura {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  opacity: calc(var(--orb-opacity) * var(--aura-intensity, .7));
  transition: opacity .6s ease;
}
.aura.off { opacity: 0; }
.aura::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(115% 85% at 50% 8%, transparent 58%, var(--vignette) 100%);
}
.orb { position: absolute; border-radius: 50%; filter: blur(70px); will-change: transform; }
.orb-1 {
  width: 58vmax; height: 58vmax; left: -14vmax; top: -16vmax;
  background: radial-gradient(circle, var(--orb-1), transparent 65%);
  animation: drift1 75s ease-in-out infinite alternate;
}
.orb-2 {
  width: 50vmax; height: 50vmax; right: -12vmax; top: 24vh;
  background: radial-gradient(circle, var(--orb-2), transparent 65%);
  animation: drift2 90s ease-in-out infinite alternate;
}
.orb-3 {
  width: 44vmax; height: 44vmax; left: 28vw; bottom: -18vmax;
  background: radial-gradient(circle, var(--orb-3), transparent 65%);
  animation: drift3 100s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(9vmax, 7vmax) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-8vmax, -6vmax) scale(.94); } }
@keyframes drift3 { to { transform: translate(-7vmax, 6vmax) scale(1.08); } }

/* content floats above the aura */
.layout, .foot { position: relative; z-index: 1; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; max-width: 100%; background: var(--bg); }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); min-height: 100vh; min-height: 100dvh; }
img, canvas, svg, video { max-width: 100%; }
/* grid/flex children must be allowed to shrink — prevents blowout */
.layout > *, .page-section > *, .preview-export > * { min-width: 0; }
body {
  height: 100%;
  overflow-x: clip;
  max-width: 100vw;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }

/* ---------- top bar (sticky, blurred — like the portfolio nav) ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--violet) 16%, var(--bg)),
    color-mix(in srgb, var(--violet) 6%, var(--bg) 92%));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 0;
  box-shadow: 0 4px 24px -8px var(--glow), 0 1px 0 color-mix(in srgb, var(--violet) 30%, transparent);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* logo is the home button: reset native button chrome, keep the brand layout */
button.brand { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.monogram { width: 42px; height: 42px; flex: none; color: var(--violet); }
.brand-name { font-family: var(--mono); font-weight: 800; font-size: 19px; letter-spacing: 1px; white-space: nowrap; }
.brand-sub { color: var(--violet); }
.brand-test { color: var(--danger, #e5484d); font-size: 12px; letter-spacing: 2px; vertical-align: 3px; }
.tagline { color: var(--dim); font-size: 12.5px; margin-top: 2px; font-style: italic; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.pill {
  font-family: var(--mono); font-size: 11px; color: var(--violet);
  border: 1px solid var(--violet); border-radius: 999px; padding: 5px 13px;
  white-space: nowrap;
}
.gh-link {
  color: var(--text); text-decoration: none; font-family: var(--mono); font-size: 13px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 16px;
  background: transparent;
}
.gh-link:hover { border-color: var(--violet); color: var(--violet); }

/* ---------- layout: PC = wide two-panel tool ---------- */
.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  flex: 1;
  align-items: start;
}

.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
}

/* ---------- category chips (portfolio .chip language) ---------- */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.tab {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 10px 6px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--mute);
  cursor: pointer; text-transform: uppercase; letter-spacing: .5px;
  min-height: 40px;
}
.tab:hover { color: var(--text); border-color: var(--dim); }
.tab.active { background: var(--violet); border-color: var(--violet); color: var(--on-accent); font-weight: 700; }

.field-label {
  display: block; font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--dim); margin: 16px 0 8px;
}
.dim { color: var(--dim); font-weight: 400; text-transform: none; letter-spacing: 0; }

#params .row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
#params label.chk {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px;
  background: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; cursor: pointer; user-select: none; color: var(--text);
  min-height: 38px;
}
#params label.chk input { accent-color: var(--violet); width: 15px; height: 15px; }
#params select, #params input[type="number"] {
  background: var(--ink); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font-size: 13px; font-family: var(--sans);
  min-height: 38px;
}
#params select:focus, #params input[type="number"]:focus { outline: none; border-color: var(--violet); }
#params .num { width: 68px; }
#params .grow { flex: 1; min-width: 90px; }
.mini-btn {
  background: var(--ink); color: var(--mute); border: 1px solid var(--line);
  border-radius: 10px; min-width: 44px; min-height: 38px; font-size: 17px;
  cursor: pointer; flex: none;
  transition: background-color .35s ease, border-color .35s ease, color .35s ease, transform .18s ease;
}
.mini-btn:hover { color: var(--violet); border-color: var(--violet); transform: translateY(-1px); }

textarea#prompt {
  width: 100%; background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 14px; font-family: var(--sans); resize: vertical; min-height: 64px;
}
textarea#prompt:focus { outline: none; border-color: var(--violet); }

/* collapsible "exact prompt sent to the AI" — no magic, see/edit via the box above */
.prompt-peek {
  margin-top: 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--ink); padding: 0 12px;
}
.prompt-peek summary {
  cursor: pointer; font-family: var(--mono); font-size: 11px; color: var(--dim);
  padding: 10px 0; list-style: none; text-transform: uppercase; letter-spacing: 1px;
}
.prompt-peek summary::-webkit-details-marker { display: none; }
.prompt-peek summary::before { content: "▸ "; color: var(--violet); }
.prompt-peek[open] summary::before { content: "▾ "; }
.prompt-peek p {
  font-family: var(--mono); font-size: 11px; color: var(--mute);
  line-height: 1.65; margin: 0 0 12px; word-break: break-word;
}
.boost-tag {
  font-size: 9px; color: var(--on-accent); background: var(--violet); border-radius: 999px;
  padding: 2px 8px; margin-left: 6px; font-weight: 700; letter-spacing: .5px;
}

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg-btn {
  background: var(--ink); color: var(--mute); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 4px; font-size: 12px; font-family: var(--mono);
  cursor: pointer; min-height: 44px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { border-color: var(--violet); color: var(--violet); font-weight: 700; }
.seg-btn .offline { display: block; font-size: 9px; color: var(--dim); font-weight: 400; margin-top: 2px; }
.seg-btn.active .offline { color: var(--violet); }

.keys { display: flex; gap: 10px; }
.key {
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: var(--kc); border: 2px solid var(--line); padding: 0;
}
.key.active { border-color: var(--violet); box-shadow: 0 0 0 3px var(--glow); }

/* ---------- primary action (portfolio .btn-primary language) ---------- */
.generate {
  display: inline-block;
  width: 100%; margin-top: 20px; padding: 14px 24px;
  background: linear-gradient(135deg, var(--violet) 0%, var(--violet-soft) 100%);
  color: var(--on-accent); border: 2px solid color-mix(in srgb, var(--violet) 60%, #fff);
  /* hand-drawn wobble — matches the MFL logo sketch style */
  border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
  font-family: var(--sans); font-weight: 800; font-size: 16px; letter-spacing: .5px;
  cursor: pointer;
  box-shadow: 0 8px 28px -8px var(--glow), 0 0 18px -4px var(--violet);
  transition: transform .18s ease, box-shadow .25s ease, filter .18s ease;
}
.generate:hover {
  background: linear-gradient(135deg, var(--violet-soft) 0%, var(--violet) 100%);
  transform: translateY(-2px) rotate(-.4deg);
  box-shadow: 0 14px 36px -8px var(--glow), 0 0 28px -4px var(--violet);
  filter: brightness(1.08);
}
.generate:active { transform: translateY(0) rotate(0) scale(.98); }
.generate:active { transform: translateY(0); }
.generate:disabled { opacity: .45; cursor: wait; }
.gen-note { color: var(--dim); font-size: 11px; margin-top: 10px; text-align: center; line-height: 1.5; }

/* ---------- pipeline stepper ---------- */
.stepper {
  list-style: none; display: flex; gap: 6px; margin: 0 0 16px; padding: 0;
  overflow-x: auto; scrollbar-width: thin;
}
.stepper li {
  flex: 1; min-width: 96px; font-family: var(--mono); font-size: 11px; color: var(--dim);
  background: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.stepper .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.stepper li.active { color: var(--text); border-color: var(--violet); }
.stepper li.active .dot { background: var(--violet); animation: pulse 1s infinite; }
.stepper li.done { color: var(--text); }
.stepper li.done .dot { background: var(--violet); animation: tickpop .45s ease; }
@keyframes tickpop { 0% { transform: scale(.3); } 55% { transform: scale(1.4); } 100% { transform: scale(1); } }
.stepper li.warn { color: var(--amber); border-color: var(--amber); }
.stepper li.warn .dot { background: var(--amber); }
.stepper li.error { color: var(--danger); border-color: var(--danger); }
.stepper li.error .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- stage canvas ---------- */
.canvas-wrap {
  position: relative;
  background: repeating-conic-gradient(var(--panel) 0% 25%, var(--ink) 0% 50%) 0 0 / 24px 24px;
  border: 1px solid var(--line); border-radius: 10px;
  min-height: 300px; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#stage { max-width: 100%; max-height: 420px; display: block; }
.stage-msg {
  position: absolute; inset: auto 0 0 0; padding: 9px 13px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); font-family: var(--mono); font-size: 12px; color: var(--dim);
  border-top: 1px solid var(--line); line-height: 1.5;
}
.stage-msg.err { color: var(--danger); }
.stage-msg.warn { color: var(--amber); }

/* ---------- retry bar (recovery path, not a dead end) ---------- */
.retry-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding: 12px 14px;
  background: rgba(251, 191, 36, .06);
  border: 1px solid var(--amber); border-radius: 10px;
}
.retry-msg { font-family: var(--mono); font-size: 12px; color: var(--amber); line-height: 1.5; }
.retry-actions { display: flex; gap: 8px; flex: none; }
.retry-actions .btn-ghost { margin-bottom: 0; white-space: nowrap; text-align: center; }
@media (max-width: 767px) {
  .retry-actions { flex-direction: column; width: 100%; }
}

/* ---------- frames strip ---------- */
.frames-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.frames-row { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px; min-height: 100px; scrollbar-width: thin; }
.frame-card {
  position: relative; flex: none; background: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center;
}
.frame-card canvas { display: block; image-rendering: pixelated; max-height: 72px; max-width: 120px; }
.frame-card .fname { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 5px; display: block; }
.frame-card .mv { display: flex; gap: 5px; justify-content: center; margin-top: 5px; }
.frame-card .mv button {
  background: none; border: 1px solid var(--line); color: var(--dim); border-radius: 6px;
  font-size: 11px; padding: 3px 9px; cursor: pointer; font-family: var(--mono); min-height: 30px;
}
.frame-card .mv button:hover { color: var(--violet); border-color: var(--violet); }

/* ---------- preview + export ---------- */
.preview-export { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; margin-top: 16px; }
.preview-box #preview {
  width: 256px; height: 256px; max-width: 100%;
  background: repeating-conic-gradient(var(--panel) 0% 25%, var(--ink) 0% 50%) 0 0 / 24px 24px;
  border: 1px solid var(--line); border-radius: 10px; image-rendering: pixelated;
  display: block;
}
/* ---------- v6.8: AI model switcher ---------- */
#aiModelBox { margin-top: 2px; }
.ai-model-select {
  width: 100%; background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; font-family: var(--sans); min-height: 42px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.ai-model-select:hover, .ai-model-select:focus-visible {
  border-color: var(--violet); box-shadow: 0 0 0 3px var(--glow); outline: none;
}
#aiKeyRow { margin-top: 8px; }
#aiKey {
  width: 100%; background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; font-family: var(--mono); min-height: 42px;
}
#aiKey:focus-visible { border-color: var(--violet); box-shadow: 0 0 0 3px var(--glow); outline: none; }
.ai-key-hint { font-size: 11px; color: var(--dim); margin: 6px 0 0; line-height: 1.5; }
.ai-key-hint a { color: var(--violet); }
.ai-model-note { font-size: 11px; color: var(--dim); margin: 6px 0 0; line-height: 1.5; min-height: 14px; }

.preview-controls { display: flex; gap: 8px; margin-top: 10px; }
.preview-controls select {
  background: var(--ink); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; font-family: var(--sans);
  min-height: 42px;
}
.btn-ghost, .export-box .btn {
  display: block; width: 100%;
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 16px; font-size: 13px; font-family: var(--mono);
  cursor: pointer; text-align: left; margin-bottom: 8px; min-height: 46px;
}
.btn-ghost:hover, .export-box .btn:hover:not(:disabled) { border-color: var(--violet); color: var(--violet); }
.export-box .btn:disabled { opacity: .4; cursor: not-allowed; }
.export-box .btn.ghost { color: var(--dim); }
.export-note { color: var(--dim); font-size: 11px; line-height: 1.6; }

/* simple layout: secondary exports fold away under one summary row */
.more-exports { display: flex; flex-direction: column; gap: 8px; }
.more-exports summary {
  cursor: pointer; list-style: none; text-align: center;
  padding: 9px 12px; border-radius: 12px; font-size: 12.5px; font-weight: 600;
  color: var(--dim); border: 1px dashed color-mix(in srgb, var(--line) 80%, transparent);
  transition: color .2s ease, border-color .2s ease, transform .15s ease;
}
.more-exports summary::-webkit-details-marker { display: none; }
.more-exports summary::after { content: " ▾"; }
.more-exports[open ] summary::after { content: " ▴"; }
.more-exports summary:hover { color: var(--text); border-color: var(--acc); transform: translateY(-1px); }

.foot {
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
  border-top: 0; color: var(--dim);
  font-family: var(--mono); font-size: 11px; text-align: center; line-height: 1.6;
  background: linear-gradient(0deg,
    color-mix(in srgb, var(--violet) 12%, var(--bg)),
    color-mix(in srgb, var(--violet) 4%, var(--bg) 96%));
  box-shadow: 0 -4px 24px -12px var(--glow);
  position: relative;
}
.foot::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--rgb-grad);
  background-size: 200% 100%;
  animation: rgbFlow var(--rgb-speed, 6s) linear infinite;
}
body.rgb-breathe .foot::before { animation: rgbBreathe var(--rgb-speed, 6s) ease-in-out infinite; }
body.no-rgb .foot::before { display: none; }

/* ---------- mobile sticky generate bar (phone-only) ---------- */
.mobile-bar { display: none; }

/* ---------- tablet: stack, keep tool feel ---------- */
@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 860px; }
  .preview-export { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- phone: genuinely different layout, thumb-first flow ---------- */
@media (max-width: 767px) {
  .topbar { padding: 10px 14px; }
  .brand-name { font-size: 16px; }
  .tagline { display: none; }
  .monogram { width: 36px; height: 36px; }
  .pill { display: none; }
  .gh-link { padding: 7px 12px; font-size: 12px; }

  .layout { padding: 20px; gap: 16px; display: flex; flex-direction: column; }
  .panel, .card { padding: 20px; }

  .tabs { gap: 6px; margin-bottom: 12px; }
  .tab { font-size: 11px; padding: 11px 4px; min-height: 44px; }

  .field-label { margin: 12px 0 6px; }

  /* in-panel generate hides on phone — the sticky bar takes over */
  .controls .generate { display: none; }

  .mobile-bar {
    display: block;
    position: sticky;
    bottom: 0;
    z-index: 60;
    padding: 8px 20px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, color-mix(in srgb, var(--bg) 97%, transparent) 55%, transparent);
    margin: 0 -20px;
  }
  .mobile-bar .generate {
    margin-top: 0;
    padding: 16px 24px;
    font-size: 16px;
    min-height: 56px;
    border-radius: 12px;
    box-shadow: 0 10px 32px var(--glow);
  }

  .stepper { gap: 5px; margin-bottom: 12px; }
  .stepper li { min-width: 0; flex: 1 0 auto; font-size: 10px; padding: 8px 9px; }

  .canvas-wrap { min-height: 220px; }
  #stage { max-height: 320px; }
  .stage-msg { font-size: 11px; }

  .retry-bar { flex-direction: column; align-items: stretch; }
  .retry-bar .btn-ghost { text-align: center; margin-bottom: 0; }

  .preview-box #preview { width: 100%; height: auto; aspect-ratio: 1 / 1; }

  .export-box .btn, .btn-ghost { min-height: 52px; font-size: 14px; }

  .frames-row { min-height: 108px; }
  .foot { font-size: 10px; padding: 12px 14px; }
}

/* ---------- v3: customize popover (theme switcher + aura controls) ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--mute);
}
.icon-btn:hover { border-color: var(--violet); color: var(--violet); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
.customize {
  position: fixed; top: 66px; right: 14px; z-index: 100; width: 272px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.cust-head {
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  letter-spacing: 1px; text-transform: uppercase;
}
.cust-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--dim); margin: 14px 0 8px;
}
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; min-height: 36px; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--sw); border: 2px solid var(--line);
}
.swatch:hover { transform: scale(1.14); }
.swatch.active { border-color: var(--violet); box-shadow: 0 0 0 3px var(--glow); }
.swatch-name { grid-column: 1 / -1; font-size: 12px; color: var(--mute); font-family: var(--mono); }
.cust-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 13px; margin: 10px 0; cursor: pointer; color: var(--text);
}
.switch {
  width: 44px; height: 24px; border-radius: 999px; padding: 0; cursor: pointer;
  background: var(--ink); border: 1px solid var(--line); position: relative; flex: none;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--dim); transition: left .2s ease, background-color .2s ease;
}
.switch[aria-checked="true"] { background: var(--violet); border-color: var(--violet); }
.switch[aria-checked="true"] .knob { left: 22px; background: var(--on-accent); }
.cust-row input[type="range"] { accent-color: var(--violet); width: 120px; }
@media (max-width: 767px) {
  .customize { left: 12px; right: 12px; width: auto; top: 60px; }
  /* swatches stay thumb-sized on phone — full-width panel was blowing them up */
  .swatches { grid-template-columns: repeat(6, minmax(0, 48px)); justify-content: start; }
}

/* ---------- v3: alive micro-interactions (tasteful, not a rave) ---------- */
.tab:hover:not(.active), .seg-btn:hover:not(.active) { transform: translateY(-1px); }
.frame-card:hover { transform: translateY(-2px); border-color: var(--violet); }
.btn-ghost:hover, .export-box .btn:hover:not(:disabled), .gh-link:hover { transform: translateY(-1px); }
/* smooth theme swaps + hover motion, one grouped rule so nothing fights */
body, .panel, .card, .topbar, .tab, .seg-btn, .frame-card, .btn-ghost,
.export-box .btn, .gh-link, .key, .icon-btn, .swatch, textarea, select,
input, .stepper li, .canvas-wrap, .preview-box #preview, .generate,
.mobile-bar .generate, .monogram {
  transition: background-color .35s ease, border-color .35s ease, color .35s ease,
              transform .18s ease, box-shadow .25s ease;
}

/* ---------- v3: respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  .stepper li.active .dot, .stepper li.done .dot { animation: none; }
  body, .panel, .card, .topbar, .tab, .seg-btn, .frame-card, .btn-ghost,
  .export-box .btn, .gh-link, .key, .icon-btn, .swatch, textarea, select,
  input, .stepper li, .canvas-wrap, .preview-box #preview, .generate,
  .mobile-bar .generate, .monogram {
    transition-duration: .01ms;
  }
}

/* ---------- v6.6: slicer (piece picker reused from v5) ---------- */
.seg.cols4 { grid-template-columns: repeat(4, 1fr); }
.knock-row {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 13px; color: var(--mute); cursor: pointer; user-select: none;
}
.knock-row input { accent-color: var(--violet); width: 16px; height: 16px; }
.split-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px; padding: 10px 2px; max-height: 340px; overflow-y: auto; scrollbar-width: thin;
}
.piece-card {
  position: relative; background: var(--ink); border: 2px solid var(--line);
  border-radius: 10px; padding: 6px; cursor: pointer; min-height: 72px;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; color: inherit;
}
.piece-card:hover:not(:disabled) { border-color: var(--dim); transform: translateY(-1px); }
.piece-card canvas { image-rendering: pixelated; max-width: 100%; display: block; }
.piece-card .pnum {
  position: absolute; top: 4px; left: 7px; font-family: var(--mono); font-size: 10px; color: var(--dim);
}
.piece-card .porder {
  position: absolute; top: -9px; right: -9px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--violet); color: var(--on-accent); font-family: var(--mono); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px var(--glow);
}
.piece-card.picked { border-color: var(--violet); box-shadow: 0 0 0 2px var(--glow); }
.piece-card.empty { opacity: .32; }
.piece-card:disabled { cursor: not-allowed; }
.piece-card .pempty { color: var(--dim); font-size: 18px; }
@media (max-width: 767px) {
  .split-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); max-height: 300px; }
  .piece-card { min-height: 64px; }
}

/* ================= v6 "THE MIXTURE" =================
 * Prompt-first hero (Seele), category cards, animated gallery + motion
 * presets (Ludo), export bundle, facing flip polish (PixelLab).
 * Design refs folded in: responsive type scale via :root vars (desert),
 * hand-rolled GSAP-style scroll reveals, component modifier system +
 * focus-visible polish (Lisbon), section eyebrow rhythm (omnifood). */

:root { --hero-size: clamp(2.4rem, 5.4vw + 1rem, 4.2rem); }

.page-section {
  position: relative; z-index: 1;
  max-width: 1440px; margin: 0 auto; padding: 0 20px;
}
section.page-section { scroll-margin-top: 78px; }

.section-title {
  font-size: clamp(1.25rem, 2.4vw + .8rem, 1.8rem);
  letter-spacing: -.5px; margin: 0 0 18px;
}
.section-title .dim { font-size: 13px; letter-spacing: 0; }
@media (max-width: 767px) {
  .section-title .dim { display: block; margin-top: 6px; line-height: 1.5; }
}

/* ---------- hero ---------- */
.hero { padding: 60px 20px 30px; text-align: center; }
.hero-inner { max-width: 780px; margin: 0 auto; }
.hero-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 3px;
  color: var(--violet); margin-bottom: 16px; font-weight: 700;
}
.hero-title {
  font-size: var(--hero-size); line-height: 1.04;
  letter-spacing: -1.5px; margin: 0 0 14px; font-weight: 800;
}
.hero-title em { font-style: normal; color: var(--violet); }
.hero-sub { color: var(--mute); font-size: 16px; max-width: 580px; margin: 0 auto 24px; line-height: 1.6; }
.hero-prompt-row { display: flex; gap: 10px; max-width: 660px; margin: 0 auto; align-items: stretch; }
#heroPrompt {
  flex: 1; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; font-size: 15px; font-family: var(--sans);
  resize: none; min-height: 58px;
  box-shadow: 0 12px 40px -12px var(--glow);
}
#heroPrompt:focus { outline: none; border-color: var(--violet); }
#heroPrompt::placeholder { color: var(--dim); }
.hero-go.generate { width: auto; margin-top: 0; padding: 14px 34px; flex: none; }
.hero-hints {
  display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  margin-top: 18px; font-family: var(--mono); font-size: 11px; color: var(--dim);
  text-transform: uppercase; letter-spacing: 1px;
}
.hero-hints span::before { content: "✓ "; color: var(--violet); }

/* ---------- category cards ---------- */
#catCards { padding-top: 26px; }
.cat-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px;
}
.cat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px 14px; cursor: pointer; color: var(--text); font-family: var(--sans);
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  transition: background-color .35s ease, border-color .35s ease, transform .18s ease, box-shadow .25s ease;
}
.cat-card svg { width: 40px; height: 40px; color: var(--violet); }
.cat-card b { font-size: 15px; }
.cat-card span { font-size: 12px; color: var(--mute); line-height: 1.45; }
.cat-card:hover { border-color: var(--violet); transform: translateY(-3px); box-shadow: 0 14px 34px -12px var(--glow); }
.cat-card:hover svg { color: var(--violet-soft); }

/* ---------- gallery (Ludo card anatomy) ---------- */
#gallery { padding-top: 44px; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
}
.gcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .35s ease, transform .18s ease, box-shadow .25s ease;
}
.gcard:hover { border-color: var(--violet); transform: translateY(-3px); box-shadow: 0 16px 38px -14px var(--glow); }
.gcanvas {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 10px; display: block;
  image-rendering: pixelated;
  background: repeating-conic-gradient(var(--ink) 0% 25%, var(--panel) 0% 50%) 0 0 / 20px 20px;
  border: 1px solid var(--line);
}
.glabel { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; }
.glabel b { color: var(--text); }
.glabel span { color: var(--dim); }
.gprompt { font-size: 12.5px; color: var(--mute); font-style: italic; line-height: 1.5; margin: 0; flex: 1; }
.gopen {
  background: transparent; border: 1px solid var(--line); color: var(--violet);
  border-radius: 10px; padding: 10px; font-family: var(--mono); font-size: 12px;
  cursor: pointer; min-height: 44px;
  transition: border-color .25s ease, transform .18s ease;
}
.gopen:hover { border-color: var(--violet); transform: translateY(-1px); }

/* ---------- motion presets ---------- */
#presets { padding-top: 40px; }
.preset-row { display: flex; gap: 12px; flex-wrap: wrap; }
.preset-chip {
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--r);
  padding: 10px 14px 10px 10px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; gap: 10px; font-family: var(--sans);
  transition: border-color .3s ease, transform .18s ease, box-shadow .25s ease;
}
.preset-chip:hover { transform: translateY(-2px); border-color: var(--dim); }
.preset-chip.active { border-color: var(--violet); box-shadow: 0 0 0 2px var(--glow); }
.pcanvas {
  width: 52px; height: 52px; border-radius: 8px; image-rendering: pixelated; display: block;
  background: repeating-conic-gradient(var(--ink) 0% 25%, var(--panel) 0% 50%) 0 0 / 14px 14px;
  border: 1px solid var(--line); flex: none;
}
.plabel { font-size: 14px; font-weight: 600; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.plabel small { font-family: var(--mono); font-size: 10px; color: var(--dim); font-weight: 400; }

/* ---------- export bundle button ---------- */
.export-box .btn.bundle {
  border-color: var(--violet); color: var(--text); font-weight: 700;
  background: color-mix(in srgb, var(--violet) 14%, transparent);
}
.export-box .btn.bundle:hover:not(:disabled) { background: var(--violet); color: var(--on-accent); }
.export-box .btn.bundle .dim { color: inherit; opacity: .75; font-size: 11px; }

/* ---------- scroll reveal (design-ref: GSAP-style entrances, hand-rolled) ----------
 * v6.1: progressive enhancement — .reveal only hides when JS is running
 * (.js on <html>). If the observer never fires, content stays visible. */
.js .reveal { opacity: 0; transform: translateY(26px); }
.js .reveal.in {
  opacity: 1; transform: none;
  transition: opacity .55s ease var(--d, 0s), transform .55s cubic-bezier(.22, 1, .36, 1) var(--d, 0s);
}
/* pop variant: hero + category cards float in on load (<600ms) — buttery, no bounce */
.js .reveal-pop { opacity: 0; }
.js .reveal-pop.in { opacity: 1; animation: popIn .6s cubic-bezier(.22, 1, .36, 1) var(--d, 0s) backwards; }
@keyframes popIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- v6.7: marquee ticker (artcraft-style infinite scroll) ---------- */
.marquee {
  overflow: hidden; white-space: nowrap; position: relative; z-index: 1;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 14px 0; margin: 8px 0 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track { display: inline-flex; gap: 26px; align-items: baseline; animation: marquee 28s linear infinite; }
.marquee-track span {
  font-family: var(--mono); font-size: 13px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--dim); white-space: nowrap;
}
.marquee-track i { color: var(--violet); font-style: normal; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee-track { animation: none; } }

/* ---------- v6.8: RGB separators (m4ster standard — all apps) ----------
 * Flowing rainbow gradient lines. Modes: flow (default) / breathing.
 * Speed via --rgb-speed (seconds). Toggle via body.no-rgb. */
:root {
  --rgb-speed: 6s;
  /* v6.16: by default the separators wear the ACTIVE THEME's colours —
   * pick Ember and the whole site's lines run orange. The gradient is
   * built from the theme tokens, so it re-skins itself per theme. */
  --rgb-grad: linear-gradient(90deg,
    var(--violet-deep), var(--violet), var(--violet-soft),
    var(--violet), var(--violet-deep), var(--violet), var(--violet-deep));
}
/* full rainbow flow is a Customize opt-in, not the default */
body.rgb-rainbow {
  --rgb-grad: linear-gradient(90deg,
    #ff2d78, #ff8c00, #ffee00, #00e676,
    #00ccff, #7c4dff, #ff2d78);
}
/* status colours (v6.15): the separators report the pipeline state —
 * theme colours while working, green done, amber needs-a-decision,
 * red failed. These sit after the rainbow rule so status always wins. */
body.status-done {
  --rgb-grad: linear-gradient(90deg,
    #00c853, #00e676, #69f0ae, #00e676, #00c853, #00e676, #00c853);
}
body.status-warn {
  --rgb-grad: linear-gradient(90deg,
    #ff8c00, #ffc400, #ffee00, #ffc400, #ff8c00, #ffc400, #ff8c00);
}
body.status-error {
  --rgb-grad: linear-gradient(90deg,
    #d50000, #ff1744, #ff5252, #ff1744, #d50000, #ff1744, #d50000);
}
/* the phone's sticky generate bar gets the same line on its top edge */
.mobile-bar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--rgb-grad);
  background-size: 200% 100%;
  animation: rgbFlow var(--rgb-speed, 6s) linear infinite;
}
body.rgb-breathe .mobile-bar::before { animation: rgbBreathe var(--rgb-speed, 6s) ease-in-out infinite; }
body.no-rgb .mobile-bar::before { display: none; }
.rgb-sep {
  height: 2px; border: 0; margin: 0; padding: 0;
  background: var(--rgb-grad);
  background-size: 200% 100%;
  animation: rgbFlow var(--rgb-speed, 6s) linear infinite;
}
@keyframes rgbFlow { to { background-position: 200% 0; } }
body.rgb-breathe .rgb-sep { animation: rgbBreathe var(--rgb-speed, 6s) ease-in-out infinite; }
@keyframes rgbBreathe { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
body.no-rgb .rgb-sep { display: none; }
/* topbar + marquee use RGB seps instead of flat borders */
.topbar { border-bottom: 0; }
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--rgb-grad);
  background-size: 200% 100%;
  animation: rgbFlow var(--rgb-speed, 6s) linear infinite;
}
body.rgb-breathe .topbar::after { animation: rgbBreathe var(--rgb-speed, 6s) ease-in-out infinite; }
body.no-rgb .topbar::after { display: none; }
.marquee { border-top: 0; border-bottom: 0; position: relative; }
.marquee::before, .marquee::after {
  content: ""; position: absolute; left: 0; right: 0; height: 2px;
  background: var(--rgb-grad);
  background-size: 200% 100%;
  animation: rgbFlow var(--rgb-speed, 6s) linear infinite;
}
.marquee::before { top: 0; }
.marquee::after { bottom: 0; }
body.rgb-breathe .marquee::before, body.rgb-breathe .marquee::after { animation: rgbBreathe var(--rgb-speed, 6s) ease-in-out infinite; }
body.no-rgb .marquee::before, body.no-rgb .marquee::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  .rgb-sep, .topbar::after, .marquee::before, .marquee::after, .foot::before, .mobile-bar::before { animation: none; }
}

/* ---------- v6.9: PWA — service worker + install button ---------- */
.install-app {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff; border: 0;
}
.install-app:hover { filter: brightness(1.1); transform: translateY(-2px); }

/* ---------- v6.8: customize save button ---------- */
.save-btn {
  width: 100%; margin-top: 14px; padding: 12px;
  background: var(--violet); color: #fff; border: 0; border-radius: 10px;
  font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform .18s ease, filter .18s ease;
}
.save-btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.save-btn:active { transform: translateY(0) scale(.98); }
.save-tick {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #16a34a; color: #fff; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.save-tick.show { opacity: 1; }

/* ---------- v6.8: cursor glow trail canvas (5IN1 GridGlow idea) ---------- */
#cursor-trail {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { #cursor-trail { display: none; } }

/* ---------- v6.8: logo letter glow (each letter glows) ---------- */
.monogram .glow-m { filter: drop-shadow(0 0 5px #a78bfa) drop-shadow(0 0 12px rgba(167,139,250,.6)); animation: letterPulse 3s ease-in-out infinite; }
.monogram .glow-f { filter: drop-shadow(0 0 5px #7dd3fc) drop-shadow(0 0 12px rgba(125,211,252,.6)); animation: letterPulse 3s ease-in-out .5s infinite; }
.monogram .glow-l { filter: drop-shadow(0 0 4px #a78bfa) drop-shadow(0 0 10px rgba(167,139,250,.6)); animation: letterPulse 3s ease-in-out 1s infinite; }
@keyframes letterPulse { 0%, 100% { opacity: .92; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .monogram .glow-m, .monogram .glow-f, .monogram .glow-l { animation: none; }
}
.monogram-wrap { position: relative; display: inline-flex; flex: none; }
.monogram-wrap::after {
  content: ""; position: absolute; inset: -9px; border-radius: 22px;
  background: radial-gradient(circle, var(--violet) 0%, transparent 68%);
  opacity: .22; pointer-events: none;
  animation: logoGlow 4.2s ease-in-out infinite;
}
.monogram { display: block; animation: logoFloat 5.2s ease-in-out infinite; }
@keyframes logoGlow { 0%, 100% { opacity: .16; } 50% { opacity: .44; } }
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ---------- focus-visible polish (Lisbon a11y spirit) ---------- */
:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus:not(:focus-visible), a:focus:not(:focus-visible),
input:focus:not(:focus-visible), select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) { outline: none; }

/* ---------- the lab sits below the landing sections ---------- */
#tool { padding-top: 44px; }
#tool.layout { margin-top: 0; }

/* ---------- tablet ---------- */
@media (max-width: 1023px) {
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 48px 16px 24px; }
}

/* ---------- phone: genuinely different, thumb-first ---------- */
@media (max-width: 767px) {
  html { zoom: 1; } /* 115% zoom causes horizontal overflow on phones — desktop only */
  .page-section { padding-left: 12px; padding-right: 12px; }
  .hero { padding: 40px 12px 20px; }
  .hero-prompt-row { flex-direction: column; align-items: center; }
  .hero-go.generate { width: calc(100% - 48px); padding: 16px; }
  #heroPrompt { min-height: 72px; font-size: 16px; } /* 16px stops iOS zoom */
  .hero-hints { gap: 12px; }

  /* full-bleed bars on mobile — no gaps at the edges */
  .topbar, .foot { border-radius: 0; }
  .mobile-bar {
    margin-left: 0; margin-right: 0;
    padding-left: calc(24px + env(safe-area-inset-left));
    padding-right: calc(24px + env(safe-area-inset-right));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 97%, transparent);
  }
  .mobile-bar .generate { width: calc(100% - 24px); margin-left: auto; margin-right: auto; display: block; }

  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cat-card { padding: 16px 10px; }
  .cat-card:last-child { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 12px; }
  .cat-card:last-child svg { width: 32px; height: 32px; }

  .gallery-grid {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
    gap: 12px; padding: 4px 12px 14px; margin: 0 -12px; scrollbar-width: thin;
  }
  .gcard { flex: 0 0 240px; scroll-snap-align: start; }

  .preset-row {
    flex-wrap: wrap; overflow-x: visible; padding: 4px 0 12px; margin: 0;
  }
  .preset-chip { flex: 1 1 calc(33.333% - 8px); min-width: 0; padding: 8px; gap: 8px; }
  .preset-chip .pcanvas { width: 40px; height: 40px; }

  #tool { padding-top: 32px; }
}

/* ---------- reduced motion: reveals show instantly, no parallax, logo rests ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-pop { opacity: 1 !important; transform: none !important; animation: none !important; }
  .js .reveal.in, .js .reveal-pop.in { transition: none; }
  .monogram, .monogram-wrap::after { animation: none; }
  .monogram-wrap::after { opacity: 0; }
}

/* ---------- v6.5: m4ster signature cursor + live interactivity ----------
 * The m4ster fingerprint: a custom orb follows the mouse everywhere
 * (desktop/fine-pointer only, respects reduced-motion). Orb glow uses
 * the theme accent (--violet), so it matches Ember/Violet/etc. Download
 * + generate CTAs get an extra signature pulse ring. */
@media (pointer: fine) {
  html.has-orb, html.has-orb * { cursor: none !important; }
}
.cursor-orb {
  position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none;
  width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  background: radial-gradient(circle, var(--violet-soft) 0%, var(--violet) 38%, transparent 72%);
  opacity: .85; will-change: transform;
  transition: width .22s ease, height .22s ease, margin .22s ease, opacity .25s ease;
}
.cursor-orb.is-hover {
  width: 42px; height: 42px; margin: -21px 0 0 -21px; opacity: 1;
}
/* signature: download/export/generate CTAs — bigger glow + pulsing ring.
 * v6.6.1: red-hot core + red ring so the orb stays distinguishable on top
 * of orange (Ember) buttons — orange-on-orange was invisible. */
.cursor-orb.is-cta {
  width: 60px; height: 60px; margin: -30px 0 0 -30px; opacity: 1;
  background: radial-gradient(circle, rgba(255,255,255,.5) 0%, rgba(255,45,45,.42) 32%, rgba(196,14,14,.32) 58%, transparent 74%);
  box-shadow: 0 0 0 3px rgba(0,0,0,.72), 0 0 26px 8px rgba(255,45,45,.55);
}
.cursor-orb.is-cta::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 3px solid #ff2d2d;
  animation: orbRing 1.15s ease-out infinite;
}
@keyframes orbRing {
  from { transform: scale(.68); opacity: .95; }
  to   { transform: scale(1.28); opacity: 0; }
}
/* no orb on touch or when the user asked for less motion */
@media (pointer: coarse), (prefers-reduced-motion: reduce) {
  .cursor-orb { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .cursor-orb.is-cta::after { animation: none; }
}

/* ---------- v6.5: background aura reaches toward the cursor ----------
 * driven by JS via inline transform on #aura (composited, no style recalc) —
 * only when the pointer is fine and motion is allowed (guarded in JS) */
.aura { will-change: transform; }

/* ---------- v6.5: logo glows harder (already alive, now stronger) ---------- */
.monogram-wrap::after { opacity: .24; }
.monogram-wrap:hover::after { opacity: .6; }
@keyframes logoGlow { 0%, 100% { opacity: .22; } 50% { opacity: .58; } }

/* ---------- v6.5: everything the cursor touches gives feedback ----------
 * gallery cards already lift+glow; extend the same language to every
 * interactive surface so nothing feels dead on hover. */
.cat-card:hover, .preset-chip:hover, .swatch:hover, .frame-card:hover,
.stepper li:hover, .tab:hover, .seg-btn:hover, .icon-btn:hover,
.key:hover {
  transform: translateY(-2px);
  border-color: var(--violet);
  box-shadow: 0 10px 30px -12px var(--glow);
}
.gh-link:hover { color: var(--violet); }

/* standalone tools: no wizard framing in tool lanes */
.tool-hidden { display: none !important; }
.tool-back {
  width: 100%; margin-bottom: 12px; padding: 10px 12px; border-radius: 10px;
  background: linear-gradient(180deg, #2c2452, #1d1838);
  border: 1px solid var(--line); color: var(--ink);
  font: 600 13px var(--mono); cursor: pointer; text-align: center;
  box-shadow: 0 2px 0 #0d0a1c, inset 0 1px 0 rgba(255, 255, 255, .09);
}
.tool-back:active { transform: translateY(1px); box-shadow: 0 1px 0 #0d0a1c, inset 0 1px 0 rgba(255, 255, 255, .09); }

/* ---------- v6.5: image → pixel art converter ---------- */
/* pixelart mode hides the sprite-pipeline controls; the converter owns the lab */
.controls.mode-pixelart #prompt,
.controls.mode-pixelart label[for="prompt"],
.controls.mode-pixelart #promptPeek,
.controls.mode-pixelart #sourceLabel,
.controls.mode-pixelart #sourceSeg,
.controls.mode-pixelart #keyLabel,
.controls.mode-pixelart #keyRow,
.controls.mode-pixelart #generate,
.controls.mode-pixelart .gen-note { display: none !important; }
.stage-panel.mode-pixelart .canvas-wrap,
.stage-panel.mode-pixelart #retryBar,
.stage-panel.mode-pixelart #framesHead,
.stage-panel.mode-pixelart #framesRow,
.stage-panel.mode-pixelart #splitHead,
.stage-panel.mode-pixelart #splitGrid,
.stage-panel.mode-pixelart .preview-export,
.stage-panel.mode-pixelart .stepper { display: none !important; }
/* phone sticky generate bar must not fire the sprite pipeline in pixelart mode */
body.mode-pixelart .mobile-bar { display: none !important; }

/* side-by-side: original | pixel art */
.pixel-side { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.pixel-side[hidden] { display: none; }
.px-fig {
  margin: 0; background: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px; text-align: center; min-width: 0;
}
.px-fig canvas {
  image-rendering: pixelated; max-width: 100%; height: auto; display: block; margin: 0 auto;
  border-radius: 8px;
  background: repeating-conic-gradient(#221d38 0 25%, #141126 0 50%) 0 0 / 18px 18px;
}
.px-fig figcaption { margin-top: 8px; font-size: 12px; font-family: var(--mono); }
.px-dims { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.px-download {
  border-color: var(--violet); color: var(--violet); font-weight: 700;
  text-align: center; margin-top: 10px;
}
.px-download:hover { background: var(--violet); color: var(--on-accent); }
.px-empty {
  grid-column: 1 / -1; text-align: center; color: var(--dim);
  font-size: 13px; padding: 40px 16px; border: 1px dashed var(--line); border-radius: var(--r);
}
@media (max-width: 767px) {
  .pixel-side { grid-template-columns: 1fr; }
  .px-dims { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- v6.6: dedicated sprite slicer ---------- */
/* slicer mode hides the sprite-pipeline controls; the slicer owns the lab.
 * The stage canvas shows the sheet with a live grid overlay, the piece picker
 * and the animated preview stay visible; export moves to dedicated buttons. */
.controls.mode-slicer #prompt,
.controls.mode-slicer label[for="prompt"],
.controls.mode-slicer #promptPeek,
.controls.mode-slicer #sourceLabel,
.controls.mode-slicer #sourceSeg,
.controls.mode-slicer #keyLabel,
.controls.mode-slicer #keyRow,
.controls.mode-slicer #generate,
.controls.mode-slicer .gen-note { display: none !important; }
.stage-panel.mode-slicer #retryBar,
.stage-panel.mode-slicer #framesHead,
.stage-panel.mode-slicer #framesRow,
.stage-panel.mode-slicer .export-box,
.stage-panel.mode-slicer .stepper { display: none !important; }
/* phone sticky generate bar must not fire the sprite pipeline in slicer mode */
body.mode-slicer .mobile-bar { display: none !important; }

/* slicer controls */
.sl-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.sl-row .dim { min-width: 52px; }
.sl-row input[type="range"] { flex: 1; accent-color: var(--violet); }
.sl-val {
  font-family: var(--mono); font-size: 12px; color: var(--violet);
  min-width: 34px; text-align: right;
}
.sl-grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0; }
.sl-grid4 label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--dim); }
.sl-grid4 .num { width: 100%; }
.sl-readout {
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  background: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin: 8px 0;
}
.sl-readout b { color: var(--violet); }
.sl-hint { font-size: 12px; color: var(--dim); margin: 8px 0; }
.sl-pick-row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.sl-download {
  border-color: var(--violet); color: var(--violet); font-weight: 700;
  text-align: center; margin-top: 10px; width: 100%;
}
.sl-download:hover { background: var(--violet); color: var(--on-accent); }
.sl-download:disabled { opacity: .4; cursor: not-allowed; }
/* sheet + grid overlay sits on the stage canvas; cut lines drawn in JS */
.stage-panel.mode-slicer .canvas-wrap { position: relative; }
@media (max-width: 767px) {
  .sl-grid4 { grid-template-columns: repeat(2, 1fr); }
}
/* slicer has its own fps/playback controls; hide the shared pipeline ones */
.stage-panel.mode-slicer .preview-controls { display: none !important; }

/* ================= v6.16 — lab redesign =================
 * Same backend, friendlier face: controls grouped into numbered step
 * cards, one unified button scale, and frames + preview fused into a
 * single Visualizer panel with a proper filmstrip. */

/* --- layout breathing room --- */
.layout { max-width: 1340px; gap: 20px; }
.panel { padding: 20px; border-radius: 18px; }

/* --- control groups (left panel) --- */
.ctl-group {
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--panel-2) 55%, transparent);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.ctl-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.ctl-head h3 {
  margin: 0; font-size: 12.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text);
}
.ctl-head h3 .dim { letter-spacing: 0; text-transform: none; font-weight: 500; }
.ctl-num {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--violet), var(--violet-deep));
  color: var(--on-accent); font-size: 12px; font-weight: 800;
  box-shadow: 0 2px 10px -2px var(--glow);
}
.ctl-group .field-label:first-child { margin-top: 0; }

/* category tabs: chunky 3×2 grid */
.controls .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.controls .tab {
  min-height: 46px; padding: 10px 6px; border-radius: 11px;
  font-size: 13.5px; font-weight: 700; text-align: center;
}

/* options: roomier rows, taller fields */
#params .row { gap: 10px; margin-bottom: 10px; }
#params select, #params input[type="number"] {
  min-height: 42px; padding: 8px 10px; font-size: 14px; border-radius: 10px;
}
#params label.chk {
  padding: 10px 13px; border-radius: 10px; font-size: 13.5px; min-height: 42px;
}
#params label.chk input { width: 17px; height: 17px; }
#params .mini-btn, #params button {
  min-height: 42px; padding: 8px 14px; border-radius: 10px; font-size: 13.5px;
}

/* describe + source */
.controls #prompt { min-height: 88px; font-size: 15px; border-radius: 12px; padding: 12px; }
.controls .seg { gap: 8px; }
.controls .seg-btn { min-height: 48px; font-size: 14px; border-radius: 12px; padding: 10px; }
.ai-model-select { min-height: 48px; font-size: 14px; border-radius: 12px; padding: 10px 12px; width: 100%; }
#aiKey { min-height: 46px; font-size: 14px; border-radius: 12px; width: 100%; }
#aiStyleSeg .seg-btn { min-height: 44px; }

/* background keys: bigger swatches */
.keys { gap: 10px; }
.key { width: 38px; height: 38px; border-radius: 11px; }

/* the one big action */
.controls .generate { min-height: 60px; font-size: 17px; margin-top: 2px; }

/* --- stage panel --- */
.stepper { gap: 8px; }
.stepper li { padding: 9px 13px; font-size: 12.5px; border-radius: 999px; }
.canvas-wrap { min-height: 330px; border-radius: 14px; }
.retry-actions .btn-ghost { min-height: 44px; padding: 10px 18px; font-size: 13.5px; border-radius: 11px; }

/* --- visualizer: frames + animation in one panel --- */
.viz-panel {
  margin-top: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--panel-2) 45%, transparent);
  border-radius: 16px;
  padding: 16px;
}
.viz-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.viz-title {
  font-family: var(--font-brand, inherit); font-size: 17px; font-weight: 800;
  letter-spacing: .02em; color: var(--text);
}
.viz-panel .frames-head { margin-top: 10px; }

/* filmstrip */
.frames-row {
  gap: 12px; padding: 12px 2px 14px; min-height: 158px;
  align-items: stretch;
}
.frame-card {
  flex: 0 0 108px; width: 108px; padding: 8px 6px 7px;
  border-radius: 12px; display: flex; flex-direction: column; align-items: center;
}
.frame-card canvas {
  max-height: 92px; max-width: 92px; margin: auto;
  border-radius: 6px;
}
.frame-card .fname { font-size: 11px; margin-top: 7px; text-align: center; }
.frame-card .mv { margin-top: 6px; gap: 6px; }
.frame-card .mv button {
  width: 32px; height: 28px; font-size: 12px; border-radius: 8px;
  display: grid; place-items: center;
}

/* preview + export side by side, preview grown up */
.preview-export {
  display: grid; grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px; margin-top: 14px; align-items: start;
}
.preview-box canvas#preview {
  width: 100%; max-width: 320px; height: auto; aspect-ratio: 1;
  border-radius: 12px; border: 1px solid var(--line);
}
.preview-controls { display: flex; gap: 8px; margin-top: 10px; max-width: 320px; }
.preview-controls select {
  flex: 1; min-height: 44px; font-size: 14px; border-radius: 11px; padding: 8px 10px;
}
.export-box .btn { min-height: 50px; font-size: 14.5px; border-radius: 12px; padding: 12px 16px; }
.export-box .btn.bundle { min-height: 56px; font-size: 15.5px; }
.more-exports summary { padding: 13px 12px; font-size: 13.5px; border-radius: 12px; }

@media (max-width: 900px) {
  .preview-export { grid-template-columns: 1fr; }
  .preview-box canvas#preview { max-width: 280px; }
  .preview-controls { max-width: 280px; }
  .panel { padding: 14px; }
  .ctl-group { padding: 12px; }
  .canvas-wrap { min-height: 260px; }
}

/* v6.16b — options form grid: label over field, pairs side by side */
.pgrid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 12px 10px; margin-top: 12px; }
.pfield > label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 6px;
}
.pfield select, .pfield input[type="number"] { width: 100%; }
.pfield .seg { gap: 6px; }
.pfield .seg-btn { min-height: 42px; padding: 8px 6px; font-size: 13px; border-radius: 10px; }
.pal-row { display: flex; gap: 8px; }
.pal-row select, .pal-row input[type="number"] { flex: 1; min-width: 0; }
.pal-row .mini-btn {
  flex: 0 0 42px; width: 42px; min-height: 42px; padding: 0;
  display: grid; place-items: center; font-size: 16px; border-radius: 10px;
}
.states-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.states-grid label.chk { justify-content: center; margin: 0; }

/* v6.16c — narrow-field fixes: palette select + facing seg were squeezed */
.pfield select, .pfield input[type="number"] { font-size: 13.5px; padding: 8px 6px 8px 10px; }
.pfield .seg-btn { white-space: nowrap; font-size: 12.5px; }
/* facing seg text ("→ right") clipped at desktop column widths — the
   #params button padding (14px) outranks .pfield .seg-btn, so say it here */
#params .pfield .seg-btn { padding: 8px 6px; font-size: 12px; }
.pal-row .mini-btn { flex-basis: 38px; width: 38px; }

/* v6.16d — steps, unmistakably: eyebrow label + a rail line joining them */
.ctl-titles { display: flex; flex-direction: column; gap: 1px; }
.ctl-step {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; color: var(--violet);
}
.ctl-group { position: relative; }
/* step rail (his 2026-10-20 call: keep the line, move it LEFT): one
   continuous line down the left edge of the step cards, Step 1 → Step 5.
   It sits at left:6px — in the card's border strip, left of ALL content
   (content starts at the 14px padding) — so it never crosses a button. */
.ctl-group::before {
  content: ""; position: absolute; left: 6px; top: -2px; bottom: -16px;
  width: 2px; border-radius: 2px;
  background: var(--violet);
  opacity: .4;
}
.ctl-group:first-of-type::before { top: 12px; }
.ctl-group:last-of-type::before { bottom: 12px; }
.controls > .generate { position: relative; z-index: 1; }

/* ================= TEST BUILD: dim flip + studio cards + 3D hub ============ */
.dim-flip {
  display: flex; gap: 4px; padding: 4px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
}
.flip-btn {
  min-height: 38px; padding: 0 16px; border-radius: 999px; border: 0;
  background: transparent; color: var(--dim); font: 700 13px var(--font);
  cursor: pointer; transition: all .18s ease; white-space: nowrap;
}
.flip-btn:hover { color: var(--text); transform: translateY(-1px); }
.flip-btn.active { background: linear-gradient(180deg, var(--violet), var(--violet-deep)); color: #fff; }
.test-pill { border-color: #ffb020; color: #ffb020; }
#studioPanel { margin-top: 14px; }
.pick-grid { display: grid; gap: 7px; margin: 4px 0 9px; }
.act-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.style-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.persp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pick-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 0; min-height: 54px; padding: 6px 4px; border-radius: 12px; cursor: pointer;
  background: var(--field, rgba(255,255,255,.03)); border: 1px solid var(--line);
  color: var(--dim); font: 600 10.5px var(--font); transition: all .15s ease;
}
.pick-card:hover { transform: translateY(-2px); border-color: var(--violet); color: var(--text); }
.pick-card.active { border-color: var(--violet); color: var(--text); background: rgba(139,92,246,.16); box-shadow: 0 0 0 1px var(--violet) inset; }
.pc-icon { font-size: 17px; line-height: 1; }
/* uniform card rows in the two big studio grids — wrapping labels were
   making each row a different height and Step 3 sprawl past 1300px */
.act-grid .pick-card, .style-grid .pick-card { height: 62px; }
.pc-label { max-width: 100%; overflow-wrap: break-word; text-align: center; }
.pc-sub { font-size: 10px; color: var(--dim); font-weight: 500; }
.stepper {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 12px; padding: 6px; margin: 6px 0 12px;
}
.stepper button {
  width: 44px; height: 40px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 18px; cursor: pointer;
}
.stepper button:hover { border-color: var(--violet); }
.stepper span { font: 800 17px var(--font); }
.proc-btn { width: 100%; min-height: 46px; }
#preview { background: repeating-conic-gradient(rgba(255,255,255,.06) 0% 25%, rgba(255,255,255,.015) 0% 50%) 0 0 / 22px 22px; }
/* ---------- test build: Fresh from the Lab (auto-scroll showcase) ---------- */
.fresh-lab { max-width: 1100px; margin: 30px auto 8px; padding: 0 18px;
  opacity: 0; transform: translateY(16px) scale(.995); transition: opacity .6s ease, transform .6s ease; }
.fresh-lab.in { opacity: 1; transform: none; }
body.dim-3d .fresh-lab { display: none; }
.fresh-head { padding: 18px 4px 12px; }
.fresh-head h2 { font-size: 24px; margin: 0 0 4px; }
.fresh-head p { color: var(--dim); margin: 0; font-size: 13.5px; }
.fresh-marquee { overflow: hidden; padding: 6px 0 14px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.fresh-track { display: flex; gap: 14px; width: max-content; will-change: transform;
  animation: marquee 46s linear infinite; }
.fresh-marquee:hover .fresh-track, .fresh-marquee:active .fresh-track { animation-play-state: paused; }
.fresh-set { display: flex; gap: 14px; }
.fresh-card { min-width: 228px; max-width: 228px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); padding: 13px 15px; }
.fresh-chip { font: 700 9.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--violet); }
.fresh-name { font-weight: 800; font-size: 16px; margin: 5px 0 3px; }
.fresh-note { color: var(--dim); font-size: 12.5px; line-height: 1.45; }
@media (prefers-reduced-motion: reduce) { .fresh-track { animation: none; } .fresh-lab { transition: none; opacity: 1; transform: none; } }
#lab3d { max-width: 1100px; margin: 26px auto 60px; padding: 0 18px; }
.lab3d-card { border: 1px solid var(--line); border-radius: 20px; padding: 30px; background: var(--panel); }
.lab3d-badge { font: 700 10.5px var(--mono); letter-spacing: .16em; color: var(--violet); }
.lab3d-card h2 { font-size: 30px; margin: 10px 0 8px; }
.lab3d-lede { color: var(--dim); max-width: 62ch; line-height: 1.55; }
.lab3d-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 20px 0; }
.m3-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.m3-name { font: 800 16px var(--font); }
.m3-by { color: var(--dim); font-size: 12px; margin: 3px 0 10px; }
.m3-chip { font: 700 10px var(--mono); letter-spacing: .12em; color: #ffb020; border: 1px solid #ffb020; border-radius: 999px; padding: 3px 9px; }
.lab3d-note { color: var(--dim); line-height: 1.55; }
/* --- 3D Lab working panel (test build) --- */
.m3-drop {
  border: 2px dashed var(--line); border-radius: 16px; padding: 22px;
  text-align: center; cursor: pointer; margin: 20px 0 14px;
  transition: border-color .15s ease, background .15s ease;
}
.m3-drop:hover, .m3-drop.drag, .m3-drop:focus-visible { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 7%, transparent); outline: none; }
.m3-thumb { max-width: 180px; max-height: 180px; border-radius: 12px; margin: 0 auto 10px; display: block; }
.m3-thumb[hidden] { display: none; }
.m3-drop-text { line-height: 1.55; color: var(--text); }
.m3-label { font: 700 11px var(--mono); letter-spacing: .12em; color: var(--dim); display: block; margin: 8px 0 6px; }
.m3-select { width: 100%; }
.m3-go { margin-top: 14px; }
.m3-status { margin-top: 14px; font-size: 13.5px; line-height: 1.55; color: var(--text); min-height: 21px; }
.m3-status.err { color: var(--danger); font-weight: 600; }
.m3-result { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.m3-result[hidden] { display: none; }
.m3-dl {
  display: block; text-align: center; padding: 13px 20px; border-radius: 12px;
  background: linear-gradient(135deg, var(--violet), var(--violet-soft));
  color: var(--on-accent); font-weight: 800; text-decoration: none;
}
.m3-dl:hover { filter: brightness(1.07); }
.m3-dl-alt { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.m3-dl-size { font-weight: 600; opacity: .85; font-size: 12.5px; }
.m3-bridge {
  width: 100%; margin-top: 12px; min-height: 42px; padding: 10px 12px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; font-family: var(--sans); cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.m3-bridge:hover, .m3-bridge:focus-visible { border-color: var(--violet); box-shadow: 0 0 0 3px var(--glow); outline: none; }
.m3-token {
  width: 100%; background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; font-family: var(--mono); min-height: 42px;
}
.m3-token:focus-visible { border-color: var(--violet); box-shadow: 0 0 0 3px var(--glow); outline: none; }
.m3-viewer {
  width: 100%; height: 320px; display: block;
  background: var(--ink); border: 1px solid var(--line); border-radius: 14px;
}
.m3-viewer[hidden] { display: none; }
/* ============ step wizard (his design, 2026-10-20) ============
 * The 5 steps live in ONE frame as pages: dots on top (clickable, filled =
 * current), one step visible at a time, Back / Next at the bottom, Generate
 * waits on the last step. Kills the 2400px skyscraper frame he flagged
 * ("left one very long, right one very square"). Auto-off in pixelart /
 * slicer modes — those keep their stacked layout. */
.wiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.wiz-dots { display: flex; gap: 9px; }
.wiz-dot {
  width: 11px; height: 11px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid color-mix(in srgb, var(--text) 40%, transparent);
  background: transparent; transition: all .15s ease;
}
.wiz-dot:hover { transform: scale(1.25); }
.wiz-dot.done { background: color-mix(in srgb, var(--text) 35%, transparent); }
/* current step = WHITE, never the theme accent (his call, 2026-10-20);
   the soft text-colored ring keeps it visible on the light Porcelain too */
.wiz-dot.now {
  background: #fff; border-color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 22%, transparent), 0 0 12px rgba(255, 255, 255, .45);
}
.wiz-count {
  font: 700 10.5px var(--mono); letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim);
}
.wiz-btns { display: flex; gap: 8px; margin-top: 4px; }
.wiz-back { flex: 0 0 auto; width: auto; min-height: 46px; padding: 10px 18px; border-radius: 12px; }
.wiz-back[disabled] { opacity: .35; cursor: default; }
.wiz-next {
  flex: 1; min-height: 46px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--violet); color: var(--on-accent);
  background: linear-gradient(180deg, var(--violet), var(--violet-deep));
  font: 700 14px var(--font);
}
.controls.wizard .ctl-group {
  display: none; border: 0; background: transparent;
  padding: 4px 2px; margin-bottom: 6px;
}
.controls.wizard .ctl-group::before { display: none; }
.controls.wizard .ctl-group.wiz-on { display: block; animation: wizIn .18s ease; }
.controls.wizard #generate, .controls.wizard .gen-note { display: none; }
.controls.wizard.wiz-last #generate { display: block; }
.controls.wizard.wiz-last .gen-note { display: block; }
@keyframes wizIn { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 900px) {
  .ctl-group::before { left: 5px; }
  .dim-flip { order: 3; }
  .act-grid, .style-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .persp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pick-card { min-height: 58px; font-size: 10.5px; }
}

/* ============ TOOLS strip: utilities live outside the generation flow ==== */
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tool-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px 18px; border-radius: 16px; cursor: pointer; font: inherit;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.tool-card svg { width: 34px; height: 34px; flex: none; color: var(--violet); }
.tool-card:hover { transform: translateY(-2px); border-color: var(--violet); }
.tool-card.active { border-color: var(--violet); box-shadow: 0 0 0 1px var(--violet) inset; background: color-mix(in srgb, var(--violet) 10%, var(--panel)); }
.tool-text { display: flex; flex-direction: column; gap: 2px; }
.tool-text b { font-size: 15.5px; }
.tool-text span { color: var(--dim); font-size: 12.5px; }
@media (max-width: 640px) { .tools-grid { grid-template-columns: 1fr; } }

/* ============ TEST BUILD: mobile topbar — stack, never pile up ============ */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .brand { order: 1; gap: 8px; }
  .monogram { width: 34px; height: 34px; }
  .brand-name { font-size: 16px; }
  .tagline { display: none; }
  .topbar-right { order: 2; margin-left: auto; gap: 8px; }
  .topbar-right .pill { display: none; }
  .test-pill { display: none; }
  .gh-link { padding: 7px 10px; font-size: 12px; }
  .dim-flip { order: 3; width: 100%; }
  .flip-btn { flex: 1; min-height: 40px; }
}

/* ---------- 3D depth pass (his standard, set 2026-10-20: "website itself
 * should feel 3d — element have 3d depth") — layered gradients, lit top
 * edges, shaded bottoms, raised actives, recessed tracks, tactile press.
 * Theme-variable based: reads on Porcelain and every dark theme. ---------- */
.dim-flip {
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 55%, var(--text) 9%), var(--panel));
  box-shadow: inset 0 2px 5px rgba(0,0,0,.22), inset 0 -1px 0 rgba(255,255,255,.07);
}
.flip-btn {
  background: linear-gradient(180deg, color-mix(in srgb, var(--text) 8%, transparent), transparent 55%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10), 0 1px 2px rgba(0,0,0,.14);
}
.flip-btn.active {
  background: linear-gradient(180deg, var(--violet-soft) 0%, var(--violet) 48%, var(--violet-deep) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 -2px 4px rgba(0,0,0,.28),
              0 4px 10px rgba(0,0,0,.30), 0 6px 18px color-mix(in srgb, var(--violet) 45%, transparent);
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  transform: translateY(-1px);
}
.flip-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 5px rgba(0,0,0,.30), 0 1px 2px rgba(0,0,0,.20); }
.generate {
  background: linear-gradient(180deg, var(--violet-soft) 0%, var(--violet) 55%, var(--violet-deep) 130%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.40), inset 0 -3px 6px rgba(0,0,0,.22),
              0 6px 16px rgba(0,0,0,.28), 0 10px 26px color-mix(in srgb, var(--violet) 35%, transparent);
  text-shadow: 0 1px 2px rgba(0,0,0,.30);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.generate:hover { transform: translateY(-2px); filter: brightness(1.05); }
.generate:active { transform: translateY(1px); box-shadow: inset 0 2px 6px rgba(0,0,0,.32), 0 2px 6px rgba(0,0,0,.25); }
.ctl-group {
  background: linear-gradient(180deg, color-mix(in srgb, #ffffff 5%, var(--panel-2)), color-mix(in srgb, var(--panel-2) 55%, transparent));
  box-shadow: 0 8px 22px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.06);
}
.pick-card {
  background: linear-gradient(180deg, color-mix(in srgb, #ffffff 5%, transparent), transparent 60%), var(--field, rgba(255,255,255,.03));
  box-shadow: 0 2px 5px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.07);
}
.pick-card:hover { box-shadow: 0 6px 14px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.10); }
.pick-card.active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--violet) 26%, transparent), color-mix(in srgb, var(--violet) 14%, transparent));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--violet) 35%, transparent),
              inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 0 1px var(--violet);
  transform: translateY(-1px);
}
.fresh-card, .lab3d-card {
  box-shadow: 0 8px 22px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.06);
}

/* ================= TEST: bottom band — visualizer + downloads centred (his order 2026-10-20)
   The viz panel leaves the right column and spans the whole tool as one
   bottom band: everything centred, preview + export side by side in the
   middle, all visible together. ================= */
.layout > .viz-band {
  grid-column: 1 / -1;
  margin-top: 0;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 10px 28px rgba(30, 41, 82, .08);
}
.viz-band .viz-head { justify-content: center; }
.viz-band .frames-head { justify-content: center; text-align: center; }
.viz-band .frames-row { justify-content: center; }
.viz-band .split-grid {
  grid-template-columns: repeat(auto-fill, 72px);
  justify-content: center;
}
.viz-band .preview-export {
  grid-template-columns: minmax(0, 400px) minmax(0, 400px);
  justify-content: center;
  align-items: start;
  max-width: 880px;
  margin-left: auto;
  margin-right: auto;
}
.viz-band .preview-box { text-align: center; }
.viz-band .preview-box canvas#preview { display: block; margin: 0 auto; }
.viz-band .preview-controls { margin-left: auto; margin-right: auto; }
.viz-band .export-box { text-align: center; }
.viz-band .export-box .btn { text-align: center; }
.viz-band .export-note { text-align: center; max-width: 520px; margin: 0 auto; }
.viz-band .more-exports summary { text-align: center; }
@media (max-width: 900px) {
  .viz-band .preview-export { grid-template-columns: minmax(0, 1fr); max-width: 480px; }
  .viz-band .split-grid { grid-template-columns: repeat(auto-fill, 64px); }
}

/* ============ TEST: Meshy-style 3D Studio ============
 * Copied 1:1 in structure from the Meshy studio (his 2026-10-20 drop):
 * dark left control rail + viewer stage with toolbar, stats chips,
 * environment popup and floating action docks. Dark in every theme,
 * like the reference. Free-forever: no credits, no crowns, no paywall. */
#lab3d { padding: 26px 18px 10px; }
.m3-studio {
  display: grid; grid-template-columns: 340px 1fr; gap: 14px;
  max-width: 1460px; margin: 0 auto; align-items: stretch;
  color: #eceef2; font-size: 14px;
}
.m3-rail, .m3-stage {
  background: linear-gradient(180deg, #1b1c21, #141519);
  border: 1px solid #26272e; border-radius: 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 40px rgba(0,0,0,.45);
}
.m3-rail { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.m3-modetabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m3-modetab {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; border-radius: 14px; border: 1px solid #26272e;
  background: #101116; color: #9ba0ab; font: 600 12.5px/1.2 inherit; cursor: pointer;
}
.m3-modetab .m3-ic { width: 24px; height: 24px; }
.m3-modetab.active { background: #1e2126; color: #cdea8f; border-color: #3a3f2c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 4px 10px rgba(0,0,0,.4); }
.m3-seg { display: flex; background: #101116; border: 1px solid #26272e; border-radius: 12px; padding: 3px; gap: 3px; }
.m3-seg-btn {
  flex: 1; padding: 8px 4px; border: 0; border-radius: 9px; background: transparent;
  color: #9ba0ab; font: 600 12.5px/1 inherit; cursor: pointer;
}
.m3-seg-btn.active { background: #26282f; color: #f2f4f7;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 3px 8px rgba(0,0,0,.45); }
.m3-topo-note, .m3-mv-note, .m3-model-desc { margin: 0; color: #8a8f9a; font-size: 12px; line-height: 1.45; }
.m3-label { font: 700 12px/1 inherit; letter-spacing: .04em; text-transform: uppercase; color: #c9ccd4; margin-top: 4px; }
.m3-label .dim { text-transform: none; letter-spacing: 0; font-weight: 500; color: #777d89; }
.m3-model-select {
  width: 100%; padding: 12px; border-radius: 14px; border: 1px solid #33353d;
  background: linear-gradient(180deg, #22242b, #191a1f); color: #eef1d6;
  font: 600 13.5px/1.35 inherit; cursor: pointer;
}
.m3-model-select option { background: #191a1f; color: #eceef2; font-weight: 500; }
.m3-tip { background: #101116; border: 1px solid #26272e; border-radius: 12px; padding: 10px 12px; color: #a7adb9; font-size: 12.5px; line-height: 1.5; }
.m3-drop {
  border: 1.5px dashed #3a3c44; border-radius: 16px; background: #101116;
  padding: 18px 14px; text-align: center; cursor: pointer; position: relative;
}
.m3-drop:hover, .m3-drop.drag { border-color: #a6f750; background: #14160f; }
.m3-drop-ic { width: 34px; height: 34px; color: #7d838f; margin-bottom: 6px; }
.m3-drop-text strong { display: block; color: #e8eaf0; font-size: 13.5px; margin-bottom: 4px; }
.m3-drop-text .dim { color: #777d89; font-size: 11.5px; line-height: 1.5; }
.m3-thumb { max-width: 100%; max-height: 130px; border-radius: 10px; margin: 0 auto 8px; display: block; }
.m3-samples-label { font-size: 11.5px; color: #8a8f9a; display: block; margin-bottom: 6px; }
.m3-samples-row { display: flex; gap: 8px; }
.m3-sample { width: 62px; height: 62px; object-fit: contain; background: #101116; border: 1px solid #2c2e35; border-radius: 12px; cursor: pointer; padding: 4px; }
.m3-sample:hover { border-color: #a6f750; }
.m3-bridge {
  padding: 10px 12px; border-radius: 12px; border: 1px solid #2c2e35; cursor: pointer;
  background: #17181d; color: #d7dae1; font: 600 12.5px/1.4 inherit; text-align: left;
}
.m3-bridge:hover { border-color: #a6f750; color: #eef1d6; }
.m3-mvrow { display: flex; align-items: center; justify-content: space-between; font-weight: 600; color: #dfe2e9; }
.m3-free-tag { background: #a6f750; color: #131503; font: 800 9.5px/1 inherit; padding: 3px 6px; border-radius: 6px; vertical-align: 2px; margin-left: 4px; }
.m3-switch {
  width: 46px; height: 26px; border-radius: 99px; border: 1px solid #3a3c44; cursor: pointer;
  background: #101116; position: relative; flex: none; padding: 0;
  box-shadow: inset 0 2px 5px rgba(0,0,0,.6);
}
.m3-switch .knob {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(180deg, #f4f5f7, #c9ccd4); transition: left .18s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,.5);
}
.m3-switch.on, .m3-switch[aria-checked="true"] { background: #56751f; border-color: #79a832; }
.m3-switch.on .knob, .m3-switch[aria-checked="true"] .knob { left: 22px; }
.m3-hintcard {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #101116; border: 1px solid #26272e; border-radius: 12px; padding: 10px 12px; color: #a7adb9; font-size: 12.5px;
}
.m3-hint-btn { border: 0; background: none; color: #a6f750; font: 700 12.5px/1 inherit; cursor: pointer; white-space: nowrap; }
.m3-token-details { border: 1px solid #26272e; border-radius: 12px; padding: 10px 12px; background: #101116; }
.m3-token-details summary { cursor: pointer; color: #c9ccd4; font-size: 12.5px; font-weight: 600; }
.m3-token { width: 100%; margin-top: 10px; padding: 10px; border-radius: 10px; border: 1px solid #33353d; background: #0c0d10; color: #eceef2; font: 13px/1.3 inherit; box-sizing: border-box; }
.m3-token-details .ai-key-hint { color: #8a8f9a; font-size: 11.5px; line-height: 1.5; }
.m3-token-details .ai-key-hint a { color: #a6f750; }
.m3-costline { text-align: center; color: #8a8f9a; font-size: 12px; }
.m3-generate {
  padding: 15px; border: 0; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, #c6ff5e, #9be82e); color: #131503;
  font: 800 16px/1 inherit; letter-spacing: .01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -3px 0 rgba(0,0,0,.18), 0 10px 22px rgba(155,232,46,.25);
}
.m3-generate:active { transform: translateY(1px); }
.m3-generate:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.m3-status { min-height: 18px; color: #a7adb9; font-size: 12.5px; line-height: 1.5; text-align: center; }
.m3-status.err { color: #ff9c9c; }

/* stage */
.m3-stage { position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 640px; }
.m3-empty { margin: auto; text-align: center; padding: 40px 30px; max-width: 640px; }
.m3-empty h3 { color: #cdea8f; font-size: 24px; margin: 0 0 26px; font-weight: 700; }
.m3-steps { display: flex; align-items: flex-start; justify-content: center; gap: 10px; margin-bottom: 22px; }
.m3-step { flex: 1; }
.m3-step-art { font-size: 40px; margin-bottom: 8px; }
.m3-step strong { display: block; color: #eef0f4; font-size: 14.5px; margin-bottom: 3px; }
.m3-step span { color: #8a8f9a; font-size: 12px; line-height: 1.45; display: block; }
.m3-step-arrow { color: #565b66; font-size: 20px; padding-top: 16px; }
.m3-empty .dim { color: #777d89; font-size: 12.5px; line-height: 1.55; }
.m3-result { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.m3-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid #232429; flex-wrap: wrap;
}
.m3-tb-icon { font-size: 16px; }
.m3-tb-sep { width: 1px; height: 20px; background: #2e2f36; }
.m3-tb-spacer { flex: 1; }
.m3-viewpreset { display: flex; align-items: center; gap: 6px; color: #dfe2e9; font-size: 13px; }
.m3-viewpreset select { background: #101116; color: #eceef2; border: 1px solid #2c2e35; border-radius: 8px; padding: 6px 8px; font: 600 13px/1 inherit; cursor: pointer; }
.m3-modes { display: flex; background: #101116; border: 1px solid #26272e; border-radius: 10px; padding: 3px; gap: 3px; }
.m3-mode { border: 0; background: transparent; color: #9ba0ab; font: 600 12.5px/1 inherit; padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.m3-mode.active { background: #a6f750; color: #131503; box-shadow: 0 3px 8px rgba(0,0,0,.4); }
.m3-tb-btn {
  border: 1px solid #2c2e35; background: #17181d; color: #d7dae1; cursor: pointer;
  font: 600 12.5px/1 inherit; padding: 9px 12px; border-radius: 10px;
}
.m3-tb-btn:hover { border-color: #a6f750; }
.m3-stats {
  position: absolute; top: 64px; left: 14px; z-index: 5; min-width: 190px;
  background: rgba(13,13,16,.88); border: 1px solid #26272e; border-radius: 14px; padding: 10px 14px;
  backdrop-filter: blur(6px);
}
.m3-stats.m3-print { top: auto; bottom: 118px; }
.m3-stat-row { display: flex; justify-content: space-between; gap: 18px; padding: 3px 0; font-size: 13px; }
.m3-stat-row span { color: #9ba0ab; }
.m3-stat-row strong { color: #f2f4f7; font-weight: 600; }
.m3-print-badge { background: #e5484d; color: #fff; border-radius: 50%; padding: 1px 7px; font-size: 12px; margin-right: 5px; }
.m3-canvas-wrap {
  position: relative; flex: 1; min-height: 430px;
  background: radial-gradient(120% 100% at 50% 30%, #232529, #131417);
}
.m3-canvas-wrap.nobg {
  background: repeating-conic-gradient(#1c1d21 0 25%, #17181c 0 50%) 0 0/26px 26px;
}
.m3-three-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.m3-viewer { position: absolute; inset: 0; width: 100%; height: 100%; --poster-color: transparent; }
.m3-envpop {
  position: absolute; top: 64px; right: 14px; z-index: 6; width: 300px;
  background: rgba(18,18,22,.97); border: 1px solid #2c2e35; border-radius: 16px; padding: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
}
.m3-env-head { font: 700 15px/1.2 inherit; color: #f2f4f7; padding-bottom: 10px; border-bottom: 1px solid #26272e; margin-bottom: 6px; }
.m3-env-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; color: #d7dae1; font-size: 13.5px; }
.m3-env-row select { background: #101116; color: #eceef2; border: 1px solid #33353d; border-radius: 9px; padding: 8px; font: 13px/1 inherit; }
.m3-env-row input[type="range"] { flex: 1; accent-color: #a6f750; }
.m3-docks { display: flex; justify-content: center; gap: 10px; padding: 12px; flex-wrap: wrap; }
.m3-dock {
  display: flex; align-items: center; gap: 4px; background: rgba(13,13,16,.92);
  border: 1px solid #26272e; border-radius: 16px; padding: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 12px 26px rgba(0,0,0,.5);
}
.m3-dock-btn {
  border: 0; background: transparent; color: #d7dae1; cursor: pointer; text-decoration: none;
  font: 600 13.5px/1 inherit; padding: 11px 14px; border-radius: 11px; white-space: nowrap;
}
.m3-dock-btn:hover { background: #22232a; }
.m3-download {
  background: linear-gradient(180deg, #c6ff5e, #9be82e); color: #131503; text-decoration: none;
  font: 800 14px/1 inherit; padding: 12px 18px; border-radius: 11px; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 6px 14px rgba(155,232,46,.25);
}
.m3-dl-size { font-weight: 600; opacity: .75; }
.m3-reusebar {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px;
  border-top: 1px solid #232429; color: #9ba0ab; font-size: 12.5px;
}
.m3-reuse-btn { border: 0; background: none; color: #d7dae1; font: 600 13px/1 inherit; cursor: pointer; white-space: nowrap; }
.m3-reusebar .lab3d-note { margin: 0; color: #9ba0ab; }
@media (max-width: 900px) {
  .m3-studio { grid-template-columns: 1fr; }
  .m3-stage { min-height: 520px; }
  .m3-stats.m3-print { bottom: auto; top: 168px; }
  .m3-envpop { width: min(300px, calc(100% - 28px)); }
}

/* ============ TEST: Model Preference picker (Meshy copy) ============
 * Rich model rows — icon, name, meta chip, one-line desc, checkmark —
 * in one shared dark popup for the 2D and 3D selects, exactly like the
 * reference. The native selects stay as hidden sources of truth. */
.mp-hidden { display: none !important; }
.mp-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 12px 14px; border-radius: 14px; cursor: pointer; text-align: left;
  border: 1px solid var(--line, #d8d4e8); color: var(--ink, #181530);
  background: linear-gradient(180deg, rgba(255,255,255,.75), rgba(255,255,255,.35));
  font: 600 14px/1.3 inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 4px 10px rgba(20,16,60,.12);
}
.mp-trigger .mp-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-trigger .mp-chev { opacity: .55; font-size: 12px; }
.mp-trigger .mp-chip, .mp-rchip {
  background: #a6f750; color: #131503; font: 800 9.5px/1 inherit;
  padding: 3px 6px; border-radius: 6px; letter-spacing: .03em; white-space: nowrap;
}
.mp-trigger.dark {
  background: linear-gradient(180deg, #22242b, #191a1f); color: #eef1d6;
  border-color: #33353d; box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 4px 10px rgba(0,0,0,.4);
  font-size: 13.5px;
}
.mp-pop {
  position: fixed; z-index: 400; max-height: 62vh; display: flex; flex-direction: column;
  background: rgba(19,19,23,.98); border: 1px solid #2e2f36; border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55); color: #eceef2; overflow: hidden;
}
.mp-pop[hidden] { display: none; }
.mp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px 9px; font: 700 14.5px/1.2 inherit; color: #f2f4f7;
}
.mp-x { border: 0; background: none; color: #9ba0ab; font-size: 13px; cursor: pointer; padding: 4px; }
.mp-list { overflow-y: auto; padding: 0 8px 10px; }
.mp-sec {
  padding: 10px 8px 5px; color: #777d89; font: 700 11px/1 inherit;
  letter-spacing: .06em; text-transform: uppercase;
}
.mp-row {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  padding: 10px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; color: #eceef2;
}
.mp-row:hover { background: #1e1f24; }
.mp-row.sel { background: #22242b; }
.mp-ic { width: 20px; text-align: center; color: #a6f750; font-size: 14px; padding-top: 1px; flex: none; }
.mp-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mp-rname { font: 600 13.5px/1.3 inherit; color: #f2f4f7; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.mp-rdesc { font: 400 12px/1.45 inherit; color: #9ba0ab; }
.mp-check { color: #a6f750; font-weight: 800; flex: none; padding-top: 1px; }

/* ============ TEST: My Assets (Meshy copy) ============ */
.assets-sec { max-width: 1460px; margin: 8px auto 0; padding: 22px 18px 6px; }
.assets-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.assets-head h2 { margin: 0 0 4px; font-size: 24px; }
.assets-sub { margin: 0; opacity: .65; font-size: 13px; }
.assets-actions { display: flex; gap: 10px; align-items: center; }
.assets-actions input[type="search"] {
  padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line, #d8d4e8);
  background: rgba(255,255,255,.5); font: 13.5px/1 inherit; min-width: 220px; color: inherit;
}
.assets-upload {
  background: linear-gradient(180deg, #c6ff5e, #9be82e); color: #131503; border: 0; cursor: pointer;
  font: 800 13.5px/1 inherit; padding: 12px 18px; border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 6px 14px rgba(155,232,46,.22);
}
.assets-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 12px; flex-wrap: wrap; }
.assets-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.assets-fbtn {
  border: 1px solid var(--line, #d8d4e8); background: transparent; color: inherit; cursor: pointer;
  font: 600 13px/1 inherit; padding: 9px 14px; border-radius: 10px;
}
.assets-fbtn.active { background: #a6f750; border-color: #a6f750; color: #131503; }
.assets-batch { font: 600 13px/1 inherit; display: flex; gap: 7px; align-items: center; cursor: pointer; }
.assets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.asset-card {
  position: relative; background: linear-gradient(180deg, #1d1e24, #141519);
  border: 1px solid #26272e; border-radius: 16px; overflow: hidden; cursor: pointer;
  box-shadow: 0 10px 22px rgba(10,8,40,.18);
}
.asset-card.picked { border-color: #a6f750; box-shadow: 0 0 0 2px #a6f750 inset, 0 10px 22px rgba(10,8,40,.18); }
.asset-thumb { width: 100%; height: 132px; object-fit: contain; display: block; padding: 10px; box-sizing: border-box; }
.asset-cube {
  position: absolute; inset: 0 0 34px; display: flex; align-items: center; justify-content: center;
  font-size: 44px; color: #3f434e;
}
.asset-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 11px; border-top: 1px solid #232429; }
.asset-name { color: #e8eaf0; font: 600 12.5px/1.25 inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-tag { color: #8a8f9a; font: 600 10.5px/1 inherit; white-space: nowrap; }
.asset-dl {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 9px;
  border: 1px solid #33353d; background: rgba(13,13,16,.9); color: #dfe2e9; cursor: pointer; font-size: 13px;
  opacity: 0; transition: opacity .15s ease;
}
.asset-card:hover .asset-dl { opacity: 1; }
.asset-check {
  position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 7px;
  border: 1.5px solid #a6f750; background: rgba(13,13,16,.85); color: #a6f750;
  font: 800 13px/22px inherit; text-align: center;
}
.assets-empty { opacity: .6; font-size: 13.5px; padding: 18px 4px; }
.assets-foot { display: flex; align-items: center; gap: 12px; padding: 12px 2px; font: 600 13px/1 inherit; }

/* ===== P4b: Tripo viewer batch ===== */
.m3-canvas-wrap{position:relative}
.m3-rdock{position:absolute;right:10px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:8px;z-index:6}
.m3-rd-btn{width:38px;height:38px;border-radius:50%;border:1px solid rgba(255,255,255,.16);background:rgba(18,18,24,.78);color:#e8e8ee;font-size:16px;cursor:pointer;backdrop-filter:blur(6px);box-shadow:0 4px 14px rgba(0,0,0,.45),inset 0 1px 0 rgba(255,255,255,.14);display:flex;align-items:center;justify-content:center}
.m3-rd-btn:hover{border-color:rgba(166,247,80,.6)}
.m3-rd-btn.active{background:#a6f750;color:#101408;border-color:#a6f750}
.m3-renderdock{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);display:flex;align-items:center;gap:9px;padding:8px 12px;border-radius:999px;background:rgba(14,14,20,.72);border:1px solid rgba(255,255,255,.12);backdrop-filter:blur(8px);z-index:6;box-shadow:0 10px 26px rgba(0,0,0,.5)}
.m3-sphere{width:30px;height:30px;border-radius:50%;border:1px solid rgba(255,255,255,.22);cursor:pointer;padding:0;box-shadow:inset -3px -5px 8px rgba(0,0,0,.45),inset 3px 4px 6px rgba(255,255,255,.28),0 3px 8px rgba(0,0,0,.4)}
.m3-sphere:hover{transform:translateY(-1px)}
.m3-sphere.active{outline:2px solid #a6f750;outline-offset:2px}
.sp-wire{background:radial-gradient(circle at 34% 30%,#2c2c34,#101014 70%);border-color:#a6f750}
.sp-clay{background:radial-gradient(circle at 34% 30%,#ffffff,#c9c9cf 72%)}
.sp-metal{background:radial-gradient(circle at 34% 30%,#ffffff,#8f979f 55%,#565d63)}
.sp-normal{background:conic-gradient(from 210deg,#7d7dff,#ff7de9,#7dffb2,#7de9ff,#7d7dff)}
.sp-grey{background:radial-gradient(circle at 34% 30%,#d6dade,#7d838a 74%)}
.sp-gold{background:radial-gradient(circle at 34% 30%,#ffe9a8,#d9a441 58%,#8a5f14)}
.sp-cyan{background:radial-gradient(circle at 34% 30%,#b8f4ff,#35c4d8 60%,#146b7a)}
.sp-texmap{background:radial-gradient(circle at 34% 30%,#cfd8e3,#4a5a6a 75%)}
.sp-roughmap{background:radial-gradient(circle at 34% 30%,#f2f2f2,#9a9a9a 60%,#555555)}
.m3-rd-sep{width:1px;height:22px;background:rgba(255,255,255,.18)}
.m3-helpop{position:absolute;right:58px;top:50%;transform:translateY(-50%);width:230px;background:rgba(16,16,22,.94);border:1px solid rgba(255,255,255,.14);border-radius:12px;padding:12px 14px;color:#dcdce4;font-size:12.5px;display:flex;flex-direction:column;gap:6px;z-index:7;box-shadow:0 14px 34px rgba(0,0,0,.55)}
.m3-helpop[hidden]{display:none}
.m3-exppop{width:300px;max-width:92vw}
.m3-exppop input[type="text"]{background:#17171f;border:1px solid rgba(255,255,255,.16);border-radius:8px;color:#eeeeee;padding:6px 9px;font-size:13px;width:150px}
.m3-exp-go{margin-top:10px;width:100%;background:#a6f750;color:#101408;border:none;border-radius:10px;padding:10px;font-weight:700;cursor:pointer;font-size:14px;box-shadow:0 6px 18px rgba(166,247,80,.25),inset 0 1px 0 rgba(255,255,255,.5)}
.m3-bridgepop{width:350px;max-width:94vw}
.m3-bridge-row{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid rgba(255,255,255,.07)}
.m3-bridge-row strong{flex:0 0 84px;font-size:13px;color:#f0f0f4}
.m3-bridge-row span{flex:1;font-size:11.5px;color:#a9a9b5;line-height:1.35}
.m3-bridge-dl{flex:0 0 auto;background:#23232e;border:1px solid rgba(255,255,255,.16);color:#c9f79a;border-radius:8px;padding:5px 9px;font-size:12px;text-decoration:none}
.m3-bridge-note{font-size:11.5px;color:#8b8b98;margin-top:9px;line-height:1.45}
.m3-drop-genlink{display:block;margin:10px auto 2px;background:none;border:none;color:#a6f750;font-size:13px;font-weight:600;cursor:pointer}
.m3-drop-genlink:hover{text-decoration:underline}

/* ===== P5: Animate panel ===== */
.lab-animate{max-width:1180px;margin:26px auto;padding:24px;border-radius:20px;background:linear-gradient(180deg,rgba(255,255,255,.045),rgba(255,255,255,.015));border:1px solid rgba(255,255,255,.09);box-shadow:0 24px 50px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,255,255,.07)}
.lab-animate[hidden]{display:none}
.la-head h2{margin:0 0 4px;font-size:24px}
.la-rigbanner{display:flex;align-items:center;gap:16px;margin:16px 0;padding:16px 18px;border-radius:14px;background:linear-gradient(120deg,rgba(166,247,80,.14),rgba(124,77,255,.14));border:1px solid rgba(166,247,80,.35);box-shadow:inset 0 1px 0 rgba(255,255,255,.12)}
.la-rig-art{font-size:30px}
.la-rig-text{flex:1;display:flex;flex-direction:column;gap:2px}
.la-rig-text span{font-size:13px;color:#b9b9c4}
.la-rig-btn{background:#a6f750;color:#101408;border:none;border-radius:10px;padding:11px 18px;font-weight:700;cursor:pointer;box-shadow:0 6px 18px rgba(166,247,80,.25),inset 0 1px 0 rgba(255,255,255,.5)}
.la-search{width:100%;padding:11px 14px;border-radius:10px;border:1px solid rgba(255,255,255,.14);background:#14141b;color:#eee;font-size:14px;margin:4px 0 6px}
.la-lib-head{margin:20px 0 10px;font-size:16px}
.la-cards{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media (max-width:760px){.la-cards{grid-template-columns:1fr}}
.la-card{padding:16px;border-radius:14px;background:#14141b;border:1px solid rgba(255,255,255,.09);box-shadow:inset 0 1px 0 rgba(255,255,255,.06)}
.la-card p{font-size:13px;color:#a9a9b5;line-height:1.45}
.la-t2m-row{display:flex;gap:8px;margin-top:10px}
.la-t2m-row input{flex:1;padding:9px 12px;border-radius:9px;border:1px solid rgba(255,255,255,.14);background:#0f0f14;color:#eee;font-size:13px}
.la-t2m-row button,.la-vid-btn{background:#23232e;border:1px solid rgba(255,255,255,.16);color:#c9f79a;border-radius:9px;padding:9px 14px;cursor:pointer;font-weight:600}
.la-note{font-size:12.5px;color:#9fe870;min-height:16px;margin-top:8px}
.la-vid{width:100%;margin-top:10px;border-radius:10px}
.la-mine{display:flex;flex-wrap:wrap;gap:8px}
.la-mine-chip{display:inline-flex;align-items:center;gap:8px;background:#1b1b24;border:1px solid rgba(166,247,80,.4);color:#e8e8ee;border-radius:999px;padding:6px 8px 6px 13px;font-size:12.5px}
.la-mine-chip button{background:#a6f750;border:none;color:#101408;border-radius:999px;padding:3px 10px;font-weight:700;cursor:pointer;font-size:12px}
.la-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
.la-preset{padding:14px 12px;border-radius:12px;background:#14141b;border:1px solid rgba(255,255,255,.09);color:#e8e8ee;cursor:pointer;text-align:left;display:flex;flex-direction:column;gap:4px;box-shadow:inset 0 1px 0 rgba(255,255,255,.06)}
.la-preset strong{font-size:13.5px}
.la-preset span{font-size:11px;color:#8b8b98}
.la-preset:hover{border-color:rgba(166,247,80,.55)}
.la-preset.active{border-color:#a6f750;background:rgba(166,247,80,.1)}

/* ===== P6: Print & Post-Processing ===== */
.lab-print[hidden]{display:none}
.pp-stats{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:12px 0}
.pp-stats div{background:#0f0f14;border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:8px 11px;display:flex;flex-direction:column}
.pp-stats span{font-size:11px;color:#8b8b98}
.pp-stats strong{font-size:15px;color:#f0f0f4}
.pp-btnrow{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.pp-btnrow button,.pp-card>button{background:#23232e;border:1px solid rgba(255,255,255,.16);color:#c9f79a;border-radius:9px;padding:8px 13px;cursor:pointer;font-weight:600;font-size:13px}
.pp-btnrow button:hover,.pp-card>button:hover{border-color:rgba(166,247,80,.6)}
.pp-palette{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}
.pp-swatch{width:52px;text-align:center}
.pp-swatch i{display:block;height:38px;border-radius:9px;border:1px solid rgba(255,255,255,.2)}
.pp-swatch span{font-size:10px;color:#a9a9b5;display:block;margin-top:4px;line-height:1.3}
.pp-quant{width:100%;border-radius:10px;margin-top:12px;border:1px solid rgba(255,255,255,.12)}
.pp-new{background:#a6f750;color:#101408;font-size:10px;font-weight:800;border-radius:5px;padding:2px 6px;vertical-align:2px}

/* ===== P7: chain box, skills, chips, compare, FAQ ===== */
.m3-chainbox{margin-top:14px;padding:13px 14px;border-radius:13px;background:rgba(124,77,255,.1);border:1px solid rgba(124,77,255,.4);box-shadow:inset 0 1px 0 rgba(255,255,255,.08)}
.m3-chainbox strong{font-size:14px}
.m3-chainbox p{font-size:12px;color:#b9b9c4;line-height:1.45;margin:4px 0 9px}
.m3-chain-row{display:flex;gap:8px}
.m3-chain-row input{flex:1;min-width:0;padding:9px 11px;border-radius:9px;border:1px solid rgba(255,255,255,.16);background:#12121a;color:#eee;font-size:13px}
.m3-chain-row button{background:#a6f750;color:#101408;border:none;border-radius:9px;padding:9px 14px;font-weight:700;cursor:pointer}
.m3-chain-status{font-size:12px;color:#9fe870;min-height:15px}
.lab-skills[hidden]{display:none}
.chiprow{display:flex;gap:8px;overflow-x:auto;padding:6px 2px 12px;scrollbar-width:thin}
.agent-chip{flex:0 0 auto;background:#1b1b24;border:1px solid rgba(255,255,255,.15);color:#e8e8ee;border-radius:999px;padding:8px 15px;font-size:13px;cursor:pointer;box-shadow:inset 0 1px 0 rgba(255,255,255,.09)}
.agent-chip:hover{border-color:rgba(166,247,80,.6);color:#c9f79a}
.sk-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:12px}
.sk-card{padding:16px;border-radius:14px;background:#14141b;border:1px solid rgba(255,255,255,.09);box-shadow:inset 0 1px 0 rgba(255,255,255,.06);display:flex;flex-direction:column;gap:6px}
.sk-card .sk-art{font-size:26px}
.sk-card strong{font-size:14.5px}
.sk-card p{font-size:12.5px;color:#a9a9b5;line-height:1.45;flex:1}
.sk-card button{background:#a6f750;color:#101408;border:none;border-radius:9px;padding:9px 13px;font-weight:700;cursor:pointer;align-self:flex-start}
.info-sec{max-width:1180px;margin:30px auto;padding:6px 20px}
.cmp-wrap{overflow-x:auto;margin-top:14px}
.cmp{width:100%;border-collapse:collapse;font-size:13.5px;min-width:640px}
.cmp th,.cmp td{padding:10px 13px;border:1px solid rgba(255,255,255,.09);text-align:left}
.cmp th{background:#17171f;color:#f0f0f4}
.cmp td{color:#c6c6cf;background:rgba(255,255,255,.02)}
.cmp td:first-child{color:#8b8b98}
.cmp .cmp-us{background:rgba(166,247,80,.08);color:#e6ffd0;font-weight:600}
.faq{border:1px solid rgba(255,255,255,.1);border-radius:12px;padding:13px 17px;margin-top:10px;background:rgba(255,255,255,.025)}
.faq summary{cursor:pointer;font-weight:600;font-size:14.5px}
.faq p{font-size:13.5px;color:#b9b9c4;line-height:1.55;margin:9px 0 3px}
