@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(fonts/archivo-var.woff2) format('woff2-variations');
}
@font-face {
  font-family: 'JB Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/jbmono-400.woff2) format('woff2');
}
@font-face {
  font-family: 'JB Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/jbmono-600.woff2) format('woff2');
}

:root {
  --paper: #f3f1ea;
  --sheet: #fbfaf6;
  --ink: #141414;
  --ink-2: #3b3a36;
  --muted: #6b675d;
  --rule: #d6d1c3;
  --rule-strong: #141414;
  --accent: #d9501a;
  --accent-ink: #a83a0f;
  --accent-soft: #fbe6da;
  --ok: #2f6b3a;
  --ok-soft: #e3efe2;
  --bad: #9b2c1c;
  --viewer-bg: #121416;
  --sans: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JB Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 40px; --s7: 72px;
  --radius: 3px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  font-stretch: 100%;
}
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1180px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 720px) { .wrap { padding-inline: 32px; } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 10; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.875rem; }

/* header / footer */
.site-header { border-bottom: 1px solid var(--rule-strong); background: var(--paper); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-stretch: 85%; letter-spacing: 0.01em; text-transform: uppercase; font-size: 0.9rem; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); }
.site-header nav, .site-footer nav { display: flex; gap: var(--s4); flex-wrap: wrap; }
.site-header nav a, .site-footer nav a { color: var(--ink-2); text-decoration: none; font-size: 0.9rem; }
.site-header nav a:hover, .site-footer nav a:hover { color: var(--accent-ink); text-decoration: underline; }
@media (max-width: 560px) { .site-header nav { display: none; } }
.site-footer { border-top: 1px solid var(--rule-strong); margin-top: var(--s7); padding-block: var(--s4); color: var(--muted); font-size: 0.875rem; }
.site-footer p { margin: 0; max-width: 60ch; }

/* intro */
.intro { padding-top: var(--s5); padding-bottom: var(--s4); }
h1 {
  font-size: clamp(2rem, 5.2vw, 3.6rem);
  line-height: 1;
  font-weight: 800;
  font-stretch: 78%;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0 0 var(--s3);
}
.lead { max-width: 74ch; margin: 0; color: var(--ink-2); font-size: 1.02rem; }
@media (max-width: 560px) { .lead { font-size: 0.95rem; } }

/* tool shell */
.tool { margin-top: var(--s3); }
.tablist { display: flex; border: 1px solid var(--rule-strong); border-bottom: 0; background: var(--paper); overflow-x: auto; scrollbar-width: none; }
.tablist::-webkit-scrollbar { display: none; }
[role='tab'] {
  flex: 1 0 auto;
  display: flex; align-items: baseline; gap: 8px;
  padding: 12px 16px;
  font: 600 0.95rem/1.2 var(--sans);
  color: var(--ink-2);
  background: transparent;
  border: 0; border-right: 1px solid var(--rule-strong);
  cursor: pointer; white-space: nowrap; text-align: left;
}
[role='tab']:last-child { border-right: 0; }
[role='tab'] .tab-n { font: 600 0.75rem var(--mono); color: var(--muted); }
[role='tab'][aria-selected='true'] { background: var(--ink); color: var(--paper); }
[role='tab'][aria-selected='true'] .tab-n { color: #f6b08f; }
[role='tab']:hover:not([aria-selected='true']) { background: var(--sheet); }
@media (max-width: 560px) {
  .tablist { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  [role='tab'] { flex-direction: column; gap: 2px; padding: 10px 10px; white-space: normal; font-size: 0.85rem; line-height: 1.15; }
}
.panel { --pad-x: var(--s4); border: 1px solid var(--rule-strong); background: var(--sheet); padding: var(--s5) var(--pad-x); }
@media (min-width: 720px) { .panel { --pad-x: var(--s5); } }

.grid-2 { display: grid; gap: var(--s5); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--s6); } }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; margin-bottom: var(--s3); padding: 0; }
.field { margin-bottom: var(--s4); }
.field label, .field > div > label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field .mt { margin-top: var(--s3); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s4); }
.hint { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }

input, select, button { font: inherit; color: inherit; }
input[type='text'], input:not([type]), input[type='number'], select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #a9a395;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.95rem;
}
select { font-family: var(--sans); cursor: pointer; }
input:focus, select:focus { border-color: var(--ink); outline: 2px solid var(--accent); outline-offset: 0; }
input[aria-invalid='true'] { border-color: var(--bad); background: #fff6f3; }

.with-unit { display: flex; align-items: stretch; }
.with-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.with-unit select, .with-unit .unit { width: auto; flex: 0 0 auto; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.with-unit .unit { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid #a9a395; border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; background: var(--paper); font: 0.9rem var(--mono); color: var(--ink-2); }
.with-unit.narrow { width: 112px; flex: 0 0 auto; }
.row { display: flex; gap: var(--s2); align-items: center; margin-top: var(--s2); }
.row .with-unit { flex: 1; }
.at { font: 600 1rem var(--mono); color: var(--muted); }
#custom-step { margin-top: var(--s2); }
.range-row { display: flex; gap: var(--s3); align-items: center; }
.range-row input[type='range'] { flex: 1; accent-color: var(--accent); min-height: 44px; }

.seg { display: flex; border: 1px solid var(--ink); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--s4); }
.seg label { flex: 1; position: relative; text-align: center; padding: 10px 6px; font-weight: 600; font-size: 0.88rem; cursor: pointer; border-right: 1px solid var(--ink); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--ink); color: var(--paper); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -4px; }

.error { color: var(--bad); font-weight: 600; font-size: 0.9rem; margin: 0; min-height: 0; }
.error:empty { display: none; }

/* results */
.results { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); border-top: 2px solid var(--ink); }
.results > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s3); align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.results dt { font-size: 0.88rem; color: var(--ink-2); }
.results dt small { display: block; color: var(--muted); font-size: 0.78rem; }
.results dd { margin: 0; font: 600 1.02rem var(--mono); text-align: right; white-space: nowrap; }
.results dd .alt { display: block; font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.results .hero dt { font-weight: 700; color: var(--ink); font-size: 0.95rem; }
.results .hero dd { font-size: clamp(1.5rem, 3.4vw, 2.1rem); color: var(--ink); }
.results .pass dd { color: var(--ok); }
.results .fail dd { color: var(--bad); }
.callout { margin: var(--s3) 0 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); font-size: 0.85rem; }
.callout.ok { border-color: var(--ok); background: var(--ok-soft); }

/* mobile: live result pinned to the bottom while the inputs are on screen */
.mini-result { display: none; }
@media (max-width: 899px) {
  .mini-result:not(:empty) {
    display: flex; justify-content: space-between; gap: var(--s3);
    position: sticky; bottom: 0; z-index: 2;
    margin: var(--s4) calc(-1 * var(--pad-x)) calc(-1 * var(--s5));
    padding: 10px var(--pad-x);
    background: var(--ink); color: var(--paper);
    font: 600 0.95rem var(--mono);
  }
  .mini-result span:last-child { color: #f6b08f; }
}

/* signature: to-scale patch */
.patch { margin: var(--s5) 0 0; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--s4); align-items: center; }
.patch canvas { width: 180px; height: 180px; border: 1px solid var(--ink); background: #fff; image-rendering: auto; }
.patch figcaption { font-size: 0.82rem; color: var(--ink-2); }
.patch figcaption b { font-family: var(--mono); }
@media (max-width: 420px) { .patch { grid-template-columns: 132px minmax(0, 1fr); } .patch canvas { width: 132px; height: 132px; } }

.setting-table { margin-top: var(--s5); }
.h-small { font-size: 0.95rem; font-weight: 700; margin: 0 0 var(--s2); text-transform: uppercase; font-stretch: 85%; letter-spacing: 0.02em; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { border-bottom: 2px solid var(--ink); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-2); white-space: nowrap; }
#settings-out td.num, #settings-out th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
#settings-out tr.current { background: var(--accent-soft); }
.tick { color: var(--ok); font-weight: 700; }
.cross { color: var(--bad); }

/* file tab */
.file-layout { display: grid; gap: var(--s5); }
@media (min-width: 960px) { .file-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.drop {
  display: grid; gap: 4px; justify-items: start;
  padding: var(--s5) var(--s4);
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  margin-bottom: var(--s3);
  transition: background 0.15s;
}
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop-title { font-weight: 800; font-size: 1.15rem; font-stretch: 85%; text-transform: uppercase; }
.drop-sub { font-size: 0.85rem; color: var(--ink-2); }
.drop-privacy { font: 0.78rem var(--mono); color: var(--ok); margin-top: 4px; }
.btn-ghost { display: block; width: 100%; min-height: 44px; margin-bottom: var(--s4); background: transparent; border: 1px solid var(--ink); border-radius: var(--radius); font-weight: 600; cursor: pointer; }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-small { min-height: 36px; padding: 6px 12px; border: 1px solid var(--ink); border-radius: var(--radius); background: #fff; cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.btn-small:hover { background: var(--ink); color: var(--paper); }
.status { font: 0.85rem var(--mono); color: var(--ink-2); margin: 0 0 var(--s3); min-height: 1.2em; }
.status.err { color: var(--bad); font-family: var(--sans); font-weight: 600; }
.progress { height: 3px; background: var(--rule); margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
.adv { margin-top: var(--s4); border-top: 1px solid var(--rule); padding-top: var(--s3); }
.adv summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.adv .with-unit { max-width: 220px; margin: var(--s2) 0; }
.notes { margin: var(--s3) 0 0; padding-left: 18px; font-size: 0.82rem; color: var(--ink-2); }
.notes:empty { display: none; }

.viewer-wrap { min-width: 0; }
.viewer { position: relative; height: clamp(320px, 58vh, 560px); background: var(--viewer-bg); border-radius: var(--radius); overflow: hidden; touch-action: none; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: var(--s4); text-align: center; color: #9aa0a6; font: 0.85rem var(--mono);
  background-image: radial-gradient(#3a3f45 1px, transparent 1px); background-size: 14px 14px; }
.viewer-controls { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-top: var(--s2); font-size: 0.85rem; }
.viewer-controls label { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.viewer-controls select { width: auto; min-height: 36px; padding: 4px 8px; }
.viewer-controls .grow { flex: 1 1 160px; }
.viewer-controls input[type='range'] { flex: 1; accent-color: var(--accent); }

/* article */
.prose { margin-top: var(--s7); }
.prose section { max-width: 820px; margin-bottom: var(--s6); }
.prose h2 { font-size: clamp(1.4rem, 2.8vw, 2rem); line-height: 1.1; font-weight: 800; font-stretch: 80%; text-transform: uppercase; margin: 0 0 var(--s4); padding-top: var(--s3); border-top: 2px solid var(--ink); }
.prose p, .prose li { color: var(--ink-2); }
.prose strong { color: var(--ink); }
.formulas { list-style: none; padding: 0; margin: var(--s4) 0; counter-reset: f; border-top: 1px solid var(--rule); }
.formulas li { counter-increment: f; padding: var(--s3) 0 var(--s3) 40px; border-bottom: 1px solid var(--rule); position: relative; }
.formulas li::before { content: counter(f, decimal-leading-zero); position: absolute; left: 0; top: var(--s3); font: 600 0.8rem var(--mono); color: var(--accent-ink); }
.f-label { display: block; font-weight: 700; color: var(--ink); font-size: 0.9rem; }
code { font-family: var(--mono); font-size: 0.9em; background: #ebe7dc; padding: 1px 5px; border-radius: 2px; color: var(--ink); white-space: nowrap; }
table.data th[scope='row'] { font-weight: 600; white-space: nowrap; }
table.data td:nth-child(3) { white-space: nowrap; font-family: var(--mono); font-size: 0.82rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
