/* Builder's Formula Lab — construction field calculator styles */

/* Dark theme (default) */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1410;
  --bg-elevated: #171d18;
  --bg-panel: #1c241e;
  --bg-input: #121812;
  --border: #2c3a2f;
  --border-strong: #3d5242;
  --text: #e8efe6;
  --text-muted: #9aab9c;
  --text-faint: #6b7a6d;
  --accent: #e8a317;
  --accent-hover: #f0b83a;
  --accent-dim: rgba(232, 163, 23, 0.14);
  --accent-text: #1a1405;
  --success: #5fbf7a;
  --danger: #e07060;
  --info: #6eb5d8;
  --header-bg: rgba(15, 20, 16, 0.92);
  --nav-backdrop: rgba(0, 0, 0, 0.5);
  --ad-region-bg: rgba(0, 0, 0, 0.15);
  --glow-1: rgba(232, 163, 23, 0.08);
  --glow-2: rgba(94, 140, 100, 0.08);
  --control-bg: #1c241e;
  --control-hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar-w: 280px;
  --header-h: 72px;
  --theme-color: #0f1410;
}

/* Light theme — high contrast for outdoor / bright jobsites */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1e8;
  --bg-elevated: #faf8f2;
  --bg-panel: #ffffff;
  --bg-input: #f7f5ef;
  --border: #d4cfc0;
  --border-strong: #b8b09a;
  --text: #1a211c;
  --text-muted: #4a554c;
  --text-faint: #6d786f;
  --accent: #b87a00;
  --accent-hover: #9a6600;
  --accent-dim: rgba(184, 122, 0, 0.12);
  --accent-text: #fffdf5;
  --success: #1f7a3a;
  --danger: #c23b2a;
  --info: #0b6e99;
  --header-bg: rgba(250, 248, 242, 0.94);
  --nav-backdrop: rgba(26, 33, 28, 0.4);
  --ad-region-bg: rgba(0, 0, 0, 0.04);
  --glow-1: rgba(184, 122, 0, 0.07);
  --glow-2: rgba(60, 120, 80, 0.06);
  --control-bg: #ffffff;
  --control-hover: rgba(0, 0, 0, 0.05);
  --shadow: 0 12px 32px rgba(40, 36, 20, 0.12);
  --theme-color: #f4f1e8;
}

/* Text size scale — index 0–4 (Small → Extra large). Default Medium (1). */
html {
  -webkit-text-size-adjust: 100%;
  font-size: 100%;
}

html[data-text-scale="0"] { font-size: 93.75%; }  /* 15px @ 16 root */
html[data-text-scale="1"] { font-size: 100%; }    /* 16px — default */
html[data-text-scale="2"] { font-size: 112.5%; }  /* 18px */
html[data-text-scale="3"] { font-size: 125%; }    /* 20px */
html[data-text-scale="4"] { font-size: 137.5%; }  /* 22px */

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, var(--glow-1), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 0%, var(--glow-2), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  min-height: var(--header-h);
  padding: 0.75rem 1.25rem;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

/* Theme + text size controls */
.a11y-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
}

.a11y-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--control-bg);
  overflow: hidden;
}

.a11y-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 2.4rem;
  min-width: 2.4rem;
  padding: 0.4rem 0.75rem;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.a11y-group .a11y-btn:last-child {
  border-right: none;
}

.a11y-btn:hover {
  background: var(--control-hover);
  color: var(--text);
}

.a11y-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.a11y-btn[aria-pressed="true"] {
  background: var(--accent-dim);
  color: var(--accent);
}

.a11y-btn--icon {
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  min-width: 2.6rem;
}

.a11y-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.a11y-btn--normal {
  min-width: 4.75rem;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

.a11y-group--text .a11y-btn:first-child {
  border-right: 1px solid var(--border);
}

.a11y-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.a11y-btn:disabled:hover {
  background: transparent;
  color: var(--text-muted);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.brand-title,
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-title a {
  color: inherit;
  text-decoration: none;
}

.brand-title a:hover {
  color: var(--accent);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
}

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

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-wrap {
  flex: 0 1 280px;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input::placeholder {
  color: var(--text-faint);
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

/* Layout */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
}

.category-nav {
  padding: 1rem 0.75rem;
  flex: 1;
}

.nav-home {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.nav-home:hover,
.nav-home.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.nav-group {
  margin-bottom: 0.35rem;
}

.nav-group-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-group-btn:hover {
  background: var(--control-hover);
}

.nav-group-btn .icon {
  font-size: 1rem;
  width: 1.35rem;
  text-align: center;
  opacity: 0.9;
}

.nav-group-btn .chevron {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 0.7rem;
  transition: transform 0.15s;
}

.nav-group.open .chevron {
  transform: rotate(90deg);
}

.nav-sub {
  list-style: none;
  margin: 0 0 0.25rem;
  padding: 0 0 0 1.9rem;
  display: none;
}

.nav-group.open .nav-sub {
  display: block;
}

.nav-sub button {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.nav-sub button:hover {
  color: var(--text);
  background: var(--control-hover);
}

.nav-sub button.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}

.sidebar-foot {
  padding: 0.85rem 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-foot p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-faint);
  line-height: 1.45;
}

.main {
  padding: 1.5rem 1.75rem 3rem;
  max-width: 1100px;
}

/* Home */
.home-hero {
  margin-bottom: 1.75rem;
}

.home-hero h1,
.home-hero h2 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}

.home-hero p {
  margin: 0 0 0.75rem;
  max-width: 46rem;
  color: var(--text-muted);
  font-size: 1.02rem;
}

.home-hero p:last-child {
  margin-bottom: 0;
}

.home-hero .lead {
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.55;
}

.home-hero .lead strong {
  color: var(--accent);
  font-weight: 600;
}

.calc-title {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.results-heading,
.math-heading {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.math-heading {
  color: var(--accent);
  font-size: 0.82rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.cat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.cat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.cat-card .icon {
  font-size: 1.5rem;
  line-height: 1;
}

.cat-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.cat-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
}

.cat-card .count {
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 500;
}

/* Calculator view */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.breadcrumb button {
  border: none;
  background: none;
  color: var(--info);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
}

.breadcrumb button:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  color: var(--text-faint);
}

.calc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.calc-category {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.calc-header h2 {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.calc-desc {
  margin: 0;
  max-width: 40rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.calc-form,
.results-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 1.25rem;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.field .hint {
  font-size: 0.75rem;
  color: var(--text-faint);
  font-weight: 400;
}

.field-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.field input[type="number"],
.field input[type="text"],
.field select {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}

.unit-badge {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  padding: 0.65rem 1.25rem;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-ghost {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* Results */
.results-panel h3 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.results.empty .results-placeholder {
  margin: 0;
  padding: 1.5rem 0.5rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.result-item.primary {
  border-color: rgba(232, 163, 23, 0.45);
  background: var(--accent-dim);
}

.result-item .label {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.result-item .value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-align: right;
}

.result-item.primary .value {
  color: var(--accent);
  font-size: 1.2rem;
}

.result-item .unit {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.result-note {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.85rem;
  border-left: 3px solid var(--info);
  background: rgba(110, 181, 216, 0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Calculator concept diagrams (theme-adaptive SVG) */
.calc-figure {
  margin: 1.15rem 0 0;
  padding: 0.85rem 0.85rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.calc-figure.hidden {
  display: none !important;
}

.calc-figure-frame {
  width: 100%;
  line-height: 0;
  border-radius: 4px;
  overflow: hidden;
}

.calc-figure-frame .diagram-svg,
.calc-figure-frame svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  color: var(--text);
}

/* Diagram class hooks — used by assets/diagrams/*.svg when inlined */
.calc-figure-frame .d-ink {
  stroke: var(--text);
  fill: none;
}

.calc-figure-frame .d-accent {
  stroke: var(--accent);
  fill: none;
}

.calc-figure-frame .d-muted {
  stroke: var(--text-muted);
  fill: none;
}

.calc-figure-frame .d-fill {
  fill: var(--accent-dim);
  stroke: none;
}

.calc-figure-frame .d-label {
  fill: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
}

.calc-figure-frame .d-mono {
  font-family: var(--mono);
  font-size: 12px;
}

.calc-figure-frame .d-accent-fill {
  fill: var(--accent);
  stroke: none;
}

.calc-figure-caption {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.math-note {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.math-note h4 {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.math-note #math-body {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.math-note #math-body p {
  margin: 0 0 0.65rem;
}

.math-note #math-body p:last-child {
  margin-bottom: 0;
}

.math-note code,
.math-note .formula {
  font-family: var(--mono);
  font-size: 0.84em;
  color: var(--text);
  background: var(--bg-input);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.math-note ul {
  margin: 0.4rem 0 0;
  padding-left: 1.15rem;
}

.math-note li {
  margin-bottom: 0.3rem;
}

/* Search results */
.search-results h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.search-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-results li button {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
}

.search-results li button:hover {
  border-color: var(--accent);
}

.search-results .sr-cat {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-weight: 600;
}

.search-results .sr-title {
  font-weight: 600;
}

.search-results .sr-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--nav-backdrop);
  z-index: 30;
}

/* Responsive */
@media (max-width: 900px) {
  .calc-layout {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: flex;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    width: min(var(--sidebar-w), 88vw);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .nav-backdrop:not([hidden]) {
    display: block;
  }

  .tagline {
    display: none;
  }

  .main {
    padding: 1.15rem 1rem 2.5rem;
  }

  .calc-header {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .search-wrap {
    flex: 1 1 auto;
    max-width: none;
  }

  .brand h1 {
    font-size: 0.95rem;
  }

  .home-hero h2 {
    font-size: 1.4rem;
  }

  .result-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .result-item .value {
    text-align: left;
  }
}

/* ─── AEO content blocks (FAQ, answers, catalog) ─── */
.aeo-section {
  margin-top: 2.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.aeo-section h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
}

.answer-card {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.answer-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  color: var(--accent);
}

.answer-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.answer-card code,
.faq-item code,
.catalog code {
  font-family: var(--mono);
  font-size: 0.84em;
  color: var(--text);
  background: var(--bg-input);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  padding: 0 1rem 0 0.35rem;
}

.faq-item summary {
  cursor: pointer;
  padding: 0.85rem 0.75rem 0.85rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  /* Keep the disclosure caret inside the box with room from the left edge */
  list-style-position: inside;
}

.faq-item summary:hover {
  color: var(--accent);
}

.faq-item p {
  margin: 0 0 1rem;
  padding: 0 0.75rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.faq-item a {
  color: var(--info);
}

.catalog-intro {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.catalog-group {
  margin-bottom: 1.25rem;
}

.catalog-group h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  color: var(--text);
}

.catalog-group ul {
  margin: 0;
  padding-left: 1.2rem;
}

.catalog-group li {
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.catalog-group a {
  color: var(--info);
  font-weight: 500;
}

.catalog-group a:hover {
  color: var(--accent);
}

/* ─── AdSense slots ─── */
.ad-region {
  display: flex;
  justify-content: center;
  width: 100%;
}

.ad-region--top {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--ad-region-bg);
  min-height: 0;
}

.ad-region--sidebar {
  padding: 0.5rem 0.75rem;
}

.ad-region--in-content {
  margin: 1rem 0 0;
}

.ad-region--footer {
  padding: 0.75rem 1rem 0;
}

.ad-slot {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  text-align: center;
  overflow: hidden;
}

.ad-slot[hidden] {
  display: none !important;
}

.ad-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.ad-slot--placeholder {
  min-height: 72px;
}

.ad-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 72px;
  padding: 0.75rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--control-hover);
}

.ad-placeholder-copy {
  font-size: 0.72rem;
  color: var(--text-faint);
  max-width: 28rem;
  line-height: 1.35;
}

.ad-slot--live {
  min-height: 90px;
}

.ad-slot--live ins.adsbygoogle {
  min-height: 90px;
}

/* ─── Site footer ─── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-top: auto;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.2fr;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.footer-brand {
  margin: 0 0 0.4rem;
  font-weight: 700;
  color: var(--accent);
}

.footer-label {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}

.footer-copy {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.3rem;
}

.footer-links a {
  color: var(--info);
  font-size: 0.85rem;
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
  color: var(--accent);
}

.footer-legal {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-faint);
  line-height: 1.45;
}

.footer-legal a {
  color: var(--text-muted);
}

/* Print-friendly results */
@media print {
  .site-header,
  .sidebar,
  .nav-toggle,
  .form-actions,
  .btn-ghost,
  .ad-region,
  .site-footer,
  .skip-link {
    display: none !important;
  }

  .shell {
    display: block;
  }

  body {
    background: white;
    color: black;
  }

  .calc-form,
  .results-panel {
    border-color: #ccc;
    background: white;
    break-inside: avoid;
  }
}

@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.15rem;
  }

  .ad-region--top {
    padding: 0.5rem 0.75rem;
  }

  .a11y-controls {
    order: 3;
    width: 100%;
    justify-content: flex-end;
  }

  .search-wrap {
    flex: 1 1 auto;
  }
}

@media (max-width: 520px) {
  .home-hero h1,
  .home-hero h2 {
    font-size: 1.4rem;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .a11y-btn--normal {
    min-width: 4.25rem;
    font-size: 0.72rem;
  }

  .a11y-btn {
    min-height: 2.6rem;
    padding: 0.45rem 0.65rem;
  }
}

/* ─── Privacy / legal pages ─── */
.legal-page .legal-main {
  max-width: 46rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

.legal-doc .breadcrumb a {
  color: var(--info);
  text-decoration: none;
  background: none;
  border: none;
  font: inherit;
  font-size: inherit;
  padding: 0;
  cursor: pointer;
}

.legal-doc .breadcrumb a:hover {
  text-decoration: underline;
  color: var(--accent);
}

.legal-header h1 {
  margin: 0 0 0.75rem;
  font-size: 1.85rem;
  letter-spacing: -0.03em;
}

.legal-meta {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.legal-doc .lead {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.6;
}

.legal-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.legal-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.legal-section p {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.legal-section p:last-child {
  margin-bottom: 0;
}

.legal-bullets {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.6;
}

.legal-bullets li {
  margin-bottom: 0.45rem;
}

.legal-bullets li:last-child {
  margin-bottom: 0;
}

.legal-section a {
  color: var(--info);
}

.legal-section a:hover {
  color: var(--accent);
}

.legal-section code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--text);
  background: var(--bg-input);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.legal-callout {
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text) !important;
}

.legal-back {
  margin: 2.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.legal-back a {
  color: var(--info);
  font-weight: 600;
  text-decoration: none;
}

.legal-back a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Prefer larger touch targets when user asks for large text */
html[data-text-scale="3"] .a11y-btn,
html[data-text-scale="4"] .a11y-btn {
  min-height: 2.75rem;
  font-size: 0.9rem;
}

html[data-text-scale="3"] .a11y-btn--normal,
html[data-text-scale="4"] .a11y-btn--normal {
  font-size: 0.85rem;
  min-width: 5.25rem;
}
