:root {
  --green: #0f6e56;
  --green-ink: #0b5341;
  --green-deep: #083f32;
  --green-soft: #e7f3ef;
  --green-mid: #b7d8cd;
  --ink: #1b211f;
  --muted: #5a6863;
  --faint: #8a9691;
  --line: #d4ddd8;
  --line-strong: #b7c4be;
  --paper: #f3f5f3;
  --card: #ffffff;
  --warn-bg: #fbf3e4;
  --warn-ink: #6d4b12;
  --danger: #9b2c2c;
  --focus: #0f6e56;
  --shadow: 0 1px 2px rgba(27, 33, 31, 0.06), 0 8px 24px rgba(27, 33, 31, 0.06);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --header-h: 3.5rem;
  --measure: 42rem;
  --gutter: clamp(1rem, 3vw, 2rem);
  --max: 72rem;
  --ad-reserve: 0px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--green-ink);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--green);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--green);
  color: #fff;
  padding: 0.4rem 0.7rem;
  z-index: 20;
  border-radius: 0 0 6px 6px;
}

.skip-link:focus {
  top: 0;
}

.ad-reserve {
  display: none;
  height: var(--ad-reserve);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
  padding: 0 var(--gutter);
}

.wordmark {
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--green);
  text-decoration: none;
  font-size: 1.15rem;
  flex: 0 0 auto;
}

.wordmark:hover {
  color: var(--green-ink);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.85rem;
  font-size: 0.92rem;
  flex: 1 1 auto;
}

.site-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--green);
  border-bottom-color: var(--green);
}

.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper);
}

.unit-toggle button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  color: var(--muted);
}

.unit-toggle button[aria-pressed="true"] {
  background: var(--green);
  color: #fff;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  font: inherit;
}

main {
  flex: 1 1 auto;
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 1.25rem var(--gutter) 3rem;
}

.page-head {
  margin-bottom: 1.25rem;
}

.page-head h1 {
  font-size: clamp(1.6rem, 2.4vw, 2.15rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.65rem;
}

.definition {
  font-size: 1.02rem;
  max-width: 46rem;
  margin: 0 0 0.75rem;
}

.crumbs {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.crumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.35rem;
  color: var(--faint);
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--green);
}

.lede-links {
  font-size: 0.92rem;
  color: var(--muted);
}

.lede-links:empty {
  display: none;
}

.money-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
}

.money-tools a {
  color: var(--green-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--green-mid);
  padding-bottom: 0.05rem;
}

.money-tools a:hover {
  color: var(--green);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(17rem, 24rem) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.15rem;
}

.card h2,
.prose h2 {
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.form-grid {
  display: grid;
  gap: 0.7rem;
}

.field {
  display: grid;
  gap: 0.25rem;
}

.field span,
.field-label {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
}

.hint {
  font-size: 0.78rem;
  color: var(--faint);
  margin: 0;
}

.dims {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

input[type="number"],
input[type="text"],
select,
textarea {
  font: inherit;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: #fff;
  color: var(--ink);
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.checks {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.checks label {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

button,
.btn {
  font: inherit;
  border-radius: 8px;
  padding: 0.48rem 0.8rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-primary,
button.primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover,
button.primary:hover {
  background: var(--green-ink);
}

.btn-ghost,
button.ghost {
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--ink);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.stat {
  background: var(--green-soft);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  min-height: 4.1rem;
}

.stat .label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--green-ink);
  font-weight: 700;
}

.stat .value {
  display: block;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  margin-top: 0.15rem;
}

.viewport {
  position: relative;
  background: linear-gradient(180deg, #eef3f1, #e3ebe7);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 22rem;
  overflow: hidden;
}

.viewport canvas,
.viewport svg {
  display: block;
  width: 100%;
  height: 22rem;
}

.viewport .caption {
  position: absolute;
  left: 0.6rem;
  bottom: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.disclaimer,
.callout {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
}

.prose {
  max-width: var(--measure);
}

.prose.wide,
.article-body {
  max-width: 46rem;
}

.prose p,
.article-body p {
  margin: 0 0 0.9rem;
}

.prose h2,
.article-body h2 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.25rem;
}

.prose h3,
.article-body h3,
.faq h3 {
  margin: 1.15rem 0 0.4rem;
  font-size: 1.02rem;
}

.prose ul,
.article-body ul,
.prose ol,
.article-body ol {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 0 1rem;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--green-soft);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.card-grid a.card {
  text-decoration: none;
  color: inherit;
  display: block;
}

.card-grid a.card:hover {
  border-color: var(--green-mid);
}

.card-grid h2,
.card-grid h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
  color: var(--green-ink);
}

.muted {
  color: var(--muted);
}

.faq {
  margin-top: 2rem;
}

.related {
  margin-top: 2rem;
}

.site-footer {
  background: var(--green-deep);
  color: #d5e6e0;
  padding: 2rem var(--gutter) 2.4rem;
  margin-top: auto;
}

.footer-grid {
  width: min(var(--max), 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.2rem 1.5rem;
  font-size: 0.88rem;
}

.site-footer a {
  color: #e7f3ef;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ccbbc;
  margin: 0 0 0.45rem;
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.28rem;
}

.footer-note {
  width: min(var(--max), 100%);
  margin: 1.4rem auto 0;
  font-size: 0.78rem;
  color: #9ccbbc;
}

.how {
  margin-top: 2rem;
}

.how ol {
  padding-left: 1.2rem;
}

.lines-table input {
  min-width: 4.5rem;
}

.embed-body {
  background: #fff;
}

.embed-body .site-header,
.embed-body .site-footer,
.embed-body .crumbs,
.embed-body .faq,
.embed-body .related,
.embed-body .how {
  display: none;
}

.embed-body main {
  padding: 0.75rem;
  max-width: none;
  width: 100%;
}

@media (max-width: 840px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0.6rem var(--gutter) 0.9rem;
    flex-direction: column;
  }

  .site-header.is-open .site-nav {
    display: flex;
  }

  .header-tools {
    margin-left: 0;
  }
}

@media print {
  .site-header,
  .site-footer,
  .nav-toggle,
  .unit-toggle,
  .actions,
  .ad-reserve,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  main {
    padding: 0;
    width: 100%;
  }

  .tool-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .card {
    box-shadow: none;
    break-inside: avoid;
  }

  .viewport {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  .print-only {
    display: block !important;
  }
}

.print-only {
  display: none;
}

tr.is-active td {
  background: var(--green-soft);
  font-weight: 650;
}

pre {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 0.8rem;
  overflow: auto;
  border-radius: 8px;
  font-size: 0.82rem;
}

#custom-pallet[hidden] {
  display: none;
}


tr.is-active td { background: var(--green-soft); font-weight: 650; }
pre { background: var(--card); border: 1px solid var(--line); padding: 0.8rem; overflow: auto; border-radius: 8px; font-size: 0.82rem; }
#custom-pallet[hidden] { display: none; }
