.nb-tools-page {
  min-height: 100vh;
  padding-top: 70px;
  background: #f7edd7;
  color: #542e00;
}

.nb-tools-hero {
  padding: clamp(3.5rem, 8vw, 7rem) max(1.25rem, calc((100vw - 1120px) / 2)) 3rem;
  background:
    linear-gradient(115deg, rgba(247, 237, 215, .96), rgba(255, 253, 248, .9)),
    url('site-banners/quick-reads-2400.jpg') center / cover;
  border-bottom: 1px solid rgba(103, 117, 79, .18);
}

.nb-tools-hero__inner {
  max-width: 790px;
}

.nb-tools-hero h1 {
  margin: 0 0 .9rem;
  color: #542e00;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(3rem, 7vw, 6rem);
  line-height: .95;
}

.nb-tools-hero p {
  max-width: 65ch;
  margin: 0;
  color: rgba(84, 46, 0, .78);
  font-size: clamp(1.05rem, 1.7vw, 1.25rem);
  line-height: 1.65;
}

.nb-tools-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
}

.nb-tools-notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .85rem;
  align-items: start;
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(103, 117, 79, .2);
  border-radius: 16px;
  background: rgba(255, 253, 248, .72);
  color: rgba(84, 46, 0, .78);
  line-height: 1.55;
}

.nb-tools-notice strong {
  color: #67754f;
}

.nb-tools-notice__mark {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #67754f;
  color: #fffaf2;
  font-weight: 900;
}

.nb-tools-tabs {
  position: sticky;
  z-index: 20;
  top: 70px;
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  margin: 0 -1.25rem 1.6rem;
  padding: .8rem 1.25rem;
  background: rgba(247, 237, 215, .96);
  border-top: 1px solid rgba(103, 117, 79, .12);
  border-bottom: 1px solid rgba(103, 117, 79, .16);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.nb-tools-tabs::-webkit-scrollbar {
  display: none;
}

.nb-tools-tab {
  flex: 0 0 auto;
  min-height: 42px;
  border: 1px solid rgba(150, 47, 51, .18);
  border-radius: 999px;
  padding: .65rem .9rem;
  background: rgba(255, 253, 248, .72);
  color: #542e00;
  font: 800 .93rem/1 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
  white-space: nowrap;
}

.nb-tools-tab:hover,
.nb-tools-tab:focus-visible {
  border-color: rgba(150, 47, 51, .42);
  outline: none;
}

.nb-tools-tab:active {
  transform: translateY(1px);
}

.nb-tools-tab.is-active {
  border-color: #962f33;
  background: #962f33;
  color: #fffaf2;
}

.nb-tool-panel {
  display: none;
  animation: nbToolPanelIn .24s ease both;
}

.nb-tool-panel.is-active {
  display: block;
}

@keyframes nbToolPanelIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.nb-tool-heading {
  max-width: 760px;
  margin-bottom: 1.5rem;
}

.nb-tool-heading h2 {
  margin: 0 0 .55rem;
  color: #542e00;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1;
}

.nb-tool-heading p {
  margin: 0;
  color: rgba(84, 46, 0, .72);
  font-size: 1.05rem;
  line-height: 1.65;
}

.nb-tool-controls,
.nb-tool-form {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid rgba(103, 117, 79, .18);
  border-radius: 18px;
  background: rgba(255, 253, 248, .78);
  box-shadow: 0 14px 36px rgba(84, 46, 0, .07);
}

.nb-tool-controls {
  grid-template-columns: minmax(220px, 1.6fr) repeat(2, minmax(150px, .7fr));
  align-items: end;
}

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

.nb-tool-field {
  display: grid;
  gap: .42rem;
  text-align: left;
}

.nb-tool-field--full {
  grid-column: 1 / -1;
}

.nb-tool-field label,
.nb-tool-field legend {
  color: #542e00;
  font-weight: 900;
}

.nb-tool-field small {
  color: rgba(84, 46, 0, .66);
  line-height: 1.45;
}

.nb-tool-input,
.nb-tool-select,
.nb-tool-textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(103, 117, 79, .3);
  border-radius: 12px;
  padding: .76rem .85rem;
  background: #fffdf8;
  color: #542e00;
  font: 500 1rem/1.4 'DM Sans', system-ui, sans-serif;
}

.nb-tool-textarea {
  min-height: 126px;
  resize: vertical;
}

.nb-tool-input:focus,
.nb-tool-select:focus,
.nb-tool-textarea:focus {
  border-color: #962f33;
  outline: 3px solid rgba(150, 47, 51, .13);
  outline-offset: 1px;
}

.nb-tool-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.nb-tool-choice {
  position: relative;
}

.nb-tool-choice input {
  position: absolute;
  opacity: 0;
}

.nb-tool-choice span {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid rgba(103, 117, 79, .24);
  border-radius: 999px;
  padding: .58rem .78rem;
  background: #fffdf8;
  color: #542e00;
  font-weight: 800;
  cursor: pointer;
}

.nb-tool-choice input:checked + span {
  border-color: #67754f;
  background: rgba(176, 186, 128, .28);
  color: #4e5d3d;
}

.nb-tool-choice input:focus-visible + span {
  outline: 3px solid rgba(150, 47, 51, .16);
  outline-offset: 2px;
}

.nb-tool-button {
  display: inline-flex;
  min-height: 46px;
  width: fit-content;
  align-items: center;
  justify-content: center;
  border: 1px solid #962f33;
  border-radius: 12px;
  padding: .78rem 1.05rem;
  background: #962f33;
  color: #fffaf2;
  font: 900 1rem/1 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(150, 47, 51, .18);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  white-space: nowrap;
}

.nb-tool-button:hover {
  background: #7f272b;
  box-shadow: 0 15px 30px rgba(150, 47, 51, .22);
}

.nb-tool-button:active {
  transform: translateY(1px);
}

.nb-tool-button:focus-visible {
  outline: 3px solid rgba(150, 47, 51, .2);
  outline-offset: 3px;
}

.nb-tool-button--secondary {
  border-color: rgba(103, 117, 79, .32);
  background: #fffdf8;
  color: #67754f;
  box-shadow: none;
}

.nb-tool-button--secondary:hover {
  background: rgba(176, 186, 128, .2);
}

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

.nb-recipe,
.nb-swap {
  border: 1px solid rgba(103, 117, 79, .18);
  border-radius: 18px;
  background: rgba(255, 253, 248, .78);
  overflow: hidden;
}

.nb-recipe summary {
  display: grid;
  gap: .7rem;
  min-height: 100%;
  padding: 1.2rem;
  cursor: pointer;
  list-style: none;
}

.nb-recipe summary::-webkit-details-marker {
  display: none;
}

.nb-recipe summary::after {
  content: 'View recipe';
  width: fit-content;
  color: #962f33;
  font-weight: 900;
}

.nb-recipe[open] summary::after {
  content: 'Hide recipe';
}

.nb-recipe h3,
.nb-swap h3,
.nb-tool-result h3,
.nb-meal-day h3 {
  margin: 0;
  color: #542e00;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.55rem;
  line-height: 1.1;
}

.nb-recipe p,
.nb-swap p {
  margin: 0;
  color: rgba(84, 46, 0, .72);
  line-height: 1.55;
}

.nb-recipe__meta,
.nb-tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .42rem;
}

.nb-recipe__meta span,
.nb-tool-tag {
  border-radius: 999px;
  padding: .35rem .58rem;
  background: rgba(176, 186, 128, .22);
  color: #4e5d3d;
  font-size: .83rem;
  font-weight: 900;
}

.nb-recipe__body {
  padding: 0 1.2rem 1.25rem;
  border-top: 1px solid rgba(103, 117, 79, .14);
}

.nb-recipe__body h4 {
  margin: 1rem 0 .55rem;
  color: #962f33;
  font-size: 1rem;
}

.nb-recipe__body ul,
.nb-recipe__body ol,
.nb-tool-result ul,
.nb-tool-result ol {
  margin: 0;
  padding-left: 1.25rem;
  color: rgba(84, 46, 0, .82);
}

.nb-recipe__body li,
.nb-tool-result li {
  margin-bottom: .42rem;
  line-height: 1.55;
}

.nb-recipe__credit {
  margin-top: 1rem;
  padding-top: .8rem;
  border-top: 1px solid rgba(103, 117, 79, .13);
  color: rgba(84, 46, 0, .68);
  font-size: .9rem;
}

.nb-recipe__credit a,
.nb-source-list a,
.nb-tool-result a {
  color: #962f33;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nb-swap {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 1rem;
  padding: 1.15rem;
}

.nb-swap__from {
  padding-right: 1rem;
  border-right: 1px solid rgba(103, 117, 79, .16);
}

.nb-swap__label {
  display: block;
  margin-bottom: .35rem;
  color: #67754f;
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nb-swap strong {
  display: block;
  margin-bottom: .45rem;
  color: #542e00;
  font-size: 1.08rem;
}

.nb-pantry-groups,
.nb-budget-grid,
.nb-meal-plan {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.nb-pantry-group,
.nb-budget-card,
.nb-meal-day,
.nb-tool-result {
  border: 1px solid rgba(103, 117, 79, .18);
  border-radius: 18px;
  padding: 1.2rem;
  background: rgba(255, 253, 248, .78);
}

.nb-pantry-group h3,
.nb-budget-card h3 {
  margin: 0 0 .8rem;
  color: #67754f;
  font-size: 1.08rem;
}

.nb-pantry-item {
  display: flex;
  gap: .65rem;
  align-items: center;
  min-height: 42px;
  color: #542e00;
  font-weight: 700;
}

.nb-pantry-item input {
  width: 20px;
  height: 20px;
  accent-color: #962f33;
}

.nb-tool-result {
  display: none;
  margin-top: 1rem;
}

.nb-tool-result.is-visible {
  display: block;
}

.nb-tool-result.is-loading {
  display: block;
  min-height: 180px;
  color: transparent;
  background:
    linear-gradient(90deg, rgba(247, 237, 215, .5), rgba(255, 255, 255, .9), rgba(247, 237, 215, .5)) 0 0 / 200% 100%,
    rgba(255, 253, 248, .78);
  animation: nbToolLoading 1.3s linear infinite;
}

@keyframes nbToolLoading {
  to { background-position: -200% 0; }
}

.nb-tool-result.is-error {
  border-color: rgba(150, 47, 51, .28);
  background: rgba(150, 47, 51, .08);
  color: #7f272b;
}

.nb-tool-result p {
  color: rgba(84, 46, 0, .78);
  line-height: 1.65;
  white-space: pre-line;
}

.nb-budget-number {
  display: block;
  margin: .3rem 0 .4rem;
  color: #962f33;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2.25rem;
  line-height: 1;
}

.nb-meal-day {
  display: grid;
  gap: .75rem;
}

.nb-meal-slot {
  display: grid;
  gap: .2rem;
  padding-top: .65rem;
  border-top: 1px solid rgba(103, 117, 79, .13);
}

.nb-meal-slot span {
  color: #67754f;
  font-size: .82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nb-grocery-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.nb-grocery-builder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.nb-grocery-builder .nb-tool-form {
  align-content: start;
  margin-bottom: 0;
}

.nb-grocery-plan-form,
.nb-grocery-builder #nb-custom-grocery-form {
  grid-column: 1 / -1;
}

.nb-grocery-plan-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.nb-grocery-cuisine-field {
  grid-column: span 2;
}

.nb-budget-heading {
  margin-bottom: 1rem !important;
}

.nb-budget-summary {
  max-width: 72ch;
  margin: -.35rem 0 1rem;
}

.nb-budget-summary strong {
  color: #542e00;
}

.nb-budget-section-heading {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 1.35rem;
}

.nb-budget-section-heading h3,
.nb-budget-section-heading p {
  margin: 0;
}

.nb-budget-section-heading p {
  margin-top: .25rem;
  font-size: .92rem;
}

.nb-budget-section-heading > span {
  flex: 0 0 auto;
  padding: .42rem .65rem;
  border-radius: 999px;
  background: rgba(176, 186, 128, .24);
  color: #4e5d3d;
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nb-budget-allocation {
  display: grid;
  gap: .72rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid rgba(103, 117, 79, .16);
  border-radius: 14px;
  background: rgba(247, 237, 215, .32);
}

.nb-budget-allocation__row {
  display: grid;
  grid-template-columns: minmax(155px, .8fr) minmax(140px, 1.5fr) minmax(78px, auto);
  gap: .8rem;
  align-items: center;
}

.nb-budget-allocation__label {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  justify-content: space-between;
  color: #542e00;
}

.nb-budget-allocation__label span {
  color: rgba(84, 46, 0, .62);
  font-size: .82rem;
  font-weight: 800;
}

.nb-budget-allocation__bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(103, 117, 79, .16);
}

.nb-budget-allocation__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #962f33;
}

.nb-budget-allocation__amount {
  color: #542e00;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.nb-grocery-result__heading {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.nb-grocery-result__heading p {
  margin: .35rem 0 0;
}

.nb-grocery-message {
  max-width: 300px;
  padding: .5rem .7rem;
  border-radius: 8px;
  background: rgba(176, 186, 128, .22);
  color: #4e5d3d;
  font-size: .88rem;
  font-weight: 800;
}

.nb-grocery-group {
  padding: 1rem;
  border: 1px solid rgba(103, 117, 79, .16);
  border-radius: 16px;
  background: rgba(255, 253, 248, .72);
}

.nb-grocery-group h4 {
  margin: 0 0 .6rem;
  color: #67754f;
}

.nb-grocery-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: .45rem;
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid rgba(103, 117, 79, .1);
  color: rgba(84, 46, 0, .82);
}

.nb-grocery-item:last-child {
  border-bottom: 0;
}

.nb-grocery-item label {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  min-width: 0;
  padding: .42rem 0;
  cursor: pointer;
}

.nb-grocery-item input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: .1rem;
  accent-color: #962f33;
}

.nb-grocery-item span {
  overflow-wrap: anywhere;
}

.nb-grocery-item.is-checked span {
  color: rgba(84, 46, 0, .48);
  text-decoration: line-through;
}

.nb-grocery-remove {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #962f33;
  font: 700 1.35rem/1 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
}

.nb-grocery-remove:hover,
.nb-grocery-remove:focus-visible {
  outline: none;
  background: rgba(150, 47, 51, .1);
}

.nb-grocery-actions {
  margin-top: 1rem;
}

.nb-label-layout {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: 1rem;
}

.nb-label-preview {
  display: grid;
  min-height: 280px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(103, 117, 79, .34);
  border-radius: 16px;
  background: rgba(247, 237, 215, .5);
  color: rgba(84, 46, 0, .62);
  text-align: center;
}

.nb-label-preview img {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}

.nb-label-score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
  margin: 1rem 0;
}

.nb-label-score {
  padding: .8rem;
  border-radius: 14px;
  background: rgba(247, 237, 215, .66);
}

.nb-label-score strong {
  display: block;
  color: #542e00;
}

.nb-label-score span {
  color: #67754f;
  font-size: .9rem;
  font-weight: 800;
}

.nb-source-list {
  margin-top: 2rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(103, 117, 79, .18);
}

.nb-source-list h2 {
  margin: 0 0 .8rem;
  color: #542e00;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.8rem;
}

.nb-source-list ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nb-source-list li {
  color: rgba(84, 46, 0, .7);
  line-height: 1.5;
}

.nb-tool-empty {
  grid-column: 1 / -1;
  padding: 2rem;
  border: 1px dashed rgba(103, 117, 79, .28);
  border-radius: 16px;
  color: rgba(84, 46, 0, .68);
  text-align: center;
}

.nb-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
}

.nb-tool-status {
  margin: 0;
  color: #67754f;
  font-weight: 800;
}

@media (max-width: 1040px) {
  .nb-tools-page { padding-top: 62px; }
  .nb-tools-tabs { top: 62px; }
  .nb-tool-controls { grid-template-columns: 1fr 1fr; }
  .nb-tool-controls .nb-tool-field:first-child { grid-column: 1 / -1; }
  .nb-grocery-plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nb-grocery-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .nb-tools-page { padding-top: 58px; }
  .nb-tools-hero { padding: 3.4rem 1rem 2.4rem; }
  .nb-tools-hero h1 { font-size: clamp(2.8rem, 15vw, 4.4rem); }
  .nb-tools-shell { padding: 1.2rem .85rem 4rem; }
  .nb-tools-tabs { top: 58px; margin-inline: -.85rem; padding-inline: .85rem; }
  .nb-tool-controls,
  .nb-tool-form__grid,
  .nb-recipe-grid,
  .nb-swap-grid,
  .nb-pantry-groups,
  .nb-budget-grid,
  .nb-meal-plan,
  .nb-grocery-builder,
  .nb-grocery-groups,
  .nb-label-layout,
  .nb-source-list ul {
    grid-template-columns: 1fr;
  }
  .nb-tool-controls .nb-tool-field:first-child { grid-column: auto; }
  .nb-swap { grid-template-columns: 1fr; }
  .nb-swap__from { padding: 0 0 .8rem; border-right: 0; border-bottom: 1px solid rgba(103, 117, 79, .16); }
  .nb-grocery-cuisine-field { grid-column: auto; }
  .nb-label-score-grid { grid-template-columns: 1fr; }
  .nb-grocery-result__heading { display: grid; }
  .nb-grocery-message { max-width: none; }
  .nb-budget-section-heading { display: grid; }
  .nb-budget-section-heading > span { justify-self: start; }
  .nb-budget-allocation__row { grid-template-columns: 1fr auto; gap: .35rem .75rem; }
  .nb-budget-allocation__bar { grid-column: 1 / -1; grid-row: 2; }
  .nb-budget-allocation__amount { grid-column: 2; grid-row: 1; }
  .nb-budget-allocation__label { justify-content: flex-start; }
  .nb-tool-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .nb-tool-panel,
  .nb-tool-result.is-loading {
    animation: none;
  }
}
