:root {
  --ink: #17252a;
  --ink-soft: #526166;
  --ink-faint: #657378;
  --paper: #f7f9f8;
  --paper-warm: #f2f5f3;
  --steel-1: #e9edec;
  --steel-2: #d9e0de;
  --steel-3: #c3cecb;
  --steel-4: #a8b5b2;
  --line: #c8d1cf;
  --line-strong: #9eaaa7;
  --cherry: #b12632;
  --cherry-deep: #841f29;
  --cherry-pale: #f6e2e3;
  --butter: #f8dc72;
  --butter-pale: #fff3bd;
  --mint-pale: #e6f0eb;
  --white: #fcfdfc;
  --shadow: 0 8px 24px rgba(23, 37, 42, 0.08);
  --shadow-tight: 0 2px 9px rgba(23, 37, 42, 0.1);
  --radius-sm: 3px;
  --radius-md: 7px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 2.5rem;
  --space-9: 3rem;
  --display: "DIN Alternate", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", sans-serif;
  --body: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--steel-1);
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.22) 0, rgba(255, 255, 255, 0.22) 1px, rgba(155, 169, 166, 0.045) 1px, rgba(155, 169, 166, 0.045) 3px);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cherry);
  outline-offset: 2px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--white);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input:hover,
select:hover {
  border-color: var(--ink-soft);
}

input:focus,
select:focus {
  border-color: var(--cherry);
  box-shadow: 0 0 0 3px rgba(177, 38, 50, 0.13);
  outline: none;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--cherry);
  background: var(--cherry-pale);
}

input::placeholder {
  color: var(--ink-faint);
  opacity: 0.85;
}

.skip-link {
  position: absolute;
  z-index: 20;
  top: var(--space-3);
  left: var(--space-3);
  padding: var(--space-2) var(--space-4);
  color: var(--white);
  background: var(--cherry-deep);
  transform: translateY(-180%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  color: var(--paper);
  background: var(--ink);
  border-bottom: 4px solid var(--cherry);
}

.header-inner,
.page-shell,
.footer-inner {
  width: min(1220px, calc(100% - 2 * var(--space-6)));
  margin-inline: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.75rem;
  gap: var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  fill: none;
  stroke: var(--butter);
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 1.8;
}

.brand-wordmark {
  font-family: var(--display);
  font-size: 1.13rem;
  font-stretch: condensed;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.brand-wordmark span {
  color: var(--cherry);
  padding-inline: 0.1em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  color: var(--steel-3);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
}

.header-code {
  white-space: nowrap;
}

.local-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.35rem 0.55rem;
  color: var(--butter);
  border: 1px solid rgba(248, 220, 114, 0.45);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--butter);
  box-shadow: 0 0 0 3px rgba(248, 220, 114, 0.16);
}

.page-shell {
  padding-block: var(--space-8) var(--space-9);
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-8);
  padding-block: var(--space-4) var(--space-7);
}

.hero-copy {
  max-width: 47rem;
}

.eyebrow,
.section-kicker,
.formula-label {
  margin: 0;
  color: var(--cherry);
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.3;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.eyebrow-rule {
  display: inline-block;
  width: 2.25rem;
  height: 0.2rem;
  background: var(--cherry);
}

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

h1,
h2 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 11ch;
  margin-bottom: var(--space-4);
  font-size: clamp(3rem, 8vw, 6.7rem);
  line-height: 0.88;
  text-wrap: balance;
}

h2 {
  margin-bottom: var(--space-2);
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  line-height: 0.98;
}

.hero-lede {
  max-width: 41rem;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  line-height: 1.55;
}

.hero-stamp {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 7.6rem;
  height: 7.6rem;
  padding: var(--space-3);
  color: var(--cherry-deep);
  border: 2px solid var(--cherry);
  border-radius: 50%;
  transform: rotate(7deg);
  text-align: center;
}

.hero-stamp .stamp-top,
.hero-stamp .stamp-bottom {
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.hero-stamp strong {
  font-family: var(--display);
  font-size: 2.35rem;
  line-height: 0.8;
}

.notice-strip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding: var(--space-3) var(--space-4);
  color: var(--ink);
  background: var(--butter-pale);
  border-top: 1px solid #d8bd58;
  border-bottom: 1px solid #d8bd58;
}

.notice-strip svg,
.assumption-note svg {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: var(--cherry-deep);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.notice-strip p {
  margin: 0;
  font-size: 0.9rem;
}

.calculator-form {
  display: grid;
  gap: var(--space-6);
}

.sheet-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-5) var(--space-6);
  background: var(--ink);
  border-bottom: 4px solid var(--cherry);
  box-shadow: var(--shadow);
}

.recipe-name-wrap {
  min-width: min(100%, 18rem);
}

.recipe-name-label {
  display: block;
  margin-top: var(--space-3);
  color: var(--steel-3);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.recipe-name-input {
  margin-top: var(--space-1);
  padding: 0.55rem 0.75rem;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--steel-4);
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
}

.recipe-name-input:hover {
  border-color: var(--paper);
}

.recipe-name-input:focus {
  border-color: var(--butter);
  box-shadow: 0 0 0 3px rgba(248, 220, 114, 0.17);
}

.toolbar-actions,
.saved-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.7rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.button-primary {
  color: var(--white);
  background: var(--cherry);
  border-color: var(--cherry);
}

.button-primary:hover:not(:disabled) {
  background: var(--cherry-deep);
  border-color: var(--cherry-deep);
}

.button-secondary {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line-strong);
}

.button-secondary:hover:not(:disabled) {
  color: var(--cherry-deep);
  border-color: var(--cherry);
  background: var(--white);
}

.sheet-toolbar .button-secondary {
  color: var(--paper);
  background: transparent;
  border-color: var(--steel-4);
}

.sheet-toolbar .button-secondary:hover:not(:disabled) {
  color: var(--butter);
  border-color: var(--butter);
  background: rgba(248, 220, 114, 0.08);
}

.button-danger {
  color: var(--cherry-deep);
  background: transparent;
  border-color: rgba(177, 38, 50, 0.4);
}

.button-danger:hover:not(:disabled) {
  color: var(--white);
  background: var(--cherry);
  border-color: var(--cherry);
}

.button:disabled {
  color: var(--ink-faint);
  background: var(--steel-2);
  border-color: var(--line);
  opacity: 0.72;
}

.button-small {
  min-height: 2.25rem;
  padding-inline: var(--space-3);
  font-size: 0.64rem;
}

.button-add {
  color: var(--cherry-deep);
  background: var(--cherry-pale);
  border-color: rgba(177, 38, 50, 0.42);
}

.button-add:hover:not(:disabled) {
  color: var(--white);
  background: var(--cherry);
  border-color: var(--cherry);
}

.add-symbol {
  display: inline-grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 0.8;
}

.form-feedback {
  min-height: 1.3rem;
  margin: calc(var(--space-2) * -1) 0 0;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(19rem, 0.82fr);
  align-items: start;
  gap: var(--space-6);
}

.panel {
  background: rgba(247, 249, 248, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-tight);
}

.ingredients-panel,
.assumptions-panel,
.price-sheet {
  min-width: 0;
}

.ingredients-panel {
  overflow: hidden;
}

.panel-heading {
  padding: var(--space-5) var(--space-6) var(--space-4);
}

.panel-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.panel-heading h2 {
  margin-top: var(--space-2);
}

.panel-intro {
  max-width: 44rem;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.ledger-count,
.sheet-tag {
  flex: 0 0 auto;
  padding: 0.35rem 0.5rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sheet-tag {
  color: var(--cherry-deep);
  border-color: rgba(177, 38, 50, 0.36);
  background: var(--cherry-pale);
}

.table-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ingredient-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: fixed;
}

.ingredient-table th,
.ingredient-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.ingredient-table th {
  padding: 0.65rem var(--space-3);
  color: var(--ink-soft);
  background: var(--steel-1);
  font-family: var(--mono);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.ingredient-table th:first-child,
.ingredient-table td:first-child {
  padding-left: var(--space-6);
}

.ingredient-table th:last-child,
.ingredient-table td:last-child {
  padding-right: var(--space-5);
}

.ingredient-table th:nth-child(1) {
  width: 22%;
}

.ingredient-table th:nth-child(2) {
  width: 16%;
}

.ingredient-table th:nth-child(3),
.ingredient-table th:nth-child(4) {
  width: 22%;
}

.ingredient-table th:nth-child(5) {
  width: 13%;
}

.ingredient-table th:nth-child(6) {
  width: 5%;
}

.ingredient-table td {
  padding: var(--space-3);
}

.ingredient-table tbody tr:last-child td {
  border-bottom: 0;
}

.ingredient-table input,
.ingredient-table select {
  min-height: 2.25rem;
  padding: 0.42rem 0.5rem;
  font-size: 0.84rem;
}

.ingredient-table select {
  min-width: 4.9rem;
  padding-right: 1.45rem;
}

.table-money-input,
.table-quantity-input,
.input-with-prefix,
.input-with-suffix {
  display: flex;
  align-items: stretch;
}

.table-money-input span,
.input-with-prefix span,
.input-with-suffix span {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--ink-soft);
  background: var(--steel-1);
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1;
}

.table-money-input span,
.input-with-prefix span {
  width: 1.8rem;
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-with-suffix span {
  min-width: 4rem;
  padding-inline: var(--space-2);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.table-money-input input,
.input-with-prefix input {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.input-with-suffix input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.table-quantity-input {
  gap: var(--space-1);
}

.table-quantity-input input {
  min-width: 0;
}

.ingredient-name-cell {
  position: relative;
}

.ingredient-name {
  font-weight: 650;
}

.line-cost-cell {
  white-space: nowrap;
}

.line-cost {
  display: block;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.35;
}

.line-status {
  display: block;
  margin-top: var(--space-1);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.57rem;
  letter-spacing: 0.03em;
}

.remove-cell {
  text-align: right;
}

.remove-row {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
  line-height: 1;
}

.remove-row:hover {
  color: var(--cherry-deep);
  background: var(--cherry-pale);
  border-color: rgba(177, 38, 50, 0.35);
}

.row-error {
  margin: var(--space-1) 0 0;
  color: var(--cherry-deep);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.3;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-5);
  color: var(--ink-soft);
  text-align: center;
}

.empty-state p {
  max-width: 24rem;
  margin-bottom: var(--space-2);
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--cherry);
  border: 1px solid var(--cherry);
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
}

.ingredient-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
}

.table-note {
  margin: 0;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.61rem;
  line-height: 1.45;
  text-align: right;
}

.assumptions-panel {
  position: sticky;
  top: var(--space-4);
}

.assumptions-panel .panel-heading {
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
}

.field-group {
  margin: 0;
  padding: var(--space-5) var(--space-6);
  border: 0;
  border-bottom: 1px solid var(--line);
}

.field-group legend {
  margin-bottom: var(--space-3);
  padding: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  gap: var(--space-4);
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field label,
.saved-select-field label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  line-height: 1.3;
  text-transform: uppercase;
}

.field input {
  min-height: 2.45rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.88rem;
}

.field-help {
  min-height: 1.2em;
  margin: var(--space-1) 0 0;
  color: var(--ink-faint);
  font-size: 0.68rem;
  line-height: 1.35;
}

.target-field input {
  border-color: #c19e31;
  background: var(--butter-pale);
}

.assumption-note {
  display: flex;
  gap: var(--space-3);
  margin: var(--space-5) var(--space-6);
  padding: var(--space-3);
  color: var(--ink-soft);
  background: var(--mint-pale);
  border-left: 3px solid #52846c;
}

.assumption-note p {
  margin: 0;
  font-size: 0.73rem;
  line-height: 1.45;
}

.price-sheet {
  overflow: hidden;
}

.results-heading {
  border-bottom: 1px solid var(--line);
}

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

.result-card {
  min-height: 8.1rem;
  padding: var(--space-5);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-card:nth-child(4n) {
  border-right: 0;
}

.result-card:nth-child(n + 5) {
  border-bottom: 0;
}

.result-label,
.result-detail {
  display: block;
}

.result-label {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.25;
  text-transform: uppercase;
}

.result-value {
  display: block;
  margin-top: var(--space-3);
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.result-detail {
  margin-top: var(--space-2);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.61rem;
  line-height: 1.35;
}

.result-card-total {
  background: var(--butter-pale);
}

.result-card-price {
  color: var(--cherry-deep);
  background: var(--butter);
}

.result-card-price .result-label,
.result-card-price .result-detail,
.result-card-price .result-value {
  color: var(--cherry-deep);
}

.result-card-profit {
  background: var(--mint-pale);
}

.result-card-serving {
  background: var(--steel-1);
}

.formula-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  padding: var(--space-5) var(--space-6);
  background: var(--steel-1);
}

.formula-strip p {
  margin: var(--space-2) 0 0;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
}

.saved-panel {
  display: grid;
  grid-template-columns: minmax(15rem, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: var(--space-7);
  margin-top: var(--space-6);
  padding: var(--space-5) var(--space-6);
}

.saved-copy h2 {
  margin-top: var(--space-2);
}

.saved-copy p:last-child {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.saved-controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: var(--space-3);
}

.saved-select-field {
  flex: 1 1 14rem;
  min-width: 0;
}

.saved-select-field select {
  min-height: 2.7rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.84rem;
}

.saved-actions {
  flex: 0 0 auto;
}

.explain-grid {
  display: grid;
  grid-template-columns: minmax(13rem, 0.72fr) minmax(0, 1.28fr);
  gap: var(--space-8);
  padding: var(--space-8) var(--space-2) var(--space-2);
}

.explain-grid h2 {
  max-width: 12ch;
  margin-top: var(--space-2);
}

.explain-copy {
  columns: 2 15rem;
  column-gap: var(--space-7);
}

.explain-copy p {
  margin-bottom: var(--space-4);
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.65;
}

.site-footer {
  color: var(--steel-3);
  background: var(--ink);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-5);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.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;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1040px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .assumptions-panel {
    position: static;
  }

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

  .result-card:nth-child(4n) {
    border-right: 1px solid var(--line);
  }

  .result-card:nth-child(2n) {
    border-right: 0;
  }

  .result-card:nth-child(n + 5) {
    border-bottom: 1px solid var(--line);
  }

  .result-card:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}

@media (max-width: 820px) {
  .header-inner,
  .page-shell,
  .footer-inner {
    width: min(100% - 2 * var(--space-4), 1220px);
  }

  .page-shell {
    padding-top: var(--space-6);
  }

  .hero {
    align-items: flex-start;
    padding-bottom: var(--space-6);
  }

  .hero-stamp {
    width: 6.25rem;
    height: 6.25rem;
  }

  .hero-stamp strong {
    font-size: 1.9rem;
  }

  .sheet-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding-inline: var(--space-4);
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .ingredient-table th:first-child,
  .ingredient-table td:first-child {
    padding-left: var(--space-4);
  }

  .ingredient-table th:last-child,
  .ingredient-table td:last-child {
    padding-right: var(--space-4);
  }

  .ingredient-footer {
    align-items: flex-start;
    flex-direction: column;
    padding-inline: var(--space-4);
  }

  .table-note {
    text-align: left;
  }

  .saved-panel {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding-inline: var(--space-4);
  }

  .saved-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .saved-actions {
    justify-content: flex-start;
  }

  .explain-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding-inline: 0;
  }

  .explain-grid h2 {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .header-inner {
    min-height: 4.15rem;
  }

  .header-meta {
    display: none;
  }

  .header-code {
    display: none;
  }

  .brand-wordmark {
    font-size: 0.98rem;
  }

  .hero {
    display: block;
  }

  h1 {
    font-size: clamp(3.1rem, 17vw, 5rem);
  }

  .hero-stamp {
    display: none;
  }

  .notice-strip {
    align-items: flex-start;
    margin-bottom: var(--space-4);
  }

  .toolbar-actions,
  .saved-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-actions .button:last-child {
    grid-column: 1 / -1;
  }

  .toolbar-actions .button,
  .saved-actions .button {
    width: 100%;
  }

  .panel-heading {
    padding-inline: var(--space-4);
  }

  .panel-heading-row {
    display: block;
  }

  .ledger-count,
  .sheet-tag {
    display: inline-block;
    margin-top: var(--space-3);
  }

  .field-group {
    padding-inline: var(--space-4);
  }

  .two-up,
  .formula-strip {
    grid-template-columns: 1fr;
  }

  .assumption-note {
    margin-inline: var(--space-4);
  }

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

  .result-card {
    min-height: 7.3rem;
    padding: var(--space-4);
  }

  .result-value {
    font-size: 1.7rem;
  }

  .formula-strip {
    gap: var(--space-4);
    padding-inline: var(--space-4);
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 540px) {
  .table-scroll {
    overflow: visible;
  }

  .ingredient-table {
    min-width: 0;
    border-collapse: separate;
  }

  .ingredient-table thead {
    display: none;
  }

  .ingredient-table,
  .ingredient-table tbody,
  .ingredient-table tr,
  .ingredient-table td {
    display: block;
  }

  .ingredient-table tbody {
    padding: var(--space-2) var(--space-3);
  }

  .ingredient-table tr.ingredient-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(5.5rem, 0.56fr);
    gap: var(--space-2) var(--space-3);
    margin: var(--space-3) 0;
    padding: var(--space-3);
    background: var(--white);
    border: 1px solid var(--line);
    box-shadow: 0 2px 5px rgba(23, 37, 42, 0.05);
  }

  .ingredient-table tr.ingredient-row td {
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .ingredient-table tr.ingredient-row td::before {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--ink-faint);
    font-family: var(--mono);
    font-size: 0.57rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .ingredient-table tr.ingredient-row .ingredient-name-cell {
    grid-column: 1 / -1;
  }

  .ingredient-table tr.ingredient-row .ingredient-name-cell::before {
    content: "Ingredient";
  }

  .ingredient-table tr.ingredient-row td:nth-child(2)::before {
    content: "Package price";
  }

  .ingredient-table tr.ingredient-row td:nth-child(3)::before {
    content: "Package size";
  }

  .ingredient-table tr.ingredient-row td:nth-child(4)::before {
    content: "Recipe uses";
  }

  .ingredient-table tr.ingredient-row .line-cost-cell {
    align-self: center;
  }

  .ingredient-table tr.ingredient-row .line-cost-cell::before {
    content: "Line cost";
  }

  .ingredient-table tr.ingredient-row .remove-cell {
    align-self: end;
    justify-self: end;
  }

  .ingredient-table tr.ingredient-row .remove-cell::before {
    content: "Remove";
    text-align: right;
  }

  .table-money-input,
  .table-quantity-input {
    min-width: 0;
  }

  .ingredient-table select {
    min-width: 4.15rem;
    padding-inline: 0.35rem;
  }

  .ingredient-footer {
    padding-top: var(--space-3);
  }

  .saved-actions {
    grid-template-columns: 1fr;
  }

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

  .result-card,
  .result-card:nth-child(2n),
  .result-card:nth-child(4n) {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .result-card:last-child {
    border-bottom: 0;
  }
}

@media print {
  @page {
    margin: 0.55in;
  }

  :root {
    --ink: #17252a;
    --ink-soft: #34454a;
    --line: #adb8b5;
  }

  body {
    color: var(--ink);
    background: var(--white);
    background-image: none;
    font-size: 10pt;
  }

  .site-header {
    color: var(--ink);
    background: var(--white);
    border-bottom: 2px solid var(--cherry);
  }

  .header-inner,
  .page-shell,
  .footer-inner {
    width: 100%;
  }

  .header-inner {
    min-height: auto;
    padding-block: 0.16in;
  }

  .brand-mark {
    stroke: var(--cherry);
  }

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

  .header-meta,
  .skip-link,
  .notice-strip,
  .toolbar-actions,
  .saved-panel,
  .explain-grid,
  .site-footer,
  .ingredient-footer,
  .form-feedback {
    display: none !important;
  }

  .page-shell {
    padding-block: 0.18in;
  }

  .hero {
    padding-block: 0.08in 0.18in;
  }

  h1 {
    max-width: none;
    font-size: 34pt;
  }

  .hero-lede {
    font-size: 10pt;
  }

  .hero-stamp {
    width: 0.85in;
    height: 0.85in;
  }

  .sheet-toolbar {
    display: block;
    padding: 0.12in 0.16in;
    background: var(--white);
    border: 1px solid var(--line);
    border-bottom: 3px solid var(--cherry);
    box-shadow: none;
  }

  .recipe-name-label {
    color: var(--ink-soft);
  }

  .recipe-name-input {
    display: block;
    width: 100%;
    margin-top: 0.02in;
    padding: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    font-size: 18pt;
  }

  .workspace-grid {
    display: block;
  }

  .ingredients-panel {
    margin-top: 0.16in;
    box-shadow: none;
  }

  .assumptions-panel {
    display: none;
  }

  .panel-heading {
    padding: 0.13in 0.16in 0.1in;
  }

  .panel-intro {
    font-size: 8pt;
  }

  .ingredient-table {
    min-width: 0;
  }

  .ingredient-table th,
  .ingredient-table td {
    padding: 0.07in 0.09in;
  }

  .ingredient-table th:first-child,
  .ingredient-table td:first-child {
    padding-left: 0.16in;
  }

  .ingredient-table th:last-child,
  .ingredient-table td:last-child {
    padding-right: 0.16in;
  }

  .price-sheet {
    margin-top: 0.16in;
    box-shadow: none;
  }

  .results-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .result-card,
  .result-card:nth-child(2n),
  .result-card:nth-child(4n) {
    min-height: 0;
    padding: 0.11in;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .result-card:nth-child(4n) {
    border-right: 0;
  }

  .result-card:nth-child(n + 5) {
    border-bottom: 0;
  }

  .result-value {
    margin-top: 0.07in;
    font-size: 17pt;
  }

  .result-detail {
    font-size: 6.5pt;
  }

  .formula-strip {
    gap: 0.2in;
    padding: 0.11in 0.16in;
  }

  .formula-strip p {
    font-size: 7pt;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Keep the working calculator compact and visually ahead of secondary content. */
.hero {
  padding-block: var(--space-6);
}

.hero h1 {
  max-width: none;
  margin-bottom: var(--space-3);
  font-size: clamp(2.7rem, 6vw, 5rem);
}

.notice-strip {
  margin-bottom: var(--space-4);
}

.result-card-price {
  outline: 3px solid var(--cherry);
  outline-offset: -3px;
}

.explain-copy h3 {
  break-after: avoid;
  margin: 0 0 var(--space-2);
  font-size: 1rem;
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 1.25rem, 1220px);
  }

  .hero {
    padding-block: var(--space-4);
  }

  .notice-strip,
  .panel-heading,
  .ingredient-footer,
  .formula-strip,
  .saved-panel {
    padding-inline: var(--space-3);
  }

  .toolbar-actions .button {
    flex: 1 1 auto;
  }
}
