:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #fffffe;
  --border: #e2e0da;
  --text: #22201d;
  --muted: #6b6862;
  --accent: #b4581f;
  --accent-soft: #fdf1e7;
  --ok: #2f7a48;
  --ok-soft: #eef6f0;
  --bad: #b23b3b;
  --bad-soft: #fbeeee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --surface: #201f24;
    --border: #34323a;
    --text: #eceaf0;
    --muted: #9d99a6;
    --accent: #e8944e;
    --accent-soft: #2c2119;
    --ok: #6fce90;
    --ok-soft: #1b2820;
    --bad: #f08b8b;
    --bad-soft: #2c1c1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

/* Layout rules below use display:flex/grid, which would otherwise win. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: clamp(1.5rem, 5vw, 4rem) 1.25rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 46rem; margin: 0 auto; }

code, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: .9em;
}

/* --- masthead --- */
.masthead { margin-bottom: 2rem; }
.masthead h1 {
  margin: 0 0 .35rem;
  font-size: clamp(1.75rem, 5vw, 2.4rem);
  letter-spacing: -.02em;
}
.tagline { margin: 0; color: var(--muted); font-size: 1.05rem; }

/* --- dropzone --- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: clamp(2rem, 8vw, 3.5rem) 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}
.dz-icon { width: 2.25rem; height: 2.25rem; color: var(--accent); margin-bottom: .5rem; }
.dz-primary { margin: 0; font-size: 1.1rem; font-weight: 600; }
.dz-secondary { margin: 0; color: var(--muted); font-size: .9rem; }

.privacy {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: .875rem;
  text-align: center;
}

/* --- result cards --- */
.results { display: grid; gap: .875rem; margin-top: 2rem; }

.card {
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card.fixed { border-left-color: var(--ok); }
.card.untouched { border-left-color: var(--muted); }
.card.failed { border-left-color: var(--bad); }
.card.working { border-left-color: var(--accent); opacity: .7; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}
.card-name {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.badge {
  padding: .12rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.fixed { background: var(--ok-soft); color: var(--ok); }
.badge.untouched { background: var(--bg); color: var(--muted); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }

.card-note { margin: .5rem 0 0; color: var(--muted); font-size: .875rem; }

/* --- diff table --- */
.changes {
  width: 100%;
  margin-top: .85rem;
  border-collapse: collapse;
  font-size: .85rem;
}
.changes th {
  padding: .3rem .6rem .3rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.changes td {
  padding: .35rem .6rem .35rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.changes tr:last-child td { border-bottom: none; }
.changes .where { color: var(--muted); white-space: nowrap; }
.val-old { color: var(--bad); text-decoration: line-through; }
.val-new { color: var(--ok); font-weight: 600; }
.diff-scroll { overflow-x: auto; }

/* --- buttons --- */
.btn {
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  /* Buttons are <button> in the tool and <a> on the static pages; the anchors
     would otherwise arrive underlined and baseline-aligned as inline text. */
  display: inline-block;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-quiet {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-quiet:hover { color: var(--text); }
.card .btn { margin-top: .85rem; }

.bulk { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }

/* --- footer --- */
.footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .875rem;
}
.footer h2 { margin: 0 0 .6rem; font-size: .95rem; color: var(--text); }
.rule-list { margin: 0; padding-left: 1.1rem; }
.rule-list li { margin-bottom: .4rem; }
.rule-list code { color: var(--text); }
.footnote { margin: 1.1rem 0 0; }

/* --- steps --- */
.step { margin-bottom: 2rem; }
.step-title {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 .35rem;
  font-size: 1.05rem;
}
.step-number {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  flex: none;
}
.step-help { margin: 0 0 .9rem; color: var(--muted); font-size: .875rem; }

/* --- printer loadout --- */
.loadout { display: flex; flex-wrap: wrap; gap: .7rem; }
.ams-slot {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .65rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.ams-number { color: var(--muted); font-size: .75rem; font-weight: 600; }
.ams-slot input[type="color"] {
  width: 100%;
  min-width: 4.2rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: none;
  cursor: pointer;
}
.ams-slot input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.ams-slot input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.ams-slot select {
  padding: .25rem .3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: .8rem;
}

/* --- assignment --- */
.assign { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-top: .9rem; }
.assign-controls { flex: 1 1 17rem; min-width: 0; }
.assign-lead { margin: 0 0 .7rem; font-size: .9rem; }
.assign-hint { margin: .7rem 0 0; color: var(--muted); font-size: .8rem; }

.parts { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.part {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .5rem;
  border-radius: 8px;
  transition: background .12s;
}
.part:hover { background: var(--bg); }
.part-chip {
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: none;
}
.part-label { flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.part-label strong { font-size: .875rem; font-weight: 600; }
.part-share { color: var(--muted); font-size: .75rem; }
.part select {
  padding: .3rem .4rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: .82rem;
}

/* --- preview --- */
.preview { margin: 0; flex: none; }
.preview-canvas {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.preview-note { margin: 0; color: var(--muted); font-size: .8rem; }

.btn.done { background: var(--ok); cursor: default; }
.card-actions:empty { display: none; }

/* --- printer bed --- */
.printer-row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; margin-bottom: .5rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field-label { color: var(--muted); font-size: .75rem; font-weight: 600; }
.field select, .field input[type="number"] {
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .875rem;
}
.field-small input { width: 5.5rem; }
.unit { display: none; }
.field-note { margin: 0 0 1rem; color: var(--muted); font-size: .78rem; }

/* --- fit verdict --- */
.fit { margin: .8rem 0 0; color: var(--muted); font-size: .82rem; }
.fit:empty { display: none; }
.fit.fit-bad {
  padding: .55rem .7rem;
  border-radius: 8px;
  background: var(--bad-soft);
  color: var(--bad);
  font-weight: 600;
}
.fit.fit-warn {
  padding: .55rem .7rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.origin { margin: .45rem 0 0; color: var(--muted); font-size: .82rem; }
.origin:empty { display: none; }

.field-wide { display: block; max-width: 30rem; margin-bottom: .3rem; }
.field-wide input[type="text"] {
  width: 100%;
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .875rem;
}

/* --- prose / SEO content --- */
.prose {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  max-width: 42rem;
}
.prose h2 {
  margin: 2.2rem 0 .6rem;
  font-size: 1.3rem;
  letter-spacing: -.01em;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 {
  margin: 1.5rem 0 .4rem;
  font-size: 1rem;
  font-weight: 600;
}
.prose p { margin: 0 0 .8rem; color: var(--muted); line-height: 1.65; }
.prose strong { color: var(--text); }
.prose code {
  padding: .1em .35em;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: .875em;
}
.error-quote {
  padding: .7rem .85rem;
  border-left: 3px solid var(--bad);
  border-radius: 0 8px 8px 0;
  background: var(--bad-soft);
  overflow-x: auto;
}
.error-quote code { background: none; color: var(--bad); white-space: nowrap; }

.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.prose a:hover { text-decoration-thickness: 2px; }

.steps-list { margin: 0 0 .8rem; padding-left: 1.2rem; color: var(--muted); line-height: 1.65; }
.steps-list li { margin-bottom: .45rem; }
.steps-list strong { color: var(--text); }

/* --- advertisement --- */
.ad-slot {
  margin: 2.5rem 0 0;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.ad-label {
  display: block;
  margin-bottom: .5rem;
  color: var(--muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
#ad-unit { min-height: 90px; display: flex; align-items: center; justify-content: center; }

.slot-shortfall {
  margin: .7rem 0 0;
  padding: .55rem .7rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .82rem;
}
.slot-shortfall:empty { display: none; }

/* --- colophon --- */
.colophon { margin: 1.1rem 0 0; font-size: .875rem; }
.colophon a { color: var(--muted); text-decoration-color: var(--border); }
.colophon a:hover { color: var(--accent); text-decoration-color: currentColor; }
.colophon-sep { margin: 0 .35rem; opacity: .5; }

.breadcrumb { margin: 0 0 1rem; font-size: .875rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

/* --- feature request form --- */
.request-form { max-width: 34rem; }
.request-form .field-wide { margin-bottom: 1rem; }
.request-form .field-note { margin-top: -.6rem; }
.req {
  margin-left: .3rem;
  color: var(--accent);
  font-weight: 500;
  text-transform: none;
}
.request-form select,
.request-form textarea,
.request-form input[type="text"],
.request-form input[type="email"] {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
}
.request-form textarea { resize: vertical; line-height: 1.5; }
.request-form select:focus-visible,
.request-form textarea:focus-visible,
.request-form input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 0;
}
.request-form .btn { margin-top: .4rem; }

/* Netlify's honeypot: a field only a bot fills in, so it must not be [hidden]. */
.hp-field { position: absolute; left: -9999px; }
