:root {
  color-scheme: light dark;
  --paper: #f1f0eb;
  --paper-deep: #e5e3db;
  --surface: #faf9f5;
  --surface-raised: #ffffff;
  --ink: #171a1c;
  --ink-muted: #50575a;
  --line: #c9ccc8;
  --line-strong: #9da2a0;
  --accent: #dd642d;
  --accent-dark: #9f3e18;
  --accent-soft: #f6dccf;
  --concrete: #898d8c;
  --concrete-top: #c6c9c7;
  --concrete-rgb: 137 141 140;
  --gravel: #96836a;
  --gravel-rgb: 150 131 106;
  --rebar: #c9552b;
  --formwork: #81532e;
  --edge: #34393a;
  --good: #216b50;
  --good-soft: #dcece4;
  --warn: #845218;
  --warn-soft: #f5e7cb;
  --radius: 8px;
  --shadow: 0 18px 42px rgb(23 26 28 / 0.09);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: "Avenir Next", Avenir, "Segoe UI", Helvetica, sans-serif;
}

:root[data-theme="dark"] {
  --paper: #111416;
  --paper-deep: #1a1e20;
  --surface: #181c1e;
  --surface-raised: #202527;
  --ink: #f1f0e9;
  --ink-muted: #a4abad;
  --line: #3b4244;
  --line-strong: #687174;
  --accent: #f07b3e;
  --accent-dark: #ff9a64;
  --accent-soft: #3b241b;
  --concrete: #777d7c;
  --concrete-top: #b4b9b7;
  --concrete-rgb: 119 125 124;
  --gravel: #756852;
  --gravel-rgb: 117 104 82;
  --rebar: #ff8652;
  --formwork: #c78b54;
  --edge: #0d0f10;
  --good: #65c49f;
  --good-soft: #17342a;
  --warn: #efb761;
  --warn-soft: #362b1b;
  --shadow: 0 24px 54px rgb(0 0 0 / 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111416;
    --paper-deep: #1a1e20;
    --surface: #181c1e;
    --surface-raised: #202527;
    --ink: #f1f0e9;
    --ink-muted: #a4abad;
    --line: #3b4244;
    --line-strong: #687174;
    --accent: #f07b3e;
    --accent-dark: #ff9a64;
    --accent-soft: #3b241b;
    --concrete: #777d7c;
    --concrete-top: #b4b9b7;
    --concrete-rgb: 119 125 124;
    --gravel: #756852;
    --gravel-rgb: 117 104 82;
    --rebar: #ff8652;
    --formwork: #c78b54;
    --edge: #0d0f10;
    --good: #65c49f;
    --good-soft: #17342a;
    --warn: #efb761;
    --warn-soft: #362b1b;
    --shadow: 0 24px 54px rgb(0 0 0 / 0.28);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, transparent 49.93%, color-mix(in srgb, var(--line) 35%, transparent) 50%, transparent 50.07%) 0 0 / 80px 80px,
    linear-gradient(transparent 49.93%, color-mix(in srgb, var(--line) 35%, transparent) 50%, transparent 50.07%) 0 0 / 80px 80px,
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

button:hover {
  border-color: var(--line-strong);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 68%, transparent);
  outline-offset: 2px;
}

a {
  color: var(--accent-dark);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  left: 1rem;
  top: -5rem;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: var(--paper);
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand b {
  color: var(--accent-dark);
}

.brand-mark {
  position: relative;
  width: 32px;
  height: 25px;
  transform: skewY(-10deg);
}

.brand-mark i {
  position: absolute;
  width: 29px;
  height: 10px;
  border: 1px solid var(--edge);
  background: var(--concrete-top);
}

.brand-mark i:first-child {
  top: 2px;
  left: 1px;
}

.brand-mark i:last-child {
  top: 11px;
  left: 3px;
  background: var(--concrete);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
}

main {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
}

.intro {
  min-height: 210px;
  padding: 3rem 0 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
}

.intro > div:first-child {
  max-width: 850px;
}

.eyebrow,
.content-label,
.result-kicker {
  display: block;
  margin: 0 0 0.5rem;
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.55rem;
  font-size: clamp(2.2rem, 5vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: -0.058em;
}

.intro p:not(.eyebrow) {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--ink-muted);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
}

.trust-line {
  display: grid;
  gap: 0.35rem;
  padding: 0 0 0.4rem 1.4rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.calculator-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.74fr) minmax(520px, 1.26fr);
  gap: 1rem;
  align-items: start;
}

.input-panel,
.stage {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
}

.input-panel {
  overflow: hidden;
}

.input-section,
.details-body {
  padding: 1.15rem;
}

.input-section + .input-section,
.options {
  border-top: 1px solid var(--line);
}

.section-heading,
.section-heading > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.section-heading {
  margin-bottom: 0.85rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.step-mark {
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.unit-toggle {
  padding: 0.4rem 0.55rem;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.shape-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.shape-tabs button {
  min-height: 43px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.shape-tabs button.is-active {
  background: var(--ink);
  color: var(--paper);
}

.presets,
.thickness-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.preset-chip,
.thickness-chips button {
  padding: 0.42rem 0.55rem;
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.preset-chip.is-active,
.thickness-chips button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.field-grid + .field-grid,
.field-grid + .thickness-row,
.thickness-row + .field-grid {
  margin-top: 0.8rem;
}

.field label {
  display: block;
  margin: 0 0 0.28rem;
  color: var(--ink-muted);
  font-size: 0.73rem;
  font-weight: 650;
}

.field small {
  display: block;
  margin-top: 0.3rem;
  color: var(--ink-muted);
  font-size: 0.68rem;
}

.number-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 45px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-raised);
}

.number-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.number-wrap input {
  width: 100%;
  min-width: 0;
  padding: 0.7rem 0.45rem 0.7rem 0.72rem;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 650;
}

.number-wrap span {
  padding-right: 0.7rem;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  white-space: nowrap;
}

select {
  width: 100%;
  min-height: 45px;
  padding: 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-raised);
  font-size: 0.82rem;
}

.range-input {
  width: 100%;
  height: 4px;
  margin: 0.7rem 0 0;
  accent-color: var(--accent);
}

.thickness-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1.05fr;
  align-items: end;
  gap: 0.75rem;
}

.thickness-chips {
  margin-bottom: 0;
}

.count-grid {
  width: calc(50% - 0.375rem);
}

.options > summary {
  min-height: 52px;
  padding: 0 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 680;
}

.options > summary > span:last-child {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
}

.options[open] > summary {
  background: var(--paper-deep);
}

.details-body {
  border-top: 1px solid var(--line);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.8rem;
  font-size: 0.8rem;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.engineering-note {
  margin: 0.9rem 0 0;
  padding: 0.7rem;
  border-left: 2px solid var(--warn);
  background: var(--warn-soft);
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.cost-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stage {
  position: sticky;
  top: 0.65rem;
  overflow: hidden;
}

.result-lead {
  padding: 1.2rem 1.3rem 1rem;
  border-bottom: 1px solid var(--line);
}

.result-lead h2 {
  margin: 0;
  font-size: clamp(1.42rem, 2.4vw, 2.1rem);
  line-height: 1.18;
  letter-spacing: -0.04em;
}

.result-lead h2 > span {
  color: var(--ink-muted);
  font-weight: 500;
}

.result-lead h2 strong {
  color: var(--accent-dark);
}

.result-lead > p {
  margin: 0.45rem 0 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.preview-shell {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 68%, color-mix(in srgb, var(--concrete-top) 30%, transparent), transparent 50%),
    linear-gradient(160deg, var(--surface-raised), var(--paper-deep));
}

.preview-shell canvas {
  display: block;
  width: 100%;
  height: 330px;
  touch-action: none;
}

.view-switch,
.preview-actions {
  position: absolute;
  z-index: 2;
  display: flex;
  gap: 1px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
}

.view-switch {
  top: 0.75rem;
  right: 0.75rem;
}

.preview-actions {
  bottom: 0.7rem;
  right: 0.7rem;
}

.view-switch button,
.preview-actions button {
  padding: 0.42rem 0.62rem;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.69rem;
}

.view-switch button.is-active {
  background: var(--ink);
  color: var(--paper);
}

.preview-hud {
  position: absolute;
  left: 0.8rem;
  bottom: 0.8rem;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.65rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}

.result-grid > div,
.bags-row > div {
  min-width: 0;
  padding: 0.85rem;
  border-right: 1px solid var(--line);
}

.result-grid > div:last-child,
.bags-row > div:last-child {
  border-right: 0;
}

.result-grid span,
.bags-row span,
.bags-row small,
.estimate-table span {
  display: block;
  color: var(--ink-muted);
  font-size: 0.66rem;
}

.result-grid strong {
  display: block;
  margin-top: 0.18rem;
  font-family: var(--mono);
  font-size: 0.89rem;
}

.bags-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}

.bags-row > div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.1rem 0.4rem;
}

.bags-row strong {
  grid-row: span 2;
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: 1.25rem;
}

.estimate-table {
  padding: 0 1.2rem;
}

.estimate-table > div {
  min-height: 48px;
  padding: 0.55rem 0;
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 1rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.estimate-table strong {
  text-align: right;
  font-size: 0.76rem;
}

.recommendation {
  margin: 0.9rem 1.2rem;
  padding: 0.85rem;
  display: grid;
  gap: 0.2rem;
  border-left: 3px solid var(--good);
  background: var(--good-soft);
}

.recommendation strong {
  font-size: 0.79rem;
}

.recommendation span {
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.recommendation[data-kind="readymix"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.warnings {
  margin: 0.9rem 1.2rem;
  padding: 0.8rem;
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  font-size: 0.73rem;
}

.actions {
  padding: 0 1.2rem 1.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.actions button,
.primary-action {
  padding: 0.62rem 0.78rem;
  font-size: 0.72rem;
  font-weight: 670;
}

.actions .primary-action,
.primary-action {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.content-block {
  max-width: 800px;
  margin: 7rem auto;
}

.content-block h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.7rem, 3.8vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.content-block > p:not(.content-label),
.faq details p {
  color: var(--ink-muted);
  font-size: 1.02rem;
}

.worked-example {
  padding: 2.3rem;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.how-to ol {
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-strong);
  counter-reset: step;
}

.how-to li {
  min-height: 76px;
  padding: 1rem 0;
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  counter-increment: step;
}

.how-to li::before {
  content: "0" counter(step);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.math-block {
  padding-left: 1.4rem;
  border-left: 4px solid var(--concrete);
}

.faq details {
  border-top: 1px solid var(--line-strong);
}

.faq details:last-child {
  border-bottom: 1px solid var(--line-strong);
}

.faq summary {
  padding: 1.1rem 2rem 1.1rem 0;
  cursor: pointer;
  font-weight: 680;
}

.faq details p {
  padding: 0 0 1.2rem;
}

footer {
  width: min(1220px, calc(100% - 32px));
  margin: 9rem auto 0;
  padding: 1.6rem 0 2.2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.75rem;
}

footer p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  padding: 0.75rem 1rem;
  border-radius: 5px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
}

.clipboard-fallback {
  position: fixed;
  left: -9999px;
}

dialog {
  width: min(680px, calc(100% - 24px));
  max-height: 84vh;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 32px 90px rgb(0 0 0 / 0.35);
}

dialog::backdrop {
  background: rgb(8 10 11 / 0.72);
  backdrop-filter: blur(3px);
}

.legal-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.65rem;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.legal-toolbar button {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

.legal-toolbar button.is-active {
  background: var(--ink);
  color: var(--paper);
}

.legal-frame article {
  padding: 1.6rem;
}

.legal-frame article h2 {
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.legal-frame article p {
  color: var(--ink-muted);
}

.legal-page {
  max-width: 720px;
  padding: 4rem 0;
}

.legal-page > a {
  display: inline-block;
  margin-bottom: 2rem;
}

.legal-page article {
  padding: 2rem;
  border: 1px solid var(--line);
  background: var(--surface);
}

.legal-page h1 {
  font-size: clamp(2.4rem, 7vw, 4rem);
}

.effective {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.not-found {
  min-height: 64vh;
  padding: 8rem 0;
}

.not-found h1 {
  max-width: 700px;
}

.not-found .primary-action {
  display: inline-block;
  margin-top: 1rem;
}

@media (max-width: 980px) {
  .calculator-shell {
    grid-template-columns: 1fr;
  }

  .stage {
    position: relative;
    top: 0;
    order: -1;
  }

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

  .trust-line {
    grid-template-columns: repeat(3, max-content);
    border-left: 0;
    border-top: 2px solid var(--accent);
    padding: 0.7rem 0 0;
  }
}

@media (max-width: 600px) {
  .site-header,
  main,
  footer {
    width: min(100% - 20px, 1220px);
  }

  .site-header {
    min-height: 62px;
  }

  .brand {
    font-size: 0.84rem;
  }

  .intro {
    min-height: 0;
    padding: 2rem 0 1.3rem;
  }

  h1 {
    font-size: clamp(2.1rem, 11vw, 3.1rem);
  }

  .trust-line {
    gap: 0.8rem;
    overflow-x: auto;
    font-size: 0.64rem;
  }

  .result-lead h2 > span {
    display: block;
    margin-top: 0.25rem;
  }

  .preview-shell,
  .preview-shell canvas {
    height: 280px;
    min-height: 280px;
  }

  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-grid > div:nth-child(2) {
    border-right: 0;
  }

  .result-grid > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .bags-row strong {
    font-size: 1rem;
  }

  .field-grid,
  .thickness-row,
  .cost-fields {
    grid-template-columns: 1fr;
  }

  .count-grid {
    width: 100%;
  }

  .estimate-table > div {
    grid-template-columns: 0.8fr 1.2fr;
  }

  .actions button {
    flex: 1 1 calc(50% - 0.3rem);
  }

  .content-block {
    margin: 4rem auto;
  }

  .worked-example {
    padding: 1.4rem;
  }

  footer {
    margin-top: 5rem;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: white;
    color: black;
  }

  .site-header,
  .intro,
  .input-panel,
  .preview-shell,
  .actions,
  .content-block,
  footer,
  dialog,
  .toast {
    display: none !important;
  }

  main,
  .calculator-shell {
    width: 100%;
    display: block;
  }

  .stage {
    position: static;
    border: 0;
    box-shadow: none;
  }
}

/* Focused calculator layout v1.1 */

html {
  scroll-padding-top: 76px;
  scroll-behavior: auto;
}

body {
  background: var(--paper);
}

.site-header {
  width: min(1280px, calc(100% - 24px));
  min-height: 56px;
}

.brand {
  gap: 0.58rem;
  font-size: 0.88rem;
}

.brand-mark {
  width: 28px;
  height: 22px;
}

.brand-mark i {
  width: 25px;
  height: 9px;
}

.brand-mark i:last-child {
  top: 10px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
}

main {
  width: min(1280px, calc(100% - 24px));
}

.intro {
  min-height: 0;
  padding: 1.1rem 0 1rem;
  display: block;
}

.intro > div:first-child {
  max-width: none;
}

h1 {
  margin-bottom: 0.25rem;
  font-size: clamp(1.9rem, 3vw, 2.75rem);
  line-height: 1;
  letter-spacing: -0.047em;
}

.intro p:not(.eyebrow) {
  display: inline;
  max-width: none;
  font-size: 0.91rem;
}

.trust-line {
  display: inline-flex;
  gap: 0;
  margin-left: 0.65rem;
  padding: 0;
  border: 0;
  color: var(--ink-muted);
  font-size: 0.63rem;
  letter-spacing: 0.02em;
  vertical-align: 0.08rem;
  white-space: nowrap;
}

.trust-line span + span::before {
  content: " · ";
  color: var(--line-strong);
}

.calculator-shell {
  display: grid;
  grid-template-areas: "input stage";
  grid-template-columns: minmax(380px, 420px) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.input-panel {
  grid-area: input;
}

.stage {
  grid-area: stage;
}

.input-panel,
.stage {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(23 26 28 / 0.06);
}

.input-toolbar {
  min-height: 58px;
  padding: 0.65rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.input-toolbar h2 {
  margin: 0;
  font-size: 0.94rem;
}

.input-kicker {
  display: block;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.setup-actions {
  display: flex;
  gap: 0.3rem;
}

.setup-actions button {
  min-height: 34px;
  padding: 0.35rem 0.5rem;
  color: var(--ink-muted);
  font-size: 0.68rem;
}

.setup-actions #btn-undo {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.core-section {
  padding: 0.8rem;
}

.shape-control {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
}

.shape-control label,
.preset-control > span,
.thickness-chips > span {
  color: var(--ink-muted);
  font-size: 0.69rem;
  font-weight: 680;
}

.shape-control select {
  min-height: 38px;
  padding: 0.35rem 0.55rem;
}

.preset-control {
  margin-bottom: 0.75rem;
}

.preset-control > span {
  display: block;
  margin-bottom: 0.3rem;
}

.presets {
  flex-wrap: nowrap;
  gap: 0.28rem;
  margin: 0;
  padding-bottom: 0.18rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.preset-chip {
  flex: 0 0 auto;
  padding: 0.35rem 0.48rem;
  white-space: nowrap;
}

.preset-chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.core-dimensions,
.shape-dimensions,
.stair-dimensions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.48rem;
}

.field label {
  margin-bottom: 0.2rem;
  font-size: 0.67rem;
}

.number-wrap,
select {
  min-height: 41px;
}

.number-wrap input {
  padding: 0.58rem 0.25rem 0.58rem 0.55rem;
  font-size: 0.82rem;
}

.number-wrap span {
  padding-right: 0.48rem;
  font-size: 0.62rem;
}

.thickness-chips {
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.28rem;
  margin: 0.65rem 0 0;
  overflow-x: auto;
}

.thickness-chips > span {
  margin-right: 0.1rem;
  white-space: nowrap;
}

.thickness-chips button {
  flex: 0 0 auto;
  min-width: 38px;
  padding: 0.33rem 0.42rem;
}

.thickness-chips button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.options > summary,
.material-breakdown > summary {
  min-height: 48px;
  padding: 0 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.options > summary > span:last-child,
.material-breakdown > summary > span:last-child {
  overflow: hidden;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.details-body {
  padding: 0.8rem;
}

.count-grid {
  width: 50%;
  margin-bottom: 0.75rem;
}

.cost-options {
  margin-top: 0.8rem;
  border: 1px solid var(--line);
}

.cost-options > summary {
  min-height: 42px;
  padding: 0 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 680;
}

.cost-options > summary span:last-child {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.59rem;
  font-weight: 500;
}

.cost-fields {
  padding: 0.7rem;
  border-top: 1px solid var(--line);
}

.stage {
  top: 0.5rem;
}

.mobile-summary {
  display: none;
}

.result-lead {
  min-height: 88px;
  padding: 0.82rem 1rem 0.75rem;
}

.result-lead h2 {
  font-size: clamp(1.4rem, 2.2vw, 1.95rem);
}

.result-lead h2 strong {
  color: var(--accent-dark);
}

.result-alternatives {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.35rem;
  color: var(--ink-muted);
  font-size: 0.7rem;
}

.result-alternatives strong {
  color: var(--ink);
  font-family: var(--mono);
}

.preview-shell,
.preview-shell canvas {
  height: 350px;
  min-height: 350px;
}

.preview-toolbar {
  position: absolute;
  z-index: 3;
  top: 0.55rem;
  right: 0.55rem;
  display: flex;
  gap: 0.3rem;
  max-width: calc(100% - 1.1rem);
  overflow-x: auto;
}

.view-switch,
.preview-actions {
  position: static;
  flex: 0 0 auto;
}

.view-switch button,
.preview-actions button {
  min-height: 38px;
  padding: 0.38rem 0.55rem;
  white-space: nowrap;
}

#btn-rebar[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.preview-hud {
  right: 0.8rem;
  max-width: calc(100% - 1.6rem);
  pointer-events: none;
}

.recommendation {
  margin: 0;
  padding: 0.8rem 1rem;
  gap: 0.55rem;
  border-left-width: 4px;
  border-bottom: 1px solid var(--line);
}

.recommendation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.recommendation-heading > div > span,
.recommendation-quantities span,
.recommendation-quantities small {
  display: block;
  color: var(--ink-muted);
  font-size: 0.62rem;
}

.recommendation-heading strong {
  display: block;
  font-size: 0.88rem;
}

.recommendation-tag {
  padding: 0.25rem 0.45rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--good);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 750;
}

.recommendation[data-kind="readymix"] .recommendation-tag {
  color: var(--accent-dark);
}

.recommendation-quantities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid color-mix(in srgb, var(--good) 25%, var(--line));
}

.recommendation-quantities > div {
  padding: 0.45rem 0.55rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 0.6rem;
}

.recommendation-quantities > div + div {
  border-left: 1px solid color-mix(in srgb, var(--good) 25%, var(--line));
}

.recommendation-quantities strong {
  font-family: var(--mono);
  font-size: 0.76rem;
}

.recommendation-quantities small {
  grid-column: 2;
}

.recommendation-fee,
.recommendation-labor {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.65rem;
}

.actions {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
}

.actions button {
  min-height: 34px;
  padding: 0.42rem 0.6rem;
}

.material-breakdown {
  border-top: 0;
}

.material-breakdown[open] > summary,
.options[open] > summary {
  background: var(--paper-deep);
}

.breakdown-body {
  border-top: 1px solid var(--line);
}

.content-block {
  max-width: 820px;
  margin: 4.5rem auto;
}

.how-estimate > details {
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.how-estimate > details > summary {
  padding: 1.2rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.how-estimate > details > summary h2 {
  margin: 0;
}

.how-estimate > details > summary > span:last-child {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.67rem;
}

.how-estimate-body {
  padding-bottom: 1.6rem;
}

.how-estimate-body h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.how-estimate-body p {
  color: var(--ink-muted);
}

.worked-example {
  padding: 1.1rem;
  box-shadow: none;
}

.how-to {
  margin-top: 1.8rem;
}

.how-to ol {
  margin-top: 0.8rem;
}

.math-block {
  margin-top: 1.8rem;
}

@media (max-width: 980px) {
  .calculator-shell {
    grid-template-areas:
      "summary"
      "input"
      "stage";
    grid-template-columns: minmax(0, 1fr);
    gap: 0.55rem;
  }

  .mobile-summary {
    position: sticky;
    z-index: 15;
    top: 0;
    grid-area: summary;
    width: 100%;
    min-height: 64px;
    padding: 0.55rem 0.72rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.12rem;
    border-color: var(--line-strong);
    background: color-mix(in srgb, var(--surface-raised) 96%, transparent);
    box-shadow: 0 5px 18px rgb(23 26 28 / 0.12);
    text-align: left;
    backdrop-filter: blur(10px);
  }

  .mobile-summary-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
  }

  .mobile-summary-top strong {
    color: var(--accent-dark);
    font-family: var(--mono);
    font-size: 1.05rem;
  }

  .mobile-summary-top > span:last-child {
    color: var(--good);
    font-family: var(--mono);
    font-size: 0.67rem;
    font-weight: 750;
  }

  .mobile-summary-bottom {
    overflow: hidden;
    color: var(--ink-muted);
    font-size: 0.69rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stage {
    position: static;
    order: initial;
  }

  .result-lead {
    display: none;
  }

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

  .preview-shell,
  .preview-shell canvas {
    height: 310px;
    min-height: 310px;
  }

  input,
  select,
  button,
  summary,
  details {
    scroll-margin-top: 76px;
  }
}

@media (max-width: 600px) {
  .site-header,
  main,
  footer {
    width: min(100% - 16px, 1280px);
  }

  .site-header {
    min-height: 54px;
  }

  .intro {
    padding: 0.72rem 0 0.7rem;
  }

  h1 {
    font-size: clamp(1.72rem, 8.3vw, 2.1rem);
  }

  .intro p:not(.eyebrow) {
    display: block;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .trust-line {
    margin: 0.25rem 0 0;
    display: flex;
    overflow: visible;
    border: 0;
    padding: 0;
    font-size: 0.57rem;
  }

  .mobile-summary {
    min-height: 60px;
  }

  .input-toolbar {
    min-height: 50px;
    padding: 0.48rem 0.55rem;
  }

  .input-toolbar h2 {
    font-size: 0.82rem;
  }

  .input-kicker {
    font-size: 0.52rem;
  }

  .setup-actions {
    gap: 0.2rem;
  }

  .setup-actions button {
    min-height: 32px;
    padding: 0.3rem 0.4rem;
    font-size: 0.6rem;
  }

  .core-section {
    padding: 0.58rem;
  }

  .shape-control {
    grid-template-columns: 76px minmax(0, 1fr);
    margin-bottom: 0.5rem;
  }

  .shape-control select {
    min-height: 36px;
  }

  .preset-control {
    margin-bottom: 0.5rem;
  }

  .preset-control > span {
    margin-bottom: 0.2rem;
  }

  .preset-chip {
    padding: 0.28rem 0.42rem;
    font-size: 0.64rem;
  }

  .core-dimensions,
  .shape-dimensions,
  .stair-dimensions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.32rem;
  }

  .field label {
    font-size: 0.61rem;
  }

  .number-wrap {
    min-height: 38px;
  }

  .number-wrap input {
    padding: 0.5rem 0.12rem 0.5rem 0.42rem;
    font-size: 0.75rem;
  }

  .number-wrap span {
    padding-right: 0.34rem;
    font-size: 0.56rem;
  }

  .thickness-chips {
    margin-top: 0.48rem;
  }

  .thickness-chips > span {
    font-size: 0.6rem;
  }

  .thickness-chips button {
    min-width: 34px;
    padding: 0.25rem 0.32rem;
    font-size: 0.63rem;
  }

  .options > summary,
  .material-breakdown > summary {
    min-height: 44px;
    padding: 0 0.58rem;
  }

  .details-body {
    padding: 0.65rem;
  }

  .preview-shell,
  .preview-shell canvas {
    height: 280px;
    min-height: 280px;
  }

  .preview-toolbar {
    top: 0.42rem;
    right: 0.42rem;
    max-width: calc(100% - 0.84rem);
  }

  .view-switch button,
  .preview-actions button {
    min-height: 36px;
    padding: 0.34rem 0.45rem;
    font-size: 0.62rem;
  }

  .preview-hud {
    left: 0.55rem;
    right: 0.55rem;
    bottom: 0.55rem;
    font-size: 0.55rem;
  }

  .recommendation {
    padding: 0.68rem;
  }

  .recommendation-quantities > div {
    display: block;
  }

  .recommendation-quantities strong,
  .recommendation-quantities small {
    margin-top: 0.08rem;
  }

  .actions {
    padding: 0.5rem 0.68rem;
  }

  .actions button {
    flex: 1 1 auto;
  }

  .content-block {
    margin: 3rem auto;
  }

  .how-estimate > details > summary h2,
  .content-block h2 {
    font-size: 1.55rem;
  }

  .how-estimate > details > summary > span:last-child {
    display: none;
  }
}

@media print {
  .mobile-summary,
  .preview-shell,
  .actions,
  .warnings {
    display: none !important;
  }

  .material-breakdown > .breakdown-body {
    display: block !important;
  }

  .recommendation,
  .material-breakdown {
    break-inside: avoid;
  }
}
