/* ==========================================================================
   ToolsHub4u — Tool page shell v3
   Restyles the existing tool markup (calc / text / pdf / seo / dev) into the
   instrument idiom. Class names are the legacy contracts; visuals are new.
   ========================================================================== */

/* ---------- tool hero: the thesis + live instrument ---------------------- */
.thero {
  position: relative;
  padding-block: clamp(24px, 3vw, 40px) clamp(20px, 2.6vw, 34px);
  border-bottom: 1px solid var(--line-1);
  overflow: hidden;
}
.thero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: end;
}
.thero__crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-400);
  margin-bottom: clamp(14px, 2vw, 22px);
}
.thero__crumbs a { color: var(--text-300); transition: color 140ms; }
.thero__crumbs a:hover { color: var(--phosphor-text); }
.thero__crumbs span[aria-current] { color: var(--text-200); }
.thero__crumbs .sep { opacity: 0.72; color: var(--text-300); }

.thero__hue {
  width: 34px; height: 3px;
  border-radius: 2px;
  background: var(--hue, var(--phosphor));
  margin-bottom: 18px;
}
.thero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 4.1vw, 3.75rem);
  line-height: 0.98;
  letter-spacing: -0.028em;
  text-wrap: balance;
  max-width: 20ch;
}
.thero__lede {
  margin-top: 16px;
  font-size: clamp(1rem, 0.45vw + 0.92rem, 1.1875rem);
  line-height: 1.55;
  color: var(--text-200);
  max-width: 52ch;
  text-wrap: pretty;
}
.thero__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 20px;
}
.thero__badges li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8125rem;
  color: var(--text-300);
}
.thero__badges .icon { color: var(--phosphor-text); }

/* the right column: a proof panel that already reads as a live instrument */
.thero__panel {
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--hue, var(--phosphor)) 7%, transparent), transparent 60%),
    var(--ink-700);
  padding: 18px 20px 20px;
  overflow: hidden;
}
.thero__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right, var(--line-1) 1px, transparent 1px);
  background-size: 25% 100%;
  opacity: 0.55;
  pointer-events: none;
}
.thero__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line-1);
  position: relative;
}
.thero__panel-body { position: relative; padding-top: 15px; }
.thero__panel-note {
  display: grid;
  gap: 5px;
}
.thero__panel-note strong {
  font-size: 0.9375rem;
  font-weight: 620;
  color: var(--text-100);
}
.thero__panel-note span { font-size: 0.8125rem; color: var(--text-300); line-height: 1.5; }

.thero__steps { margin-top: 16px; position: relative; }

/* ---------- workbench: the tool itself ----------------------------------- */
.wb {
  padding-block: clamp(24px, 3.2vw, 40px) clamp(40px, 5vw, 72px);
}
.wb__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.wb__head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.375rem, 1.6vw + 1rem, 1.875rem);
  letter-spacing: -0.02em;
}

/* the legacy two-column tool grid, retuned */
.wb-grid, .pdf-grid, .seo-grid, .dev-grid, .txt-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(14px, 1.6vw, 22px);
  align-items: start;
}
@media (max-width: 980px) {
  .wb-grid, .pdf-grid, .seo-grid, .dev-grid, .txt-grid { grid-template-columns: 1fr; }
}

/* the form panel */
.wb-form {
  display: grid;
  gap: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  background: var(--ink-700);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.wb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-1);
  background: color-mix(in srgb, var(--text-100) 3%, transparent);
}
.wb-head h3 {
  font-size: 0.9375rem;
  font-weight: 620;
  letter-spacing: -0.006em;
  color: var(--text-100);
  font-family: var(--font-text);
}
.wb-head .spacer { flex: 1; }
.wb-head .icon { color: var(--text-400); }
.wb-step {
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 3px;
  background: var(--phosphor);
  color: var(--phosphor-ink);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  flex: none;
}
.wb-head--sub {
  border-top: 1px solid var(--line-1);
  background: transparent;
}

.wb-fields { display: grid; gap: 16px; padding: 18px 16px; }
.wb-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

/* The hidden attribute must win over the grid display above: without this
   rule a data-show-if block stays visible and every branch of the form shows
   at once. */
[data-show-if][hidden] { display: none !important; }
.wb-field { display: grid; gap: 7px; min-width: 0; align-content: start; }
.wb-field--wide { grid-column: 1 / -1; }

/* ---------- stacked workbench: two input columns, result underneath ----- */
.wb-grid.wb-grid--stack { grid-template-columns: minmax(0, 1fr); }
.wb-grid--stack > .wb-result { position: static; }
.wb-grid--stack .res-primary::after { background-size: 56px 100%; }

.wb-fields.wb-fields--split {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(14px, 1.8vw, 22px);
  align-items: start;
}
.wb-fields--split > .wb-side {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  padding-left: clamp(14px, 1.8vw, 22px);
  border-left: 1px solid var(--line-1);
}
.wb-fields--split > .wb-field--main { min-width: 0; }
.wb-fields--split > .wb-field--main textarea { min-height: 240px; }
/* a page whose side column carries more controls gets a taller paste area */
.wb-fields--split.wb-fields--tall > .wb-field--main textarea { min-height: clamp(300px, 24vw, 360px); }
.wb-fields--split > .wb-side { align-self: stretch; }
.wb-fields--split .wb-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .wb-fields.wb-fields--split { grid-template-columns: minmax(0, 1fr); }
  .wb-fields--split > .wb-side {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line-1);
    padding-top: 16px;
  }
}
@media (max-width: 620px) {
  .wb-fields--split .wb-row { grid-template-columns: minmax(0, 1fr); }
}

/* two equal input columns, wide fields spanning both ------------------- */
.wb-fields.wb-fields--pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px clamp(14px, 1.8vw, 22px);
  align-items: start;
}
.wb-fields--pair > .wb-field--wide { grid-column: 1 / -1; }
.wb-fields--pair > .wb-field > textarea { min-height: 220px; }
.wb-fields--pair > .wb-field--wide textarea { min-height: 220px; }
.wb-fields--pair > .wb-field--wide > .wb-input-wrap { max-width: 360px; }
@media (max-width: 760px) {
  .wb-fields.wb-fields--pair { grid-template-columns: minmax(0, 1fr); }
}
.wb-field > label, .wb-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-300);
}
/* a checkbox label is prose, not a field caption */
.wb-field > label.wb-check {
  font-family: var(--font-text);
  font-size: 0.875rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-200);
}
.wb-check .wb-hint { display: block; margin-top: 2px; }
.wb-hint {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-300);
}

/* inputs: every control adopts the panel material */
.wb-form input[type="text"],
.wb-form input[type="number"],
.wb-form input[type="search"],
.wb-form input[type="email"],
.wb-form input[type="url"],
.wb-form input[type="date"],
.wb-form input[type="time"],
.wb-form input[type="password"],
.wb-form textarea,
.wb-form select,
.wb-input-wrap input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: var(--ink-800);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text-100);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  transition: border-color 150ms, box-shadow 150ms, background-color 150ms;
}
.wb-form input:hover, .wb-form textarea:hover, .wb-form select:hover { border-color: var(--line-3); }
.wb-form input:focus, .wb-form textarea:focus, .wb-form select:focus {
  outline: none;
  border-color: var(--phosphor-text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--phosphor) 15%, transparent);
  background: var(--ink-700);
}
.wb-form textarea { min-height: 130px; line-height: 1.6; resize: vertical; font-variant-numeric: normal; }
.wb-form select { appearance: none; cursor: pointer; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-300) 50%), linear-gradient(135deg, var(--text-300) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.wb-form input::placeholder, .wb-form textarea::placeholder { color: var(--text-400); }

/* input with a unit suffix */
.wb-input-wrap { position: relative; display: block; }
.wb-input-wrap.has-suffix input { padding-right: 46px; }
.wb-input-wrap .suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-400);
  pointer-events: none;
}

/* segmented control */
.wb-segment {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--ink-800);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
}
.wb-segment label { position: relative; cursor: pointer; }
.wb-segment input { position: absolute; opacity: 0; width: 0; height: 0; }
.wb-segment span {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 3px;
  font-size: 0.8125rem;
  font-weight: 520;
  color: var(--text-300);
  text-align: center;
  transition: background-color 170ms var(--ease-soft), color 170ms;
}
.wb-segment label:hover span { color: var(--text-100); }
.wb-segment input:checked + span {
  background: var(--text-100);
  color: var(--ink-900);
  font-weight: 600;
}
.wb-segment input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* checkbox */
.wb-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  /* 2px of block margin keeps stacked rows 27px apart, so each 24px target
     gets its own space instead of two circles overlapping */
  margin-block: 2px;
  font-size: 0.875rem;
  color: var(--text-200);
  cursor: pointer;
  line-height: 1.5;
}
.wb-check input[type="checkbox"] {
  appearance: none;
  width: 24px; height: 24px;
  min-height: 24px;
  margin-top: -2px;
  flex: none;
  border: 1px solid var(--line-3);
  border-radius: 4px;
  background: var(--ink-800);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms;
}
.wb-check input[type="checkbox"]:checked {
  background: var(--phosphor);
  border-color: var(--phosphor-text);
}
.wb-check input[type="checkbox"]:checked::after {
  content: "";
  width: 11px; height: 6px;
  border-left: 2px solid var(--phosphor-ink);
  border-bottom: 2px solid var(--phosphor-ink);
  transform: rotate(-45deg) translate(1px, -2px);
}

/* form footer */
.wb-form__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-top: 1px solid var(--line-1);
  background: color-mix(in srgb, var(--text-100) 2.5%, transparent);
}
.wb-form__foot .btn-quiet { font-size: 0.8125rem; color: var(--text-300); }
.wb-form__foot .btn-quiet:hover { color: var(--text-100); }
.wb-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-200);
}
.wb-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--phosphor);
  animation: pulse-live 2.4s var(--ease-soft) infinite;
}
@media (prefers-reduced-motion: reduce) { .wb-dot { animation: none; } }

/* ---------- result panel ------------------------------------------------- */
.wb-result {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  background: var(--ink-700);
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-h) + 20px);
  box-shadow: var(--shadow-1);
}
@media (max-width: 980px) { .wb-result { position: static; } }
.wb-result__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-1);
  background: color-mix(in srgb, var(--phosphor) 5%, transparent);
  flex-wrap: wrap;
}
.wb-result__head h3 {
  font-size: 0.9375rem;
  font-weight: 620;
  color: var(--text-100);
  font-family: var(--font-text);
  margin-right: auto;
}
.wb-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-1);
  font-size: 0.75rem;
  color: var(--text-300);
  transition: color 140ms, border-color 140ms, background-color 140ms;
}
.wb-copy:hover { color: var(--text-100); border-color: var(--line-2); background: color-mix(in srgb, var(--text-100) 6%, transparent); }
.wb-copy .icon { width: 14px; height: 14px; }

/* the legacy result markup */
.calc-out { padding: 20px 18px; }
.res-primary {
  padding: 18px 18px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--phosphor) 26%, transparent);
  background: color-mix(in srgb, var(--phosphor) 7%, transparent);
  position: relative;
  overflow: hidden;
}
.res-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right, color-mix(in srgb, var(--phosphor) 30%, transparent) 1px, transparent 1px);
  background-size: 20% 100%;
  opacity: 0.16;
  pointer-events: none;
}
.res-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-100);
  margin-bottom: 6px;
}
.res-value {
  font-family: var(--font-mono);
  font-size: clamp(1.875rem, 3.6vw, 2.75rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.032em;
  font-variant-numeric: tabular-nums;
  color: var(--text-100);
  overflow-wrap: anywhere;
}
.res-status {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--text-200);
  display: flex;
  align-items: center;
  gap: 8px;
}
.res-status[data-tone="good"] { color: var(--phosphor-text); font-weight: 500; }
.res-status[data-tone="warn"] { color: var(--cat-calculators); }
.res-status[data-tone="bad"] { color: var(--cat-pdf); }
.res-note { margin-top: 8px; font-size: 0.8125rem; color: var(--text-300); line-height: 1.5; }

/* per-format output blocks -------------------------------------------------
   One bordered box per format, each carrying its own copy button, so only
   the wanted format gets taken. */
.res-blocks { display: grid; gap: 12px; margin: 16px 16px 0; }
.res-block {
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
  background: var(--ink-800);
  overflow: hidden;
}
.res-block__head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px 7px 14px;
  border-bottom: 1px solid var(--line-1);
}
.res-block__title {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-300);
}
.res-block__badge {
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--phosphor) 42%, transparent);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--phosphor-text);
}
.res-block__head .wb-copy { margin-left: auto; }
.res-block .txt-output {
  border: 0;
  border-radius: 0;
  background: var(--ink-800);
  min-height: 116px;
  max-height: 300px;
}
.res-block .txt-output:hover { border-color: transparent; }
.res-block .txt-output:focus { outline-offset: -3px; }
.res-block__links {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 14px 16px;
  list-style: none;
}
.res-block__links a {
  color: var(--phosphor-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.res-block__links a:hover { color: var(--text-100); }
.res-block__note {
  margin: 0;
  padding: 0 16px 13px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-300);
}
@media (max-width: 620px) {
  .res-blocks { margin: 14px 0 0; }
}

.res-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  margin-top: 16px;
  border-top: 1px solid var(--line-1);
  padding-top: 14px;
}
.res-stat { padding-right: 12px; margin-right: 12px; border-right: 1px solid var(--line-1); min-width: 0; }
.res-stat:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.res-stat dt {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-400);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.res-stat dd {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-100);
  overflow-wrap: anywhere;
}

.res-table-wrap { margin-top: 16px; border: 1px solid var(--line-1); border-radius: var(--radius-sm); overflow: hidden; }
.res-table { font-size: 0.8125rem; }
.res-table caption {
  text-align: left;
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-400);
  border-bottom: 1px solid var(--line-1);
  background: color-mix(in srgb, var(--text-100) 2.5%, transparent);
}
.res-table th, .res-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line-1); }
.res-table th {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-400);
  font-weight: 500;
}
.res-table td { color: var(--text-200); font-variant-numeric: tabular-nums; }
.res-table td:last-child { text-align: right; font-family: var(--font-mono); color: var(--text-100); }
.res-table tr:last-child td { border-bottom: 0; }
.res-table tr.is-total td { color: var(--phosphor-text); font-weight: 600; background: color-mix(in srgb, var(--phosphor) 5%, transparent); }

/* ---------- prose + sidebar --------------------------------------------- */
.tbody { padding-block: clamp(40px, 5vw, 76px); border-top: 1px solid var(--line-1); }
.tbody__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
  min-width: 0;
  gap: clamp(28px, 4vw, 64px);
  align-items: start;
}
@media (max-width: 980px) { .tbody__grid { grid-template-columns: 1fr; } }

.prose { max-width: 72ch; }
.prose > * + * { margin-top: 1.05em; }
.prose h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 1.6vw + 1.1rem, 2.125rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-top: clamp(32px, 3.6vw, 48px);
  margin-bottom: 14px;
  color: var(--text-100);
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.prose h3 {
  font-family: var(--font-text);
  font-weight: 620;
  font-size: 1.0625rem;
  margin-top: 28px;
  margin-bottom: 8px;
  color: var(--text-100);
}
.prose p, .prose li { font-size: 1rem; line-height: 1.72; color: var(--text-200); }
.prose ul, .prose ol { padding-left: 0; display: grid; gap: 8px; }
.prose ul li { position: relative; padding-left: 18px; }
.prose ul li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.66em;
  width: 5px; height: 5px;
  border-radius: 1px;
  background: var(--phosphor);
  opacity: 0.7;
}
.prose ol { counter-reset: n; }
.prose ol li { counter-increment: n; position: relative; padding-left: 26px; }
.prose ol li::before {
  content: counter(n);
  position: absolute;
  left: 0; top: 0.1em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--phosphor-text);
}
.prose a { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-color: var(--line-3); }
.prose a:hover { text-decoration-color: currentColor; color: var(--phosphor-text); }
.prose strong { color: var(--text-100); font-weight: 620; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--ink-600);
  border: 1px solid var(--line-1);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--phosphor-text);
}
.prose blockquote {
  border-left: 2px solid var(--phosphor);
  padding-left: 18px;
  color: var(--text-200);
  font-size: 1.0625rem;
}

/* reference tables inside prose */
.ref-table { font-size: 0.875rem; border: 1px solid var(--line-1); border-radius: var(--radius-sm); overflow: hidden; }
.ref-table th, .ref-table td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line-1); }
.ref-table th {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  color: var(--text-300);
  font-weight: 500;
  background: color-mix(in srgb, var(--text-100) 3%, transparent);
}
.ref-table td { color: var(--text-200); }
.ref-table td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-100); }
.ref-table tr:last-child td { border-bottom: 0; }
.ref-table-wrap { overflow-x: auto; min-width: 0; max-width: 100%; -webkit-overflow-scrolling: touch; }
.ref-table-wrap[tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* callouts the tool prose already uses */
.formula, .example {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--ink-700);
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-200);
}
.formula {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  border-left: 2px solid var(--phosphor);
  background: color-mix(in srgb, var(--phosphor) 5%, var(--ink-700));
}
.example strong:first-child { display: block; margin-bottom: 6px; color: var(--phosphor-text); font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; }

/* sidebar */
.calc-side, .tool-side {
  display: grid;
  gap: 14px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  align-content: start;
}
@media (max-width: 980px) { .calc-side, .tool-side { position: static; } }
.side-card {
  border: 1px solid var(--line-1);
  border-radius: var(--radius-md);
  background: var(--ink-700);
  padding: 16px 17px;
}
.side-card h2, .side-card h3 {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 550;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-400);
  margin-bottom: 11px;
}
.side-card ol, .side-card ul { display: grid; gap: 8px; }
.side-card li { list-style: none; }
.side-card a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-200);
  transition: color 140ms;
  line-height: 1.4;
}
.side-card a::before {
  content: "";
  width: 4px; height: 4px;
  border-radius: 1px;
  background: var(--line-3);
  flex: none;
  transition: background-color 140ms;
}
.side-card a:hover { color: var(--phosphor-text); }
.side-card a:hover::before { background: var(--phosphor); }
.side-card p { font-size: 0.875rem; color: var(--text-300); line-height: 1.6; }

/* ---------- FAQ ---------------------------------------------------------- */
.faq { padding-block: clamp(40px, 5vw, 72px); border-top: 1px solid var(--line-1); }
.faq__grid { display: grid; grid-template-columns: minmax(0, 0.36fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
@media (max-width: 860px) { .faq__grid { grid-template-columns: 1fr; } }
.faq h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--step-4); letter-spacing: -0.02em; }
.faq details {
  border-bottom: 1px solid var(--line-1);
  padding: 2px 0;
}
.faq details:first-of-type { border-top: 1px solid var(--line-1); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 2px;
  font-size: 1rem;
  font-weight: 550;
  color: var(--text-100);
  cursor: pointer;
  transition: color 140ms;
  list-style: none;
}
.faq summary:hover { color: var(--phosphor-text); }
.faq summary::after {
  content: "";
  width: 10px; height: 10px;
  flex: none;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 260ms var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.faq__a { padding: 0 2px 18px; font-size: 0.9375rem; line-height: 1.68; color: var(--text-300); max-width: 68ch; }

/* ---------- related tools ------------------------------------------------
   The "next tool" block that closes every tool page. The markup shipped
   .related__head / .related__list but only .related itself was ever styled,
   so this rendered as a bulleted list of four full-width text rows.
   Surface is the one place after the tool where the reader is deciding what
   to do next, so it gets real weight: a display head, a mono count, and
   tiles that echo the homepage grid.
   ---------------------------------------------------------------------- */
.related {
  padding-block: clamp(44px, 5vw, 76px);
  border-top: 1px solid var(--line-1);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--ink-800) 55%, transparent), transparent 60%);
}

.related__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.related__head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-3);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-100);
}
.related__head > a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-300);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}
.related__head > a:hover,
.related__head > a:focus-visible { color: var(--text-100); border-bottom-color: var(--phosphor); }
.related__head > a:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.related__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.related__list > li { min-width: 0; display: flex; }

.related__list a {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 13px 15px;
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
  background: var(--ink-800);
  text-decoration: none;
  transition: border-color 150ms var(--ease-out), background-color 150ms var(--ease-out),
              transform 150ms var(--ease-out);
}
.related__list a::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--phosphor);
  opacity: 0;
  transition: opacity 150ms var(--ease-out);
}
.related__list a:hover,
.related__list a:focus-visible {
  border-color: color-mix(in srgb, var(--phosphor) 45%, var(--line-2));
  background: var(--ink-750, #191d22);
  transform: translateY(-1px);
}
.related__list a:hover::after,
.related__list a:focus-visible::after { opacity: 1; }
.related__list a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.related__list .name {
  display: block;
  font-family: var(--font-text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--text-100);
}
.related__list .fam {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-400);
}
/* One arrow per tile, drawn in the second column. */
.related__list a > .fam::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 2px;
  vertical-align: -2px;
  background-color: currentColor;
  -webkit-mask: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M9 7h8v8'/%3E%3C/svg%3E");
  mask: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M9 7h8v8'/%3E%3C/svg%3E");
  opacity: 0;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
  transform: translate(-3px, 3px);
}
.related__list a:hover > .fam::after,
.related__list a:focus-visible > .fam::after { opacity: 1; transform: translate(0, 0); }

/* A grid variant of the related-tools section. The grid was laid out but its
   items were never styled, so they rendered as bare inline text. Same visual
   language as the list tiles, so the two variants read as one section. */
/* Pages that put the h2 straight in the section (no .related__head wrapper)
   get the same spacing and treatment as the list pages. */
.related > .shell > h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-3);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 22px;
  color: var(--text-100);
}
.related__head + .related__grid { margin-top: 22px; }

.related__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
}

.related__item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 12px;
  min-height: 64px;
  padding: 13px 15px;
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
  background: var(--ink-800);
  text-decoration: none;
  transition: border-color 150ms var(--ease-out), background-color 150ms var(--ease-out),
              transform 150ms var(--ease-out);
}
.related__item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--key-hue, var(--phosphor));
  opacity: 0;
  transition: opacity 150ms var(--ease-out);
}
.related__item:hover,
.related__item:focus-visible {
  border-color: color-mix(in srgb, var(--key-hue, var(--phosphor)) 45%, var(--line-2));
  background: var(--ink-750, #191d22);
  transform: translateY(-1px);
}
.related__item:hover::before,
.related__item:focus-visible::before { opacity: 1; }
.related__item:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.related__name {
  display: block;
  font-family: var(--font-text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-100);
}
.related__meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-400);
}
/* The sprite icon in the second column: one size, one colour, always. */
.related__go,
.related__item > svg.icon {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-400);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.related__item:hover .related__go,
.related__item:focus-visible .related__go,
.related__item:hover > svg.icon,
.related__item:focus-visible > svg.icon {
  color: var(--text-100);
  transform: translate(1px, -1px);
}

@media (max-width: 640px) {
  .related__list { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .related__list a,
  .related__item { min-height: 58px; padding: 11px 13px; }
  .related__head { margin-bottom: 16px; }
  .related__head h2 { font-size: var(--step-2); }
  .related__grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .related__head + .related__grid { margin-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .related__list a, .related__list a::after, .related__list .fam::after,
  .related__item, .related__item::before, .related__go { transition: none; }
  .related__list a:hover, .related__list a:focus-visible { transform: none; }
  .related__list a:hover > .fam::after,
  .related__list a:focus-visible > .fam::after { transform: none; }
  .related__item:hover, .related__item:focus-visible { transform: none; }
  .related__item:hover .related__go,
  .related__item:focus-visible .related__go { transform: none; }
}

/* ---------- legacy related grid (kept for pages that still use it) -------- */
.related { padding-block: clamp(40px, 5vw, 72px); border-top: 1px solid var(--line-1); }
.related h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--step-3); letter-spacing: -0.02em; margin-bottom: 20px; }
.related__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

/* ---------- no-JS + tool-specific safety --------------------------------- */
.js .no-js-note { display: none; }
.no-js-note {
  border: 1px solid color-mix(in srgb, var(--action) 45%, transparent);
  background: color-mix(in srgb, var(--action) 10%, transparent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.875rem;
  color: var(--text-100);
  margin-bottom: 16px;
}

/* ---------- responsive --------------------------------------------------- */
@media (max-width: 1080px) {
  .thero__grid { grid-template-columns: 1fr; align-items: start; }
  .thero h1 { max-width: 24ch; }
}
@media (max-width: 640px) {
  .wb-fields { padding: 14px 13px; gap: 14px; }
  .wb-head { padding: 11px 13px; }
  .wb-result__head { padding: 11px 13px; }
  .calc-out { padding: 14px 13px; }
  .res-primary { padding: 14px 14px 16px; }
  .res-stats { grid-template-columns: repeat(2, 1fr); row-gap: 12px; }
  .res-stat { padding-right: 10px; margin-right: 10px; }
  .res-stat:nth-child(2n) { border-right: 0; margin-right: 0; padding-right: 0; }
  .thero__panel { padding: 14px 15px 16px; }
}

