:root {
  color-scheme: light;
  --header-h: 56px;
  --paper: #f4f7fa;
  --card: #ffffff;
  --ink: #1e3a4c;
  --ink-soft: #5a6d7d;
  --accent: #3d7a6e;
  --accent-wash: #dceee9;
  --accent-strong: #2f6358;
  --on-accent: #ffffff;
  --water: #6ba3c7;
  --line: #d4dde4;
  --line-soft: #e4eaef;
  --warn: #c45c26;
  --warn-wash: #fdeee6;
  --warn-line: #e8c4b0;
  --warn-ink: #8a4a18;
  --danger: #b5483b;
  --danger-wash: #fde8e4;
  --danger-line: #ecc8c4;
  --danger-ink: #7a2e26;
  --ok-wash: #e4f2e8;
  --ok-line: #b8d8c4;
  --ok-ink: #2d5a40;
  --shadow: 0 1px 2px rgba(30, 58, 76, 0.06), 0 4px 14px rgba(30, 58, 76, 0.06);
  --max: 1120px;
  --prose: 44rem;
  --radius: 14px;
  --tap: 44px;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Charter, Georgia, ui-serif, serif;
}

/* Dark mode: token remap only. Diagrams and icons keep their own light tiles. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0f1a21;
    --card: #16242d;
    --ink: #e6eef3;
    --ink-soft: #a9bac6;
    --accent: #7cc7b5;
    --accent-wash: #1d3a35;
    --accent-strong: #8fd3c2;
    --on-accent: #0f1a21;
    --line: #2b3d49;
    --line-soft: #22323d;
    --warn: #f0a070;
    --warn-wash: #33221a;
    --warn-line: #5a3a28;
    --warn-ink: #f5c29a;
    --danger: #f08a7c;
    --danger-wash: #361e1b;
    --danger-line: #5c302a;
    --danger-ink: #f6b2a8;
    --ok-wash: #1a3024;
    --ok-line: #2f5a40;
    --ok-ink: #a8dcb8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--water); outline-offset: 2px; border-radius: 6px; }
p, ul, ol { margin: 0 0 0.85rem; }
li { margin: 0.2rem 0; }
code { font-size: 0.9em; background: var(--line-soft); padding: 0.1em 0.35em; border-radius: 5px; overflow-wrap: anywhere; }
.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--card);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}
.skip:focus { top: 0.75rem; }

/* ---------- header ---------- */
.top {
  position: relative;
  z-index: 30;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.25rem 1rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--tap);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.005em;
  color: var(--ink);
  text-decoration: none;
}
.brand img { width: 32px; height: 32px; flex: none; }
/* Phone: one compact row under the wordmark. Every link stays visible; it scrolls sideways only if text is enlarged. */
.top nav {
  display: flex;
  width: calc(100% + 0.4rem);
  margin: 0 -0.2rem;
  justify-content: space-between;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.top nav::-webkit-scrollbar { display: none; }
.top nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
}
.top nav a:hover { background: var(--accent-wash); color: var(--ink); }
@media (max-width: 374px) {
  .top-inner { padding-left: 0.75rem; padding-right: 0.75rem; }
  .top nav a { font-size: 0.8rem; }
}

/* ---------- page and type ---------- */
.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.75rem 1rem 3.5rem;
}
.page-narrow { max-width: var(--prose); }
h1, h2, h3 {
  font-family: var(--serif);
  line-height: 1.2;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: clamp(1.7rem, 6.4vw, 2.5rem); line-height: 1.12; margin: 0.5rem 0 0.75rem; letter-spacing: -0.005em; }
h2 { font-size: clamp(1.28rem, 4.6vw, 1.6rem); margin: 2.25rem 0 0.7rem; }
h3 { font-size: 1.1rem; margin: 0 0 0.35rem; }
.lede { font-size: 1.06rem; line-height: 1.55; color: var(--ink-soft); max-width: 38rem; margin: 0 0 1rem; }
.stain-head { display: flex; gap: 0.8rem; align-items: center; margin: 0.4rem 0 0.75rem; }
.stain-head .ico { flex: none; }
.stain-head .ico svg { width: 56px; height: 56px; }
.stain-head h1 { margin: 0; flex: 1; min-width: 0; }
.crumb { font-size: 0.88rem; color: var(--ink-soft); margin: 0.25rem 0 0.35rem; }
.crumb a { color: var(--ink-soft); display: inline-block; padding: 0.55rem 0; }
.crumb a:hover { color: var(--ink); }
.prose-block { max-width: var(--prose); }

/* ---------- home hero and finder ---------- */
.hero-home {
  display: grid;
  gap: 1rem;
  background: linear-gradient(160deg, var(--card) 0%, var(--accent-wash) 60%, var(--paper) 100%);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem 1.1rem 1.35rem;
  margin: 0.5rem 0 1.25rem;
}
.hero-home h1 { margin-top: 0; }
.hero-home .lede { color: var(--ink); opacity: 0.85; }
.hero-art svg { width: 100%; max-width: 312px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  background: var(--accent);
  color: var(--on-accent);
  border: 2px solid var(--accent);
  transition: filter 0.15s;
}
.btn:hover { color: var(--on-accent); filter: brightness(0.92); }
.btn-ghost { background: var(--card); color: var(--accent); }
.btn-ghost:hover { color: var(--accent); background: var(--accent-wash); filter: none; }

.finder-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1rem 1rem;
  margin: 1rem 0 1.5rem;
  box-shadow: var(--shadow);
}
.finder-panel h2 { margin: 0 0 0.75rem; font-size: 1.25rem; }
.finder-panel > label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.3rem; }
.finder-panel > select { margin-bottom: 0.75rem; }
.finder-row {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.finder-row label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}
.finder-row select, .finder-row input, .finder-panel > select, .matrix-mobile select {
  width: 100%;
  min-height: 48px;
  font: inherit;
  padding: 0.45rem 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
.finder-row .btn { width: 100%; min-height: 48px; font-size: 1.05rem; }
.finder-result {
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  background: var(--accent-wash);
  font-size: 0.98rem;
}
/* Links on tinted panels use the deeper teal to keep AA contrast. */
.finder-result a, .callout-safety a, .do-first a, .do-not-box a, .hero-home a:not(.btn) { color: var(--accent-strong); }
.finder-result a { font-weight: 700; font-size: 1.05rem; display: inline-block; padding: 0.35rem 0; }
.finder-result h2 { margin: 0 0 0.4rem; font-size: 1.15rem; }
.finder-result p:last-child { margin-bottom: 0; }

/* ---------- callouts ---------- */
.callout-safety {
  background: var(--warn-wash);
  border: 1px solid var(--warn-line);
  border-left: 4px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  margin: 1rem 0 1.25rem;
}
.callout-safety h2 { margin: 0 0 0.35rem; font-size: 1.12rem; }
.callout-safety p:last-child { margin-bottom: 0; }
.callout-patch, .differs, .care-notes {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--water);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  margin: 1rem 0 1.25rem;
  font-size: 0.98rem;
}
.differs { border-left-color: var(--accent); }
.care-notes h2 { margin: 0 0 0.4rem; font-size: 1.08rem; }
.care-notes ul { margin: 0; padding-left: 1.2rem; }
.care-notes li { margin: 0.35rem 0; }

.do-first {
  background: var(--ok-wash);
  border: 1px solid var(--ok-line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 0.9rem;
  margin: 1rem 0;
}
.do-first h2 { margin: 0 0 0.55rem; font-size: 1.2rem; color: var(--ok-ink); }
.do-first ol { margin: 0; padding-left: 1.35rem; }
.do-first li { margin: 0.45rem 0; font-weight: 600; padding-left: 0.15rem; }
.do-first li::marker { color: var(--ok-ink); font-weight: 700; }
.do-first p { margin: 0; }

.do-not-box {
  background: var(--danger-wash);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem 0.8rem;
  margin: 1rem 0;
}
.do-not-box h2 { margin: 0 0 0.45rem; font-size: 1.1rem; color: var(--danger-ink); }
.do-not-box ul { margin: 0; padding-left: 1.2rem; }
.do-not-box li { margin: 0.3rem 0; }

/* ---------- section heads and tile cards ---------- */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  margin: 2.25rem 0 0.75rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { margin: 0; }
.section-head a { font-size: 0.95rem; font-weight: 600; display: inline-flex; align-items: center; min-height: var(--tap); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.75rem, 1fr));
  gap: 0.6rem;
}
.card-grid > .tile-card-wrap { margin: 0; }
.tile-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  column-gap: 0.6rem;
  align-items: center;
  height: 100%;
  min-height: 4.5rem;
  padding: 0.6rem 0.65rem 0.6rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tile-card:hover {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.tile-card:active { transform: none; }
.tile-card .ico {
  grid-column: 1;
  align-self: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}
.tile-card .ico svg { width: 48px; height: 48px; }
.tile-card .tile-body {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  justify-content: center;
}
.tile-card .title {
  font-weight: 700;
  line-height: 1.22;
  font-size: 0.97rem;
  overflow-wrap: break-word;
}
.tile-card .meta { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.25; }

/* ---------- step overview and step cards ---------- */
.hero-diagram { margin: 1.5rem 0 0.5rem; }
.hero-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr));
  gap: 0.6rem;
}
.hero-steps li { margin: 0; display: grid; gap: 0.35rem; align-content: start; }
.hero-steps .ov-art { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--card); }
.hero-steps .ov-art svg { width: 100%; }
.hero-steps .ov-cap { display: flex; gap: 0.35rem; align-items: flex-start; font-size: 0.8rem; line-height: 1.25; font-weight: 600; }
.ov-num {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.step-cards { display: grid; gap: 0.85rem; margin: 0.75rem 0 2rem; }
.step-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 0.4rem;
  display: grid;
  gap: 0.5rem;
  align-content: start;
}
.step-card h3 { margin: 0; font-size: 1.12rem; }
.step-card .step-num {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.step-card .diagram { border-radius: 12px; overflow: hidden; background: #f7fafc; border: 1px solid var(--line-soft); }
.step-card .diagram svg { width: 100%; max-width: 360px; margin: 0 auto; }
.step-card p { margin: 0 0 0.6rem; }

/* ---------- badges, tables, matrix ---------- */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-safe { background: var(--ok-wash); color: var(--ok-ink); }
.badge-test-first { background: var(--warn-wash); color: var(--warn-ink); }
.badge-pro, .badge-pro-needed { background: var(--danger-wash); color: var(--danger-ink); }

.fabric-grid-mini { margin: 1.5rem 0; }
.fabric-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }

.hub-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.hub-table th, .hub-table td { padding: 0.6rem 0.65rem; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.hub-table thead th { background: var(--paper); font-weight: 700; }
.hub-table .sticky-col { position: sticky; left: 0; z-index: 2; background: var(--card); }

.matrix-desktop { display: none; }
.matrix-mobile { display: block; }
.matrix-mobile label { font-weight: 600; display: block; margin: 0.75rem 0 0.35rem; }
.matrix-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  -webkit-overflow-scrolling: touch;
}
.mx {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  min-width: max-content;
}
.mx th, .mx td { border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 0; }
.mx thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--paper);
  vertical-align: bottom;
  height: 7.5rem;
  font-weight: 600;
  min-width: 2.75rem;
}
.mx thead th.mx-surface { left: 0; z-index: 4; text-align: left; padding: 0.5rem; }
.mx-stain a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.2rem;
  text-decoration: none;
  color: var(--ink);
  min-height: 7rem;
  justify-content: flex-end;
}
.mx-stain a:hover { background: var(--accent-wash); }
.mx-lbl {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.72rem;
  max-height: 4.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mx-ico svg { width: 28px; height: 28px; }
.mx tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
  padding: 0.4rem 0.55rem;
  min-width: 8.5rem;
  max-width: 9.5rem;
  text-align: left;
}
.mx-surface-inner { display: flex; align-items: center; gap: 0.45rem; font-weight: 600; font-size: 0.85rem; }
.mx td { text-align: center; width: var(--tap); height: var(--tap); }
.mx td a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: var(--tap); text-decoration: none; }
.mx td a:hover { background: var(--accent-wash); }

.mx-mobile-list { list-style: none; padding: 0; margin: 0.75rem 0 0; display: grid; gap: 0.45rem; }
.mx-mobile-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 3.25rem;
  margin: 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.mx-mobile-list a { font-weight: 600; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 0.5rem; min-height: var(--tap); }
.mx-mobile-list svg { width: 28px; height: 28px; flex: none; }

/* ---------- FAQ, details, sources ---------- */
.faq { margin: 2rem 0; }
.faq h2 { margin-bottom: 0.6rem; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 0 0.85rem; margin: 0.5rem 0; background: var(--card); }
details summary {
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: '';
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
details[open] summary::before { transform: rotate(45deg); }
details[open] { padding-bottom: 0.35rem; }
details > p { margin: 0 0 0.75rem 1.1rem; }
details.fabric-table-wrap { padding: 0 0.5rem; }

.affiliate {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 2rem 0;
  background: var(--card);
  font-size: 0.95rem;
}
.affiliate h2 { margin-top: 0; font-size: 1.15rem; }
.affiliate .muted { color: var(--ink-soft); font-size: 0.88rem; }
.sources { margin-top: 2.25rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.92rem; color: var(--ink-soft); }
.sources h2 { margin-top: 0; font-size: 1.15rem; }
.sources a { overflow-wrap: anywhere; }

/* ---------- footer ---------- */
.foot {
  margin-top: 1rem;
  background: var(--card);
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.foot-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}
.foot-about { display: flex; gap: 0.65rem; align-items: flex-start; max-width: 38rem; margin: 0 0 0.75rem; }
.foot-about img { width: 24px; height: 24px; flex: none; margin-top: 0.1rem; }
.foot nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1rem;
  border-top: 1px solid var(--line-soft);
  padding-top: 0.5rem;
}
.foot nav a { color: var(--ink); min-height: var(--tap); display: inline-flex; align-items: center; text-decoration: none; }
.foot nav a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- wider screens ---------- */
@media (min-width: 640px) {
  html { scroll-padding-top: calc(var(--header-h) + 16px); }
  .top { position: sticky; top: 0; }
  .top-inner { flex-wrap: nowrap; min-height: var(--header-h); padding: 0 1.25rem; }
  .top nav { width: auto; margin: 0; gap: 0.1rem; overflow: visible; }
  .top nav a { padding: 0 0.6rem; font-size: 0.95rem; }
  .page { padding: 1.25rem 1.5rem 4rem; }
  .finder-row { grid-template-columns: 1fr 1fr auto; align-items: end; }
  .finder-row .btn { width: auto; padding: 0 1.75rem; }
  .finder-panel { padding: 1.25rem 1.25rem 1.1rem; }
  .hero-home { padding: 1.75rem 1.75rem 1.75rem; }
  .hero-steps { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.75rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 0.7rem; }
  .foot nav { display: flex; flex-wrap: wrap; column-gap: 1.25rem; }
  .foot-inner { padding: 2rem 1.5rem 3rem; }
}
@media (min-width: 900px) {
  :root { --header-h: 60px; }
  .hero-home { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2rem; padding: 2.25rem 2.25rem; }
  .hero-art svg { width: 340px; max-width: none; }
  .matrix-desktop { display: block; }
  .matrix-mobile { display: none; }
  .step-cards { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .step-card:nth-child(odd):last-child { grid-column: 1 / -1; max-width: calc(50% - 0.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  .tile-card, .btn, details summary::before { transition: none; }
  .tile-card:hover { transform: none; }
}
