:root {
  color-scheme: light;
  --paper: #f2f1e9;
  --panel: #fbfaf3;
  --ink: #172e28;
  --muted: #4f645a;
  --green: #163933;
  --green-2: #254a40;
  --soft: #e0e8d8;
  --rule: #cbd1c2;
  --accent: #a33e23;
  --error: #8b2d23;
  --error-paper: #f7e5dc;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --gutter: clamp(16px, 3.8vw, 52px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 100%; scroll-padding-top: 20px; }
body {
  margin: 0;
  min-width: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.57 var(--sans);
}
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--accent); }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p, ol, ul, dl, figure { margin: 0; }
h1, h2, h3 { line-height: 1.11; }
h1, h2 { letter-spacing: -.045em; }
h3 { letter-spacing: -.02em; }
img, svg { max-width: 100%; }
.shell { width: min(100%, 1320px); margin-inline: auto; padding-inline: var(--gutter); }

.skip {
  position: absolute;
  top: 10px;
  left: var(--gutter);
  transform: translateY(-200%);
  z-index: 2;
  background: var(--panel);
  padding: 9px 13px;
}
.skip:focus { transform: translateY(0); }
.site-header { border-bottom: 1px solid var(--rule); }
.site-bar, .site-footer .shell { display: flex; align-items: center; gap: 16px 24px; }
.site-bar { min-height: 76px; justify-content: space-between; }
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 1.125rem;
  line-height: 1.15;
  font-weight: 750;
  white-space: nowrap;
  letter-spacing: -.045em;
  text-decoration: none;
}
.brand-mark, .brand-mark svg { display: block; width: 32px; height: 32px; }
.site-bar nav, .site-footer nav { display: flex; align-items: center; flex-wrap: wrap; gap: 6px clamp(16px, 2.5vw, 32px); }
.site-bar nav a, .site-footer nav a { font-size: .9375rem; font-weight: 650; text-decoration: none; }
.site-bar nav a:hover, .site-footer nav a:hover { text-decoration: underline; }
.site-footer { border-top: 1px solid var(--rule); margin-top: 54px; }
.site-footer .shell { padding-block: 27px; flex-wrap: wrap; }
.site-footer p { color: var(--muted); }
.site-footer nav { margin-left: auto; }

.button {
  display: inline-flex;
  min-height: 43px;
  justify-content: center;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 5px;
  line-height: 1.25;
  font-size: .9375rem;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}
.button-primary { color: var(--panel); background: var(--green); }
.button-primary:hover { color: var(--panel); background: var(--green-2); }
.button-secondary { color: var(--ink); background: var(--panel); border-color: var(--rule); }
.button-secondary:hover { color: var(--green); border-color: var(--muted); }
.button-link { color: var(--muted); background: none; text-decoration: underline; text-underline-offset: .18em; }

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, .93fr) minmax(0, 1.07fr);
  align-items: center;
  gap: clamp(28px, 5vw, 70px);
  padding-block: clamp(45px, 7.1vw, 105px) clamp(42px, 6vw, 80px);
}
.hero-copy h1 { font-size: clamp(2.9rem, 5.15vw, 4.6rem); line-height: .99; letter-spacing: -.05em; font-weight: 700; }
.hero-copy p { max-width: 36ch; margin-block: 23px 24px; font-size: clamp(1.04rem, 1.55vw, 1.27rem); color: var(--muted); }
.hero-drawing { padding: 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); transform: rotate(-1.5deg); }
.hero-drawing .shop-diagram { border-radius: 3px; }
.hero-drawing figcaption { padding: 8px 7px 0; }
.hero-drawing figcaption a { color: var(--green); text-decoration-color: var(--rule); }
.hero-drawing figcaption a:hover { color: var(--accent); }

.landing-section { margin-block: 8px 52px; }
.section-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 22px; margin-bottom: 18px; }
.section-title h2 { font-size: clamp(1.9rem, 3.6vw, 3.1rem); }
.section-title p { color: var(--muted); }
.tool-grid, .guide-index { display: grid; list-style: none; padding: 0; gap: 10px; }
.tool-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  height: 100%;
  padding: clamp(15px, 2vw, 25px);
  min-height: 195px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 7px;
  text-decoration: none;
}
.tool-card:hover { border-color: var(--green); color: var(--green); background: #f5f7ec; }
.card-icon { width: 42px; height: 42px; color: var(--accent); }
.tool-card h3 { font-size: 1.15rem; }
.tool-card p { color: var(--muted); font-size: .9375rem; line-height: 1.45; }
.guide-index { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.guide-index details, .faq details { border: 1px solid var(--rule); background: var(--panel); border-radius: 5px; }
.guide-index details[open], .faq details[open] { border-color: var(--muted); }
.guide-index summary, .faq summary {
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  padding: 12px 14px;
  font-weight: 700;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "+";
  flex: none;
  color: var(--accent);
  font: 700 1.25rem/1 var(--mono);
}
details[open] > summary::before { content: "−"; }
.guide-index summary small { margin-left: auto; color: var(--muted); text-align: right; font-weight: 550; }
.guide-index ul { padding: 0 15px 13px 39px; }
.guide-index li { margin-block: 4px; }

.breadcrumbs { margin-block: 23px 16px; }
.breadcrumbs ol { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0 9px; color: var(--muted); font-size: .875rem; }
.breadcrumbs li { display: flex; gap: 9px; align-items: baseline; }
.breadcrumbs li + li::before { content: "/"; color: #64776c; }
.page-heading { margin-bottom: 23px; }
.page-heading h1 { max-width: 23ch; font-size: clamp(2.4rem, 4.6vw, 4.1rem); line-height: 1.01; }
.page-heading p { max-width: 71ch; margin-top: 14px; color: var(--muted); font-size: 1.0625rem; }
.shop-note {
  max-width: 80ch;
  padding: 11px 15px;
  margin-bottom: 19px;
  background: var(--soft);
  border-left: 3px solid var(--green);
  border-radius: 0 4px 4px 0;
}

.workbench-grid { display: grid; grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr); gap: 14px; align-items: start; }
.setup-panel, .drawing-panel, .results-panel {
  min-width: 0;
  padding: clamp(14px, 2vw, 25px);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 7px;
}
.setup-heading, .drawing-heading, .output-heading, .setup-actions {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px;
}
.jump-panel { display: none; }
.setup-heading h2, .drawing-heading h2, .output-heading h2 { font-size: clamp(1.3rem, 2vw, 1.8rem); }
.unit-toggle { display: flex; width: max-content; gap: 2px; background: var(--soft); border-radius: 5px; padding: 3px; }
.unit-toggle button {
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--green);
  font: 700 .875rem/1 var(--mono);
  min-width: 44px;
  min-height: 36px;
}
.unit-toggle button[aria-pressed="true"] { background: var(--green); color: var(--panel); }

.input-section, .input-row { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.input-section { margin-top: 17px; }
.input-section legend, .input-section h3 { color: var(--green); font-size: .98rem; font-weight: 760; padding: 0; line-height: 1.35; }
.input-section legend, .input-section h3 { margin-bottom: 7px; }
.input-section.rows { border-top: 1px solid var(--rule); padding-top: 14px; }
.rows > .hint { margin: -3px 0 9px; }
.input-row { border: 1px solid var(--rule); border-radius: 5px; margin-bottom: 10px; padding: 0 10px 2px; }
.input-row legend { padding-inline: 5px; margin-left: -2px; font-size: .875rem; }
.fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 10px; }
.field label, .share-controls label { display: block; color: var(--ink); font-size: .875rem; line-height: 1.25; font-weight: 650; margin-bottom: 4px; }
.field[data-field="slide"], .field[data-field="grain"], .field[data-field="moisture"], .field[data-field="basis"],
.field[data-field="tandemSize"], .field[data-field="profile"], .field[data-field$=".name"] { grid-column: 1 / -1; }
.field, .field input, .field select { min-width: 0; width: 100%; }
.control, .share-controls input, #sheet-selector select {
  background: #fffefb;
  border: 1px solid #a9b5a5;
  border-radius: 4px;
}
.control { display: grid; grid-template-columns: minmax(0, 1fr); }
.control.has-suffix { grid-template-columns: minmax(0, 1fr) auto; }
.control:focus-within { outline: 2px solid var(--green); outline-offset: 1px; }
.control :focus-visible { outline: none; }
.control input, .control select { min-height: 40px; border: 0; background: transparent; padding: 6px 9px; color: var(--ink); }
.control input { font-family: var(--mono); font-size: .95rem; }
.control input[inputmode] { font-variant-numeric: tabular-nums; }
.control span { align-self: center; padding-inline: 2px 8px; color: var(--muted); font: .8125rem/1 var(--mono); }
.control select, #sheet-selector select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  font-size: .9375rem;
}
.control:has([aria-invalid="true"]) { border-color: var(--error); background: var(--error-paper); }
.hint, .field-error { display: block; font-size: .8125rem; line-height: 1.38; color: var(--muted); }
.field .hint, .field .field-error { margin-top: 4px; }
.field-error { color: var(--error); }
.remove-row { justify-self: end; display: flex; width: max-content; min-height: 36px; margin-left: auto; padding-inline: 5px; font-size: .8125rem; }
.setup-actions { border-top: 1px solid var(--rule); margin-top: 15px; padding-top: 12px; }
.share-controls { margin-top: 12px; }
.share-controls > div { display: flex; align-items: stretch; gap: 6px; }
.share-controls input { min-width: 40px; flex: 1; color: var(--green); padding: 6px 8px; font-family: var(--mono); font-size: .875rem; }
.form-errors, .result-warning, .notice {
  background: var(--error-paper);
  color: var(--error);
  border-left: 3px solid var(--error);
  border-radius: 0 4px 4px 0;
  padding: 9px 11px;
  margin-top: 12px;
  font-size: .875rem;
}
.workbench-status { margin: 9px 0 0; color: var(--muted); font-size: .875rem; }
.workbench-status:empty { margin: 0; }
.drawing-panel figure { margin-top: 12px; }
.shop-diagram { display: block; width: 100%; height: auto; border-radius: 4px; }
figcaption { padding-top: 6px; line-height: 1.38; font-size: .875rem; color: var(--muted); }
#sheet-selector { display: flex; align-items: center; gap: 6px; font-size: .875rem; color: var(--muted); }
#sheet-selector select { min-height: 39px; color: var(--ink); padding-left: 8px; }
.diagram-placeholder { display: grid; place-items: center; min-height: 130px; text-align: center; padding: 18px; background: var(--soft); border-radius: 4px; color: var(--green); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; margin-top: 13px; }
.stats > div { min-width: 0; padding: 10px 12px; background: var(--panel); }
.stats dt { color: var(--muted); font-size: .875rem; line-height: 1.25; font-weight: 650; }
.stats dd { margin: 4px 0 0; color: var(--green); font: 700 clamp(1.05rem, 2.1vw, 1.45rem)/1.12 var(--mono); overflow-wrap: anywhere; }
.results-panel { margin-top: 14px; }
.output-heading { border-bottom: 1px solid var(--rule); padding-bottom: 12px; }
.output-heading .hint { margin-top: 4px; }
.export-controls { display: flex; gap: 5px; flex-wrap: wrap; }
.export-controls .button { padding-inline: 11px; }
.measurements { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px 13px; padding: 11px 0; }
.measurements > div { display: flex; justify-content: space-between; gap: 7px; border-bottom: 1px solid #dfe3d7; padding: 4px 0; align-items: baseline; }
.measurements dt, .measurements dd { min-width: 0; font-size: .875rem; line-height: 1.3; }
.measurements dt { color: var(--muted); }
.measurements dd {
  margin: 0;
  font-family: var(--mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}
.output-table { margin-top: 16px; }
.output-table h3 { font-size: 1.12rem; margin-bottom: 8px; }
.table-scroll { overflow-x: auto; max-width: 100%; border: 1px solid var(--rule); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; text-align: left; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--rule); }
th { color: var(--ink); background: var(--soft); line-height: 1.2; }
td { min-width: 70px; font-variant-numeric: tabular-nums; line-height: 1.35; }
td:first-child { font-weight: 650; }
tbody tr:nth-child(even) { background: #f2f5e9; }
tbody tr:last-child td { border-bottom: 0; }
.print-only { display: none; }

.article-grid { display: grid; grid-template-columns: minmax(0, 1.07fr) minmax(0, .93fr); gap: clamp(20px, 4vw, 52px); margin-top: 39px; }
.article-grid h2, .related h2, .reading-page h2 { font-size: clamp(1.4rem, 2.8vw, 2.1rem); margin-bottom: 13px; }
.method-steps { padding-left: 22px; }
.method-steps li { padding-left: 2px; margin-bottom: 11px; }
.method-steps h3, .formula h3 { font-size: 1rem; margin-bottom: 3px; }
.method-steps p, .method > p, .faq p { color: var(--muted); }
.formula {
  margin-block: 14px 10px;
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: var(--panel);
}
.formula p { font-family: var(--mono); font-size: .875rem; overflow-wrap: anywhere; }
.sources { padding-left: 21px; margin-top: 8px; }
.sources li + li { margin-top: 5px; }
.faq details + details { margin-top: 7px; }
.faq p { padding: 0 14px 13px 34px; }
.related { margin-top: 35px; border-top: 1px solid var(--rule); padding-top: 22px; }
.related ul, .text-links { list-style: none; display: grid; padding: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
.related li, .text-links li { padding: 8px 11px; border: 1px solid var(--rule); background: var(--panel); border-radius: 4px; }
.related p { margin-top: 12px; }
.reading-page { max-width: 900px; }
.reading-page section { margin-block: 24px; border-top: 1px solid var(--rule); padding-top: 21px; }
.reading-page section p + p, .reading-page .text-links { margin-top: 12px; }
.missing { padding-top: clamp(45px, 9vw, 100px); }

@media (max-width: 1050px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-card { min-height: 153px; }
  .measurements { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 750px) {
  .site-bar { min-height: 63px; }
  .home-hero { grid-template-columns: minmax(0, 1fr); padding-top: 42px; max-width: 620px; }
  .hero-drawing { transform: none; }
  .hero-copy h1 { font-size: clamp(2.9rem, 9.8vw, 4.15rem); }
  .hero-copy p { margin-block: 16px 18px; }
  .workbench-grid, .article-grid { grid-template-columns: minmax(0, 1fr); }
  .drawing-panel { order: -1; }
  .jump-panel { display: inline-block; font-size: .875rem; font-weight: 650; }
  .drawing-panel figure { max-width: 600px; margin-inline: auto; }
}

@media (max-width: 460px) {
  .page-heading h1 { font-size: clamp(2rem, 8.7vw, 2.4rem); }
  .site-bar { align-items: flex-start; flex-direction: column; gap: 8px; padding-block: 12px; }
  .site-bar nav { gap: 9px 20px; padding-left: 1px; }
  .site-footer .shell { gap: 9px 12px; }
  .site-footer p { flex-basis: 100%; }
  .site-footer nav { margin-left: 0; }
  .guide-index, .related ul, .text-links { grid-template-columns: minmax(0, 1fr); }
  .tool-grid { gap: 7px; }
  .tool-card { padding: 11px; }
  .tool-card h3 { font-size: 1.04rem; }
  .tool-card p { font-size: .875rem; }
  .field[data-field]:has(select:is([name="back"], [name="sheet"], [name="joint"], [name="sizeMode"], [name="species"])) { grid-column: 1 / -1; }
  .measurements > div { display: block; }
  .measurements dd { margin-top: 3px; text-align: left; }
}

@media print {
  @page { margin: 12mm; }
  body { background: white; font-size: 10pt; }
  .shell { max-width: none; padding: 0; }
  .skip, .site-header, .site-footer, .breadcrumbs, .setup-panel, #sheet-selector,
  .export-controls, .jump-panel, .article-grid, .shop-note, .related, noscript { display: none !important; }
  .print-only { display: block; margin-top: 10pt; }
  .print-only h2 { font-size: 13pt; margin-bottom: 2pt; }
  .print-value { white-space: normal; }
  .page-heading { margin-bottom: 8pt; }
  .page-heading h1 { max-width: none; font-size: 22pt; }
  .page-heading p { margin-top: 6pt; font-size: 10pt; }
  .workbench-grid { display: block; }
  .drawing-panel, .results-panel { padding: 0; background: white; border: 0; }
  .drawing-panel figure { width: min(100%, 125mm); margin: 5pt auto 0; break-inside: avoid; }
  .shop-diagram { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .drawing-panel h2, .results-panel h2 { font-size: 14pt; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 5pt; break-inside: avoid; }
  .stats > div { padding: 4pt; }
  .stats dd { font-size: 11pt; }
  .stats dt, .measurements dt, .measurements dd, figcaption { font-size: 8.5pt; }
  .measurements { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-scroll { overflow: visible; border-radius: 0; }
  table { table-layout: auto; width: 100%; font-size: 8pt; }
  thead { display: table-header-group; }
  th, td { padding: 3pt 4pt; min-width: 0; overflow-wrap: anywhere; }
  tr { break-inside: avoid; }
  .output-table h3 { break-after: avoid; }
  .home-hero { grid-template-columns: 1fr 1fr; padding: 0; }
  .hero-copy h1 { font-size: 33pt; }
  .hero-drawing { transform: none; }
  .tool-card { break-inside: avoid; min-height: 0; }
}

@media screen and (max-width: 620px) {
  .table-scroll { overflow: visible; }
  .table-scroll table, .table-scroll tbody { display: block; }
  .table-scroll thead {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .table-scroll tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 3px 7px; }
  .table-scroll tbody tr + tr { border-top: 1px solid var(--rule); }
  .table-scroll td { min-width: 0; border-bottom: 0; padding: 5px 5px 7px; overflow-wrap: anywhere; }
  .table-scroll td::before { display: block; content: attr(data-label); color: var(--muted); font-size: .8125rem; font-weight: 550; }
}
