@font-face {
  font-family: 'Space Grotesk';
  src: url('assets/fonts/space-grotesk.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/fonts/ibm-plex-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/fonts/ibm-plex-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Silkscreen';
  src: url('assets/fonts/silkscreen.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #090b07;
  --bg-soft: #0d0f0b;
  --panel: #11130e;
  --panel-raised: #151810;
  --panel-deep: #0b0d08;
  --text: #f0f1e8;
  --text-soft: #c7cbbd;
  --muted: #909687;
  --dim: #656b5d;
  --line: rgba(227, 238, 208, 0.1);
  --line-strong: rgba(227, 238, 208, 0.17);
  --lime: #b9ee6a;
  --lime-bright: #d0ff8d;
  --lime-deep: #8fca43;
  --lime-ink: #1a2410;
  --amber: #f0be65;
  --danger: #ef7d69;
  --blue: #75b9d9;
  --font-ui: 'Space Grotesk', 'Trebuchet MS', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  --font-pixel: 'Silkscreen', 'Courier New', monospace;
  --radius-xl: 20px;
  --radius-lg: 15px;
  --radius-md: 11px;
  --shadow-panel: 0 26px 80px rgba(0, 0, 0, 0.34), 0 1px 0 rgba(255, 255, 255, 0.025) inset;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse 55% 42% at 82% -12%, rgba(185, 238, 106, 0.08), transparent 62%),
    radial-gradient(ellipse 45% 38% at 8% 8%, rgba(117, 185, 217, 0.035), transparent 65%),
    var(--bg);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { display: block; }
::selection { background: rgba(185, 238, 106, 0.25); color: #fff; }

.noise {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.024;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */
.topbar {
  position: relative;
  z-index: 20;
  height: 72px;
  flex: 0 0 72px;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 7, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  min-width: 188px;
}

.brand-mark {
  width: 34px;
  height: 38px;
  filter: drop-shadow(0 6px 14px rgba(185, 238, 106, 0.13));
  transition: transform 0.5s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-7deg) translateY(-1px); }
.brand-mark svg { width: 100%; height: 100%; }

.brand-copy { display: flex; flex-direction: column; line-height: 1; gap: 5px; }
.brand-copy strong {
  font-family: var(--font-pixel);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.055em;
}
.brand-copy em {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  font-style: normal;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.engine-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 auto;
  padding: 8px 12px;
  border: 1px solid rgba(185, 238, 106, 0.1);
  border-radius: 999px;
  background: rgba(185, 238, 106, 0.035);
  color: #b7c3aa;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.13em;
}
.status-light, .live-chip > span, .dna-live > span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(185, 238, 106, 0.09), 0 0 12px rgba(185, 238, 106, 0.6);
  animation: pulse-dot 2.6s ease-in-out infinite;
}
.status-divider { color: #3c4435; }
.status-muted { color: var(--dim); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.78); }
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease), box-shadow 0.2s ease;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-ghost { color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.btn-primary {
  background: var(--lime);
  color: var(--lime-ink);
  box-shadow: 0 7px 24px rgba(144, 197, 63, 0.16), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
}
.btn-primary:hover { background: var(--lime-bright); box-shadow: 0 9px 30px rgba(144, 197, 63, 0.22), 0 1px 0 rgba(255, 255, 255, 0.35) inset; }

.btn-outline {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.016);
  color: var(--text-soft);
}
.btn-outline:hover { border-color: rgba(185, 238, 106, 0.3); color: var(--text); background: rgba(185, 238, 106, 0.035); }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border: 1px solid rgba(15, 22, 8, 0.18);
  border-radius: 4px;
  background: rgba(15, 22, 8, 0.1);
  color: currentColor;
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1;
}

.top-export { height: 38px; padding-inline: 15px; font-size: 12px; }
.top-export kbd { background: rgba(20, 29, 10, 0.12); border-color: rgba(20, 29, 10, 0.16); }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.015);
  color: var(--muted);
  transition: 0.2s ease;
}
.icon-button svg { width: 16px; height: 16px; }
.icon-button:hover { color: var(--text); border-color: rgba(185, 238, 106, 0.26); background: rgba(185, 238, 106, 0.05); transform: translateY(-1px); }
.icon-button.small { width: 29px; height: 29px; }
.icon-button.small svg { width: 14px; height: 14px; }

/* ---------- Layout ---------- */
.studio {
  width: 100%;
  max-width: 1760px;
  height: calc(100vh - 100px);
  min-height: 640px;
  margin: 0 auto;
  padding: 13px 18px;
  display: grid;
  grid-template-columns: 338px minmax(460px, 1fr) 294px;
  gap: 13px;
  position: relative;
  z-index: 2;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 28%),
    var(--panel);
  box-shadow: var(--shadow-panel);
  min-height: 0;
}

.controls-panel,
.variations-panel {
  padding: 18px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #31382b transparent;
}
.controls-panel::-webkit-scrollbar,
.variations-panel::-webkit-scrollbar { width: 5px; }
.controls-panel::-webkit-scrollbar-thumb,
.variations-panel::-webkit-scrollbar-thumb { background: #31382b; border-radius: 10px; }

.stage-panel {
  padding: 20px 20px 17px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 45% at 50% 20%, rgba(185, 238, 106, 0.022), transparent 65%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 30%),
    var(--panel);
}

/* ---------- Type ---------- */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.eyebrow > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 16px;
  border: 1px solid rgba(185, 238, 106, 0.2);
  border-radius: 4px;
  color: var(--lime);
  font-size: 7.5px;
  letter-spacing: 0.04em;
}

.panel-intro h1 {
  margin: 11px 0 7px;
  font-size: 31px;
  line-height: 1.02;
  letter-spacing: -0.055em;
  font-weight: 500;
}
.panel-intro h1 span { color: var(--lime); }
.panel-intro p {
  max-width: 280px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}

/* ---------- Prompt ---------- */
.prompt-form { margin-top: 16px; }
.field-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.field-label {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.char-count { color: var(--dim); font-family: var(--font-mono); font-size: 8px; }

.prompt-box {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel-deep);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.prompt-box:focus-within {
  border-color: rgba(185, 238, 106, 0.48);
  box-shadow: 0 0 0 3px rgba(185, 238, 106, 0.07);
  background: #0c0f09;
}
.prompt-box input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  letter-spacing: -0.01em;
}
.prompt-box input::placeholder { color: var(--dim); }
.prompt-submit {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--lime);
  color: var(--lime-ink);
  transition: background 0.2s ease, transform 0.25s var(--ease);
}
.prompt-submit:hover { background: var(--lime-bright); transform: translateX(1px); }
.prompt-submit svg { width: 17px; height: 17px; }

.parsed-tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 23px; margin-top: 7px; }
.parsed-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.018);
  color: #acb4a1;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.025em;
  white-space: nowrap;
  animation: tag-in 0.35s var(--ease) both;
}
.parsed-tag::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--dim); }
.parsed-tag.material { color: var(--text); border-color: rgba(255, 255, 255, 0.12); }
.parsed-tag.material::before { background: var(--text-soft); }
.parsed-tag.effect { color: #b7ce97; border-color: rgba(185, 238, 106, 0.14); background: rgba(185, 238, 106, 0.035); }
.parsed-tag.effect::before { background: var(--lime); }
.parsed-tag.accent { color: var(--tag-color, var(--lime)); border-color: color-mix(in srgb, var(--tag-color, var(--lime)) 25%, transparent); }
.parsed-tag.accent::before { background: var(--tag-color, var(--lime)); }
.parsed-tag.muted { color: var(--dim); }
@keyframes tag-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.prompt-examples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 7px;
  margin-top: 5px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
}
.prompt-examples > span { letter-spacing: 0.13em; text-transform: uppercase; }
.prompt-examples button {
  padding: 0;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7.5px;
  line-height: 1.6;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.prompt-examples button:hover { color: var(--lime); border-color: rgba(185, 238, 106, 0.3); }

/* ---------- Control blocks ---------- */
.control-block {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.control-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.hint { color: var(--dim); font-size: 7.5px; letter-spacing: 0.02em; text-transform: none; }
.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.03em;
  transition: color 0.2s ease;
}
.text-button:hover { color: var(--lime); }

.material-trigger {
  width: 100%;
  height: 53px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 9px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-deep);
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s var(--ease);
}
.material-trigger:hover {
  border-color: rgba(185, 238, 106, 0.34);
  background: #0d100a;
  transform: translateY(-1px);
}
.material-thumb-wrap {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background:
    linear-gradient(45deg, #1a1d17 25%, transparent 25%, transparent 75%, #1a1d17 75%),
    linear-gradient(45deg, #1a1d17 25%, #12140f 25%, #12140f 75%, #1a1d17 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  overflow: hidden;
}
.material-thumb-wrap canvas { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.material-trigger-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.material-trigger-copy strong { font-size: 12px; font-weight: 500; color: var(--text); letter-spacing: -0.01em; }
.material-trigger-copy small { color: var(--dim); font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.chevron { width: 16px; height: 16px; margin-left: auto; color: var(--dim); flex: 0 0 auto; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-deep);
}
.segmented button {
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: 0.2s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: #202719;
  border-color: rgba(185, 238, 106, 0.16);
  color: var(--lime);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.slider-row { margin-top: 8px; }
.slider-row:first-of-type { margin-top: 2px; }
.slider-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.slider-label label { color: var(--muted); font-size: 10px; }
.slider-label output { color: var(--lime); font-family: var(--font-mono); font-size: 8.5px; min-width: 25px; text-align: right; }

input[type='range'] {
  --val: 50%;
  display: block;
  width: 100%;
  height: 15px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  outline: none;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(185, 238, 106, 0.88) 0 var(--val), #292e23 var(--val) 100%);
}
input[type='range']::-moz-range-track { height: 3px; border-radius: 99px; background: #292e23; }
input[type='range']::-moz-range-progress { height: 3px; border-radius: 99px; background: rgba(185, 238, 106, 0.88); }
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 2px solid #0b0d08;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 1px rgba(185, 238, 106, 0.35), 0 2px 7px rgba(0, 0, 0, 0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
input[type='range']:hover::-webkit-slider-thumb { transform: scale(1.14); box-shadow: 0 0 0 4px rgba(185, 238, 106, 0.08), 0 2px 7px rgba(0, 0, 0, 0.55); }
input[type='range']::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 2px solid #0b0d08;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 1px rgba(185, 238, 106, 0.35);
}
#hueRange::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, #d95f5f, #e3bf58, #82ce5e, #58d3ca, #6084df, #ab6fdd, #d95f9d, #d95f5f);
  opacity: 0.8;
}
#hueRange::-moz-range-track { background: linear-gradient(90deg, #d95f5f, #e3bf58, #82ce5e, #58d3ca, #6084df, #ab6fdd, #d95f9d, #d95f5f); }
#hueRange::-moz-range-progress { background: transparent; }
#hueRange::-webkit-slider-thumb { background: #f1f6e6; }

.forge-button {
  width: 100%;
  height: 47px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 15px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  background: linear-gradient(180deg, var(--lime-bright), var(--lime));
  color: var(--lime-ink);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  box-shadow:
    0 10px 26px rgba(126, 192, 52, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 -1px 0 rgba(35, 57, 12, 0.15) inset;
  transition: transform 0.2s var(--ease), box-shadow 0.2s ease, filter 0.2s ease;
}
.forge-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.035);
  box-shadow: 0 14px 34px rgba(126, 192, 52, 0.23), 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}
.forge-button:active { transform: translateY(0) scale(0.995); }
.forge-button .forge-spark { width: 17px; height: 17px; }
.forge-button .forge-spark svg { width: 100%; height: 100%; }
.forge-button kbd {
  position: absolute;
  right: 14px;
  border-color: rgba(20, 31, 10, 0.18);
  background: rgba(20, 31, 10, 0.07);
}
.forge-button { position: relative; }
.forge-button.is-forging .forge-spark { animation: spark-spin 0.55s var(--ease); }
@keyframes spark-spin { to { transform: rotate(180deg) scale(1.2); } }

.local-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 11px 0 0;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.2px;
  letter-spacing: 0.015em;
}
.local-note > span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime-deep); }

/* ---------- Stage head ---------- */
.stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.stage-title-wrap { min-width: 0; }
.title-line { display: flex; align-items: center; gap: 10px; margin-top: 8px; min-width: 0; }
.title-line h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: -0.045em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seam-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 19px;
  padding: 0 7px;
  border: 1px solid rgba(185, 238, 106, 0.16);
  border-radius: 4px;
  background: rgba(185, 238, 106, 0.04);
  color: #a9bf88;
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.seam-badge > span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); }

.view-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-deep);
  flex: 0 0 auto;
}
.view-switch button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 29px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font-size: 9.5px;
  font-weight: 500;
  transition: 0.2s ease;
}
.view-switch button svg { width: 13px; height: 13px; }
.view-switch button:hover { color: var(--text-soft); }
.view-switch button.active {
  background: #202719;
  border-color: rgba(185, 238, 106, 0.14);
  color: var(--lime);
}

/* ---------- Stage viewport ---------- */
.stage-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 345px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background:
    radial-gradient(ellipse 40% 44% at 50% 46%, rgba(183, 234, 103, 0.072), transparent 72%),
    radial-gradient(ellipse 70% 50% at 50% 110%, rgba(0, 0, 0, 0.32), transparent 70%),
    #0b0d08;
  isolation: isolate;
}
.stage-viewport::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(235, 245, 220, 0.033) 1px, transparent 1px),
    linear-gradient(90deg, rgba(235, 245, 220, 0.033) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: radial-gradient(ellipse 70% 72% at 50% 50%, #000 10%, transparent 82%);
  opacity: 0.65;
  pointer-events: none;
}
.stage-viewport::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  box-shadow: 0 -80px 120px rgba(0, 0, 0, 0.18) inset, 0 0 0 1px rgba(255, 255, 255, 0.012) inset;
  pointer-events: none;
}
.stage-aura {
  position: absolute;
  z-index: 0;
  width: 52%;
  aspect-ratio: 1;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(185, 238, 106, 0.085), rgba(185, 238, 106, 0.018) 45%, transparent 70%);
  filter: blur(18px);
  pointer-events: none;
}

.stage-coordinates {
  position: absolute;
  z-index: 5;
  left: 13px;
  bottom: 11px;
  display: flex;
  gap: 9px;
  color: rgba(196, 207, 186, 0.35);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  pointer-events: none;
}
.stage-coordinates span + span::before { content: '/'; margin-right: 9px; color: rgba(196, 207, 186, 0.18); }

.corner-bracket {
  position: absolute;
  z-index: 5;
  width: 14px;
  height: 14px;
  pointer-events: none;
  opacity: 0.38;
}
.corner-bracket.tl { left: 11px; top: 11px; border-top: 1px solid #bdd0aa; border-left: 1px solid #bdd0aa; }
.corner-bracket.br { right: 11px; bottom: 11px; border-bottom: 1px solid #bdd0aa; border-right: 1px solid #bdd0aa; }

.viewport-topline {
  position: absolute;
  z-index: 6;
  top: 13px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 6.8px;
  letter-spacing: 0.13em;
  pointer-events: none;
}
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 19px;
  padding: 0 7px;
  border: 1px solid rgba(185, 238, 106, 0.1);
  border-radius: 4px;
  background: rgba(10, 13, 7, 0.5);
  color: #99ad83;
  backdrop-filter: blur(4px);
}
.live-chip > span { width: 4px; height: 4px; }

.reset-view {
  position: absolute;
  z-index: 7;
  top: 40px;
  right: 13px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(11, 13, 8, 0.66);
  color: var(--dim);
  backdrop-filter: blur(6px);
  transition: 0.2s ease;
}
.reset-view svg { width: 13px; height: 13px; }
.reset-view:hover { color: var(--lime); border-color: rgba(185, 238, 106, 0.3); }

/* 3D scene */
.scene-wrap {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  padding-top: 6px;
}
.cube-float { animation: cube-float 8s ease-in-out infinite; transform-style: preserve-3d; }
@keyframes cube-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.scene {
  --cube-size: clamp(190px, 21vw, 246px);
  width: var(--cube-size);
  height: var(--cube-size);
  transform-style: preserve-3d;
  position: relative;
}
.cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-24deg) rotateY(-37deg);
  cursor: grab;
  touch-action: none;
  transition: transform 0.45s var(--ease);
  will-change: transform;
}
.cube.is-dragging { cursor: grabbing; transition: none; }
.cube.is-rubbing { transition: none; }
.cube-face {
  position: absolute;
  inset: 0;
  background-color: #171b13;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  backface-visibility: hidden;
  box-shadow:
    0 0 0 1px rgba(8, 11, 5, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 0 24px rgba(4, 7, 2, 0.1);
  overflow: hidden;
}
.cube-face::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.face-front { transform: translateZ(calc(var(--cube-size) / 2)); }
.face-back { transform: rotateY(180deg) translateZ(calc(var(--cube-size) / 2)); }
.face-right { transform: rotateY(90deg) translateZ(calc(var(--cube-size) / 2)); }
.face-left { transform: rotateY(-90deg) translateZ(calc(var(--cube-size) / 2)); }
.face-top { transform: rotateX(90deg) translateZ(calc(var(--cube-size) / 2)); }
.face-bottom { transform: rotateX(-90deg) translateZ(calc(var(--cube-size) / 2)); }

.face-front::after { background: linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 45%, rgba(0, 0, 0, 0.05)); }
.face-right::after { background: rgba(4, 7, 2, 0.23); }
.face-left::after { background: rgba(4, 7, 2, 0.38); }
.face-top::after { background: linear-gradient(135deg, rgba(255, 255, 245, 0.14), transparent 68%); }
.face-bottom::after { background: rgba(4, 6, 3, 0.46); }
.face-back::after { background: rgba(4, 7, 2, 0.4); }

.cube-edge { display: none; }

.floor-glow {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 68%;
  width: min(380px, 48%);
  height: 56px;
  transform: translate(-50%, 0) rotate(-4deg);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.18) 48%, transparent 72%);
  filter: blur(9px);
  pointer-events: none;
}

.drag-hint {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  background: rgba(9, 11, 7, 0.55);
  color: rgba(198, 207, 188, 0.45);
  font-family: var(--font-mono);
  font-size: 6.8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(5px);
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.drag-hint svg { width: 11px; height: 11px; }
.drag-hint.is-hidden { opacity: 0; }

.stage-callouts { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.callout {
  position: absolute;
  right: 6%;
  color: rgba(204, 215, 194, 0.4);
  font-family: var(--font-mono);
  font-size: 6.2px;
  letter-spacing: 0.12em;
}
.callout-top { top: 33%; }
.callout-side { top: 66%; }
.callout-line {
  position: absolute;
  right: calc(6% + 55px);
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(204, 215, 194, 0.2));
}
.line-top { top: calc(33% + 4px); }
.line-side { top: calc(66% + 4px); }

/* Tile view */
.tile-wrap {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 6;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 45px 22px 38px;
}
.stage-viewport.is-tile .scene-wrap,
.stage-viewport.is-tile .stage-callouts,
.stage-viewport.is-tile .drag-hint { display: none; }
.stage-viewport.is-tile .tile-wrap { display: flex; }

.tile-frame {
  position: relative;
  width: min(54vh, 390px);
  max-width: 100%;
  aspect-ratio: 1;
  padding: 1px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  background: #12150e;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.48),
    0 0 0 5px rgba(9, 11, 7, 0.45),
    0 0 0 6px rgba(255, 255, 255, 0.035);
  animation: tile-in 0.35s var(--ease);
}
@keyframes tile-in { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }
.tile-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #0c0e09;
}
.tile-axis {
  position: absolute;
  color: rgba(210, 220, 200, 0.38);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  pointer-events: none;
}
.tile-axis.horizontal { right: -22px; top: 50%; transform: rotate(90deg) translateX(50%); }
.tile-axis.vertical { left: 50%; bottom: -18px; transform: translateX(-50%); }
.tile-wrap p {
  margin: 0;
  color: rgba(194, 205, 184, 0.35);
  font-family: var(--font-mono);
  font-size: 6.8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tile-wrap p span { color: rgba(185, 238, 106, 0.55); margin: 0 4px; }

/* ---------- Stage controls ---------- */
.stage-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 17px;
  padding: 14px 2px 0;
}
.toolbar-label {
  display: block;
  margin-bottom: 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.seed-control { flex: 0 0 auto; }
.seed-field {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 3px 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-deep);
  transition: border-color 0.2s ease;
}
.seed-field:focus-within { border-color: rgba(185, 238, 106, 0.38); }
.seed-field > span { color: var(--dim); font-family: var(--font-mono); font-size: 9px; }
.seed-field input {
  width: 72px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #c5ccba;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.02em;
}
.seed-field button {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  transition: 0.2s ease;
}
.seed-field button:hover { color: var(--lime); background: rgba(185, 238, 106, 0.08); }
.seed-field button svg { width: 13px; height: 13px; }

.resolution-group {
  display: flex;
  gap: 2px;
  padding: 2px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-deep);
}
.resolution-group button {
  min-width: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  transition: 0.2s ease;
}
.resolution-group button:hover { color: var(--text-soft); }
.resolution-group button.active { background: #232a1c; color: var(--lime); border-color: rgba(185, 238, 106, 0.12); }

.palette-control { min-width: 0; flex: 1; margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; }
.palette-swatches {
  display: flex;
  width: 100%;
  max-width: 156px;
  height: 32px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-deep);
}
.palette-swatches span {
  flex: 1;
  min-width: 0;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  transition: transform 0.2s var(--ease);
}
.palette-swatches span:hover { transform: scaleY(1.12); }

/* ---------- Export row ---------- */
.export-row {
  display: flex;
  gap: 7px;
  padding-top: 12px;
}
.download-main { flex: 1; height: 44px; border-radius: 9px; font-size: 12px; }
.download-main kbd { margin-left: 2px; background: rgba(20, 30, 9, 0.08); border-color: rgba(20, 30, 9, 0.13); }
.btn-outline { height: 44px; padding: 0 12px; border-radius: 9px; font-size: 10.5px; }
.btn-outline svg { width: 16px; height: 16px; }
.zip-tag { color: var(--dim); font-family: var(--font-mono); font-size: 6.5px; padding-left: 1px; }
.copy-button { width: 44px; height: 44px; border-radius: 9px; flex: 0 0 auto; }
.copy-button svg { width: 16px; height: 16px; }

/* ---------- Variations ---------- */
.variations-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.variations-head h2 {
  margin: 8px 0 0;
  font-size: 23px;
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -0.045em;
}
.variations-sub { margin: 7px 0 13px; color: var(--dim); font-size: 10px; line-height: 1.45; }

.variation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.variation-card {
  --card-hue: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d100a;
  text-align: left;
  overflow: hidden;
  transition: border-color 0.22s ease, background 0.22s ease, transform 0.22s var(--ease), box-shadow 0.22s ease;
  animation: variant-in 0.45s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
@keyframes variant-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
.variation-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--accent, #b9ee6a) 9%, transparent), transparent 60%);
  pointer-events: none;
}
.variation-card:hover {
  border-color: rgba(185, 238, 106, 0.33);
  background: #10140b;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.28);
}
.variation-card canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 5px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.024) 1px, transparent 1px),
    #0a0c08;
  background-size: 14px 14px;
  image-rendering: pixelated;
}
.variation-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 2px;
  min-height: 15px;
}
.variation-seed { color: #747c68; font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.02em; }
.variation-load { display: flex; align-items: center; gap: 3px; color: var(--dim); font-family: var(--font-mono); font-size: 6px; letter-spacing: 0.06em; text-transform: uppercase; transition: color 0.2s ease; }
.variation-load svg { width: 9px; height: 9px; }
.variation-card:hover .variation-load { color: var(--lime); }
.variation-card.is-current { border-color: rgba(185, 238, 106, 0.45); }
.variation-card.is-current::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px rgba(185, 238, 106, 0.8);
}

.skeleton-card { min-height: 104px; border-radius: 9px; background: linear-gradient(110deg, #10130d 30%, #171c13 50%, #10130d 70%); background-size: 200% 100%; animation: skeleton 1.3s linear infinite; }
@keyframes skeleton { to { background-position: -200% 0; } }

.dna-card {
  margin-top: 12px;
  padding: 10px 11px 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(10, 12, 8, 0.55);
}
.dna-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.dna-live { display: inline-flex; align-items: center; gap: 5px; color: #8da573; letter-spacing: 0.07em; font-size: 6px; }
.dna-live > span { width: 4px; height: 4px; }
.dna-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  border-bottom: 1px dotted rgba(227, 238, 208, 0.075);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.02em;
}
.dna-row:last-child { border-bottom: 0; }
.dna-row > span { color: var(--dim); }
.dna-row strong { color: #b9c0af; font-weight: 400; font-size: 7.5px; text-align: right; }
.with-check { display: inline-flex; align-items: center; gap: 3px; color: #a7c783 !important; }
.with-check svg { width: 9px; height: 9px; }
.dna-palette { display: flex; gap: 2px; }
.dna-palette span { width: 12px; height: 12px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05) inset; }

.tip-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 9px;
  padding: 10px;
  border: 1px solid rgba(185, 238, 106, 0.12);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(185, 238, 106, 0.06), rgba(185, 238, 106, 0.015));
}
.tip-mark { color: var(--lime); font-size: 14px; line-height: 1; margin-top: 1px; text-shadow: 0 0 16px rgba(185, 238, 106, 0.35); }
.tip-card p { margin: 0; color: #919b84; font-size: 9.5px; line-height: 1.5; }
.tip-card strong { display: block; margin-bottom: 3px; color: #c3d2ac; font-family: var(--font-mono); font-size: 7px; font-weight: 500; letter-spacing: 0.11em; text-transform: uppercase; }

.shortcut-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 8px 0 0;
  color: #50574a;
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.04em;
}
.shortcut-note kbd { min-width: 15px; height: 15px; border-color: rgba(255, 255, 255, 0.07); background: rgba(255, 255, 255, 0.025); color: #6e765f; font-size: 6.5px; }
.shortcut-note > span { width: 2px; height: 2px; border-radius: 50%; background: #42483b; }

/* ---------- Footer ---------- */
.site-footer {
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  border-top: 1px solid rgba(227, 238, 208, 0.055);
  color: #4e5548;
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  background: rgba(9, 11, 7, 0.5);
}
.footer-center { color: #41473c; letter-spacing: 0.04em; text-transform: none; font-size: 7px; }

/* ---------- Material popover ---------- */
.material-popover {
  position: fixed;
  inset: auto;
  width: min(568px, calc(100vw - 24px));
  max-height: min(680px, calc(100vh - 24px));
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(227, 238, 208, 0.17);
  border-radius: 17px;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(185, 238, 106, 0.055), transparent 70%),
    #12150e;
  color: var(--text);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.62), 0 1px 0 rgba(255, 255, 255, 0.035) inset;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #353d2d transparent;
}
.material-popover:not(:popover-open) { display: none; }
.material-popover:popover-open { animation: pop-in 0.22s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-5px) scale(0.985); } to { opacity: 1; transform: none; } }
.material-popover::backdrop { background: rgba(3, 5, 2, 0.3); backdrop-filter: blur(2px); }
.popover-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 13px; }
.popover-eyebrow { color: var(--lime-deep); font-family: var(--font-mono); font-size: 6.5px; letter-spacing: 0.16em; margin-bottom: 5px; }
.popover-head h3 { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.04em; }
.material-groups { display: flex; flex-direction: column; gap: 13px; }
.material-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.material-group-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.material-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.material-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 45px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 12, 8, 0.55);
  text-align: left;
  transition: 0.18s ease;
}
.material-option:hover { border-color: rgba(185, 238, 106, 0.3); background: rgba(185, 238, 106, 0.04); transform: translateY(-1px); }
.material-option.is-selected { border-color: rgba(185, 238, 106, 0.48); background: rgba(185, 238, 106, 0.07); }
.material-option canvas { width: 33px; height: 33px; flex: 0 0 auto; border-radius: 4px; image-rendering: pixelated; display: block; }
.material-option span { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 7.8px; line-height: 1.2; }
.material-option.is-selected span { color: var(--lime); }
.popover-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.03em;
}
.popover-foot > span:first-child { display: flex; align-items: center; gap: 6px; }
.popover-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--lime-deep); }

/* ---------- Dialog ---------- */
.how-dialog {
  width: min(830px, calc(100vw - 30px));
  max-height: min(88vh, 820px);
  padding: 0;
  border: 1px solid rgba(227, 238, 208, 0.18);
  border-radius: 22px;
  background:
    radial-gradient(ellipse 60% 38% at 55% -5%, rgba(185, 238, 106, 0.08), transparent 65%),
    #11140d;
  color: var(--text);
  box-shadow: 0 40px 140px rgba(0, 0, 0, 0.7);
  overflow-y: auto;
}
.how-dialog::backdrop { background: rgba(3, 5, 2, 0.7); backdrop-filter: blur(8px); }
.how-dialog[open] { animation: dialog-in 0.35s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
.how-dialog .dialog-close { position: absolute; top: 17px; right: 17px; z-index: 2; }
.dialog-content { padding: 40px 42px 36px; }
.dialog-kicker { display: flex; align-items: center; gap: 7px; color: var(--lime); font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.16em; }
.dialog-kicker > span { width: 5px; height: 5px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px rgba(185, 238, 106, 0.7); }
.dialog-content h2 { margin: 15px 0 12px; font-size: 43px; line-height: 0.98; letter-spacing: -0.06em; font-weight: 500; }
.dialog-lede { max-width: 590px; margin: 0; color: #a1a895; font-size: 13px; line-height: 1.65; }
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 27px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--line); }
.how-grid article { background: #0f120c; padding: 19px; }
.how-grid article > span { color: var(--lime-deep); font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.1em; }
.how-grid h3 { margin: 10px 0 6px; font-size: 13px; font-weight: 500; letter-spacing: -0.02em; }
.how-grid p { margin: 0; color: #858d79; font-size: 10.5px; line-height: 1.6; }
.honest-note { display: flex; gap: 12px; margin-top: 18px; padding: 16px; border: 1px solid rgba(240, 190, 101, 0.15); border-radius: 11px; background: rgba(240, 190, 101, 0.035); }
.honest-icon { color: var(--amber); font-size: 16px; line-height: 1; }
.honest-note strong { display: block; margin-bottom: 4px; color: #d5c29a; font-family: var(--font-mono); font-size: 7px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; }
.honest-note p { margin: 0; color: #9a927f; font-size: 10.5px; line-height: 1.6; }
.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 25px; }
.dialog-actions .btn { height: 41px; padding: 0 18px; font-size: 11.5px; }
.dialog-actions > span { color: var(--dim); font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.05em; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; z-index: 100; left: 50%; bottom: 27px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(185, 238, 106, 0.22);
  border-radius: 8px;
  background: rgba(15, 19, 11, 0.96);
  color: #d6dfc9;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.45);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  animation: toast-in 0.3s var(--ease);
  backdrop-filter: blur(10px);
}
.toast::before { content: '✦'; color: var(--lime); font-size: 10px; }
.toast.is-error { border-color: rgba(239, 125, 105, 0.25); }
.toast.is-error::before { content: '!'; color: var(--danger); }
.toast.is-leaving { animation: toast-out 0.24s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(5px); } }

/* ---------- Focus / reduced motion ---------- */
:focus-visible { outline: 2px solid rgba(185, 238, 106, 0.7); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1260px) {
  .studio { grid-template-columns: 318px minmax(420px, 1fr) 274px; gap: 11px; padding-inline: 13px; }
  .controls-panel, .variations-panel { padding: 19px 17px; }
  .stage-panel { padding: 18px 17px 15px; }
  .panel-intro h1 { font-size: 30px; }
  .scene { --cube-size: clamp(180px, 19vw, 222px); }
  .stage-toolbar { gap: 12px; }
  .palette-swatches { max-width: 128px; }
}

@media (max-width: 1120px) {
  .studio {
    height: auto;
    min-height: 0;
    grid-template-columns: 320px minmax(0, 1fr);
    padding: 12px;
  }
  .stage-panel { min-height: 690px; }
  .variations-panel { grid-column: 1 / -1; overflow: visible; display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(260px, 0.8fr); column-gap: 18px; align-items: start; }
  .variations-head, .variations-sub, .variation-grid, .shortcut-note { grid-column: 1; }
  .variation-grid { grid-template-columns: repeat(3, 1fr); }
  .variation-card canvas { aspect-ratio: 1.24; }
  .dna-card { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
  .tip-card { grid-column: 2; margin-top: 12px; }
  .shortcut-note { margin-top: 14px; }
  .engine-status { margin: 0; }
  .topbar { gap: 14px; }
  .site-footer { height: auto; min-height: 28px; padding: 7px 16px; flex-wrap: wrap; }
  .site-footer .footer-center { display: none; }
}

@media (max-width: 860px) {
  .topbar { height: 62px; flex-basis: 62px; padding: 0 15px; gap: 10px; }
  .brand { min-width: 0; }
  .brand-copy em { display: none; }
  .engine-status { display: none; }
  .studio { grid-template-columns: 1fr; height: auto; padding: 10px; gap: 10px; }
  .stage-panel { order: 1; min-height: 650px; }
  .controls-panel { order: 2; overflow: visible; }
  .variations-panel { order: 3; grid-column: auto; display: block; padding: 20px; }
  .variations-panel .variation-grid { grid-template-columns: repeat(3, 1fr); }
  .variations-panel .dna-card { margin-top: 15px; }
  .variations-panel .tip-card { margin-top: 11px; }
  .site-footer { display: none; }
  .stage-viewport { min-height: 390px; }
  .panel-intro h1 { font-size: 34px; }
  .controls-panel { padding: 22px 20px; }
  .controls-panel .panel-intro p { max-width: 440px; }
  .scene { --cube-size: clamp(205px, 37vw, 260px); }
  .stage-callouts { display: none; }
  .material-options { grid-template-columns: repeat(4, 1fr); }
  .how-grid { grid-template-columns: 1fr; }
  .dialog-content { padding: 34px 28px 28px; }
  .dialog-content h2 { font-size: 35px; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 12px; height: 58px; flex-basis: 58px; }
  .brand-mark { width: 29px; height: 33px; }
  .brand-copy strong { font-size: 12px; }
  .topbar-actions { gap: 5px; }
  .btn-ghost { width: 34px; padding: 0; }
  .btn-ghost svg { width: 17px; height: 17px; }
  .btn-ghost { font-size: 0; gap: 0; }
  .top-export { height: 34px; padding: 0 10px; font-size: 10px; }
  .top-export kbd { display: none; }
  .top-export svg { width: 15px; height: 15px; }
  .studio { padding: 8px; gap: 8px; }
  .stage-panel, .controls-panel, .variations-panel { padding: 15px; border-radius: 16px; }
  .stage-panel { min-height: 570px; }
  .stage-head { gap: 8px; }
  .title-line { gap: 7px; flex-wrap: wrap; }
  .title-line h2 { font-size: 19px; }
  .seam-badge { height: 17px; font-size: 6px; }
  .eyebrow { font-size: 7.5px; }
  .view-switch button { padding: 0 7px; font-size: 0; gap: 0; }
  .view-switch button svg { width: 15px; height: 15px; }
  .view-switch button { width: 30px; justify-content: center; }
  .stage-viewport { min-height: 320px; margin-top: 11px; }
  .scene { --cube-size: min(48vw, 210px); }
  .stage-toolbar { flex-wrap: wrap; gap: 10px; }
  .palette-control { display: none; }
  .seed-control { flex: 1; }
  .seed-field input { flex: 1; width: auto; }
  .export-row { flex-wrap: wrap; }
  .download-main { flex: 1 1 100%; order: 0; }
  .btn-outline { flex: 1; order: 1; height: 40px; }
  .copy-button { order: 2; width: 40px; height: 40px; }
  .download-main { height: 42px; }
  .view-switch { padding: 2px; }
  .panel-intro h1 { font-size: 30px; }
  .controls-panel { padding: 18px 15px; }
  .prompt-examples { gap: 4px 6px; }
  .prompt-examples button { font-size: 7px; }
  .variations-panel .variation-grid, .variation-grid { grid-template-columns: 1fr 1fr; }
  .variation-card canvas { aspect-ratio: 1.12; }
  .material-options { grid-template-columns: repeat(3, 1fr); }
  .material-popover { width: calc(100vw - 16px); padding: 14px; border-radius: 14px; }
  .how-dialog { width: calc(100vw - 16px); max-height: 92vh; border-radius: 16px; }
  .dialog-content { padding: 30px 20px 23px; }
  .dialog-content h2 { font-size: 31px; }
  .dialog-lede { font-size: 11.5px; }
  .dialog-actions { flex-direction: column; align-items: stretch; }
  .dialog-actions > span { text-align: center; }
  .drag-hint { display: none; }
  .stage-callouts { display: none; }
  .site-footer { display: none; }
  .local-note { font-size: 6.8px; }
  .toast { max-width: calc(100vw - 30px); }
}

@media (max-height: 760px) and (min-width: 1121px) {
  .studio { min-height: 0; }
  .panel-intro h1 { font-size: 29px; }
  .panel-intro p { font-size: 11px; }
  .prompt-form { margin-top: 16px; }
  .control-block { margin-top: 13px; padding-top: 12px; }
  .forge-button { margin-top: 14px; height: 43px; }
  .local-note { margin-top: 8px; }
  .stage-viewport { min-height: 290px; }
  .scene { --cube-size: clamp(172px, 18vw, 210px); }
  .variation-card canvas { aspect-ratio: 1.22; }
  .tip-card { padding: 10px; }
  .dna-row { min-height: 24px; }
}
/* ---------- Interaction states ---------- */
body.dialog-open { overflow: hidden; }
.stage-viewport.is-pulsing .stage-aura { animation: aura-pop 0.6s var(--ease); }
@keyframes aura-pop {
  0% { transform: translate(-50%, -50%) scale(0.72); opacity: 0.4; }
  55% { transform: translate(-50%, -50%) scale(1.22); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.btn:disabled, .icon-button:disabled { opacity: 0.55; cursor: wait; transform: none; }
.material-popover { z-index: 80; }

@media (max-height: 840px) and (min-width: 1121px) {
  .panel-intro h1 { font-size: 27px; margin: 8px 0 6px; }
  .panel-intro p { font-size: 10.5px; line-height: 1.4; }
  .prompt-form { margin-top: 10px; }
  .prompt-examples { display: none; }
  .control-block { margin-top: 9px; padding-top: 9px; }
  .material-trigger { height: 47px; }
  .material-thumb-wrap { width: 38px; height: 38px; }
  .slider-row { margin-top: 5px; }
  .forge-button { margin-top: 11px; height: 42px; }
  .local-note { margin-top: 7px; }
  .variations-sub { margin: 5px 0 9px; }
  .variation-card { padding: 4px; }
  .dna-card { margin-top: 8px; }
  .dna-row { min-height: 22px; }
  .tip-card { margin-top: 7px; padding: 9px; }
  .shortcut-note { margin-top: 6px; }
}

@media (max-height: 840px) and (min-width: 1121px) {
  .tip-card, .shortcut-note { display: none; }
}

/* ---------- Optional AI layer ---------- */
.parsed-tag.ai {
  color: #ecc879;
  border-color: rgba(240, 190, 101, 0.26);
  background: rgba(240, 190, 101, 0.06);
}
.parsed-tag.ai::before { background: var(--amber); box-shadow: 0 0 7px rgba(240, 190, 101, 0.6); }

.forge-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
  margin-top: 15px;
}
.forge-row .forge-button {
  margin-top: 0;
  width: auto;
  flex: 1;
  min-width: 0;
}
.ai-action {
  width: 56px;
  flex: 0 0 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  border: 1px solid rgba(240, 190, 101, 0.32);
  border-radius: 11px;
  background:
    radial-gradient(ellipse 90% 80% at 50% 0%, rgba(240, 190, 101, 0.18), transparent 70%),
    #18160e;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  transition: 0.22s var(--ease);
}
.ai-action svg { width: 15px; height: 15px; transition: transform 0.35s var(--ease); }
.ai-action:hover {
  border-color: rgba(240, 190, 101, 0.65);
  background:
    radial-gradient(ellipse 90% 80% at 50% 0%, rgba(240, 190, 101, 0.28), transparent 70%),
    #1c190f;
  color: #ffd98e;
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(162, 119, 39, 0.18);
}
.ai-action:hover svg { transform: rotate(12deg) scale(1.08); }

.ai-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 19px;
  padding: 0 7px;
  border: 1px solid rgba(240, 190, 101, 0.3);
  border-radius: 4px;
  background: rgba(240, 190, 101, 0.07);
  color: #e8c884;
  font-family: var(--font-mono);
  font-size: 6.6px;
  letter-spacing: 0.09em;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: 0.18s ease;
}
.ai-mode-badge[hidden] { display: none; }
.ai-mode-badge:hover { border-color: rgba(240, 190, 101, 0.58); background: rgba(240, 190, 101, 0.12); color: #ffdb95; }
.ai-mode-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 7px rgba(240, 190, 101, 0.65); }
.ai-mode-exit { opacity: 0.55; font-size: 8px; margin-left: 1px; }

.ai-dialog {
  width: min(590px, calc(100vw - 24px));
  max-height: min(92vh, 830px);
  padding: 0;
  border: 1px solid rgba(240, 190, 101, 0.2);
  border-radius: 23px;
  background:
    radial-gradient(ellipse 58% 34% at 55% -4%, rgba(240, 190, 101, 0.1), transparent 65%),
    radial-gradient(ellipse 55% 40% at 100% 110%, rgba(185, 238, 106, 0.035), transparent 70%),
    #12140e;
  color: var(--text);
  box-shadow: 0 40px 140px rgba(0, 0, 0, 0.72);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #493d25 transparent;
}
.ai-dialog::backdrop { background: rgba(3, 5, 2, 0.74); backdrop-filter: blur(9px); }
.ai-dialog[open] { animation: dialog-in 0.35s var(--ease); }
.ai-dialog .dialog-close { position: absolute; top: 18px; right: 18px; z-index: 2; }
.ai-content { padding: 37px 40px 31px; }
.ai-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
}
.ai-kicker > span { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px rgba(240, 190, 101, 0.7); }
.ai-content h2 {
  margin: 15px 0 11px;
  font-size: 42px;
  line-height: 0.97;
  letter-spacing: -0.06em;
  font-weight: 500;
}
.ai-content h2 span { color: var(--amber); }
.ai-lede { max-width: 510px; margin: 0; color: #a3a896; font-size: 12.5px; line-height: 1.62; }

.ai-provider-card {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin-top: 21px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 11, 7, 0.55);
}
.ai-provider-main, .ai-provider-model { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ai-provider-label { color: var(--dim); font-family: var(--font-mono); font-size: 6.3px; letter-spacing: 0.13em; }
.ai-provider-card strong { color: #c8cdbb; font-size: 10.5px; font-weight: 500; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-provider-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 7px;
  border: 1px solid rgba(185, 238, 106, 0.18);
  border-radius: 4px;
  background: rgba(185, 238, 106, 0.04);
  color: #a6bf87;
  font-family: var(--font-mono);
  font-size: 6.2px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.ai-provider-state > span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); }
.ai-provider-state.checking { color: var(--dim); border-color: var(--line); background: rgba(255,255,255,.015); }
.ai-provider-state.checking > span { background: var(--dim); animation: pulse-dot 1.6s infinite; }
.ai-provider-state.free { color: #e7c479; border-color: rgba(240, 190, 101, 0.22); background: rgba(240, 190, 101, 0.05); }
.ai-provider-state.free > span { background: var(--amber); }
.ai-provider-state.offline { color: #d5907f; border-color: rgba(239, 125, 105, 0.22); background: rgba(239, 125, 105, 0.04); }
.ai-provider-state.offline > span { background: var(--danger); }

#aiForm { margin-top: 18px; }
.ai-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.ai-label-row label { color: var(--text-soft); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.13em; text-transform: uppercase; }
.ai-label-row > span { color: var(--dim); font-family: var(--font-mono); font-size: 7px; }
.ai-prompt-box {
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #0b0d08;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ai-prompt-box:focus-within { border-color: rgba(240, 190, 101, 0.5); box-shadow: 0 0 0 3px rgba(240, 190, 101, 0.06); }
.ai-prompt-box textarea {
  display: block;
  width: 100%;
  min-height: 63px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: 1.5;
}
.ai-prompt-box textarea::placeholder { color: var(--dim); }
.ai-chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ai-chip-row button {
  height: 23px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.016);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  transition: 0.18s ease;
}
.ai-chip-row button:hover { color: var(--amber); border-color: rgba(240, 190, 101, 0.3); background: rgba(240, 190, 101, 0.035); }

.ai-pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
}
.ai-pipeline span {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 6px;
  background: #0e110b;
  color: #858d7b;
  font-family: var(--font-mono);
  font-size: 6.4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.ai-pipeline i { color: #b39358; font-style: normal; font-size: 5.8px; }
.ai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 21px;
  margin-top: 13px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.2px;
  line-height: 1.45;
}
.ai-status.is-working { color: #c5ad7a; }
.ai-status.is-working::before { content: ''; width: 4px; height: 4px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); animation: pulse-dot 1.2s infinite; }
.ai-status.is-error { color: #e8a392; }
.ai-status.is-error::before { content: '!'; color: var(--danger); font-weight: 500; }
.ai-generate {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  background: linear-gradient(180deg, #f5ce80, #e9b85f);
  color: #251d0d;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(190, 147, 62, 0.14), 0 1px 0 rgba(255, 255, 255, 0.35) inset;
  transition: 0.2s var(--ease);
}
.ai-generate svg { width: 16px; height: 16px; }
.ai-generate:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 14px 32px rgba(190, 147, 62, 0.22); }
.ai-generate:disabled { opacity: 0.65; cursor: wait; transform: none; }
.ai-generate.is-loading svg { animation: spark-spin 1.4s linear infinite; }
.ai-privacy { margin: 9px 0 0; color: #626956; font-family: var(--font-mono); font-size: 6.4px; line-height: 1.5; }

.ai-unavailable {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 17px;
  padding: 14px;
  border: 1px solid rgba(239, 125, 105, 0.18);
  border-radius: 9px;
  background: rgba(239, 125, 105, 0.035);
}
.ai-unavailable[hidden] { display: none; }
.ai-unavailable strong { color: #d5aa9d; font-size: 11px; font-weight: 500; }
.ai-unavailable p { margin: 0; color: #98887f; font-size: 9.5px; line-height: 1.5; }
.ai-unavailable code { display: block; margin-top: 3px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 5px; background: #0b0d08; color: #b5bdab; font-family: var(--font-mono); font-size: 7px; overflow-x: auto; }

.export-row .btn-outline { flex: 0 1 auto; }
.export-row .download-main { min-width: 160px; }

@media (max-width: 1260px) {
  .ai-action { width: 50px; flex-basis: 50px; }
  .export-row .download-main { min-width: 130px; }
}

@media (max-width: 840px) {
  .ai-dialog { width: calc(100vw - 18px); max-height: 92vh; }
  .ai-content { padding: 32px 26px 27px; }
  .ai-content h2 { font-size: 36px; }
  .ai-provider-card { grid-template-columns: 1fr 1fr; }
  .ai-provider-state { grid-column: 1 / -1; justify-self: start; }
  .ai-pipeline { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .forge-row { margin-top: 13px; }
  .forge-row .forge-button { height: 43px; font-size: 11.5px; }
  .ai-action { height: 43px; width: 50px; flex-basis: 50px; }
  .ai-dialog { width: calc(100vw - 12px); max-height: 94vh; border-radius: 17px; }
  .ai-content { padding: 26px 17px 22px; }
  .ai-content h2 { font-size: 31px; }
  .ai-lede { font-size: 11px; }
  .ai-provider-card { grid-template-columns: 1fr; gap: 8px; }
  .ai-provider-state { grid-column: auto; }
  .ai-pipeline span { font-size: 6px; padding: 7px 5px; }
  .export-row .btn-outline { font-size: 9.5px; padding: 0 8px; gap: 5px; }
  .export-row .zip-tag { display: none; }
  .export-row .download-main { min-width: 0; }
}

@media (max-height: 840px) and (min-width: 1121px) {
  .forge-row { margin-top: 11px; }
  .forge-row .forge-button { height: 42px; }
  .ai-action { height: 42px; }
}

.ai-blend-control {
  margin-top: 14px;
  padding: 10px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 11, 7, 0.4);
}
.ai-blend-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.ai-blend-head label { color: #9ca48f; font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.08em; text-transform: uppercase; }
.ai-blend-head output { color: var(--amber); font-family: var(--font-mono); font-size: 8px; }
.ai-blend-control input[type='range']::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, #5b7350 0 var(--val), #2c2c22 var(--val) 100%);
}
.ai-blend-control input[type='range']::-moz-range-track { background: #2c2c22; }
.ai-blend-control input[type='range']::-moz-range-progress { background: #5b7350; }
.ai-blend-control input[type='range']::-webkit-slider-thumb { background: var(--amber); box-shadow: 0 0 0 1px rgba(240, 190, 101, 0.35), 0 2px 7px rgba(0,0,0,.5); }
.ai-blend-scale { display: flex; justify-content: space-between; margin-top: 1px; color: #50584a; font-family: var(--font-mono); font-size: 6px; letter-spacing: 0.04em; }
.ai-status.is-success { color: #a9c78a; }
.ai-status.is-success::before { content: '✓'; color: var(--lime); }

/* ---------- Library launcher & finisher launcher ---------- */
.library-launch {
  gap: 7px;
  padding-inline: 10px;
}
.library-label { display: inline; }
.library-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 17px;
  padding: 0 5px;
  border: 1px solid rgba(185, 238, 106, 0.18);
  border-radius: 99px;
  background: rgba(185, 238, 106, 0.07);
  color: var(--lime);
  font-family: var(--font-mono);
  font-size: 7px;
  line-height: 1;
}
.library-count.is-empty { color: var(--dim); border-color: var(--line); background: rgba(255,255,255,.015); }

.stage-head-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.finish-launch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 35px;
  padding: 0 10px;
  border: 1px solid rgba(240, 190, 101, 0.22);
  border-radius: 9px;
  background: rgba(240, 190, 101, 0.035);
  color: #cfb478;
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 500;
  transition: 0.2s ease;
}
.finish-launch svg { width: 13px; height: 13px; }
.finish-launch:hover { color: #ffdb95; border-color: rgba(240, 190, 101, 0.48); background: rgba(240, 190, 101, 0.08); transform: translateY(-1px); }
.ai-mode-badge.is-saved { color: #b4d58d; border-color: rgba(185, 238, 106, 0.28); background: rgba(185, 238, 106, 0.06); }
.ai-mode-badge.is-saved .ai-mode-dot { background: var(--lime); box-shadow: 0 0 7px rgba(185, 238, 106, 0.65); }

/* ---------- Library dialog ---------- */
.library-dialog {
  width: min(1120px, calc(100vw - 26px));
  max-width: none;
  max-height: 90vh;
  padding: 0;
  border: 1px solid rgba(227, 238, 208, 0.17);
  border-radius: 22px;
  background:
    radial-gradient(ellipse 55% 35% at 50% -5%, rgba(185, 238, 106, 0.065), transparent 65%),
    #11140d;
  color: var(--text);
  box-shadow: 0 40px 140px rgba(0, 0, 0, 0.74);
  overflow: hidden;
}
.library-dialog::backdrop { background: rgba(3, 5, 2, 0.74); backdrop-filter: blur(9px); }
.library-dialog[open] { animation: dialog-in 0.35s var(--ease); }
.library-shell { display: flex; flex-direction: column; max-height: 90vh; min-height: 500px; }
.library-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 30px 18px;
  border-bottom: 1px solid var(--line);
}
.library-kicker { display: flex; align-items: center; gap: 7px; color: var(--lime); font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.16em; }
.library-kicker > span { width: 5px; height: 5px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 9px rgba(185,238,106,.7); }
.library-head h2 { margin: 9px 0 5px; font-size: 33px; line-height: 1; letter-spacing: -0.055em; font-weight: 500; }
.library-head p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.library-head-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.library-head-actions .btn-outline { height: 35px; font-size: 9.5px; padding: 0 11px; }
.library-head-actions .btn-outline svg { width: 14px; height: 14px; }
.library-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 6, 0.24);
}
.library-search {
  width: min(260px, 32vw);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-deep);
  transition: border-color 0.2s ease;
}
.library-search:focus-within { border-color: rgba(185, 238, 106, 0.4); }
.library-search svg { width: 14px; height: 14px; color: var(--dim); flex: 0 0 auto; }
.library-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 10px;
}
.library-search input::placeholder { color: var(--dim); }
.library-filters { display: flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-deep); }
.library-filters button {
  height: 28px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.04em;
  transition: 0.18s ease;
}
.library-filters button:hover { color: var(--text-soft); }
.library-filters button.active { background: #232a1c; color: var(--lime); border-color: rgba(185,238,106,.12); }
.library-result-count { margin-left: auto; color: var(--dim); font-family: var(--font-mono); font-size: 7px; white-space: nowrap; }
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  padding: 18px 30px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #333b2b transparent;
}
.library-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0c0f09;
  overflow: hidden;
  transition: 0.22s var(--ease);
  animation: variant-in 0.4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 25ms);
}
.library-card:hover { border-color: rgba(185, 238, 106, 0.27); transform: translateY(-2px); box-shadow: 0 12px 35px rgba(0,0,0,.3); }
.library-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.library-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1.28;
  object-fit: cover;
  background:
    linear-gradient(rgba(255,255,255,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.026) 1px, transparent 1px),
    #090b07;
  background-size: 16px 16px;
  image-rendering: pixelated;
}
.library-open::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(5,7,3,.46));
  pointer-events: none;
}
.library-origin {
  position: absolute;
  z-index: 1;
  top: 7px;
  left: 7px;
  height: 18px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(185,238,106,.18);
  border-radius: 4px;
  background: rgba(9,12,7,.72);
  color: #a9bf89;
  font-family: var(--font-mono);
  font-size: 6px;
  letter-spacing: 0.08em;
  backdrop-filter: blur(5px);
}
.library-origin.is-ai { color: #e4c078; border-color: rgba(240,190,101,.25); }
.library-origin.is-saved { color: #b4d58d; border-color: rgba(185,238,106,.24); }
.library-body { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 5px; }
.library-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-soft); font-size: 10.5px; font-weight: 500; letter-spacing: -0.01em; }
.library-prompt { min-height: 18px; color: var(--dim); font-size: 8px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.library-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 1px; color: #5f6856; font-family: var(--font-mono); font-size: 6.5px; }
.library-card-actions { display: flex; align-items: center; gap: 2px; position: absolute; z-index: 2; top: 6px; right: 6px; }
.library-card-actions button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 5px;
  background: rgba(9,12,7,.7);
  color: #8b9383;
  backdrop-filter: blur(5px);
  transition: 0.18s ease;
}
.library-card-actions button svg { width: 12px; height: 12px; }
.library-card-actions button:hover { color: var(--lime); border-color: rgba(185,238,106,.3); background: rgba(19,24,14,.9); }
.library-card-actions button.is-favorite { color: var(--amber); border-color: rgba(240,190,101,.25); }
.library-card-actions button[data-action="delete"]:hover { color: var(--danger); border-color: rgba(239,125,105,.3); }
.library-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 30px; text-align: center; }
.library-empty[hidden] { display: none; }
.library-empty-mark { color: var(--lime); font-size: 22px; text-shadow: 0 0 25px rgba(185,238,106,.3); }
.library-empty h3 { margin: 12px 0 5px; font-size: 17px; font-weight: 500; letter-spacing: -0.03em; }
.library-empty p { max-width: 310px; margin: 0; color: var(--dim); font-size: 10px; line-height: 1.55; }
.library-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 30px;
  border-top: 1px solid var(--line);
  color: #565e4f;
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.025em;
}
.library-foot > span:first-child { display: flex; align-items: center; gap: 5px; }
.library-live-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 7px rgba(185,238,106,.6); }
.library-sep { color: #3e4539; }

/* ---------- Finisher dialog ---------- */
.finisher-dialog {
  width: min(1050px, calc(100vw - 24px));
  max-width: none;
  max-height: 92vh;
  padding: 0;
  border: 1px solid rgba(227, 238, 208, 0.17);
  border-radius: 22px;
  background:
    radial-gradient(ellipse 50% 36% at 50% -5%, rgba(185, 238, 106, 0.06), transparent 65%),
    #10130d;
  color: var(--text);
  box-shadow: 0 40px 140px rgba(0,0,0,.78);
  overflow: hidden;
}
.finisher-dialog::backdrop { background: rgba(2,4,2,.8); backdrop-filter: blur(10px); }
.finisher-dialog[open] { animation: dialog-in 0.32s var(--ease); }
.finisher-shell { display: flex; flex-direction: column; max-height: 92vh; }
.finisher-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 17px;
  border-bottom: 1px solid var(--line);
}
.finisher-title-wrap { min-width: 0; }
.finisher-kicker { display: flex; align-items: center; gap: 7px; color: var(--lime); font-family: var(--font-mono); font-size: 6.8px; letter-spacing: 0.16em; }
.finisher-kicker > span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 8px rgba(185,238,106,.65); }
.finisher-head h2 { margin: 8px 0 3px; font-size: 25px; line-height: 1; letter-spacing: -0.05em; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finisher-head p { margin: 0; color: var(--dim); font-family: var(--font-mono); font-size: 7px; }
.finisher-head-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.finisher-faces { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-deep); }
.finisher-face {
  height: 29px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.02em;
  transition: 0.18s ease;
}
.finisher-face:hover { color: var(--text-soft); }
.finisher-face.active { background: #232a1c; border-color: rgba(185,238,106,.14); color: var(--lime); }
.finisher-body { display: grid; grid-template-columns: minmax(0, 1fr) 284px; gap: 19px; padding: 18px 24px 22px; overflow-y: auto; }
.finisher-canvas-pane { min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.finisher-canvas-wrap {
  position: relative;
  width: min(100%, 470px);
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 3px;
  overflow: hidden;
  background-color: #0a0c08;
  background-image:
    linear-gradient(45deg, #1b1f17 25%, transparent 25%, transparent 75%, #1b1f17 75%),
    linear-gradient(45deg, #1b1f17 25%, #10130d 25%, #10130d 75%, #1b1f17 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
  box-shadow: 0 22px 55px rgba(0,0,0,.4);
}
#finisherCanvas { display: block; width: 100%; height: auto; image-rendering: pixelated; cursor: crosshair; outline: none; touch-action: none; }
#finisherCanvas.is-picker { cursor: copy; }
#finisherCanvas.is-eraser { cursor: cell; }
.finisher-cursor { position: absolute; top: 0; left: 0; z-index: 2; border: 1px solid rgba(255,255,255,.85); box-shadow: 0 0 0 1px rgba(0,0,0,.7); pointer-events: none; }
.finisher-coord { position: absolute; right: 6px; bottom: 6px; z-index: 2; padding: 3px 5px; border-radius: 3px; background: rgba(5,7,3,.66); color: #c0cbb2; font-family: var(--font-mono); font-size: 6px; letter-spacing: 0.04em; pointer-events: none; backdrop-filter: blur(4px); }
.finisher-canvas-foot { display: flex; justify-content: space-between; gap: 10px; max-width: 470px; width: 100%; margin: 0 auto; color: #596251; font-family: var(--font-mono); font-size: 6.4px; letter-spacing: 0.02em; }
.finisher-dot { color: #3e4639; margin: 0 3px; }
.finisher-tools { min-width: 0; display: flex; flex-direction: column; gap: 13px; }
.finisher-section { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.finisher-section-title { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-bottom: 7px; color: var(--text-soft); font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.1em; text-transform: uppercase; }
.finisher-section-title > span { color: var(--dim); font-size: 6px; letter-spacing: 0.01em; text-transform: none; }
.finisher-tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.finisher-tool {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 35px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10,12,8,.4);
  color: var(--muted);
  font-size: 9px;
  transition: 0.18s ease;
}
.finisher-tool svg { width: 13px; height: 13px; flex: 0 0 auto; }
.finisher-tool:hover { color: var(--text); border-color: rgba(185,238,106,.24); }
.finisher-tool.active { color: var(--lime); border-color: rgba(185,238,106,.3); background: rgba(185,238,106,.06); }
.finisher-brush-row { display: grid; grid-template-columns: repeat(3, 27px) 1fr 1fr; gap: 4px; align-items: center; }
.finisher-brush, .finisher-toggle {
  height: 29px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  transition: 0.18s ease;
}
.finisher-brush:hover, .finisher-toggle:hover { color: var(--text-soft); border-color: rgba(185,238,106,.2); }
.finisher-brush.active { color: var(--lime); border-color: rgba(185,238,106,.3); background: rgba(185,238,106,.06); }
.finisher-toggle { padding: 0 6px; font-family: var(--font-ui); font-size: 8px; }
.finisher-toggle.is-on { color: var(--lime); border-color: rgba(185,238,106,.26); background: rgba(185,238,106,.055); }
.finisher-palette { display: flex; flex-wrap: wrap; gap: 5px; }
.finisher-swatch { width: 25px; height: 25px; padding: 0; border: 1px solid rgba(255,255,255,.13); border-radius: 5px; box-shadow: 0 0 0 1px rgba(0,0,0,.16) inset; transition: 0.16s ease; }
.finisher-swatch:hover { transform: translateY(-1px); }
.finisher-swatch.active { box-shadow: 0 0 0 2px #0e100b, 0 0 0 3px var(--lime); }
.finisher-custom-color { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 26px; margin-top: 6px; padding: 0 4px 0 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--dim); font-family: var(--font-mono); font-size: 6.5px; }
.finisher-custom-color input { width: 42px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
.finisher-history-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 4px; }
.finisher-history-btn { height: 29px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); font-family: var(--font-mono); font-size: 7px; transition: 0.18s ease; }
.finisher-history-btn:hover:not(:disabled) { color: var(--text); border-color: rgba(185,238,106,.22); }
.finisher-history-btn:disabled { opacity: .34; cursor: default; }
.finisher-mini { padding-bottom: 0; border-bottom: 0; }
.finisher-mini canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 230 / 150;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    #090b07;
  background-size: 14px 14px;
}
.finisher-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 5px; margin-top: auto; padding-top: 3px; }
.finisher-actions .btn { height: 37px; font-size: 9.5px; padding: 0 10px; border-radius: 8px; }

@media (max-width: 1260px) {
  .library-label { display: none; }
  .library-launch { gap: 4px; padding-inline: 8px; }
  .finish-launch span { display: none; }
  .finish-launch { width: 34px; justify-content: center; padding: 0; }
}

@media (max-width: 900px) {
  .library-dialog { width: calc(100vw - 18px); max-height: 92vh; }
  .library-shell { max-height: 92vh; }
  .library-head { padding: 22px 20px 15px; }
  .library-toolbar { padding: 11px 20px; flex-wrap: wrap; }
  .library-search { width: 100%; flex: 1 1 100%; }
  .library-grid { padding: 14px 20px 20px; }
  .library-foot { padding: 9px 20px; }
  .finisher-dialog { width: calc(100vw - 18px); max-height: 94vh; }
  .finisher-shell { max-height: 94vh; }
  .finisher-head { padding: 18px 18px 14px; flex-wrap: wrap; }
  .finisher-body { grid-template-columns: 1fr; padding: 14px 18px 18px; }
  .finisher-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  .finisher-actions { grid-column: 1 / -1; }
  .finisher-mini { grid-column: 1 / -1; }
  .finisher-canvas-wrap { width: min(100%, 430px); }
}

@media (max-width: 620px) {
  .topbar-actions { gap: 3px; }
  .library-launch { width: auto; padding: 0 7px; gap: 4px; }
  .library-label { display: none; }
  .library-count { font-size: 6.5px; min-width: 17px; height: 16px; padding: 0 4px; }
  .stage-head { flex-wrap: wrap; }
  .stage-head-actions { width: 100%; justify-content: flex-end; }
  .finish-launch { width: auto; padding: 0 8px; gap: 5px; }
  .finish-launch span { display: inline; }
  .library-dialog { width: calc(100vw - 10px); max-height: 94vh; border-radius: 16px; }
  .library-shell { min-height: 540px; max-height: 94vh; }
  .library-head { padding: 18px 15px 13px; gap: 8px; }
  .library-head h2 { font-size: 26px; }
  .library-head p { font-size: 9px; }
  .library-head-actions .btn-outline { width: 34px; padding: 0; font-size: 0; }
  .library-head-actions .btn-outline svg { width: 14px; height: 14px; }
  .library-toolbar { padding: 9px 15px; gap: 7px; }
  .library-filters { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .library-filters button { padding: 0 7px; font-size: 6.5px; }
  .library-result-count { margin-left: auto; font-size: 6.5px; }
  .library-grid { grid-template-columns: 1fr 1fr; gap: 7px; padding: 12px 15px 16px; }
  .library-body { padding: 7px 8px 8px; }
  .library-name { font-size: 9.5px; }
  .library-prompt { font-size: 7.5px; }
  .library-meta-row { font-size: 6px; }
  .library-origin { font-size: 5.5px; height: 16px; padding: 0 5px; }
  .library-card-actions button { width: 21px; height: 21px; }
  .library-foot { padding: 8px 15px; font-size: 5.8px; }
  .library-foot > span:last-child { display: none; }
  .finisher-dialog { width: calc(100vw - 10px); max-height: 95vh; border-radius: 16px; }
  .finisher-shell { max-height: 95vh; }
  .finisher-head { padding: 15px 14px 12px; }
  .finisher-head h2 { font-size: 21px; }
  .finisher-head-right { width: 100%; justify-content: space-between; }
  .finisher-face { height: 27px; padding: 0 8px; font-size: 7px; }
  .finisher-body { padding: 11px 14px 16px; }
  .finisher-tools { grid-template-columns: 1fr; }
  .finisher-canvas-foot { font-size: 5.8px; }
  .finisher-canvas-wrap { width: 100%; }
}
.parsed-tag.library {
  color: #b4d58d;
  border-color: rgba(185, 238, 106, 0.2);
  background: rgba(185, 238, 106, 0.045);
}
.parsed-tag.library::before { background: var(--lime); box-shadow: 0 0 6px rgba(185, 238, 106, 0.55); }

/* Fit the six How-it-works cards without a clipped first view. */
.how-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) {
  .how-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .how-grid { grid-template-columns: 1fr; }
  .finisher-actions {
    position: sticky;
    bottom: -1px;
    z-index: 4;
    padding: 9px 0 3px;
    background: #10130d;
    border-top: 1px solid var(--line);
  }
}
.finisher-save-note {
  margin: 0 0 7px;
  color: #596251;
  font-family: var(--font-mono);
  font-size: 6.2px;
  line-height: 1.45;
  letter-spacing: 0.015em;
}
.finisher-save-note span { color: #3f4739; margin: 0 2px; }

/* ---------- Resource-pack builder ---------- */
.pack-dialog {
  width: min(980px, calc(100vw - 24px));
  max-width: none;
  max-height: 90vh;
  padding: 0;
  border: 1px solid rgba(227, 238, 208, 0.17);
  border-radius: 22px;
  background:
    radial-gradient(ellipse 55% 35% at 50% -5%, rgba(185, 238, 106, 0.06), transparent 65%),
    #11140d;
  color: var(--text);
  box-shadow: 0 40px 140px rgba(0,0,0,.74);
  overflow: hidden;
}
.pack-dialog::backdrop { background: rgba(3,5,2,.74); backdrop-filter: blur(9px); }
.pack-dialog[open] { animation: dialog-in 0.34s var(--ease); }
.pack-shell { display: flex; flex-direction: column; max-height: 90vh; }
.pack-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 28px 18px;
  border-bottom: 1px solid var(--line);
}
.pack-kicker { display: flex; align-items: center; gap: 7px; color: var(--lime); font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.16em; }
.pack-kicker > span { width: 5px; height: 5px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 9px rgba(185,238,106,.7); }
.pack-head h2 { margin: 9px 0 5px; font-size: 32px; line-height: 1; letter-spacing: -0.055em; font-weight: 500; }
.pack-head p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.pack-body { display: grid; grid-template-columns: minmax(0, 1fr) 296px; gap: 0; min-height: 0; flex: 1; overflow: hidden; }
.pack-block-column { display: flex; flex-direction: column; min-height: 0; padding: 18px 24px 20px; }
.pack-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--muted); font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.1em; text-transform: uppercase; }
.pack-section-head > span:last-child { color: var(--dim); font-size: 6.5px; letter-spacing: 0.02em; text-transform: none; }
.pack-entries { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; min-height: 170px; max-height: 365px; padding-right: 3px; scrollbar-width: thin; scrollbar-color: #333b2b transparent; }
.pack-entry {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 11px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0c0f09;
  animation: variant-in .3s var(--ease) both;
}
.pack-entry-thumb {
  width: 104px;
  height: 82px;
  border-radius: 6px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    #090b07;
  background-size: 14px 14px;
}
.pack-entry-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pack-entry-main { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.pack-entry-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pack-entry-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); font-size: 11px; font-weight: 500; }
.pack-entry-meta { color: var(--dim); font-family: var(--font-mono); font-size: 6.5px; }
.pack-entry label { display: flex; align-items: center; gap: 6px; margin-top: 1px; color: var(--dim); font-family: var(--font-mono); font-size: 6.5px; letter-spacing: 0.03em; }
.pack-entry select {
  flex: 1;
  min-width: 0;
  height: 29px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  background: var(--panel-deep);
  color: #b9c3ae;
  font-family: var(--font-mono);
  font-size: 7px;
}
.pack-entry select:focus { border-color: rgba(185,238,106,.38); }
.pack-entry-remove {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--dim);
  transition: .18s ease;
}
.pack-entry-remove svg { width: 11px; height: 11px; }
.pack-entry-remove:hover { color: var(--danger); border-color: rgba(239,125,105,.3); }
.pack-empty { display: flex; align-items: center; justify-content: center; min-height: 170px; border: 1px dashed var(--line); border-radius: 9px; color: var(--dim); font-family: var(--font-mono); font-size: 7px; text-align: center; padding: 20px; }
.pack-add { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.pack-add-row { display: flex; gap: 6px; }
.pack-add-row select {
  flex: 1;
  min-width: 0;
  height: 35px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-deep);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 7px;
}
.pack-add-row .btn { height: 35px; flex: 0 0 auto; font-size: 9px; }
.pack-add-row .btn:disabled { opacity: .45; cursor: default; }
.pack-add p { margin: 7px 0 0; color: #596251; font-size: 8px; line-height: 1.45; }
.pack-side { display: flex; flex-direction: column; gap: 13px; padding: 18px 20px 20px; border-left: 1px solid var(--line); background: rgba(8,10,6,.24); overflow-y: auto; }
.pack-setting { }
.pack-formats { display: flex; flex-direction: column; gap: 4px; }
.pack-format-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 43px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10,12,8,.4);
  cursor: pointer;
  transition: .18s ease;
}
.pack-format-card:hover { border-color: rgba(185,238,106,.2); }
.pack-format-card:has(input:checked) { border-color: rgba(185,238,106,.34); background: rgba(185,238,106,.055); }
.pack-format-card input { accent-color: var(--lime); width: 11px; height: 11px; margin: 0; }
.pack-format-card span { display: flex; flex-direction: column; gap: 1px; }
.pack-format-card strong { color: var(--text-soft); font-size: 9.5px; font-weight: 500; }
.pack-format-card small { color: var(--dim); font-family: var(--font-mono); font-size: 6px; }
.pack-format-note { min-height: 33px; margin: 7px 0 0; color: #616a59; font-family: var(--font-mono); font-size: 6.2px; line-height: 1.45; }
.pack-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--line); }
.pack-summary div { display: flex; flex-direction: column; gap: 3px; padding: 9px; background: #0d100a; }
.pack-summary span { color: var(--dim); font-family: var(--font-mono); font-size: 5.8px; letter-spacing: 0.08em; text-transform: uppercase; }
.pack-summary strong { color: #b8c1ae; font-family: var(--font-mono); font-size: 8px; font-weight: 400; }
.pack-tint-note { padding: 10px; border: 1px solid rgba(240,190,101,.14); border-radius: 7px; background: rgba(240,190,101,.03); }
.pack-tint-note > span { color: #d1b47a; font-family: var(--font-mono); font-size: 6px; letter-spacing: 0.1em; text-transform: uppercase; }
.pack-tint-note p { margin: 5px 0 0; color: #897f6e; font-size: 7.5px; line-height: 1.45; }
.pack-export {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: auto;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px;
  background: linear-gradient(180deg, var(--lime-bright), var(--lime));
  color: var(--lime-ink);
  font-size: 10.5px;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(126,192,52,.15);
  transition: .2s var(--ease);
}
.pack-export:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.03); }
.pack-export:disabled { opacity: .45; cursor: default; }
.pack-export svg { width: 14px; height: 14px; }
.pack-export kbd { border-color: rgba(20,30,10,.18); background: rgba(20,30,10,.07); font-size: 6.5px; height: 16px; min-width: 24px; }
.pack-foot { margin: 0; color: #535c4c; font-family: var(--font-mono); font-size: 6px; line-height: 1.5; text-align: center; }
.pack-foot code { color: #7d8972; }

@media (max-width: 900px) {
  .pack-dialog { width: calc(100vw - 18px); max-height: 92vh; }
  .pack-shell { max-height: 92vh; }
  .pack-head { padding: 20px 20px 14px; }
  .pack-body { grid-template-columns: 1fr; overflow-y: auto; }
  .pack-block-column { overflow: visible; padding: 14px 20px; }
  .pack-entries { max-height: none; overflow: visible; }
  .pack-side { border-left: 0; border-top: 1px solid var(--line); padding: 14px 20px 20px; overflow: visible; }
  .pack-formats { display: grid; grid-template-columns: repeat(3, 1fr); }
  .pack-format-card { align-items: flex-start; }
  .pack-export { margin-top: 4px; }
}

@media (max-width: 620px) {
  .pack-dialog { width: calc(100vw - 10px); max-height: 94vh; border-radius: 16px; }
  .pack-shell { max-height: 94vh; }
  .pack-head { padding: 16px 15px 12px; gap: 10px; }
  .pack-head h2 { font-size: 25px; }
  .pack-head p { font-size: 9px; }
  .pack-block-column { padding: 12px 15px; }
  .pack-side { padding: 12px 15px 16px; }
  .pack-entry { grid-template-columns: 82px minmax(0,1fr); gap: 8px; }
  .pack-entry-thumb { width: 82px; height: 72px; }
  .pack-entry-top strong { font-size: 9.5px; }
  .pack-formats { grid-template-columns: 1fr; }
  .pack-format-card { min-height: 39px; flex-direction: row; }
  .pack-add-row { flex-wrap: wrap; }
  .pack-add-row select { flex: 1 1 100%; }
  .pack-add-row .btn { flex: 1; }
  .pack-summary { grid-template-columns: 1fr 1fr; }
  .pack-export { height: 44px; }
}
.pack-tint-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10,12,8,.35);
  cursor: pointer;
  transition: .18s ease;
}
.pack-tint-toggle:hover { border-color: rgba(185,238,106,.2); }
.pack-tint-toggle:has(input:checked) { border-color: rgba(185,238,106,.3); background: rgba(185,238,106,.045); }
.pack-tint-toggle.is-disabled { opacity: .5; cursor: not-allowed; }
.pack-tint-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pack-toggle-track { width: 27px; height: 15px; flex: 0 0 auto; padding: 2px; border-radius: 99px; background: #2a3023; transition: background .2s ease; }
.pack-toggle-track > span { display: block; width: 11px; height: 11px; border-radius: 50%; background: #818b77; transition: transform .2s var(--ease), background .2s ease; }
.pack-tint-toggle input:checked + .pack-toggle-track { background: rgba(185,238,106,.38); }
.pack-tint-toggle input:checked + .pack-toggle-track > span { transform: translateX(12px); background: var(--lime); }
.pack-toggle-copy { display: flex; flex-direction: column; gap: 1px; }
.pack-toggle-copy strong { color: var(--text-soft); font-size: 8.5px; font-weight: 500; }
.pack-toggle-copy small { color: var(--dim); font-family: var(--font-mono); font-size: 5.8px; }
.pack-tint-status { min-height: 19px; margin: 6px 0 0; color: #636a5c; font-family: var(--font-mono); font-size: 6px; line-height: 1.45; }
.pack-tint-status.is-warning { color: #b49159; }
.pack-tint-status.is-on { color: #a7c783; }

/* ---------- AI candidate comparison ---------- */
.ai-concept-count { margin-top: 12px; padding: 9px 12px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(9,11,7,.35); }
.ai-concept-count .ai-blend-head { margin-bottom: 6px; }
.ai-concept-count .ai-blend-head > span:first-child { color: #9ca48f; font-family: var(--font-mono); font-size: 7px; letter-spacing: .08em; text-transform: uppercase; }
.ai-concept-count .ai-blend-head > span:last-child { color: var(--dim); font-family: var(--font-mono); font-size: 6.2px; }
.ai-count-group { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-deep); }
.ai-count-group button { width: 34px; height: 25px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--dim); font-family: var(--font-mono); font-size: 7.5px; transition: .18s ease; }
.ai-count-group button:hover { color: var(--text-soft); }
.ai-count-group button.active { color: #e8c884; border-color: rgba(240,190,101,.22); background: rgba(240,190,101,.07); }
.ai-count-group button:disabled { opacity: .4; cursor: default; }
.ai-candidates { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.ai-candidates[hidden] { display: none; }
.ai-candidates-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ai-candidates-head > div { display: flex; align-items: center; gap: 7px; }
.ai-candidates-head span { color: #b7a575; font-family: var(--font-mono); font-size: 6.3px; letter-spacing: .12em; }
.ai-candidates-head strong { color: var(--dim); font-family: var(--font-mono); font-size: 6.3px; font-weight: 400; }
.ai-add-candidate { height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-family: var(--font-mono); font-size: 6.5px; transition: .18s ease; }
.ai-add-candidate:hover:not(:disabled) { color: var(--amber); border-color: rgba(240,190,101,.28); }
.ai-add-candidate:disabled { opacity: .4; cursor: default; }
.ai-candidate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ai-candidate {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0f09;
  text-align: left;
  transition: .18s ease;
  animation: variant-in .3s var(--ease) both;
  animation-delay: calc(var(--i,0) * 35ms);
}
.ai-candidate:hover { border-color: rgba(240,190,101,.3); transform: translateY(-1px); }
.ai-candidate.is-selected { border-color: rgba(240,190,101,.62); background: rgba(240,190,101,.05); box-shadow: 0 0 0 1px rgba(240,190,101,.1) inset; }
.ai-candidate canvas { width: 100%; height: auto; aspect-ratio: 1.17; display: block; border-radius: 4px; background:
  linear-gradient(rgba(255,255,255,.024) 1px, transparent 1px),
  linear-gradient(90deg, rgba(255,255,255,.024) 1px, transparent 1px),
  #090b07; background-size: 13px 13px; }
.ai-candidate-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 2px; }
.ai-candidate-meta strong { color: var(--muted); font-family: var(--font-ui); font-size: 7.5px; font-weight: 500; }
.ai-candidate.is-selected .ai-candidate-meta strong { color: #e8c884; }
.ai-candidate-meta span { color: var(--dim); font-family: var(--font-mono); font-size: 5.8px; }
.ai-candidate-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.ai-candidate-actions p { margin: 0; color: var(--dim); font-family: var(--font-mono); font-size: 6.2px; line-height: 1.4; }
.ai-use-candidate { height: 31px; flex: 0 0 auto; padding: 0 11px; border: 1px solid rgba(185,238,106,.22); border-radius: 6px; background: rgba(185,238,106,.07); color: #c6e0a2; font-family: var(--font-ui); font-size: 8px; font-weight: 500; transition: .18s ease; }
.ai-use-candidate:hover:not(:disabled) { background: rgba(185,238,106,.13); border-color: rgba(185,238,106,.42); color: var(--lime-bright); }
.ai-use-candidate:disabled { opacity: .4; cursor: default; }
@media (max-width: 620px) {
  .ai-candidate-grid { grid-template-columns: 1fr 1fr; }
  .ai-candidate-actions { align-items: flex-start; flex-direction: column; }
  .ai-use-candidate { width: 100%; }
}

/* ---------- Version history ---------- */
.version-dialog {
  width: min(900px, calc(100vw - 24px));
  max-width: none;
  max-height: 88vh;
  padding: 0;
  border: 1px solid rgba(227,238,208,.17);
  border-radius: 20px;
  background:
    radial-gradient(ellipse 55% 35% at 50% -5%, rgba(185,238,106,.055), transparent 65%),
    #11140d;
  color: var(--text);
  box-shadow: 0 40px 140px rgba(0,0,0,.74);
  overflow: hidden;
}
.version-dialog::backdrop { background: rgba(3,5,2,.74); backdrop-filter: blur(9px); }
.version-dialog[open] { animation: dialog-in .32s var(--ease); }
.version-shell { display: flex; flex-direction: column; max-height: 88vh; }
.version-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 24px 26px 16px; border-bottom: 1px solid var(--line); }
.version-kicker { display: flex; align-items: center; gap: 7px; color: var(--lime); font-family: var(--font-mono); font-size: 6.8px; letter-spacing: .16em; }
.version-kicker > span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 8px rgba(185,238,106,.65); }
.version-head h2 { margin: 8px 0 4px; font-size: 27px; line-height: 1; letter-spacing: -.05em; font-weight: 500; }
.version-head p { margin: 0; color: var(--dim); font-size: 9px; }
.version-head-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.version-head-actions .btn-outline { height: 34px; font-size: 9px; }
.version-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 16px 26px 22px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #333b2b transparent; }
.version-card { display: flex; flex-direction: column; gap: 5px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #0c0f09; }
.version-card.is-current { border-color: rgba(185,238,106,.3); background: rgba(185,238,106,.035); }
.version-card img { width: 100%; aspect-ratio: 1.25; object-fit: cover; display: block; border-radius: 5px; background: #090b07; image-rendering: pixelated; }
.version-card-copy { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 0 2px; }
.version-card-copy strong { color: var(--text-soft); font-size: 8.5px; font-weight: 500; }
.version-card-copy span { color: var(--dim); font-family: var(--font-mono); font-size: 6px; }
.version-card-actions { display: flex; gap: 3px; }
.version-card-actions button { flex: 1; height: 26px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-family: var(--font-mono); font-size: 6.5px; transition: .18s ease; }
.version-card-actions button:hover { color: var(--lime); border-color: rgba(185,238,106,.28); }
.version-card-actions button[data-version-action="restore"] { color: #b6d791; border-color: rgba(185,238,106,.18); background: rgba(185,238,106,.045); }
.version-empty { grid-column: 1 / -1; padding: 40px 20px; text-align: center; color: var(--dim); font-family: var(--font-mono); font-size: 7.5px; }
.version-foot { padding: 9px 26px; border-top: 1px solid var(--line); color: #535c4c; font-family: var(--font-mono); font-size: 6.2px; }
@media (max-width: 700px) {
  .version-dialog { width: calc(100vw - 12px); max-height: 92vh; border-radius: 16px; }
  .version-shell { max-height: 92vh; }
  .version-head { padding: 18px 15px 13px; flex-wrap: wrap; }
  .version-head h2 { font-size: 22px; }
  .version-head-actions { width: 100%; justify-content: space-between; }
  .version-grid { grid-template-columns: 1fr 1fr; padding: 12px 15px 16px; gap: 6px; }
  .version-foot { padding: 8px 15px; }
}
.share-launch {
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.015);
  color: var(--dim);
  transition: .2s ease;
}
.share-launch svg { width: 14px; height: 14px; }
.share-launch:hover { color: var(--lime); border-color: rgba(185,238,106,.3); background: rgba(185,238,106,.045); transform: translateY(-1px); }
.share-launch:disabled { opacity: .45; cursor: wait; transform: none; }
@media (max-width: 620px) {
  .share-launch { width: 35px; height: 35px; flex-basis: 35px; }
}

/* ---------- Keyboard / accessibility polish ---------- */
.shortcut-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8,10,6,.4);
}
.shortcut-sheet > div { display: flex; align-items: center; gap: 4px; min-height: 22px; padding-right: 9px; border-right: 1px solid rgba(255,255,255,.045); }
.shortcut-sheet > div:last-child { border-right: 0; padding-right: 0; }
.shortcut-sheet kbd { min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 4px; border: 1px solid rgba(227,238,208,.16); border-bottom-color: rgba(0,0,0,.4); border-radius: 4px; background: #1a1f15; color: #aeb99d; font-family: var(--font-mono); font-size: 6.5px; box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.shortcut-sheet span { color: var(--dim); font-family: var(--font-mono); font-size: 6.4px; }
:where(button, a, input, select, textarea):focus-visible { outline: 2px solid rgba(185,238,106,.72); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.pack-entry-controls { display: flex; gap: 2px; flex: 0 0 auto; }
.pack-entry-controls button { width: 21px; height: 21px; display: grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--dim); transition: .18s ease; }
.pack-entry-controls button svg { width: 12px; height: 12px; }
.pack-entry-controls button:hover:not(:disabled) { color: var(--text-soft); background: rgba(255,255,255,.04); border-color: var(--line); }
.pack-entry-controls button:disabled { opacity: .25; cursor: default; }
.pack-entry-controls .pack-entry-remove:hover { color: #d98171; border-color: rgba(217,129,113,.22); background: rgba(217,129,113,.05); }

/* ---------- Import existing textures ---------- */
.import-strip { margin-top: 9px; }
.import-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px dashed rgba(227,238,208,.16);
  border-radius: 7px;
  background: rgba(255,255,255,.012);
  color: var(--muted);
  text-align: left;
  transition: .18s ease;
}
.import-button:hover { border-color: rgba(185,238,106,.32); background: rgba(185,238,106,.035); color: var(--text-soft); }
.import-button:disabled { opacity: .5; cursor: wait; }
.import-button > svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--lime); }
.import-button > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.import-button strong { font-size: 8.5px; font-weight: 500; }
.import-button small { color: var(--dim); font-family: var(--font-mono); font-size: 5.8px; }
.import-button kbd { margin-left: auto; min-width: 18px; height: 18px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: rgba(0,0,0,.18); color: var(--dim); font-family: var(--font-mono); font-size: 6px; }
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  background: rgba(4,6,3,.82);
  backdrop-filter: blur(5px);
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-card { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 46px 58px; border: 2px dashed rgba(185,238,106,.48); border-radius: 18px; background: rgba(15,19,11,.82); box-shadow: 0 30px 90px rgba(0,0,0,.5); }
.drop-card svg { width: 30px; height: 30px; color: var(--lime); }
.drop-card strong { font-size: 20px; letter-spacing: -.04em; font-weight: 500; }
.drop-card span { color: var(--dim); font-family: var(--font-mono); font-size: 7px; }
body.is-dragging-file .drop-overlay { display: grid; }
.variation-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 170px; padding: 22px; border: 1px dashed rgba(227,238,208,.13); border-radius: 9px; text-align: center; background: rgba(7,9,5,.28); }
.variation-empty span { color: #8d997c; font-family: var(--font-mono); font-size: 6.5px; letter-spacing: .14em; }
.variation-empty p { max-width: 240px; margin: 0; color: var(--dim); font-size: 8.5px; line-height: 1.6; }
.footer-version { display: inline-flex; align-items: center; justify-content: flex-end; gap: 9px; }
.footer-update { padding: 0; border: 0; border-bottom: 1px dotted rgba(185,238,106,.35); background: none; color: #9cbd78; font-family: var(--font-mono); font-size: 6.5px; letter-spacing: .04em; }
.footer-update:hover { color: var(--lime); border-bottom-color: rgba(185,238,106,.7); }
.footer-update:disabled { opacity: .55; cursor: wait; }

@supports (padding: env(safe-area-inset-top)) {
  body { padding-top: env(safe-area-inset-top); padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left); }
}
.footer-api { color: #8ba071; font-family: var(--font-mono); font-size: 6.5px; text-decoration: none; border-bottom: 1px dotted rgba(185,238,106,.25); }
.footer-api:hover { color: var(--lime); border-bottom-color: rgba(185,238,106,.65); }

.material-search { display: block; margin: 0 0 9px; }
.material-search input { width: 100%; height: 29px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; background: rgba(8,10,6,.45); color: var(--text-soft); font-family: var(--font-mono); font-size: 7px; outline: none; }
.material-search input::placeholder { color: var(--dim); }
.material-search input:focus { border-color: rgba(185,238,106,.38); }

/* ---------- Item / weapon studio ---------- */
.item-studio-button { margin-top: 6px; }
.item-studio-button > svg { color: #d6a65c; }
.item-dialog { width: min(920px, calc(100vw - 24px)); max-width: none; max-height: 90vh; padding: 0; border: 1px solid rgba(227,238,208,.17); border-radius: 20px; background: radial-gradient(ellipse 50% 35% at 50% -5%, rgba(214,166,92,.07), transparent 65%), #11140d; color: var(--text); box-shadow: 0 40px 140px rgba(0,0,0,.74); overflow: hidden; }
.item-dialog::backdrop { background: rgba(3,5,2,.74); backdrop-filter: blur(9px); }
.item-dialog[open] { animation: dialog-in .32s var(--ease); }
.item-shell { display: flex; flex-direction: column; max-height: 90vh; }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 25px 15px; border-bottom: 1px solid var(--line); }
.item-kicker { display: flex; align-items: center; gap: 7px; color: #d6a65c; font-family: var(--font-mono); font-size: 6.8px; letter-spacing: .16em; }
.item-kicker > span { width: 4px; height: 4px; border-radius: 50%; background: #d6a65c; box-shadow: 0 0 8px rgba(214,166,92,.6); }
.item-head h2 { margin: 8px 0 4px; font-size: 27px; line-height: 1; letter-spacing: -.05em; font-weight: 500; }
.item-head p { margin: 0; color: var(--dim); font-size: 9px; }
.item-body { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; padding: 17px 25px 22px; overflow-y: auto; }
.item-controls { display: flex; flex-direction: column; gap: 11px; }
.item-control-block { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(8,10,6,.35); }
.item-control-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-family: var(--font-mono); font-size: 6.5px; letter-spacing: .08em; text-transform: uppercase; }
.item-control-head span:last-child { color: var(--dim); text-transform: none; letter-spacing: 0; }
.item-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.item-type-grid button { height: 33px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-family: var(--font-ui); font-size: 8px; transition: .18s ease; }
.item-type-grid button:hover { border-color: rgba(214,166,92,.3); color: var(--text-soft); }
.item-type-grid button.active { border-color: rgba(214,166,92,.42); background: rgba(214,166,92,.09); color: #f0d29a; }
.item-field { display: flex; align-items: center; gap: 8px; margin: 0 0 7px; color: var(--dim); font-family: var(--font-mono); font-size: 6.5px; }
.item-field:last-child { margin-bottom: 0; }
.item-field > span { flex: 0 0 68px; }
.item-field select, .item-field input { flex: 1; min-width: 0; height: 28px; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; background: #0c0f09; color: var(--text-soft); font-family: var(--font-mono); font-size: 7px; outline: none; }
.item-field select:focus, .item-field input:focus { border-color: rgba(214,166,92,.38); }
.item-inline { display: flex; align-items: flex-end; gap: 5px; }
.item-inline .item-field { flex: 1; margin: 0; }
.item-inline .item-field > span { flex: 0 0 auto; }
.item-seed { flex: 1 1 auto !important; }
.item-size { flex: 0 0 74px !important; }
.item-dice { width: 28px; height: 28px; flex: 0 0 28px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-size: 13px; line-height: 1; }
.item-dice:hover { color: #f0d29a; border-color: rgba(214,166,92,.3); }
.item-note { color: var(--dim); font-family: var(--font-mono); font-size: 5.8px; line-height: 1.5; }
.item-note code { color: #a7b494; font-size: 5.6px; }
.item-preview-panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.item-preview-frame { display: grid; place-items: center; min-height: 300px; border: 1px solid var(--line); border-radius: 10px; background-color: #0b0d08; background-image: linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.035) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.035) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.035) 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
.item-preview-frame canvas { width: min(100%, 384px); height: auto; image-rendering: pixelated; }
.item-preview-meta { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 0 3px; }
.item-preview-meta h3 { margin: 0; font-size: 20px; line-height: 1; letter-spacing: -.04em; font-weight: 500; }
.item-preview-meta p { margin: 4px 0 0; color: #a5b294; font-family: var(--font-mono); font-size: 6.5px; }
.item-palette { display: flex; gap: 3px; }
.item-palette span { width: 14px; height: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 3px; }
.item-actions { display: flex; gap: 6px; }
.item-actions .btn { flex: 1; height: 34px; font-size: 8.5px; }
.item-actions .btn-primary { border-color: rgba(214,166,92,.28); background: rgba(214,166,92,.09); color: #f0d29a; }
@media (max-width: 760px) {
  .item-dialog { width: calc(100vw - 12px); max-height: 94vh; border-radius: 16px; }
  .item-shell { max-height: 94vh; }
  .item-head { padding: 17px 15px 12px; }
  .item-head h2 { font-size: 22px; }
  .item-body { grid-template-columns: 1fr; padding: 12px 15px 16px; gap: 12px; }
  .item-preview-frame { min-height: 220px; }
  .item-actions { flex-wrap: wrap; }
  .item-actions .btn { flex: 1 1 45%; }
}
.item-target-field input { font-size: 6.5px; color: #a5b294; }
.item-variants-wrap { margin-top: 2px; }
.item-variants-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; color: #d6a65c; font-family: var(--font-mono); font-size: 6.2px; letter-spacing: .08em; }
.item-variants-head span:last-child { color: var(--dim); letter-spacing: 0; text-transform: none; }
.item-variants-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.item-variant { position: relative; aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: 4px; background-color: #0b0d08; background-image: linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.035) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.035) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.035) 75%); background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0; transition: .15s ease; }
.item-variant canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.item-variant:hover { border-color: rgba(214,166,92,.38); transform: translateY(-1px); }
.item-variant.is-current { border-color: rgba(214,166,92,.65); box-shadow: 0 0 0 1px rgba(214,166,92,.15) inset; }
@media (max-width: 760px) { .item-variants-grid { grid-template-columns: repeat(8, 1fr); gap: 3px; } }

/* ---------- 16-variant block sheet ---------- */
.variant-sheet-btn { height: 24px; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--dim); font-family: var(--font-mono); font-size: 6.4px; transition: .18s ease; }
.variant-sheet-btn:hover:not(:disabled) { color: var(--lime); border-color: rgba(185,238,106,.3); }
.variant-sheet-btn:disabled { opacity: .3; cursor: default; }
.variant-sheet-dialog { width: min(960px, calc(100vw - 24px)); max-width: none; max-height: 90vh; padding: 0; border: 1px solid rgba(227,238,208,.17); border-radius: 20px; background: #11140d; color: var(--text); box-shadow: 0 40px 140px rgba(0,0,0,.74); overflow: hidden; }
.variant-sheet-dialog::backdrop { background: rgba(3,5,2,.74); backdrop-filter: blur(9px); }
.variant-sheet-dialog[open] { animation: dialog-in .32s var(--ease); }
.variant-sheet-shell { display: flex; flex-direction: column; max-height: 90vh; }
.variant-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 25px 14px; border-bottom: 1px solid var(--line); }
.variant-sheet-kicker { display: flex; align-items: center; gap: 7px; color: var(--lime); font-family: var(--font-mono); font-size: 6.8px; letter-spacing: .16em; }
.variant-sheet-kicker span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); }
.variant-sheet-head h2 { margin: 8px 0 3px; font-size: 27px; line-height: 1; letter-spacing: -.05em; font-weight: 500; }
.variant-sheet-head p { margin: 0; color: var(--dim); font-size: 9px; }
.variant-sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 15px 25px 20px; overflow-y: auto; }
.variant-sheet-card { display: flex; flex-direction: column; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: #0c0f09; transition: .18s ease; }
.variant-sheet-card:hover { border-color: rgba(185,238,106,.35); transform: translateY(-1px); }
.variant-sheet-card.is-current { border-color: rgba(185,238,106,.6); box-shadow: 0 0 0 1px rgba(185,238,106,.12) inset; }
.variant-sheet-card canvas { width: 100%; height: auto; aspect-ratio: 1.2; display: block; border-radius: 4px; background: #090b07; image-rendering: pixelated; }
.variant-sheet-card span { color: var(--dim); font-family: var(--font-mono); font-size: 6px; text-align: right; }
.variant-sheet-foot { padding: 9px 25px; border-top: 1px solid var(--line); color: #535c4c; font-family: var(--font-mono); font-size: 6.2px; }
@media (max-width: 700px) { .variant-sheet-dialog { width: calc(100vw - 12px); max-height: 94vh; border-radius: 16px; } .variant-sheet-shell { max-height: 94vh; } .variant-sheet-head { padding: 16px 14px 11px; } .variant-sheet-head h2 { font-size: 22px; } .variant-sheet-grid { grid-template-columns: repeat(3, 1fr); padding: 11px 14px 15px; gap: 5px; } .variant-sheet-foot { padding: 8px 14px; } }

/* ---------- Universal texture packer ---------- */
.any-pack-button { margin-top: 6px; }
.any-pack-button > svg { color: #8ab7ff; }
.any-pack-dialog { width: min(820px, calc(100vw - 24px)); max-width: none; max-height: 90vh; padding: 0; border: 1px solid rgba(227,238,208,.17); border-radius: 20px; background: #11140d; color: var(--text); box-shadow: 0 40px 140px rgba(0,0,0,.74); overflow: hidden; }
.any-pack-dialog::backdrop { background: rgba(3,5,2,.74); backdrop-filter: blur(9px); }
.any-pack-dialog[open] { animation: dialog-in .32s var(--ease); }
.any-pack-shell { display: flex; flex-direction: column; max-height: 90vh; }
.any-pack-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 25px 15px; border-bottom: 1px solid var(--line); }
.any-pack-kicker { display: flex; align-items: center; gap: 7px; color: #8ab7ff; font-family: var(--font-mono); font-size: 6.8px; letter-spacing: .16em; }
.any-pack-kicker > span { width: 4px; height: 4px; border-radius: 50%; background: #8ab7ff; }
.any-pack-head h2 { margin: 8px 0 4px; font-size: 27px; line-height: 1; letter-spacing: -.05em; font-weight: 500; }
.any-pack-head p { margin: 0; max-width: 600px; color: var(--dim); font-size: 9px; line-height: 1.5; }
.any-pack-body { display: flex; flex-direction: column; gap: 12px; padding: 15px 25px 18px; overflow-y: auto; }
.any-pack-settings { display: flex; flex-direction: column; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(8,10,6,.35); }
.any-pack-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.any-pack-add-row { display: flex; align-items: center; gap: 8px; }
.any-pack-add-row .btn { height: 30px; font-size: 7.5px; }
.any-pack-add-row > span { color: var(--dim); font-family: var(--font-mono); font-size: 5.8px; }
.any-pack-list { display: flex; flex-direction: column; gap: 5px; }
.any-entry { display: grid; grid-template-columns: 42px minmax(0,1fr) 26px; gap: 8px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #0c0f09; }
.any-entry-thumb { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; background-color: #090b07; background-image: linear-gradient(45deg,rgba(255,255,255,.05) 25%,transparent 25%),linear-gradient(-45deg,rgba(255,255,255,.05) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,rgba(255,255,255,.05) 75%),linear-gradient(-45deg,transparent 75%,rgba(255,255,255,.05) 75%); background-size: 10px 10px; background-position: 0 0,0 5px,5px -5px,-5px 0; overflow: hidden; }
.any-entry-thumb img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.any-entry-thumb span { color: #8ab7ff; font-family: var(--font-mono); font-size: 5.5px; }
.any-entry-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.any-entry-main input { width: 100%; height: 23px; padding: 0 6px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: #a5b294; font-family: var(--font-mono); font-size: 6.2px; outline: none; }
.any-entry-main input:hover, .any-entry-main input:focus { border-color: var(--line); background: #090b07; }
.any-entry-main small { color: #535c4c; font-family: var(--font-mono); font-size: 5.5px; padding-left: 6px; }
.any-entry-remove { width: 24px; height: 24px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--dim); font-size: 14px; line-height: 1; }
.any-entry-remove:hover { color: #ff8a7a; border-color: rgba(255,138,122,.25); }
.any-pack-empty { display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; min-height: 100px; border: 1px dashed var(--line); border-radius: 8px; color: var(--dim); font-family: var(--font-mono); font-size: 6px; text-align: center; }
.any-pack-empty strong { color: var(--muted); font-family: var(--font-ui); font-size: 11px; font-weight: 500; }
.any-pack-empty[hidden] { display: none; }
.any-pack-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 25px; border-top: 1px solid var(--line); color: var(--dim); font-family: var(--font-mono); font-size: 6.4px; }
.any-pack-foot .btn { height: 32px; font-size: 8px; }
@media (max-width: 720px) { .any-pack-dialog { width: calc(100vw - 12px); max-height: 94vh; border-radius: 16px; } .any-pack-shell { max-height: 94vh; } .any-pack-head { padding: 16px 14px 11px; } .any-pack-head h2 { font-size: 22px; } .any-pack-body { padding: 11px 14px 14px; } .any-pack-row { grid-template-columns: 1fr; } .any-pack-foot { padding: 9px 14px; } }

/* ---------- Theme motif sheets ---------- */
.theme-studio-button { margin-top: 6px; }
.theme-studio-button > svg { color: #e7b75c; }
.theme-dialog { width: min(980px, calc(100vw - 24px)); max-width: none; max-height: 92vh; padding: 0; border: 1px solid rgba(227,238,208,.17); border-radius: 20px; background: #11140d; color: var(--text); box-shadow: 0 40px 140px rgba(0,0,0,.74); overflow: hidden; }
.theme-dialog::backdrop { background: rgba(3,5,2,.74); backdrop-filter: blur(9px); }
.theme-dialog[open] { animation: dialog-in .32s var(--ease); }
.theme-shell { display: flex; flex-direction: column; max-height: 92vh; }
.theme-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 25px 14px; border-bottom: 1px solid var(--line); }
.theme-kicker { display: flex; align-items: center; gap: 7px; color: #e7b75c; font-family: var(--font-mono); font-size: 6.8px; letter-spacing: .16em; }
.theme-kicker span { width: 4px; height: 4px; border-radius: 50%; background: #e7b75c; }
.theme-head h2 { margin: 8px 0 3px; font-size: 27px; line-height: 1; letter-spacing: -.05em; font-weight: 500; }
.theme-head p { margin: 0; color: var(--dim); font-size: 9px; line-height: 1.5; }
.theme-tabs { display: flex; gap: 4px; padding: 10px 25px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.theme-tab { flex: 0 0 auto; height: 29px; padding: 0 11px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--dim); font-family: var(--font-mono); font-size: 6.6px; }
.theme-tab.active { color: #f0d29a; border-color: rgba(231,183,92,.4); background: rgba(231,183,92,.08); }
.theme-body { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 16px; padding: 15px 25px 20px; overflow-y: auto; }
.theme-preview-panel { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.theme-preview-frame { display: grid; place-items: center; min-height: 310px; border: 1px solid var(--line); border-radius: 10px; background: #0b0d08; }
.theme-preview-frame canvas { width: min(100%, 384px); height: auto; image-rendering: pixelated; }
.theme-preview-meta { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.theme-preview-meta h3 { margin: 0; font-size: 19px; line-height: 1; letter-spacing: -.04em; font-weight: 500; }
.theme-preview-meta p { margin: 4px 0 0; color: #a5b294; font-family: var(--font-mono); font-size: 6.2px; }
.theme-palette { display: flex; gap: 3px; }
.theme-palette span { width: 14px; height: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 3px; }
.theme-actions { display: flex; gap: 6px; }
.theme-actions .btn { flex: 1; height: 34px; font-size: 8px; }
.theme-actions .btn-primary { border-color: rgba(231,183,92,.28); background: rgba(231,183,92,.09); color: #f0d29a; }
.theme-grid-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.theme-grid-head { display: flex; justify-content: space-between; color: #e7b75c; font-family: var(--font-mono); font-size: 6.2px; letter-spacing: .08em; }
.theme-grid-head span:last-child { color: var(--dim); letter-spacing: 0; }
.theme-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; }
.theme-card { padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: #0c0f09; }
.theme-card:hover { border-color: rgba(231,183,92,.38); }
.theme-card.is-current { border-color: rgba(231,183,92,.65); }
.theme-card canvas { width: 100%; height: auto; aspect-ratio: 1; display: block; image-rendering: pixelated; border-radius: 3px; }
.theme-seed-row { display: flex; align-items: flex-end; gap: 5px; margin-top: 4px; }
.theme-seed-row .item-field { flex: 1; margin: 0; }
.theme-seed-row .item-field > span { flex: 0 0 auto; }
.theme-format { flex: 0 0 140px !important; }
@media (max-width: 760px) { .theme-dialog { width: calc(100vw - 12px); max-height: 94vh; border-radius: 16px; } .theme-shell { max-height: 94vh; } .theme-head { padding: 16px 14px 11px; } .theme-head h2 { font-size: 22px; } .theme-tabs { padding: 8px 14px; } .theme-body { grid-template-columns: 1fr; padding: 11px 14px 15px; } .theme-preview-frame { min-height: 220px; } .theme-grid { grid-template-columns: repeat(4,1fr); } .theme-format { flex: 1 1 auto !important; } }
.any-pack-template { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(8,10,6,.35); }
.any-pack-template-head { display: flex; justify-content: space-between; gap: 8px; color: #8ab7ff; font-family: var(--font-mono); font-size: 6.2px; letter-spacing: .08em; margin-bottom: 6px; }
.any-pack-template-head span:last-child { color: var(--dim); letter-spacing: 0; text-transform: none; }
.any-pack-template-row { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.any-pack-template-row select { flex: 1 1 220px; height: 29px; border: 1px solid var(--line); border-radius: 4px; background: #0c0f09; color: var(--text-soft); font-family: var(--font-mono); font-size: 6.5px; padding: 0 6px; }
.any-pack-template-row .btn { height: 29px; font-size: 7px; }

/* ---------- Global UI text scale ---------- */
body { zoom: var(--ui-zoom, 1.2); }

/* Legibility floor for the smallest labels. */
small { font-size: 9px !important; }
.make-copy small { font-size: 8.5px !important; }
.make-copy strong { font-size: 11px; }
.make-card em { font-size: 8px; }
.make-title-row p { font-size: 11px; }
.make-kicker, .eyebrow { font-size: 8.5px; }
.shortcut-note { font-size: 8.5px; }
.variations-sub { font-size: 11px; }
.dna-row { font-size: 9px; }
.field-label { font-size: 8.5px; }
.item-field { font-size: 8px; }
.item-control-head { font-size: 8px; }
.item-note { font-size: 8px; }
.footer-version, .site-footer { font-size: 8.5px; }
.material-option span { font-size: 8px; }

/* ---------- Front-page capability map ---------- */
.make-strip { padding: 18px 24px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(15,18,11,.55), rgba(9,11,7,.2)); }
.make-head { max-width: 1400px; margin: 0 auto 10px; }
.make-kicker { display: flex; align-items: center; gap: 7px; color: var(--lime); font-family: var(--font-mono); font-size: 6.8px; letter-spacing: .16em; }
.make-kicker span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 8px rgba(185,238,106,.6); }
.make-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-top: 5px; }
.make-title-row h2 { margin: 0; font-size: 24px; line-height: 1; letter-spacing: -.05em; font-weight: 500; }
.make-title-row p { margin: 0; color: var(--dim); font-size: 9px; line-height: 1.45; max-width: 520px; text-align: right; }
.make-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 6px; max-width: 1400px; margin: 0 auto; }
.make-card { display: grid; grid-template-columns: 27px minmax(0,1fr); grid-template-rows: 1fr auto; gap: 2px 8px; min-height: 82px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: #0d100a; text-align: left; color: var(--muted); transition: .18s ease; }
.make-card:hover { border-color: rgba(185,238,106,.3); background: #11150d; transform: translateY(-1px); }
.make-icon { grid-row: 1 / span 2; display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid var(--line); border-radius: 5px; color: #8fa57a; background: rgba(8,10,6,.4); }
.make-icon svg { width: 16px; height: 16px; }
.make-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.make-copy strong { color: var(--text-soft); font-family: var(--font-ui); font-size: 10px; font-weight: 500; line-height: 1.1; }
.make-copy small { color: var(--dim); font-family: var(--font-mono); font-size: 5.8px; line-height: 1.35; }
.make-card em { grid-column: 2; color: #68745d; font-family: var(--font-mono); font-size: 5.6px; font-style: normal; letter-spacing: .04em; text-transform: uppercase; }
.make-generate .make-icon { color: var(--lime); border-color: rgba(185,238,106,.22); }
.make-generate em { color: #9fc36d; }
.make-pack .make-icon { color: #8ab7ff; border-color: rgba(138,183,255,.25); }
.make-pack em { color: #8ab7ff; }
@media (max-width: 1080px) { .make-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } .make-title-row p { max-width: 380px; } }
@media (max-width: 800px) { .make-grid { grid-template-columns: repeat(3, minmax(0,1fr)); } .make-title-row { align-items: flex-start; flex-direction: column; gap: 2px; } .make-title-row p { text-align: left; } }
@media (max-width: 560px) { .make-strip { padding: 13px 11px 12px; } .make-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .make-title-row h2 { font-size: 21px; } .make-card { min-height: 86px; padding: 8px; } .make-copy small { font-size: 5.5px; } }
.any-pack-health.is-warning { color: #ffbd6b; }
.any-pack-health.is-ok { color: #9fc36d; }
.any-entry-warning { color: #ffbd6b !important; }

.make-copy strong { font-size: 11px !important; }
@media (max-width: 560px) {
  .make-grid { display: flex; overflow-x: auto; gap: 6px; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .make-card { flex: 0 0 150px; min-height: 92px; scroll-snap-align: start; }
}

/* ---------- Pixel editor ---------- */
.pixel-dialog { width: min(1100px, calc(100vw - 24px)); max-width: none; max-height: 92vh; padding: 0; border: 1px solid rgba(227,238,208,.17); border-radius: 18px; background: #11140d; color: var(--text); box-shadow: 0 40px 140px rgba(0,0,0,.74); overflow: hidden; }
.pixel-dialog::backdrop { background: rgba(3,5,2,.78); backdrop-filter: blur(9px); }
.pixel-dialog[open] { animation: dialog-in .3s var(--ease); }
.pixel-shell { display: flex; flex-direction: column; max-height: 92vh; }
.pixel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 22px 13px; border-bottom: 1px solid var(--line); }
.pixel-kicker { display: flex; align-items: center; gap: 6px; color: var(--lime); font-family: var(--font-mono); font-size: 8px; letter-spacing: .14em; }
.pixel-kicker span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); }
.pixel-head h2 { margin: 7px 0 2px; font-size: 24px; line-height: 1; letter-spacing: -.045em; font-weight: 500; }
.pixel-head p { margin: 0; color: var(--dim); font-family: var(--font-mono); font-size: 8px; }
.pixel-body { display: grid; grid-template-columns: 40px minmax(0,1fr) 235px; gap: 12px; padding: 13px 22px 15px; overflow: auto; }
.pixel-tools { display: flex; flex-direction: column; gap: 5px; }
.pixel-tools button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-size: 17px; line-height: 1; }
.pixel-tools button:hover { color: var(--text-soft); border-color: rgba(185,238,106,.3); }
.pixel-tools button.active { color: var(--lime); border-color: rgba(185,238,106,.45); background: rgba(185,238,106,.08); }
.pixel-tools button:disabled { opacity: .3; }
.pixel-tools-sep { height: 1px; background: var(--line); margin: 3px 0; }
.pixel-stage { display: grid; place-items: center; min-height: 360px; border: 1px solid var(--line); border-radius: 9px; background-color: #0b0d08; background-image: linear-gradient(45deg, rgba(255,255,255,.06) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.06) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.06) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.06) 75%); background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0; overflow: auto; }
.pixel-stage canvas { width: auto; max-width: 100%; height: auto; image-rendering: pixelated; touch-action: none; cursor: crosshair; }
.pixel-side { display: flex; flex-direction: column; gap: 9px; }
.pixel-section { padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: rgba(8,10,6,.35); }
.pixel-section-head { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 7px; text-transform: uppercase; letter-spacing: .06em; }
.pixel-section-head span:last-child { color: var(--dim); text-transform: none; letter-spacing: 0; }
.pixel-color-row { display: flex; gap: 6px; align-items: center; }
.pixel-color-row input[type=color] { width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 4px; background: transparent; padding: 2px; }
.pixel-color-row input[type=range] { flex: 1; accent-color: var(--lime); }
.pixel-palette { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.pixel-palette button { width: 18px; height: 18px; border: 1px solid rgba(255,255,255,.15); border-radius: 3px; }
.pixel-frames { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.pixel-frames button { width: 28px; height: 26px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--dim); font-family: var(--font-mono); font-size: 8px; }
.pixel-frames button.active { color: var(--lime); border-color: rgba(185,238,106,.45); background: rgba(185,238,106,.08); }
.pixel-frame-actions { display: flex; gap: 4px; margin-bottom: 6px; }
.pixel-frame-actions .btn { flex: 1; height: 26px; font-size: 7px; }
.pixel-actions { display: flex; flex-direction: column; gap: 5px; margin-top: auto; }
.pixel-actions .btn { height: 32px; font-size: 8px; }
.pixel-foot { display: flex; justify-content: space-between; gap: 10px; padding: 8px 22px; border-top: 1px solid var(--line); color: var(--dim); font-family: var(--font-mono); font-size: 8px; }
@media (max-width: 760px) { .pixel-dialog { width: calc(100vw - 10px); max-height: 94vh; border-radius: 14px; } .pixel-shell { max-height: 94vh; } .pixel-body { grid-template-columns: 36px minmax(0,1fr); padding: 10px 12px; } .pixel-side { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; } .pixel-actions { grid-column: 1 / -1; flex-direction: row; } .pixel-actions .btn { flex: 1; } .pixel-stage { min-height: 240px; } .pixel-stage canvas { width: min(100%, 320px); } .pixel-tools button { width: 30px; height: 30px; } .pixel-head { padding: 14px 13px 10px; } .pixel-foot { padding: 7px 13px; } }
.any-pack-foot-actions { display: flex; gap: 5px; align-items: center; }
.any-pack-foot-actions .btn { height: 30px; }
#anyPackDraftState { color: #68745d; }
.any-entry { grid-template-columns: 42px minmax(0,1fr) 24px 26px !important; }
.any-entry-edit { width: 24px; height: 24px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--dim); font-size: 12px; line-height: 1; }
.any-entry-edit:hover { color: var(--lime); border-color: rgba(185,238,106,.3); }
@media (max-width: 560px) { .any-pack-foot { flex-wrap: wrap; } .any-pack-foot-actions { width: 100%; } .any-pack-foot-actions .btn { flex: 1; } }

/* ---------- Pack snapshot history ---------- */
.pack-history-dialog { width: min(720px, calc(100vw - 24px)); max-height: 80vh; padding: 0; border: 1px solid rgba(227,238,208,.17); border-radius: 16px; background: #11140d; color: var(--text); box-shadow: 0 40px 120px rgba(0,0,0,.7); overflow: hidden; }
.pack-history-dialog::backdrop { background: rgba(3,5,2,.72); backdrop-filter: blur(8px); }
.pack-history-shell { display: flex; flex-direction: column; max-height: 80vh; }
.pack-history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 22px 12px; border-bottom: 1px solid var(--line); }
.pack-history-kicker { display: flex; gap: 6px; align-items: center; color: #8ab7ff; font-family: var(--font-mono); font-size: 8px; letter-spacing: .14em; }
.pack-history-kicker span { width: 4px; height: 4px; border-radius: 50%; background: #8ab7ff; }
.pack-history-head h2 { margin: 7px 0 2px; font-size: 23px; line-height: 1; letter-spacing: -.04em; font-weight: 500; }
.pack-history-head p { margin: 0; color: var(--dim); font-size: 9px; }
.pack-history-list { display: flex; flex-direction: column; gap: 5px; padding: 12px 22px 16px; overflow-y: auto; }
.pack-history-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #0c0f09; }
.pack-history-item strong { display: block; color: var(--text-soft); font-size: 10px; font-weight: 500; }
.pack-history-item small { color: var(--dim); font-family: var(--font-mono); font-size: 8px; }
.pack-history-actions { display: flex; gap: 4px; }
.pack-history-actions .btn { height: 27px; font-size: 7px; }
.pack-history-empty { padding: 32px 22px; color: var(--dim); font-family: var(--font-mono); font-size: 9px; text-align: center; }
.pack-history-empty[hidden] { display: none; }
@media (max-width: 560px) { .pack-history-dialog { width: calc(100vw - 10px); } .pack-history-head { padding: 14px 13px 10px; } .pack-history-list { padding: 10px 13px 13px; } .pack-history-item { grid-template-columns: 1fr; } .pack-history-actions .btn { flex: 1; } }

/* ---------- Item motif studio ---------- */
.item-motif-button { margin-top: 6px; }
.item-motif-button > svg { color: #d8a0e8; }
.item-motif-frame { background-color: #0b0d08; background-image: linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.05) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.05) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.05) 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.item-motif-frame canvas { image-rendering: pixelated; }
.item-card { padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: #0c0f09; }
.item-card:hover { border-color: rgba(216,160,232,.38); }
.item-card.is-current { border-color: rgba(216,160,232,.65); }
.item-card-canvas { aspect-ratio: 1; display: grid; place-items: center; background-color: #090b07; background-image: linear-gradient(45deg, rgba(255,255,255,.04) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.04) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.04) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.04) 75%); background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0; border-radius: 3px; overflow: hidden; }
.item-motif-dialog .theme-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .item-motif-dialog .theme-grid { grid-template-columns: repeat(4, 1fr); } }
