@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/pixelify-sans-latin-700.f54f30a241c6.woff2") format("woff2");
}

:root {
  --paper: #f5efe3;
  --paper-deep: #e5d9c6;
  --card: #fffdf7;
  --ink: #25211f;
  --ink-soft: #665f57;
  --coral: #e45b3f;
  --coral-dark: #b93d27;
  --yellow: #f2c94c;
  --mint: #9ed8c7;
  --teal: #267f77;
  --blue: #5177c8;
  --line: #2f2926;
  --display: "Pixelify Sans", ui-monospace, monospace;
  --sans: ui-rounded, "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --shadow: 0 5px 0 var(--line);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(47, 41, 38, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 41, 38, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  font: 16px/1.55 var(--sans);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.wrap {
  width: min(1420px, calc(100% - 2rem));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: -5rem;
  left: 1rem;
  padding: 0.65rem 1rem;
  color: white;
  background: var(--ink);
  border-radius: 8px;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  background: rgba(245, 239, 227, 0.96);
  border-bottom: 2px solid var(--line);
  backdrop-filter: blur(12px);
}

.site-header .wrap {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  font: 700 1.28rem var(--display);
}

.logo b {
  color: var(--coral-dark);
}

.logo-mark {
  display: grid;
  grid-template-columns: repeat(2, 9px);
  gap: 3px;
  transform: rotate(-4deg);
}

.logo-mark i {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--line);
  border-radius: 2px;
}

.logo-mark i:nth-child(1) { background: var(--coral); }
.logo-mark i:nth-child(2) { background: var(--yellow); }
.logo-mark i:nth-child(3) { background: var(--mint); }
.logo-mark i:nth-child(4) { background: var(--blue); }

.main-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.84rem;
  font-weight: 800;
}

.main-nav a {
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.nav-cta {
  padding: 0.36rem 0.8rem;
  background: var(--yellow);
  border: 2px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--line);
}

.breadcrumb {
  padding-top: 1rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.breadcrumb ol {
  display: flex;
  gap: 0.45rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 0.45rem;
  color: #978c80;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.62fr);
  gap: 4rem;
  align-items: center;
  padding: 3.5rem 0 2.5rem;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.6rem;
  color: var(--teal);
  font: 900 0.75rem/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-family: var(--display);
  line-height: 1.05;
}

h1 {
  max-width: 850px;
  margin-bottom: 1rem;
  font-size: clamp(2.8rem, 6.5vw, 5.8rem);
  letter-spacing: -0.045em;
}

h1 span {
  display: inline-block;
  padding: 0.02em 0.16em 0.08em;
  color: #fff;
  background: var(--coral-dark);
  transform: rotate(-1.2deg);
}

.hero-copy > p:not(.eyebrow) {
  max-width: 760px;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.6vw, 1.18rem);
}

.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0;
  margin: 1.25rem 0 0;
  list-style: none;
}

.hero-points li {
  padding: 0.28rem 0.58rem;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font: 800 0.75rem var(--mono);
}

.hero-motif {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  aspect-ratio: 1.25;
  padding: 1.25rem;
  overflow: hidden;
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 24px;
  box-shadow: 10px 10px 0 var(--mint), 12px 12px 0 var(--line);
  transform: rotate(1.4deg);
}

.hero-motif i {
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 45% 45% 38% 38%;
}

.hero-motif i:nth-child(4n + 1) { background: #e31d42; }
.hero-motif i:nth-child(4n + 2) { background: #ffd600; }
.hero-motif i:nth-child(4n + 3) { background: #06b7c4; }
.hero-motif i:nth-child(4n + 4) { background: #5c184e; }

.tool-shell {
  padding: 0.85rem;
  background: var(--ink);
  border-radius: 20px;
  box-shadow: 0 9px 0 rgba(37, 33, 31, 0.25);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(440px, 1.65fr) minmax(290px, 0.85fr);
  gap: 0.85rem;
  align-items: start;
}

.panel,
.stage {
  min-width: 0;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.panel {
  padding: 1rem;
}

.panel h2 {
  margin-bottom: 0.45rem;
  font-size: 1.35rem;
}

.panel h3 {
  margin-bottom: 0.45rem;
  font-size: 1.05rem;
}

.panel-copy,
.fine-print {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.control-stack {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.control-group {
  display: grid;
  gap: 0.42rem;
  padding-top: 0.85rem;
  border-top: 1.5px dashed #b7aa9a;
}

.control-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.label,
.field > span,
.range-label {
  font-size: 0.76rem;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--coral-dark);
}

.range-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.range-label output {
  color: var(--coral-dark);
  font-family: var(--mono);
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 124px;
  padding: 1rem;
  color: var(--ink-soft);
  text-align: center;
  background: #f7f2e8;
  border: 2px dashed #8e8072;
  border-radius: 10px;
  cursor: pointer;
}

.dropzone strong {
  display: block;
  color: var(--ink);
}

.dropzone[data-dragging="true"] {
  background: #dff3eb;
  border-color: var(--teal);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.button,
.icon-button,
.tool-button,
.sample-button,
.swatch {
  appearance: none;
  border: 2px solid var(--line);
  cursor: pointer;
}

.button {
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  font-weight: 900;
  background: var(--yellow);
  border-radius: 9px;
  box-shadow: 0 3px 0 var(--line);
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--line);
}

.button.secondary {
  background: var(--card);
}

.button.coral {
  color: white;
  background: var(--coral-dark);
}

.button-row,
.sample-row,
.stage-actions,
.zoom-tools,
.edit-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.button-row > .button {
  flex: 1 1 130px;
}

.sample-button {
  padding: 0.38rem 0.56rem;
  background: #fff;
  border-radius: 999px;
  font: 800 0.72rem var(--mono);
}

.sample-button:hover {
  background: var(--mint);
}

.stage {
  overflow: hidden;
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem;
  border-bottom: 2px solid var(--line);
}

.stage-title {
  min-width: 0;
}

.stage-title h2 {
  margin: 0 0 0.15rem;
  font-size: 1.25rem;
}

.stage-title p {
  margin: 0;
  color: var(--ink-soft);
  font: 700 0.72rem var(--mono);
}

.icon-button,
.tool-button {
  min-width: 38px;
  min-height: 38px;
  padding: 0.42rem 0.52rem;
  background: #fff;
  border-radius: 8px;
  font: 900 0.76rem var(--mono);
}

.icon-button:hover,
.tool-button:hover {
  background: #f5ead8;
}

.icon-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.tool-button[aria-pressed="true"] {
  color: #fff;
  background: var(--teal);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.65rem 0.9rem;
  background: #eee5d8;
  border-bottom: 2px solid var(--line);
}

.canvas-scroll {
  min-height: 560px;
  max-height: 72vh;
  overflow: auto;
  padding: 1rem;
  background-color: #d8cbb8;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.28) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.28) 25%, transparent 25%);
  background-size: 22px 22px;
}

#patternCanvas {
  display: block;
  max-width: none;
  margin-inline: auto;
  background: #fff;
  border: 2px solid var(--line);
  box-shadow: 6px 6px 0 rgba(47, 41, 38, 0.25);
  touch-action: none;
}

.status {
  min-height: 1.3rem;
  padding: 0.55rem 0.9rem;
  margin: 0;
  color: var(--ink-soft);
  border-top: 1px solid #cfc2b1;
  font: 800 0.72rem var(--mono);
}

.status[data-state="error"] {
  color: #a72f20;
  background: #fff0eb;
}

.status[data-state="success"] {
  color: #14675d;
  background: #e5f6f0;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 0.38rem;
  max-height: 260px;
  padding: 0.15rem;
  overflow: auto;
}

.swatch {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  background: var(--swatch);
  border-radius: 8px;
}

.swatch span {
  position: absolute;
  right: 2px;
  bottom: 2px;
  left: 2px;
  overflow: hidden;
  padding: 0.08rem;
  color: var(--label-color, #fff);
  background: var(--label-bg, rgba(0, 0, 0, 0.58));
  border-radius: 4px;
  font: 900 0.56rem var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch[aria-pressed="true"] {
  outline: 4px solid var(--yellow);
  outline-offset: 1px;
}

.replace-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.35rem;
  align-items: end;
}

.replace-arrow {
  padding-bottom: 0.58rem;
  font-weight: 900;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.metric {
  padding: 0.55rem;
  background: #f3ecdf;
  border: 1.5px solid #b5a99a;
  border-radius: 8px;
}

.metric strong,
.metric span {
  display: block;
}

.metric strong {
  font: 900 1rem var(--mono);
}

.metric span {
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.materials {
  display: grid;
  gap: 0.4rem;
  max-height: 290px;
  overflow: auto;
}

.material-row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.36rem 0;
  border-bottom: 1px solid #ded4c7;
  font-size: 0.74rem;
}

.material-dot {
  width: 18px;
  height: 18px;
  background: var(--material);
  border: 1.5px solid var(--line);
  border-radius: 50%;
}

.material-row code {
  font-weight: 900;
}

.row-guide {
  display: grid;
  gap: 0.38rem;
  max-height: 380px;
  overflow: auto;
  padding-right: 0.2rem;
}

.guide-row {
  padding: 0.5rem;
  background: #f7f1e6;
  border-left: 4px solid var(--row-accent);
  border-radius: 0 7px 7px 0;
  font: 700 0.68rem/1.45 var(--mono);
}

.guide-row strong {
  color: var(--coral-dark);
}

.disclosure {
  margin-top: 0.8rem;
}

.disclosure summary {
  cursor: pointer;
  font-weight: 900;
}

.content-section {
  padding: 4.5rem 0 0;
}

.content-section > h2,
.section-heading h2 {
  margin-bottom: 0.7rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.section-heading {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 0.55fr);
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.4rem;
}

.section-heading p {
  margin: 0;
  color: var(--ink-soft);
}

.steps,
.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.step,
.feature {
  position: relative;
  padding: 1.1rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 0.8rem;
  background: var(--yellow);
  border: 2px solid var(--line);
  border-radius: 50%;
  font: 900 0.85rem var(--mono);
}

.step h3,
.feature h3 {
  margin-bottom: 0.45rem;
  font-size: 1.25rem;
}

.step p,
.feature p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.feature:nth-child(2) { background: #e7f5ef; }
.feature:nth-child(3) { background: #fff2cf; }
.feature:nth-child(4) { background: #f9e8eb; }

.faq-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.faq-list details {
  align-self: start;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 10px;
}

.faq-list summary {
  cursor: pointer;
  font-weight: 900;
}

.faq-list p {
  margin: 0.65rem 0 0;
  color: var(--ink-soft);
}

.related {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.related a {
  display: block;
  padding: 1.2rem;
  text-decoration: none;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.related a:hover {
  background: #fff2cf;
}

.related strong,
.related span {
  display: block;
}

.related strong {
  margin-bottom: 0.3rem;
  font: 700 1.35rem var(--display);
}

.related span {
  color: var(--ink-soft);
}

.site-footer {
  padding: 2.5rem 0;
  margin-top: 5rem;
  background: #ded2c0;
  border-top: 2px solid var(--line);
}

.site-footer .wrap {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2rem;
}

.site-footer p {
  max-width: 760px;
  margin: 0;
  color: #574f48;
  font-size: 0.8rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-content: start;
  justify-content: flex-end;
  font-size: 0.82rem;
  font-weight: 800;
}

#printSheet {
  display: none;
}

@media (max-width: 1180px) {
  .tool-grid {
    grid-template-columns: minmax(245px, 0.62fr) minmax(460px, 1.38fr);
  }

  .results-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .results-panel > .panel-kicker,
  .results-panel > h2,
  .results-panel > .panel-copy {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .main-nav a:not(.nav-cta) {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 2.2rem;
    padding-top: 2.3rem;
  }

  .hero-motif {
    width: min(460px, 92%);
    justify-self: center;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .results-panel {
    grid-column: auto;
    display: block;
  }

  .canvas-scroll {
    min-height: 420px;
  }

  .steps,
  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }

  .section-heading,
  .site-footer .wrap {
    grid-template-columns: 1fr;
  }

  .footer-links {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .wrap {
    width: min(100% - 1rem, 1420px);
  }

  h1 {
    font-size: clamp(2.55rem, 16vw, 4.3rem);
  }

  .tool-shell {
    padding: 0.45rem;
    border-radius: 13px;
  }

  .stage-head,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stage-actions,
  .zoom-tools {
    width: 100%;
  }

  .stage-actions > *,
  .zoom-tools > * {
    flex: 1;
  }

  .steps,
  .feature-grid,
  .faq-list,
  .related {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  @page {
    margin: 10mm;
  }

  body {
    background: #fff;
  }

  body > :not(#printSheet) {
    display: none !important;
  }

  #printSheet {
    display: block;
    color: #111;
    font: 10pt/1.35 Arial, sans-serif;
  }

  #printSheet .print-title {
    margin: 0 0 4mm;
    font: 700 20pt/1.1 Arial, sans-serif;
  }

  #printSheet img {
    width: 100%;
    height: auto;
    max-height: 215mm;
    object-fit: contain;
    object-position: top left;
  }

  .print-meta,
  .print-legend,
  .print-guide {
    margin-top: 4mm;
  }

  .print-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2mm 5mm;
  }

  .print-guide {
    columns: 2;
    column-gap: 8mm;
    font: 8pt/1.4 var(--mono);
  }
}
