/* ToolboxCalc. Each section has its own accent colour, set by a sec-* class
   on <body> (or on any element, for the home page's mixed lists), and every
   component reads --accent / --accent-soft rather than a fixed colour. */

:root {
  --ink: #16202a;
  --ink-soft: #4a5663;
  --ink-faint: #6b7683;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #e3e8ed;
  --line-strong: #cad3dc;
  --tint: #f4f6f8;
  --accent: #c2531c;
  --accent-soft: #fdf0e8;
  --accent-ink: #ffffff;
  --hero: #121a23;
  --shadow: 0 1px 2px rgba(22, 32, 42, 0.04), 0 6px 20px rgba(22, 32, 42, 0.06);
  --shadow-lift: 0 2px 4px rgba(22, 32, 42, 0.05), 0 14px 32px rgba(22, 32, 42, 0.10);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.sec-building      { --accent: #c2531c; --accent-soft: #fdf0e8; }
.sec-electrical    { --accent: #2456d3; --accent-soft: #ecf1fe; }
.sec-garden        { --accent: #23773f; --accent-soft: #e7f4eb; }
.sec-everyday-math { --accent: #6a3dd1; --accent-soft: #f1ecfd; }

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9eef3;
    --ink-soft: #b4bfca;
    --ink-faint: #8e9aa6;
    --bg: #0f151b;
    --surface: #18212a;
    --line: #26323d;
    --line-strong: #36444f;
    --tint: #1f2a34;
    --accent: #f08a4b;
    --accent-soft: #33221a;
    --accent-ink: #111820;
    --hero: #0b1015;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 32px rgba(0, 0, 0, 0.4);
  }
  .sec-building      { --accent: #f08a4b; --accent-soft: #33221a; }
  .sec-electrical    { --accent: #7aa2ff; --accent-soft: #1b2540; }
  .sec-garden        { --accent: #5fca85; --accent-soft: #16301f; }
  .sec-everyday-math { --accent: #ab8cff; --accent-soft: #261d3d; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

h1, h2, h3, .brand, .section-card strong, .tile strong, .pct-answer strong, .result strong {
  font-family: var(--display);
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { max-width: 880px; }
.icon { width: 1em; height: 1em; display: block; flex: none; }

/* ---------- masthead ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.masthead .wrap { max-width: 1040px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; font-size: 19px; }
.wordmark span { color: #c2531c; }
@media (prefers-color-scheme: dark) { .wordmark span { color: #f08a4b; } }
.logo {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #e0692b, #b8461a);
  color: #fff; font-size: 20px;
  box-shadow: 0 3px 10px rgba(194, 83, 28, 0.35);
}

.sitenav { margin-left: auto; }
.sitenav ul { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; flex-wrap: wrap; }
.sitenav a {
  display: flex; align-items: center; gap: 7px;
  color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 650;
  padding: 7px 11px; border-radius: 999px;
}
.sitenav a .icon { color: var(--accent); font-size: 17px; }
.sitenav a:hover, .sitenav a:focus-visible { background: var(--accent-soft); color: var(--ink); }

/* ---------- hero (home) ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(600px 300px at 8% 0%, rgba(240, 138, 75, 0.35), transparent 70%),
    radial-gradient(500px 280px at 92% 10%, rgba(122, 162, 255, 0.30), transparent 70%),
    radial-gradient(500px 260px at 70% 110%, rgba(95, 202, 133, 0.25), transparent 70%),
    radial-gradient(420px 220px at 20% 120%, rgba(171, 140, 255, 0.22), transparent 70%),
    var(--hero);
  color: #fff;
  padding: 64px 0 72px;
}
.hero .eyebrow { color: #ffb88a; }
.hero h1 { font-size: clamp(32px, 5.6vw, 54px); max-width: 16ch; margin-bottom: 14px; color: #fff; }
.hero .lead { color: rgba(255, 255, 255, 0.78); font-size: clamp(16.5px, 2.2vw, 19px); max-width: 60ch; }

.search {
  display: flex; align-items: center; gap: 10px;
  max-width: 560px; margin-top: 28px;
  background: #fff; color: #5b6672;
  border-radius: 14px; padding: 4px 6px 4px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-size: 20px;
}
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16.5px; color: #16202a;
  padding: 13px 4px;
}
.search:focus-within { box-shadow: 0 0 0 3px rgba(240, 138, 75, 0.6), 0 10px 30px rgba(0, 0, 0, 0.25); }

/* ---------- section cards (home) ---------- */

.section-cards {
  list-style: none; margin: -40px 0 8px; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  position: relative;
}
.section-card {
  display: flex; flex-direction: column; gap: 6px; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-decoration: none; color: var(--ink-soft); font-size: 14px; line-height: 1.5;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.section-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--accent); }
.section-card-icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px;
  background: var(--accent-soft); color: var(--accent); font-size: 26px; margin-bottom: 8px;
}
.section-card strong { color: var(--ink); font-size: 18px; }
.section-card em { margin-top: auto; padding-top: 8px; font-style: normal; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 6px; }

/* ---------- banner (section hubs) ---------- */

.banner { background: var(--accent-soft); border-bottom: 1px solid var(--line); padding: 4px 0 34px; }
.banner .crumbs { padding-top: 16px; }
.banner-head { display: flex; gap: 20px; align-items: flex-start; margin-top: 12px; }
.banner-icon {
  display: grid; place-items: center; flex: none;
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--accent); color: #fff; font-size: 38px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
}
.banner h1 { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.chips span {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 650; color: var(--ink-soft);
}

/* ---------- tiles (calculator lists) ---------- */

.hub { margin: 36px 0; }
.hub h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; margin: 0 0 14px; letter-spacing: -0.01em;
}
.hub h2 a { color: inherit; text-decoration: none; }
.hub h2 a:hover { color: var(--accent); }
.hub-icon {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); font-size: 19px;
}
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tiles li[hidden], [data-section][hidden], .section-cards[hidden] { display: none; }
.tile {
  display: flex; gap: 14px; align-items: flex-start; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--accent); }
.tile-icon {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 22px;
}
.tile-text strong { display: block; color: var(--ink); font-size: 15.5px; line-height: 1.3; margin-bottom: 4px; }
.tile-text span { display: block; color: var(--ink-faint); font-size: 13.5px; line-height: 1.45; }
.no-results {
  text-align: center; color: var(--ink-soft); background: var(--surface);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 28px; margin: 28px 0;
}

/* ---------- features (home) ---------- */

.features { margin: 52px 0 12px; }
.features h2 { font-size: clamp(22px, 3.4vw, 28px); margin: 0 0 18px; letter-spacing: -0.015em; }
.features ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.feature-icon {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 22px; margin-bottom: 12px;
}
.feature h3 { margin: 0 0 6px; font-size: 17px; }
.feature p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

/* ---------- page head ---------- */

.crumbs { font-size: 13px; color: var(--ink-faint); padding: 20px 0 0; }
.crumbs a { color: var(--ink-faint); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs ol { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; flex-wrap: wrap; }
.crumbs li:not(:last-child)::after { content: "\203A"; margin-left: 6px; color: var(--line-strong); }

.pagehead { padding: 14px 0 4px; }
.pagehead.with-icon { display: flex; gap: 18px; align-items: flex-start; }
.page-icon {
  display: grid; place-items: center; flex: none;
  width: 60px; height: 60px; border-radius: 17px; margin-top: 4px;
  background: var(--accent-soft); color: var(--accent); font-size: 32px;
}
.eyebrow { font-weight: 800; letter-spacing: 0.12em; color: var(--accent); font-size: 12px; text-transform: uppercase; margin: 0 0 6px; }
h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.1; margin: 0 0 10px; letter-spacing: -0.025em; font-weight: 800; }
.lead { font-size: 17.5px; color: var(--ink-soft); margin: 0; max-width: 62ch; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px;
  margin: 22px 0;
  box-shadow: var(--shadow-lift);
}

/* ---------- calculator form ---------- */

.calc-top { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-weight: 650; font-size: 14.5px; }
.input-row { display: flex; align-items: stretch; }
.field input, .field select, .calc-top select, .pct input, .pct select {
  font: inherit;
  font-size: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  min-width: 0;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input-row input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-row .unit {
  display: flex; align-items: center; padding: 0 12px;
  border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 10px 10px 0;
  background: var(--tint); color: var(--ink-faint); font-size: 13px; white-space: nowrap;
}
.input-row .unit:empty { display: none; }
.input-row input:only-child { border-radius: 10px; }
.field input:focus, .field select:focus, .calc-top select:focus, .pct input:focus, .pct select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.hint { font-size: 12.5px; color: var(--ink-faint); margin: 0; line-height: 1.45; }

.calc-top label { font-size: 13px; font-weight: 650; color: var(--ink-faint); display: flex; align-items: center; gap: 8px; }
.calc-top select { width: auto; padding: 8px 10px; font-size: 14px; }

.primary {
  margin-top: 20px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 14px 28px;
  font: inherit;
  font-size: 16px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: transform .12s ease, filter .12s ease;
}
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
@media (prefers-color-scheme: dark) { .primary { color: #10161c; } }

/* ---------- results ---------- */

.results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.result { background: var(--tint); border-radius: 13px; padding: 16px; min-width: 0; }
.result strong { display: block; font-size: clamp(21px, 3.4vw, 28px); line-height: 1.15; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.result span { display: block; font-size: 12.5px; color: var(--ink-faint); margin-top: 6px; }
/* The first tile is the answer people came for. */
.results .result:first-child { background: var(--accent); }
.results .result:first-child strong, .results .result:first-child span { color: #fff; }
.results .result:first-child span { opacity: 0.85; }
@media (prefers-color-scheme: dark) {
  .results .result:first-child strong, .results .result:first-child span { color: #10161c; }
}
.working { font-size: 13px; color: var(--ink-faint); margin: 14px 0 0; line-height: 1.55; font-variant-numeric: tabular-nums; }
.note { font-size: 13px; color: var(--ink-faint); margin: 12px 0 0; }

/* Verdict tiles: a limit check has to read as pass or fail at a glance. */
.results .result.pass { background: #e7f5ea; box-shadow: inset 0 0 0 1px #9ed4ae; }
.results .result.pass strong { color: #1c6b34; }
.results .result.fail { background: #fdeceb; box-shadow: inset 0 0 0 1px #edaba6; }
.results .result.fail strong { color: #a12b1e; }
@media (prefers-color-scheme: dark) {
  .results .result.pass { background: #17301f; box-shadow: inset 0 0 0 1px #2f6b42; }
  .results .result.pass strong { color: #86dba1; }
  .results .result.fail { background: #331a18; box-shadow: inset 0 0 0 1px #7a3a33; }
  .results .result.fail strong { color: #f3968b; }
}

/* ---------- percentage calculator ---------- */

.pct-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pct-box { background: var(--tint); border-radius: 14px; padding: 18px; min-width: 0; }
.pct-title { margin: 0 0 10px; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.pct-sentence { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.pct input { width: 96px; padding: 9px 10px; font-weight: 700; text-align: center; }
.pct select { width: auto; padding: 9px 10px; font-weight: 700; }
.pct-answer { margin: 16px 0 2px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pct-answer strong { font-size: clamp(30px, 5vw, 38px); line-height: 1; color: var(--accent); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.pct-dir { font-weight: 700; color: var(--ink-soft); }
.pct-work { margin: 6px 0 0; font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ---------- prose ---------- */

main .prose, .wrap > .prose {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 26px 14px;
  margin: 22px 0;
}
.prose h2 {
  font-size: clamp(20px, 3vw, 24px); margin: 30px 0 10px; letter-spacing: -0.015em;
  display: flex; align-items: center; gap: 10px;
}
.prose h2::before { content: ""; width: 4px; height: 1.05em; border-radius: 4px; background: var(--accent); flex: none; }
.prose h2:first-child { margin-top: 22px; }
.prose p { color: var(--ink-soft); margin: 0 0 14px; max-width: 70ch; }
.prose ul { color: var(--ink-soft); max-width: 70ch; padding-left: 22px; }
.prose li { margin-bottom: 7px; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--ink); }
.prose a { color: var(--accent); }
.prose abbr { text-decoration: underline dotted; cursor: help; }

.formula {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
  font-size: 15.5px;
  color: var(--ink) !important;
  font-variant-numeric: tabular-nums;
}

/* Direct-answer block: the question as a heading, the answer in the first
   sentence. Styled to read as the answer, not as more prose. */
main .prose.answer { background: var(--accent-soft); border-color: transparent; }
.prose.answer .answer-lead {
  font-size: 18px; line-height: 1.55; color: var(--ink);
  background: var(--surface); border-radius: 12px; padding: 14px 16px; max-width: none;
}
.prose.answer .answer-lead strong { color: var(--ink); }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; margin: 18px 0 24px; -webkit-overflow-scrolling: touch; }
table.ref {
  border-collapse: separate; border-spacing: 0;
  width: 100%; font-size: 14.5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  font-variant-numeric: tabular-nums;
}
table.ref caption {
  caption-side: top; text-align: left;
  font-size: 12.5px; font-weight: 800; color: var(--accent);
  padding: 0 0 8px; text-transform: uppercase; letter-spacing: 0.08em;
}
table.ref th, table.ref td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--line); }
table.ref thead th { background: var(--accent-soft); font-size: 13px; color: var(--ink); white-space: nowrap; }
table.ref tbody tr:nth-child(even) td, table.ref tbody tr:nth-child(even) th { background: var(--tint); }
table.ref tbody tr:last-child td, table.ref tbody tr:last-child th { border-bottom: 0; }
table.ref td { color: var(--ink-soft); }
table.ref tbody th { color: var(--ink); font-weight: 650; }

/* ---------- faq ---------- */

main .prose.faq { padding-bottom: 8px; }
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq details:last-of-type { border-bottom: 0; }
.faq summary {
  font-weight: 680; cursor: pointer; font-size: 16px; list-style: none;
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; flex: none;
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 17px; line-height: 1;
}
.faq details[open] summary::after { content: "\2212"; }
.faq details p { color: var(--ink-soft); margin: 10px 0 0; max-width: 70ch; }

/* ---------- related ---------- */

.related ul { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 9px; }
.related a {
  display: inline-block; border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 8px 15px; font-size: 14px; font-weight: 600; text-decoration: none;
  color: var(--ink-soft); background: var(--surface);
}
.related a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- ads ---------- */

.adslot { margin: 26px 0; min-height: 90px; text-align: center; }

/* ---------- footer ---------- */

footer.sitefoot { background: var(--surface); border-top: 1px solid var(--line); margin-top: 56px; padding: 28px 0 40px; color: var(--ink-faint); font-size: 14px; }
footer.sitefoot .wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
footer.sitefoot a { color: var(--ink-faint); text-decoration: none; }
footer.sitefoot a:hover { color: var(--accent); text-decoration: underline; }
footer.sitefoot nav { margin-left: auto; display: flex; gap: 18px; flex-wrap: wrap; }
.disclaimer { font-size: 13px; color: var(--ink-faint); margin: 12px 0 0; max-width: 78ch; }

.contact-block { background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; }

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  .section-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .features ul { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .fields, .results, .pct-grid { grid-template-columns: 1fr; }
  .masthead { position: static; }
  .sitenav { margin-left: 0; width: 100%; }
  .sitenav ul { gap: 2px; }
  .sitenav a { padding: 6px 9px; font-size: 13.5px; }
  footer.sitefoot nav { margin-left: 0; }
  .masthead .wrap { gap: 8px; }
  .hero { padding: 40px 0 64px; }
  .section-cards { gap: 10px; }
  .section-card { padding: 16px; }
  .section-card span:not(.section-card-icon) { display: none; }
  .banner-head { flex-direction: column; gap: 14px; }
  .banner-icon { width: 58px; height: 58px; font-size: 30px; border-radius: 16px; }
  .pagehead.with-icon { flex-direction: column; gap: 12px; }
  .page-icon { width: 50px; height: 50px; font-size: 27px; }
  main .prose, .wrap > .prose { padding: 2px 18px 10px; }
  .card { padding: 18px; }
  .tiles { grid-template-columns: 1fr; }
}

/* Pass/fail verdicts are sentences, not numbers: smaller, and never broken
   mid-word. */
.results .result.pass strong, .results .result.fail strong { font-size: clamp(17px, 2.3vw, 20px); line-height: 1.25; overflow-wrap: break-word; }
.result strong { overflow-wrap: break-word; }

@media (max-width: 620px) {
  .pct input { width: 76px; padding: 8px 6px; }
  .pct-sentence { gap: 6px; font-size: 15px; }
}
