html {
  scroll-behavior: smooth;
}

.content-copy {
  display: grid;
  gap: 1rem;
  color: #475569;
  line-height: 1.75;
}

.content-copy a,
.result-conversion-link {
  color: #be185d;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.content-copy a:hover,
.result-conversion-link:hover {
  color: #9d174d;
}

.content-copy a:focus-visible,
.result-conversion-link:focus-visible {
  border-radius: 0.2rem;
  outline: 2px solid #db2777;
  outline-offset: 3px;
}

.content-callout {
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: #fff;
  padding: 1.5rem;
}

.content-list {
  display: grid;
  gap: 0.75rem;
  color: #334155;
}

.content-list li {
  position: relative;
  padding-left: 1.25rem;
}

.content-list li::before {
  position: absolute;
  left: 0;
  color: #db2777;
  content: "•";
  font-weight: 800;
}

.faq-grid {
  display: grid;
  gap: 1.5rem;
}

.faq-item {
  border-top: 1px solid #e2e8f0;
  padding-top: 1.5rem;
}

.faq-item h3 {
  color: #0f172a;
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1.4;
}

.faq-item p {
  margin-top: 0.6rem;
  color: #475569;
  line-height: 1.7;
}

.nutrition-hero {
  background:
    radial-gradient(circle at 18% 18%, rgba(236, 72, 153, 0.28), transparent 34%),
    radial-gradient(circle at 86% 12%, rgba(59, 130, 246, 0.12), transparent 28%),
    linear-gradient(135deg, #111827 0%, #111827 48%, #241521 100%);
}

.nutrition-hero-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), transparent);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), transparent);
}

.calculator-shell {
  overflow: visible;
  box-shadow:
    0 30px 75px rgba(15, 23, 42, 0.12),
    0 6px 18px rgba(15, 23, 42, 0.06);
}

.calculator-workspace {
  display: grid;
  min-width: 0;
}

.calculator-builder,
.calculator-results {
  min-width: 0;
}

.calculator-builder {
  position: relative;
  border-radius: 1rem 1rem 0 0;
}

.calculator-builder:focus-within {
  z-index: 40;
}

.calculator-results {
  border-radius: 0 0 1rem 1rem;
}

.result-conversion {
  margin-top: 1rem;
  border: 1px solid #fbcfe8;
  border-radius: 0.9rem;
  background: #fff;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.result-conversion-eyebrow {
  color: #be185d;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.result-conversion-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1rem;
  margin-top: 1rem;
}

.result-conversion-link {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: 9999px;
  background: #fce7f3;
  color: #be185d;
  font-size: 0.75rem;
  font-weight: 800;
}

.step-number-small {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.6875rem;
}

.batch-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: #0f172a;
  font-size: 0.9375rem;
  font-weight: 750;
}

.batch-control .batch-input {
  width: 5.25rem;
  min-width: 5.25rem;
  min-height: 2.5rem;
  flex: 0 0 5.25rem;
  padding-block: 0.5rem;
  text-align: center;
}

.ingredients-section {
  margin-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1.25rem;
}

.ingredients-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.ingredient-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.primary-button.calculate-button {
  margin-top: 1rem;
  padding: 0.72rem 1.25rem;
}

.field-label {
  display: block;
  margin-bottom: 0.4rem;
  color: #334155;
  font-size: 0.8125rem;
  font-weight: 700;
}

.field-control {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.65rem;
  background: #fff;
  padding: 0.625rem 0.75rem;
  color: #0f172a;
  font-size: 1rem;
  line-height: 1.25rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field-control:focus {
  outline: none;
  border-color: #ec4899;
  box-shadow: 0 0 0 4px rgba(251, 207, 232, 0.8);
}

.field-control[aria-invalid="true"] {
  border-color: #b45309;
  box-shadow: 0 0 0 3px rgba(253, 230, 138, 0.65);
}

.ingredient-row {
  position: relative;
  border: 1px solid #e2e8f0;
  border-radius: 0.85rem;
  background: #fff;
  padding: 0.75rem;
}

.ingredient-row:focus-within {
  z-index: 50;
}

.ingredient-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 0.6rem;
  align-items: start;
}

.ingredient-name-field {
  min-width: 0;
  grid-column: 1 / -1;
}

.ingredient-combobox {
  position: relative;
}

.ingredient-search-input {
  padding-right: 2.35rem;
}

.ingredient-search-input.is-matched {
  border-color: #a7f3d0;
  background-image: radial-gradient(circle, #059669 0 42%, transparent 47%);
  background-position: right 0.9rem center;
  background-repeat: no-repeat;
  background-size: 0.72rem 0.72rem;
}

.ingredient-source {
  margin-top: 0.25rem;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 650;
}

.ingredient-source::first-letter {
  color: #059669;
}

.ingredient-excluded {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 650;
}

.ingredient-excluded .text-button {
  min-height: auto;
  padding: 0.2rem 0.35rem;
  font-size: 0.75rem;
}

.ingredient-actions {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: flex-end;
}

.row-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.75rem;
  border-radius: 9999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.row-status::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  flex: none;
  border-radius: 9999px;
  background: currentColor;
}

.status-ready {
  background: #ecfdf5;
  color: #047857;
}

.status-needs-match,
.status-needs-weight {
  background: #fff7ed;
  color: #9a3412;
}

.status-excluded {
  background: #f1f5f9;
  color: #475569;
}

.status-unavailable {
  background: #fef2f2;
  color: #b91c1c;
}

.weight-panel {
  margin-top: 0.7rem;
  border: 1px solid #fde68a;
  border-radius: 0.7rem;
  background: #fffbeb;
  padding: 0.75rem;
}

.weight-panel-title {
  color: #92400e;
  font-weight: 800;
}

.weight-panel .portion-option {
  background: rgba(255, 255, 255, 0.72);
  padding: 0.6rem;
}

.autocomplete-panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: min(22rem, 55vh);
  overflow-y: auto;
  border: 1px solid #cbd5e1;
  border-radius: 0.8rem;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16), 0 3px 9px rgba(15, 23, 42, 0.08);
}

.autocomplete-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  padding: 0.72rem 0.8rem;
  text-align: left;
  cursor: pointer;
}

.autocomplete-option:last-child {
  border-bottom: 0;
}

.autocomplete-option:hover,
.autocomplete-option.is-active,
.autocomplete-option[aria-selected="true"] {
  background: #fdf2f8;
}

.autocomplete-option:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid #ec4899;
  outline-offset: -2px;
}

.autocomplete-option-name {
  min-width: 0;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.autocomplete-message {
  padding: 0.85rem;
  color: #475569;
  font-size: 0.875rem;
}

.autocomplete-message .autocomplete-action {
  min-height: auto;
  margin-top: 0.35rem;
  padding: 0.3rem 0.45rem;
}

.autocomplete-error {
  color: #991b1b;
}

.autocomplete-exclude {
  margin-top: 0.8rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.7rem;
}

.search-spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  margin-right: 0.5rem;
  vertical-align: -0.1rem;
  border: 2px solid #fbcfe8;
  border-top-color: #db2777;
  border-radius: 9999px;
  animation: spin 700ms linear infinite;
}

.data-badge {
  display: inline-flex;
  border-radius: 9999px;
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  color: #475569;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.portion-option {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.75rem;
  cursor: pointer;
}

.portion-option:focus-within {
  border-color: #ec4899;
  box-shadow: 0 0 0 3px rgba(251, 207, 232, 0.75);
}

.primary-button,
.secondary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  border-radius: 9999px;
  font-weight: 700;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.primary-button {
  border: 1px solid #db2777;
  background: #db2777;
  padding: 0.65rem 1.15rem;
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: #be185d;
  border-color: #be185d;
}

.secondary-button {
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 0.6rem 1rem;
  color: #334155;
}

.secondary-button:hover:not(:disabled) {
  border-color: #f9a8d4;
  background: #fdf2f8;
  color: #be185d;
}

.text-button {
  border: 0;
  background: transparent;
  padding: 0.35rem 0.6rem;
  color: #be185d;
}

.text-button:hover:not(:disabled) {
  background: #fdf2f8;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.text-button:focus-visible,
.result-tab:focus-visible,
.remove-button:focus-visible,
.source-link:focus-visible {
  outline: 2px solid #ec4899;
  outline-offset: 3px;
}

.primary-button:disabled,
.secondary-button:disabled,
.text-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.remove-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: 0.65rem;
  color: #64748b;
  font-size: 1.25rem;
}

.remove-label {
  display: inline;
  margin-left: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 700;
}

.remove-button:hover {
  background: #f8fafc;
  color: #be185d;
}

.inline-message {
  border-radius: 0.75rem;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  padding: 0.75rem 0.9rem;
  color: #9a3412;
  font-size: 0.875rem;
}

.inline-message.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.result-notice {
  padding: 0.7rem 0.8rem;
  line-height: 1.45;
}

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

.nutrient-card {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.75rem;
}

.calories-card {
  border-color: #fbcfe8;
  background: #fdf2f8;
}

.ingredient-details-section {
  margin-top: 1.25rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
}

.ingredient-breakdown {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.ingredient-detail {
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 0.65rem;
  background: #fff;
}

.ingredient-detail summary {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  color: #334155;
  font-size: 0.8125rem;
  line-height: 1.35;
  cursor: pointer;
  list-style: none;
}

.ingredient-detail summary::-webkit-details-marker {
  display: none;
}

.ingredient-detail summary::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  flex: none;
  margin-top: 0.33rem;
  border-right: 2px solid #db2777;
  border-bottom: 2px solid #db2777;
  transform: rotate(-45deg);
  transition: transform 150ms ease;
}

.ingredient-detail[open] summary::before {
  transform: rotate(45deg);
}

.ingredient-detail summary:focus-visible {
  outline: 2px solid #ec4899;
  outline-offset: -2px;
}

.ingredient-detail-name {
  color: #0f172a;
  font-weight: 750;
}

.ingredient-detail-body {
  border-top: 1px solid #f1f5f9;
  padding: 0.7rem 0.75rem 0.75rem;
}

.ingredient-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.55rem 0.85rem;
  font-size: 0.75rem;
}

.results-footnote {
  margin-top: 1rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.85rem;
  color: #64748b;
  font-size: 0.75rem;
  line-height: 1.55;
}

.result-tab {
  min-height: 2.5rem;
  border-radius: 9999px;
  padding: 0.55rem 1rem;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 700;
}

.result-tab[aria-selected="true"] {
  background: #0f172a;
  color: #fff;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 9999px;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 640px) {
  .nutrient-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .ingredient-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

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

@media (min-width: 768px) {
  .faq-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 3rem;
  }

  .calculator-builder {
    border-radius: 1.5rem 1.5rem 0 0;
  }

  .calculator-results {
    border-radius: 0 0 1.5rem 1.5rem;
  }
}

@media (min-width: 1024px) {
  .calculator-workspace {
    grid-template-columns: minmax(0, 42fr) minmax(0, 58fr);
  }

  .calculator-builder {
    border-radius: 1.5rem 0 0 1.5rem;
  }

  .calculator-results {
    border-radius: 0 1.5rem 1.5rem 0;
  }

  .ingredient-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) 2.75rem;
  }

  .ingredient-name-field {
    grid-column: 1 / -1;
  }

  .ingredient-actions {
    grid-column: auto;
    justify-content: flex-end;
    padding-top: 1.65rem;
  }

  .remove-label {
    display: none;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
