/* Stitch Tuner. Mobile-first, system fonts, no external requests. */
:root {
  --ink: #1b2a3b;
  --ink-2: #3a4a5c;
  --muted: #5b6876;
  --line: #dfd8cb;
  --paper: #fbf8f2;
  --card: #ffffff;
  --cream: #f4efe6;
  --accent: #c2410c;
  --accent-ink: #9a3412;
  --blue: #2563eb;
  --ok: #166534;
  --warn: #92400e;
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --stitch: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 16px);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; font-family: var(--sans); font-size: 1.0625rem; line-height: 1.65;
  color: var(--ink); background: var(--paper);
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.1rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .6rem 1rem; z-index: 99; }
.skip:focus { left: .5rem; top: .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.small { font-size: .875rem; color: var(--muted); }

/* Header */
.site-header { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.site-header::after { content: ""; display: block; height: 3px; background: var(--stitch); opacity: .9; }
.header-inner { display: flex; align-items: center; gap: .75rem; min-height: 58px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; font-family: var(--serif); font-size: 1.3rem; letter-spacing: .01em; }
.brand b { color: #fdba74; font-weight: 700; }
.logo-mark { width: 30px; height: 30px; --accent: #fb923c; }
.primary { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -1.1rem; padding: 0 1.1rem; }
.primary::-webkit-scrollbar { display: none; }
.primary ul { display: flex; gap: .2rem; list-style: none; margin: 0; padding: 0 0 .45rem; white-space: nowrap; }
.primary a { display: block; color: #e6ebf1; text-decoration: none; font-size: .9rem; padding: .4rem .65rem; border-radius: 999px; }
.primary a:hover, .primary a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; }
.search-link { margin-left: auto; display: inline-flex; align-items: center; gap: .35rem; color: #fff; text-decoration: none; font-size: .9rem; padding: .4rem .7rem; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; }
.search-link svg { width: 18px; height: 18px; }
@media (min-width: 980px) {
  .primary { order: 0; width: auto; margin: 0 0 0 1rem; padding: 0; overflow: visible; }
  .primary ul { padding: 0; }
}

/* Breadcrumbs */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 1.1rem 0 .4rem; font-size: .85rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: .3rem; color: #b3aa9a; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink-2); }

/* Article */
.doc { max-width: 760px; }
.doc-head h1 { font-family: var(--serif); font-size: clamp(1.9rem, 5.5vw, 2.75rem); line-height: 1.15; margin: .4rem 0 .6rem; letter-spacing: -.01em; }
.lede { font-size: 1.18rem; color: var(--ink-2); margin: 0 0 .7rem; }
.meta { font-size: .85rem; color: var(--muted); margin: 0 0 1.4rem; padding-bottom: 1rem; border-bottom: 2px dashed var(--line); }
.meta a { color: var(--muted); }
.answer { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 0 0 1.4rem; box-shadow: 0 1px 0 rgba(0,0,0,.03); }
.answer p { margin: 0; }
.answer .answer-label { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--accent-ink); margin-bottom: .3rem; }
.toc { background: var(--cream); border-radius: var(--radius); padding: .8rem 1.1rem; margin: 0 0 1.6rem; }
.toc summary { cursor: pointer; font-weight: 700; font-size: .95rem; }
.toc ol { margin: .5rem 0 0; padding-left: 1.2rem; font-size: .95rem; columns: 1; }
.toc li { margin: .2rem 0; break-inside: avoid; }
@media (min-width: 700px) { .toc ol { columns: 2; column-gap: 2rem; } }

.prose h2 { font-family: var(--serif); font-size: clamp(1.45rem, 4vw, 1.8rem); line-height: 1.25; margin: 2.4rem 0 .7rem; }
.prose h3 { font-size: 1.15rem; margin: 1.8rem 0 .4rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.05rem; }
.prose li { margin: .3rem 0; }
.prose code, .prose kbd { font-family: var(--mono); font-size: .9em; background: var(--cream); padding: .1em .35em; border-radius: 4px; }
.prose hr { border: 0; height: 2px; background: var(--stitch); opacity: .4; margin: 2rem 0; }
.prose blockquote { margin: 1.2rem 0; padding: .2rem 1rem; border-left: 4px solid var(--line); color: var(--ink-2); }

.table-wrap { overflow-x: auto; margin: 1.2rem 0 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; line-height: 1.45; }
caption { text-align: left; font-weight: 700; padding: .75rem 1rem .4rem; font-size: .95rem; }
th, td { text-align: left; vertical-align: top; padding: .6rem .8rem; border-top: 1px solid var(--line); }
thead th { background: var(--cream); border-top: 0; font-size: .85rem; letter-spacing: .01em; white-space: nowrap; }
tbody th { font-weight: 600; }
tbody tr:nth-child(even) td, tbody tr:nth-child(even) th { background: #fcfaf6; }

ol.steps { list-style: none; counter-reset: s; padding: 0; }
ol.steps > li { counter-increment: s; position: relative; padding: .1rem 0 .4rem 2.6rem; margin: 0 0 .8rem; }
ol.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 1.85rem; height: 1.85rem; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; font-size: .9rem; display: grid; place-items: center; }

.callout { border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1.3rem 0; background: #eef4ff; border: 1px solid #c7d7fb; }
.callout p:last-child { margin-bottom: 0; }
.callout.tip { background: #f0f7f1; border-color: #bfe0c6; }
.callout.warn { background: #fff5eb; border-color: #f7c99d; }
.callout.note { background: #eef4ff; border-color: #c7d7fb; }
.takeaways { background: var(--ink); color: #eef2f6; border-radius: var(--radius); padding: 1rem 1.3rem; margin: 1.5rem 0; }
.takeaways h2 { color: #fff; margin: .2rem 0 .5rem !important; font-size: 1.2rem !important; }
.takeaways a { color: #fdba74; }
.verdict { border: 2px dashed var(--accent); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.5rem 0; background: var(--card); }
.verdict .verdict-label { font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--accent-ink); margin-bottom: .3rem; }
.verdict p:last-child { margin-bottom: 0; }
figure.diagram { margin: 1.5rem 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
figure.diagram svg { display: block; margin: 0 auto; width: 100%; height: auto; max-height: 360px; font-family: var(--sans); }
figure.diagram figcaption { font-size: .88rem; color: var(--muted); margin-top: .6rem; }
dl.symptoms { margin: 1rem 0 1.4rem; }
dl.symptoms dt { font-weight: 700; margin-top: .7rem; }
dl.symptoms dd { margin: .15rem 0 0 0; padding-left: .9rem; border-left: 3px solid var(--line); }

/* FAQ, sources, related */
.faqs, .sources { margin-top: 2.5rem; }
.faqs h2, .sources h2, .related h2 { font-family: var(--serif); font-size: 1.5rem; margin: 0 0 .8rem; }
details.faq { border-top: 1px solid var(--line); }
details.faq:last-child { border-bottom: 1px solid var(--line); }
details.faq summary { cursor: pointer; list-style: none; padding: .85rem 2rem .85rem 0; position: relative; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; position: absolute; right: .3rem; top: .65rem; font-size: 1.4rem; color: var(--accent); }
details.faq[open] summary::after { content: "\2212"; }
details.faq summary h3 { display: inline; font-size: 1.02rem; margin: 0; font-weight: 650; }
details.faq div { padding: 0 0 .9rem; color: var(--ink-2); }
details.faq div p { margin: 0 0 .6rem; }
.sources ul { padding-left: 1.1rem; font-size: .95rem; }
.src-note { color: var(--muted); }
.src-note::before { content: "("; } .src-note::after { content: ")"; }
.fixit { margin: 2rem 0 0; font-size: .92rem; color: var(--muted); padding-top: 1rem; border-top: 2px dashed var(--line); }
.related { margin: 3rem 0 1rem; }

.cards { list-style: none; padding: 0; margin: 1rem 0 1.5rem; display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .related .cards, .home .cards { grid-template-columns: repeat(3, 1fr); } }
.card a { display: flex; flex-direction: column; gap: .25rem; height: 100%; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; transition: border-color .15s, transform .15s; }
.card a:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--accent-ink); font-weight: 700; }
.card-title { font-weight: 700; font-size: 1.02rem; line-height: 1.3; }
.card-desc { font-size: .9rem; color: var(--muted); line-height: 1.45; }

/* Tools */
.tool { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin: 0 0 2rem; box-shadow: 0 2px 10px rgba(27,42,59,.05); }
.tool > h2 { margin-top: 0 !important; }
.tool-form { display: grid; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .field legend { font-weight: 650; font-size: .95rem; }
.field fieldset { border: 0; padding: 0; margin: 0; }
.field-row { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .field-row { grid-template-columns: repeat(2, 1fr); } }
.hint { margin: 0 !important; font-size: .82rem; color: var(--muted); }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  font: inherit; font-size: 1rem; color: var(--ink); width: 100%; padding: .65rem .75rem; min-height: 46px;
  border: 1.5px solid #cfc6b6; border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.2); }
.btn { font: inherit; font-weight: 700; background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: .7rem 1.2rem; min-height: 46px; cursor: pointer; justify-self: start; }
.btn:hover { background: var(--accent-ink); }
.btn.secondary { background: var(--ink); }
.result { margin-top: 1rem; padding: 1rem; border-radius: 12px; background: var(--cream); }
.result:empty { display: none; }
.result > :first-child { margin-top: 0; }
.result > :last-child { margin-bottom: 0; }
.result h3 { margin: 1rem 0 .4rem; font-size: 1.05rem; }
.result-big { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 0 0 .3rem !important; color: var(--ink); }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); margin: 0 .25rem .25rem 0; }
.pill.hi { background: #fde7d9; border-color: #f7b98f; color: var(--accent-ink); }
.pill.mid { background: #fdf3d8; border-color: #f0d38a; color: #7c5a05; }
.pill.lo { background: #e8f1ff; border-color: #bcd2fa; color: #1e429f; }

/* Home */
.hero { background: var(--ink); color: #eef2f6; padding: 2.6rem 0 2.8rem; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 14px; height: 3px; background: var(--stitch); opacity: .55; }
.hero h1 { font-family: var(--serif); font-size: clamp(2.1rem, 7vw, 3.6rem); line-height: 1.08; margin: 0 0 .9rem; color: #fff; max-width: 16ch; letter-spacing: -.015em; }
.hero h1 em { font-style: normal; color: #fdba74; }
.hero p { font-size: 1.15rem; max-width: 46ch; margin: 0 0 1.4rem; color: #d3dbe4; }
.hero-search { display: flex; gap: .5rem; max-width: 560px; }
.hero-search input { flex: 1; border: 0; }
.hero-search .btn { justify-self: auto; }
.hero-quick { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1.1rem; padding: 0; list-style: none; }
.hero-quick a { display: inline-block; font-size: .88rem; color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.28); padding: .35rem .8rem; border-radius: 999px; }
.hero-quick a:hover { background: rgba(255,255,255,.1); }
.band { padding: 2.6rem 0; }
.band.alt { background: var(--cream); }
.band h2 { font-family: var(--serif); font-size: clamp(1.6rem, 4.5vw, 2.1rem); margin: 0 0 .4rem; line-height: 1.2; }
.band .sub { color: var(--muted); margin: 0 0 1.2rem; max-width: 62ch; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.section-head a { font-weight: 600; font-size: .95rem; }
.clusters { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .clusters { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .clusters { grid-template-columns: repeat(3, 1fr); } }
.clusters a { display: block; height: 100%; padding: 1.1rem 1.15rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); border-top: 4px solid var(--ink); }
.clusters a:hover { border-top-color: var(--accent); }
.clusters strong { display: block; font-family: var(--serif); font-size: 1.2rem; margin-bottom: .2rem; }
.clusters span { color: var(--muted); font-size: .92rem; }
.symptom-grid { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .6rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 760px) { .symptom-grid { grid-template-columns: repeat(4, 1fr); } }
.symptom-grid a { display: block; height: 100%; padding: .8rem .9rem; background: var(--card); border: 1px dashed #c9bfae; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem; line-height: 1.3; }
.symptom-grid a:hover { border-style: solid; border-color: var(--accent); }
.symptom-grid small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.method { display: grid; gap: 1.5rem; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 860px) { .method { grid-template-columns: 1.1fr 1fr; } }
.method ol { counter-reset: m; list-style: none; padding: 0; margin: 0; }
.method li { counter-increment: m; padding: .55rem 0 .55rem 2.6rem; position: relative; border-bottom: 1px dashed var(--line); }
.method li::before { content: counter(m); position: absolute; left: 0; top: .5rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 2px solid var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center; font-size: .9rem; }
.trust { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .trust { grid-template-columns: repeat(3, 1fr); } }
.trust div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.trust h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.trust p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.cta-link { font-weight: 700; }

/* Glossary */
.glossary dt { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; margin-top: 1.3rem; scroll-margin-top: 90px; }
.glossary dd { margin: .2rem 0 0; }
.glossary dt:target { color: var(--accent-ink); }
.az { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0; list-style: none; margin: 0 0 1rem; }
.az a { display: inline-block; min-width: 2rem; text-align: center; padding: .2rem .4rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: var(--card); }

/* Search */
.search-results { list-style: none; padding: 0; }
.search-results li { padding: .8rem 0; border-bottom: 1px solid var(--line); }
.search-results a { font-weight: 700; font-size: 1.05rem; }
.search-results p { margin: .2rem 0 0; color: var(--muted); font-size: .92rem; }

/* Footer */
.site-footer { margin-top: 4rem; background: var(--ink); color: #c9d2dc; padding: 2.4rem 0 1.6rem; font-size: .93rem; }
.site-footer::before { content: ""; display: block; height: 3px; background: var(--stitch); opacity: .7; margin-top: -2.4rem; margin-bottom: 2.4rem; }
.site-footer a { color: #e6ebf1; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.foot-grid { display: grid; gap: 1.6rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.foot-about p { margin: .6rem 0 0; max-width: 36ch; }
.foot-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 .5rem; color: #fdba74; }
.foot-h a { color: #fdba74; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: .3rem 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: 2rem 0 1rem; padding-top: 1.2rem; border-top: 1px solid rgba(255,255,255,.15); }
.site-footer .small { color: #9fb0c1; }

@media print {
  .site-header, .site-footer, .related, .toc, .crumbs, .fixit { display: none; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
