:root {
  --bg: #fff6fb;
  --card: #ffffff;
  --ink: #2a1020;
  --muted: #6e5565;
  --pink: #c8107a;
  --pink-soft: #ffe3f3;
  --rule: #f3c6e0;
  --code-bg: #2b1430;
  --code-ink: #ffe6f4;
  --code-dim: #c79bb8;
  --gown: #3b7dd8;
  --head: #e0338f;
  --orig: #b9820e;
  --join: #1c9e6e;
  --strong: #1f7a4a;
  --medium: #3b6fc4;
  --weak: #b35a00;
  --estimate: #7a4fc4;
  --open: #b0234a;
  --bar: linear-gradient(#ffd6ef, #ff8fd0 50%, #f26cbf 51%, #ffb0de);
  --plate: #fff6fb;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a0d16;
    --card: #26121f;
    --ink: #fbe9f3;
    --muted: #c9a9bb;
    --pink: #ff7cc5;
    --pink-soft: #3a1830;
    --rule: #4a2440;
    --code-bg: #12070f;
    --strong: #5fd39a;
    --medium: #86aef0;
    --weak: #f0a15a;
    --estimate: #b99af0;
    --open: #ff7a9a;
    --orig: #e6b84a;
    --bar: linear-gradient(#b34d8a, #9c2f74 50%, #86235f 51%, #a0407c);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1a0d16;
  --card: #26121f;
  --ink: #fbe9f3;
  --muted: #c9a9bb;
  --pink: #ff7cc5;
  --pink-soft: #3a1830;
  --rule: #4a2440;
  --code-bg: #12070f;
  --strong: #5fd39a;
  --medium: #86aef0;
  --weak: #f0a15a;
  --estimate: #b99af0;
  --open: #ff7a9a;
  --orig: #e6b84a;
  --bar: linear-gradient(#b34d8a, #9c2f74 50%, #86235f 51%, #a0407c);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-wrap: break-word;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

a { color: var(--pink); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }

h1, h2, h3 { font-family: "Trebuchet MS", "Verdana", system-ui, sans-serif; line-height: 1.2; }
h1 { font-size: clamp(28px, 6vw, 44px); margin: 28px 0 8px; color: var(--pink); letter-spacing: -0.5px; }
h2 { font-size: clamp(22px, 4vw, 28px); margin: 56px 0 12px; }
h3 { font-size: 18px; margin: 28px 0 8px; }
p { margin: 0 0 14px; max-width: 70ch; }
.lede { font-size: 18px; color: var(--muted); max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

code { font: 0.9em ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--pink-soft); padding: 1px 5px; border-radius: 5px; }

.top {
  border-bottom: 2px solid var(--rule);
  background: var(--card);
}
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { font: 700 20px "Trebuchet MS", Verdana, sans-serif; color: var(--pink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand .spark { color: var(--orig); }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 15px; }
.top nav a { text-decoration: none; color: var(--ink); padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a:hover { border-bottom-color: var(--rule); }
.top nav a[aria-current="page"] { color: var(--pink); border-bottom-color: var(--pink); }

.window {
  background: var(--card);
  border: 2px solid var(--pink);
  border-radius: 14px;
  overflow: hidden;
  margin: 20px 0;
  box-shadow: 0 6px 0 var(--rule);
}
.window > .bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bar);
  color: #fff; font: 700 14px "Trebuchet MS", Verdana, sans-serif;
  text-shadow: 0 1px 1px rgb(120 0 70 / 0.6);
}
.window > .bar .dots { display: inline-flex; gap: 5px; }
.window > .bar .dots i { width: 11px; height: 11px; border-radius: 50%; background: rgb(255 255 255 / 0.75); border: 1px solid rgb(120 0 70 / 0.35); }
.window > .body { padding: 16px; }
.window.plate > .body { background: var(--plate); color: #2a1020; --muted: #6e5565; --pink: #c8107a; --gown: #3b7dd8; --head: #e0338f; --orig: #b9820e; --join: #1c9e6e; }

img.px, canvas.px { image-rendering: pixelated; image-rendering: crisp-edges; }
img { max-width: 100%; height: auto; }
.shot img { display: block; width: 100%; }

figure { margin: 0; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }

.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; counter-reset: step; }
.steps li { counter-increment: step; }
.steps a {
  display: block; height: 100%; text-decoration: none; color: var(--ink);
  background: var(--card); border: 2px solid var(--rule); border-radius: 12px; padding: 12px 14px;
}
.steps a:hover { border-color: var(--pink); }
.steps a::before { content: counter(step); display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; border-radius: 50%; background: var(--pink); color: #fff; font: 700 14px "Trebuchet MS", sans-serif; }
.steps strong { font-family: "Trebuchet MS", Verdana, sans-serif; }
.steps span { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }

.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.cast article { background: var(--card); border: 2px solid var(--rule); border-radius: 12px; padding: 12px 8px 10px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.cast .stage { height: 414px; display: flex; align-items: flex-end; justify-content: center; width: 100%; overflow: hidden; }
.cast .stage img { max-width: none; flex: none; }
.cast h3 { font-size: 16px; margin: 10px 0 2px; }
.cast p { font-size: 13px; color: var(--muted); margin: 0; }
.franchise { margin-top: 28px; font-size: 15px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

.grade { display: inline-block; font: 700 12px system-ui, sans-serif; padding: 1px 8px; border-radius: 999px; border: 1.5px solid currentColor; white-space: nowrap; }
.grade.strong { color: var(--strong); }
.grade.medium { color: var(--medium); }
.grade.weak { color: var(--weak); }
.grade.estimate { color: var(--estimate); }
.grade.open { color: var(--open); }

.code { margin: 16px 0; border-radius: 12px; overflow: hidden; border: 2px solid var(--rule); }
.code .file { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--code-bg); color: var(--code-dim); font: 13px ui-monospace, Menlo, monospace; padding: 8px 14px 0; }
.code pre { margin: 0; padding: 10px 14px 14px; background: var(--code-bg); color: var(--code-ink); overflow-x: auto; font: 13px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace; tab-size: 4; }
.code pre code { background: none; padding: 0; font: inherit; border-radius: 0; }
.code pre .gap { color: var(--code-dim); }
.code pre mark { background: rgb(255 124 197 / 0.22); color: inherit; border-radius: 3px; }

.pairs { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; margin: 16px 0; }
.pairs figure { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 220px; }
.pairs figcaption { max-width: 200px; }
.arrow { align-self: center; font-size: 28px; color: var(--pink); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

.legend { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 4px; border-radius: 2px; display: inline-block; }
.legend .gown { background: var(--gown); }
.legend .head { background: var(--head); }
.legend .orig { background: var(--orig); }
.legend .join { background: var(--join); height: 10px; opacity: 0.6; }

.ramps { width: 100%; border-collapse: collapse; font-size: 14px; }
.ramps th, .ramps td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.ramps th { font-weight: 600; white-space: nowrap; }
.ramp { display: flex; }
.ramp span { width: 22px; height: 22px; }
.ramp span:first-child { border-radius: 5px 0 0 5px; }
.ramp span:last-child { border-radius: 0 5px 5px 0; }
.scroll { overflow-x: auto; }

.layers { list-style: none; margin: 0; padding: 0; border: 2px solid var(--rule); border-radius: 10px; overflow: hidden; font: 13px ui-monospace, Menlo, monospace; }
.layers li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--rule); background: var(--card); }
.layers li:last-child { border-bottom: 0; }
.layers .swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; border: 2px solid; }
.layers .gown .swatch { border-color: var(--gown); }
.layers .head .swatch { border-color: var(--head); }
.layers .orig .swatch { border-color: var(--orig); }
.layers .empty .swatch { border-style: dashed; border-color: var(--muted); }

.originals { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.originals figure { background: var(--plate); border: 2px solid var(--rule); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; text-align: center; }
.originals figcaption { color: #6e5565; }

.stamp { display: grid; grid-template-columns: auto auto; gap: 16px; align-items: center; justify-content: start; }
.stamp pre { margin: 0; font: 15px/1.15 ui-monospace, Menlo, monospace; letter-spacing: 2px; background: var(--code-bg); color: var(--code-ink); padding: 12px; border-radius: 10px; }
@media (max-width: 520px) { .stamp { grid-template-columns: 1fr; } }

.demo { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: end; }
@media (max-width: 640px) { .demo { grid-template-columns: 1fr; } }
.demo canvas { display: block; }
.demo label { font-weight: 600; display: block; margin-bottom: 6px; }
.demo input[type="range"] { width: 100%; max-width: 360px; accent-color: var(--pink); }
.demo output { display: block; font: 15px ui-monospace, Menlo, monospace; margin-top: 8px; }

.lineup { display: flex; gap: 6px; align-items: flex-end; padding: 8px 4px 4px; width: max-content; }
.lineup figure { display: flex; flex-direction: column; align-items: center; text-align: center; width: min-content; }
.lineup img { max-width: none; }
.lineup figcaption { font-size: 12px; line-height: 1.3; white-space: nowrap; margin-top: 6px; }

table.heights { width: 100%; border-collapse: collapse; font-size: 14px; }
table.heights th, table.heights td { text-align: left; padding: 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.heights th { font-family: "Trebuchet MS", sans-serif; }
table.heights td:nth-child(2) { white-space: nowrap; }
@media (max-width: 640px) {
  table.heights thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.heights tr { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
  table.heights td { border: 0; padding: 0; }
  table.heights td:first-child { font-weight: 600; }
  table.heights td:last-child { grid-column: 1 / -1; }
}

.note { border-left: 4px solid var(--pink); background: var(--pink-soft); padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 16px 0; }
.note p:last-child { margin-bottom: 0; }

footer.site { margin-top: 72px; border-top: 2px solid var(--rule); background: var(--card); padding: 24px 0 40px; font-size: 14px; color: var(--muted); }
footer.site p { max-width: 80ch; }
footer.site .credit { color: var(--ink); }

.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 442px), 1fr)); gap: 12px; margin: 16px 0; }
.sets figure { background: var(--plate); border: 2px solid var(--rule); border-radius: 10px; padding: 8px; text-align: center; }
.sets figcaption { color: #6e5565; }
