:root {
  --paper: #e9dfcf;
  --surface: #fffaf0;
  --ink: #171219;
  --muted: #746b70;
  --line: #c9bcaa;
  --main: #f3ead5;
  --accent: #f47721;
  --violet: #67408d;
  --night: #171219;
  --panel: #25192a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --motion-speed: 1;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgb(103 64 141 / 16%), transparent 34rem),
    radial-gradient(circle at 94% 6%, rgb(244 119 33 / 15%), transparent 32rem),
    var(--paper);
  font-family: "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
}

button,
input,
a { font: inherit; }

button { color: inherit; }

button:focus-visible,
input:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 4px solid #2769ff;
  outline-offset: 3px;
}

.page {
  width: min(1650px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 80px;
}

.hero {
  position: relative;
  display: flex;
  min-height: 274px;
  padding: 38px 40px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  border: 1px solid #3d2c43;
  border-radius: 28px;
  color: var(--main);
  background:
    radial-gradient(circle at 83% 30%, #f7d888 0 46px, transparent 47px),
    radial-gradient(circle at 86% 26%, #171219 0 43px, transparent 44px),
    linear-gradient(145deg, #171219, #281832 68%, #3a203d);
  box-shadow: 0 22px 65px rgb(42 24 32 / 20%);
  overflow: hidden;
}

.hero::after {
  position: absolute;
  right: -2%;
  bottom: -26px;
  width: 43%;
  height: 108px;
  background: #0d0a0f;
  clip-path: polygon(0 100%, 0 72%, 9% 72%, 9% 52%, 13% 52%, 13% 70%, 25% 70%, 25% 38%, 29% 38%, 29% 67%, 41% 67%, 41% 48%, 45% 48%, 45% 70%, 58% 70%, 58% 24%, 62% 24%, 62% 65%, 74% 65%, 74% 43%, 79% 43%, 79% 68%, 90% 68%, 90% 52%, 95% 52%, 95% 70%, 100% 70%, 100% 100%);
  content: "";
  opacity: .62;
}

.hero-copy { position: relative; z-index: 2; min-width: 0; }

.eyebrow,
.collection-heading p,
.control-label {
  margin: 0;
  color: #7b4aa2;
  font: 900 12px/1.2 var(--mono);
  letter-spacing: .13em;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: #ffb06f;
}

.eyebrow i {
  position: relative;
  width: 19px;
  height: 19px;
  border: 2px solid var(--accent);
  border-radius: 50% 50% 45% 45%;
}

.eyebrow i::after {
  position: absolute;
  inset: 6px -7px -7px 6px;
  z-index: -1;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

h1 {
  margin: 0;
  color: #fff9eb;
  font-size: min(5.5vw, 86px);
  line-height: .95;
  letter-spacing: 0;
  white-space: nowrap;
}

.lead {
  margin: 21px 0 0;
  color: #bdb2bd;
  font-size: clamp(17px, 1.7vw, 26px);
  font-weight: 750;
}

.lead strong { color: #fff5df; }

.hero-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.hero-actions button {
  min-height: 49px;
  padding: 0 17px;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 14px;
  background: rgb(255 250 240 / 94%);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.hero-actions button.accent { border-color: var(--accent); background: var(--accent); color: #171219; }

.pack-count {
  display: flex;
  min-height: 49px;
  padding: 0 13px;
  align-items: center;
  gap: 9px;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 14px;
  background: rgb(255 255 255 / 9%);
}

.pack-count b { color: #ff9a4e; font: 900 25px/1 var(--mono); }
.pack-count small { max-width: 50px; font: 900 10px/1.1 var(--mono); }

.hero-bat {
  position: absolute;
  z-index: 1;
  width: 72px;
  color: var(--accent);
  transform-origin: center;
  pointer-events: none;
}

.bat-one { top: 31px; right: 24%; transform: rotate(-16deg); }
.bat-two { top: 86px; right: 16%; width: 46px; color: #9b70bd; }
.hero-bat svg { display: block; width: 100%; fill: currentColor; filter: drop-shadow(0 5px 8px rgb(0 0 0 / 32%)); }

.collection,
.how-to {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 18px 55px rgb(48 32 29 / 12%);
}

.collection { margin-top: 22px; }

.collection-heading {
  display: flex;
  min-height: 105px;
  padding: 18px 28px;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.collection-heading.compact { min-height: 91px; }

.section-number {
  display: grid;
  flex: 0 0 auto;
  width: 53px;
  height: 53px;
  place-items: center;
  border-radius: 50%;
  background: #241827;
  color: white;
  font: 900 13px/1 var(--mono);
}

.section-number.violet { background: var(--violet); }

.collection-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 2.25vw, 35px);
  line-height: 1.05;
  letter-spacing: 0;
}

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

.heading-meta span,
.heading-meta b,
.license-note {
  padding: 10px 12px;
  border-radius: 999px;
  background: #efede8;
  font: 900 10px/1 var(--mono);
}

.heading-meta span { color: var(--violet); }
.heading-meta b { color: white; background: #4c315a; }
.heading-meta b.is-paused { background: #ddd9d2; color: var(--muted); }
.license-note { margin-left: auto; color: #654bc9; background: #eeeaff; }

.studio {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 830px;
}

.controls {
  border-right: 1px solid var(--line);
  background: #f7f2e8;
}

.control-block {
  padding: 22px 23px;
  border-bottom: 1px solid var(--line);
}

.control-block.compact { padding-block: 18px; }

.motion-switch { display: grid; gap: 6px; }
.motion-switch button { min-width: 0; min-height: 44px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffaf0; text-align: left; font-size: 12px; font-weight: 800; cursor: pointer; }
.motion-switch button[aria-pressed="true"] { color: white; background: #4c315a; border-color: #4c315a; }
.motion-switch small { display: block; margin-top: 5px; font-size: 10px; font-weight: 500; }
.control-help { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.part-motion { display: inline-block; margin: 10px 0; color: #654179; font-size: 11px; font-weight: 800; }
.dialog-motion { padding: 12px 18px; border-top: 1px solid var(--line); }
.dialog-motion .motion-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dialog-motion .motion-switch button { text-align: center; }

.control-block h3 {
  margin: 7px 0 15px;
  font-size: 18px;
  letter-spacing: 0;
}

.format-switch,
.canvas-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #e5e1da;
}

.format-switch button,
.canvas-switch button {
  min-width: 0;
  min-height: 48px;
  padding: 5px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: 900 10px/1 var(--mono);
  cursor: pointer;
}

.format-switch small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.format-switch button[aria-pressed="true"],
.canvas-switch button[aria-pressed="true"] { background: var(--ink); color: white; box-shadow: 0 3px 8px rgb(23 19 31 / 16%); }
.format-switch button[aria-pressed="true"] small { color: var(--main); }

/* The selected button is the anchor; the pill follows its actual bounds. */
.canvas-switch { position: relative; isolation: isolate; }
.canvas-switch button { position: relative; z-index: 1; }
@supports (anchor-name: --halloween-canvas) and (left: anchor(left)) and (width: anchor-size(width)) {
  .canvas-switch button[aria-pressed="true"] {
    anchor-name: --halloween-canvas;
    background: transparent;
    box-shadow: none;
  }
  .canvas-switch::after {
    content: "";
    position: absolute;
    position-anchor: --halloween-canvas;
    top: anchor(top);
    left: anchor(left);
    width: anchor-size(width);
    height: anchor-size(height);
    z-index: 0;
    border-radius: 9px;
    background: var(--ink);
    box-shadow: 0 3px 8px rgb(23 19 31 / 16%);
    pointer-events: none;
    transition: top .24s ease, left .24s ease, width .24s ease, height .24s ease;
  }
}

.control-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.control-heading output { padding: 7px 9px; border-radius: 999px; color: #5d43c8; background: #e7e2ff; font: 900 10px/1 var(--mono); }

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--violet);
  cursor: pointer;
}

.range-labels { display: flex; margin-top: 5px; justify-content: space-between; color: var(--muted); font: 800 10px/1 var(--mono); }

.color-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.color-controls label {
  display: grid;
  min-width: 0;
  padding: 9px;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  font: 900 10px/1 var(--mono);
}
.color-controls input { width: 100%; height: 34px; padding: 0; border: 0; background: transparent; cursor: pointer; }

.palette-presets { display: flex; margin-top: 10px; gap: 7px; }
.palette-presets button {
  display: flex;
  flex: 1;
  height: 31px;
  padding: 4px;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  cursor: pointer;
}
.palette-presets button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.palette-presets i { width: 21%; height: 100%; border-radius: 4px; background: var(--swatch-1); }
.palette-presets i:nth-child(2) { background: var(--swatch-2); }
.palette-presets i:nth-child(3) { background: var(--swatch-3); }
.palette-presets [data-palette="classic"] { --swatch-1: #fff5dc; --swatch-2: #ff7a1a; --swatch-3: #171826; }
.palette-presets [data-palette="witch"] { --swatch-1: #f7f1df; --swatch-2: #9b59b6; --swatch-3: #171826; }
.palette-presets [data-palette="moon"] { --swatch-1: #d9efff; --swatch-2: #55c7e8; --swatch-3: #192d50; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-row h3 { margin-bottom: 0; }
.control-block.compact > p { margin: 11px 0 0; color: var(--muted); font-size: 10px; font-weight: 650; line-height: 1.55; }
.toggle { position: relative; flex: 0 0 auto; width: 50px; height: 29px; padding: 0; border: 0; border-radius: 999px; background: #b8b2bc; cursor: pointer; }
.toggle span { position: absolute; top: 4px; left: 4px; width: 21px; height: 21px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgb(0 0 0 / 20%); transition: transform .18s ease; }
.toggle[aria-checked="true"] { background: var(--violet); }
.toggle[aria-checked="true"] span { transform: translateX(21px); }

.reset-button {
  display: block;
  width: calc(100% - 46px);
  min-height: 46px;
  margin: 18px 23px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--main);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}

.gallery-panel { min-width: 0; background: #d3c8b9; }

.gallery-toolbar {
  display: flex;
  min-height: 66px;
  padding: 10px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid #ad9e8d;
  background: #c4b7a6;
}

.search-box {
  display: flex;
  width: min(410px, 62%);
  min-height: 43px;
  padding: 0 13px;
  align-items: center;
  gap: 9px;
  border: 1px solid #a8a59f;
  border-radius: 11px;
  background: #f9f7f1;
}

.search-box span { color: var(--violet); font-size: 21px; font-weight: 900; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 12px; font-weight: 750; }
.gallery-toolbar p { display: flex; margin: 0; align-items: center; gap: 8px; color: #615d65; font: 900 10px/1 var(--mono); }
.gallery-toolbar p i { width: 8px; height: 8px; border-radius: 50%; background: #16a57f; box-shadow: 0 0 0 4px rgb(22 165 127 / 14%); }

.parts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  padding: 18px;
}

.part-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #4a394b;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 22px rgb(35 23 31 / 16%);
  transition: transform .18s ease, box-shadow .18s ease;
}

.part-card:hover { transform: translateY(-3px); box-shadow: 0 15px 28px rgb(35 23 31 / 23%); }

.part-card[hidden] { display: none; }

.part-preview {
  position: relative;
  display: grid;
  height: 232px;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid #4a394b;
  background:
    radial-gradient(circle at 50% 42%, #493251 0, #2c1d32 43%, #171219 76%);
  isolation: isolate;
}

.parts-grid[data-canvas="light"] .part-preview,
.dialog-preview[data-canvas="light"] { background: #f4ead9; }

.parts-grid[data-canvas="grid"] .part-preview,
.dialog-preview[data-canvas="grid"] {
  background-color: #251a29;
  background-image:
    linear-gradient(rgb(255 255 255 / 7%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 7%) 1px, transparent 1px);
  background-size: 18px 18px;
}

.part-preview::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(170deg, transparent 0 74%, rgb(4 3 5 / 33%) 75%),
    radial-gradient(circle at 50% 47%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 57%);
  content: "";
}

.part-preview > [data-preview-host] {
  width: min(92%, 250px);
  height: min(92%, 196px);
}

.svg-host svg,
.lottie-host svg { display: block; width: 100% !important; height: 100% !important; }

.part-badges {
  position: absolute;
  top: 11px;
  left: 11px;
  z-index: 4;
  display: flex;
  gap: 6px;
  align-items: center;
}
.part-format {
  padding: 7px 8px;
  border-radius: 8px;
  color: #fff8ea;
  background: #2b202f;
  font: 900 10px/1 var(--mono);
}

.part-format.is-lottie { color: white; background: #67408d; }

.replay-one {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 4;
  display: grid;
  width: 33px;
  height: 33px;
  padding: 0;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 50%;
  color: white;
  background: rgb(23 19 31 / 65%);
  font-size: 17px;
  cursor: pointer;
}

.part-body { padding: 16px 17px 17px; }
.part-index { color: #8b5b36; font: 900 10px/1 var(--mono); }
.part-body h3 { margin: 7px 0 6px; font-size: 18px; letter-spacing: 0; }
.part-body p { min-height: 32px; margin: 0; color: var(--muted); font-size: 10px; font-weight: 650; line-height: 1.55; }
.part-tags { display: flex; margin-top: 11px; flex-wrap: wrap; gap: 5px; }
.part-tags span { padding: 6px 7px; border-radius: 999px; background: #eee5d8; color: #62565b; font: 850 10px/1 var(--mono); }
.lottie-preview-link { padding:7px 8px; border:0; border-radius:8px; color:white; background:#67408d; font:900 10px/1 var(--mono); cursor:pointer; transition:background-color .15s,box-shadow .15s; }
.lottie-preview-link:hover { background:#44245f; box-shadow:0 2px 0 #211627; }
.lottie-preview-link:focus-visible { outline:3px solid #ffbf16; outline-offset:3px; }
.part-actions { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 13px; }
.part-actions button {
  position: relative;
  z-index: 2;
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid var(--ink);
  border-radius: 9px;
  background: white;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}
.part-actions button:first-child { border-color: #bd591c; background: var(--accent); color: #171219; }
.part-actions button[data-action="download"],
.dialog-shell #downloadButton { border-color: #583476; background: #67408d; color: #fff; }
.part-actions button[data-action="png"],
.dialog-shell #downloadPngButton { border-color: #245448; background: #326e5e; color: #fff; }
.part-actions button:disabled, .dialog-shell > footer button:disabled { cursor: wait; opacity: .65; }

.character-peek {
  position: absolute;
  z-index: 1;
  bottom: calc(100% - 5px);
  width: 96px;
  height: 48px;
  overflow: hidden;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
}
.character-peek img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: contain;
  opacity: 0;
  transform: translateY(var(--peek-travel, 52px));
  transform-origin: 50% 75%;
}
.character-peek.is-peeking img { animation: halloween-button-peek 1.7s ease-in-out both; }
@keyframes halloween-button-peek {
  0%, 100% { opacity: 0; transform: translateY(var(--peek-travel, 52px)) rotate(0); }
  18% { opacity: 1; transform: translateY(0) rotate(-5deg); }
  32%, 65% { opacity: 1; transform: translateY(0) rotate(0); }
  76% { opacity: 1; transform: translateY(3px) rotate(4deg); }
  94% { opacity: 0; transform: translateY(var(--peek-travel, 52px)) rotate(0); }
}
@media (prefers-reduced-motion: reduce), (hover: none), (pointer: coarse) {
  .character-peek { display: none; }
}

.parts-grid.is-paused svg *,
.dialog-preview.is-paused svg * { animation-play-state: paused !important; }

.empty-state {
  min-height: 520px;
  padding: 90px 20px;
  text-align: center;
}
.empty-state span { display: grid; width: 58px; height: 58px; margin: 0 auto 18px; place-items: center; border-radius: 50%; background: var(--violet); color: white; font-size: 24px; font-weight: 900; }
.empty-state strong { display: block; font-size: 19px; }
.empty-state p { color: var(--muted); font-size: 11px; }

.how-to { margin-top: 22px; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.how-grid article { min-width: 0; padding: 28px; border-right: 1px solid var(--line); }
.how-grid article:last-child { border-right: 0; }
.how-grid article > span { color: #6447d2; font: 900 10px/1 var(--mono); letter-spacing: .12em; }
.how-grid h3 { margin: 11px 0 15px; font-size: 22px; letter-spacing: 0; }
.how-grid pre { min-height: 140px; margin: 0; padding: 17px; overflow: auto; border-radius: 13px; background: var(--night); color: #d7ff8c; white-space: pre-wrap; }
.how-grid code { font: 750 11px/1.6 var(--mono); }
.how-grid p { margin: 15px 0 0; color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.6; }
.how-grid .tips { background: #f0c78e; }
.how-grid ul { display: grid; margin: 21px 0 0; padding: 0; gap: 13px; list-style: none; }
.how-grid li { position: relative; padding-left: 20px; font-size: 12px; font-weight: 800; line-height: 1.45; }
.how-grid li::before { position: absolute; top: 2px; left: 0; content: "✓"; }
.how-grid li code { padding: 3px 5px; border-radius: 5px; background: rgb(255 255 255 / 58%); color: var(--ink); font-size: 10px; }

.source-note {
  display: flex;
  min-height: 62px;
  padding: 12px 28px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  background: #eeebe5;
}
.source-note p { margin: 0; color: var(--muted); font-size: 10px; font-weight: 650; }
.source-note a { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; font: 900 10px/1 var(--mono); text-decoration: none; }

.code-dialog {
  width: min(980px, calc(100% - 30px));
  max-height: calc(100dvh - 30px);
  padding: 0;
  overflow: hidden auto;
  border: 2px solid var(--ink);
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 12px 12px 0 var(--accent);
}

.code-dialog::backdrop { background: rgb(16 12 23 / 76%); backdrop-filter: blur(6px); }
.lottie-modal-open { overflow:hidden; }
.lottie-dialog { width:min(860px,calc(100% - 24px)); height:min(870px,calc(100dvh - 24px)); max-height:calc(100dvh - 24px); overflow:hidden; }
.lottie-dialog .dialog-shell { height:100%; display:flex; flex-direction:column; }
.lottie-dialog .dialog-shell > header { flex-shrink:0; }
.lottie-dialog iframe { display:block; width:100%; flex:1; min-height:0; border:0; background:#f5f0e5; }
#lottieCollectionButton { padding:9px 11px; border:1px solid var(--line); border-radius:9px; color:var(--ink); background:white; font:900 10px/1 var(--mono); cursor:pointer; }
.dialog-shell > header { display: flex; min-height: 76px; padding: 14px 18px; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.dialog-shell > header span { color: var(--violet); font: 900 10px/1 var(--mono); }
.dialog-shell > header h2 { margin: 6px 0 0; font-size: 24px; letter-spacing: 0; }
.dialog-shell > header button { position: relative; display: grid; flex-shrink: 0; width: 42px; height: 42px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; cursor: pointer; }
.dialog-shell > header button::before,
.dialog-shell > header button::after { content: ""; position: absolute; top: 50%; left: 50%; width: 16px; height: 2px; border-radius: 1px; background: currentColor; pointer-events: none; transform: translate(-50%, -50%) rotate(45deg); }
.dialog-shell > header button::after { transform: translate(-50%, -50%) rotate(-45deg); }
.dialog-preview { display: grid; height: 260px; place-items: center; overflow: hidden; background: var(--night); }
.dialog-preview > svg,
.dialog-preview > .lottie-host { width: 330px; max-width: 88%; height: 230px; }
.dialog-preview > svg { display: block; }
.dialog-tabs { display: flex; padding: 10px 18px; gap: 7px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #eeebe5; }
.dialog-tabs button { min-height: 35px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; font-size: 10px; font-weight: 900; cursor: pointer; }
.dialog-tabs button[aria-selected="true"] { background: var(--ink); color: white; }
.code-dialog pre { min-height: 260px; max-height: 320px; margin: 0; padding: 22px; overflow: auto; background: #211d27; color: #d9ff91; white-space: pre; }
.code-dialog pre code { font: 700 11px/1.65 var(--mono); }
.dialog-shell > footer { display: flex; min-height: 72px; padding: 13px 18px; align-items: center; justify-content: space-between; gap: 18px; }
.dialog-shell > footer p { margin: 0; color: var(--muted); font: 900 10px/1 var(--mono); }
.dialog-shell > footer div { display: flex; flex-wrap: wrap; gap: 8px; }
.dialog-shell > footer button { min-height: 42px; padding: 0 14px; border: 1px solid var(--ink); border-radius: 10px; background: white; font-size: 10px; font-weight: 900; cursor: pointer; }
.dialog-shell > footer button.accent { background: var(--main); box-shadow: 3px 3px 0 var(--ink); }

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  display: flex;
  min-width: 230px;
  min-height: 58px;
  padding: 10px 14px;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--ink);
  border-radius: 13px;
  background: var(--ink);
  color: white;
  box-shadow: 5px 5px 0 var(--main);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast span { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 8px; background: var(--main); color: var(--ink); font-weight: 900; }
.toast p { margin: 0; font-size: 11px; font-weight: 850; }

/* UI feedback stays separate from the SVG motion modes. */
button {
  transition: background-color .18s ease, color .18s ease, border-color .18s ease,
    box-shadow .18s ease, filter .18s ease, transform .18s ease;
}
@media (hover: hover) {
  .part-actions button:hover,
  .hero-actions button:hover,
  .dialog-shell > footer button:hover,
  .reset-button:hover { filter: brightness(1.08); box-shadow: 0 4px 0 rgb(23 18 25 / 22%); }
  .motion-switch button:hover { border-color: #67408d; background: #efe2f6; box-shadow: 0 3px 8px rgb(76 49 90 / 14%); }
  .motion-switch button[aria-pressed="true"]:hover { background: #624073; }
  .canvas-switch button:hover { box-shadow: inset 0 0 0 2px #9b70bd; }
  .palette-presets button:hover { border-color: #67408d; filter: brightness(1.08); }
  .dialog-tabs button:hover { box-shadow: inset 0 0 0 2px #9b70bd; }
  .dialog-shell > header button:hover { background: #efe2f6; border-color: #67408d; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .part-actions button:hover,
  .hero-actions button:hover,
  .motion-switch button:hover,
  .palette-presets button:hover,
  .dialog-shell > footer button:hover,
  .reset-button:hover { transform: translateY(-2px); }
}
button:active { filter: brightness(.96); }
@media (prefers-reduced-motion: no-preference) {
  .part-actions button:active,
  .hero-actions button:active,
  .motion-switch button:active,
  .palette-presets button:active,
  .dialog-shell > footer button:active,
  .reset-button:active { transform: translateY(0) scale(.98); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 1320px) {
  .parts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .page { width: min(100% - 24px, 820px); padding-top: 18px; }
  .hero { min-height: 205px; padding-inline: 8px; flex-direction: column; align-items: flex-start; }
  h1 { font-size: min(7vw, 66px); }
  .hero-actions { width: 100%; }
  .hero-bat { display: none; }
  .studio { grid-template-columns: 1fr; }
  .controls { display: grid; grid-template-columns: repeat(2, 1fr); border-right: 0; border-bottom: 1px solid var(--line); }
  .control-block { border-right: 1px solid var(--line); }
  .control-block:nth-child(even) { border-right: 0; }
  .reset-button { align-self: center; width: calc(100% - 46px); }
  .how-grid { grid-template-columns: 1fr; }
  .how-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 650px) {
  .page { width: min(100% - 16px, 520px); padding-bottom: 42px; }
  .hero { min-height: 180px; gap: 16px; }
  h1 { font-size: 7.15vw; }
  .lead { margin-top: 13px; font-size: 14px; }
  .pack-count { display: none; }
  .hero-actions button { min-height: 42px; padding: 0 12px; }
  .collection, .how-to { border-radius: 19px; }
  .collection-heading { min-height: 85px; padding: 14px; }
  .collection-heading.compact { min-height: 80px; }
  .section-number { width: 43px; height: 43px; border-radius: 13px; }
  .collection-heading h2 { font-size: 18px; }
  .collection-heading p { font-size: 10px; }
  .heading-meta span, .license-note { display: none; }
  .collection-heading { flex-wrap: wrap; }
  .collection-heading > div:not(.heading-meta) { flex: 1; min-width: 0; }
  .heading-meta { flex-basis: 100%; margin-left: 59px; }
  .heading-meta b { line-height: 1.5; white-space: nowrap; }
  .controls { display: block; }
  .control-block { border-right: 0; }
  .reset-button { margin-bottom: 20px; }
  .gallery-toolbar { min-height: 61px; padding: 9px 11px; }
  .search-box { width: 100%; }
  .gallery-toolbar p { display: none; }
  .parts-grid { grid-template-columns: 1fr; padding: 11px; }
  .part-preview { height: 235px; }
  .part-body p { min-height: 0; }
  .source-note { align-items: flex-start; flex-direction: column; }
  .dialog-preview { height: 210px; }
  .dialog-shell > footer { align-items: flex-start; flex-direction: column; }
  .dialog-shell > footer div { width: 100%; }
  .dialog-shell > footer button { flex: 1; }
  .toast { right: 14px; bottom: 14px; left: 14px; min-width: 0; }
}
