:root {
  color-scheme: light;
  --ink: #171a1d;
  --muted: #68717a;
  --paper: #f4f6f8;
  --surface: #ffffff;
  --soft: #eef1f4;
  --soft-strong: #e6eaee;
  --line: #dde2e7;
  --line-strong: #c9d0d7;
  --signal: #f5c84c;
  --signal-soft: #fff3c9;
  --signal-dark: #8b5b00;
  --accent: #376f8a;
  --accent-soft: #e7eff4;
  --cyan: #376f8a;
  --danger: #a34732;
  --shadow: 0 14px 34px rgba(29, 45, 57, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
}

body.dialog-open { overflow: hidden; }
button, input, select { font: inherit; }
button, select, label { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 30;
  padding: 10px 13px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: var(--signal);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  min-height: 78px;
  color: #fff;
  background: #151714;
}

.header-inner {
  width: min(1480px, calc(100% - 48px));
  min-height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #171916;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong { font-size: 20px; }

.source-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #dfe2db;
  font-size: 12px;
}
.source-status strong { color: #fff; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #62c88f; }

.tool-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 26px auto 0;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  align-items: start;
  gap: 42px;
}

.inventory-panel,
.results-panel { min-width: 0; }

.inventory-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  padding: 22px 16px 18px;
  overflow: auto;
  border: 0;
  border-radius: 6px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 1px 2px rgba(29,45,57,.06);
}

.results-panel { min-height: 720px; padding-bottom: 30px; }

.section-heading,
.results-toolbar,
.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

h1, h2 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
h2 { font-size: 23px; }

.inventory-count { color: var(--muted); font-size: 12px; }
.inventory-actions { height: 18px; margin-top: 7px; text-align: right; }

.text-button {
  padding: 3px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.text-button:hover { color: var(--ink); }

.search-field {
  position: relative;
  display: block;
  margin: 11px 0 10px;
}

.search-field input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.search-field input:focus { border-color: #7e8c97; box-shadow: 0 0 0 3px rgba(55,111,138,.13); }
.search-icon { display: none; }

.selected-summary {
  min-height: 22px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
}

.ingredient-list {
  max-height: calc(100vh - 230px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  overflow: auto;
  padding-right: 3px;
}

.ingredient-option { position: relative; min-width: 0; }
.ingredient-option input {
  position: absolute;
  top: 50%;
  right: 12px;
  z-index: 1;
  width: 17px;
  height: 17px;
  margin: -8px 0 0;
  accent-color: var(--ink);
  cursor: pointer;
}
.ingredient-option > span {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 40px 7px 10px;
  border: 0;
  border-radius: 4px;
  background: var(--soft);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.ingredient-option:hover > span { background: var(--soft-strong); }
.ingredient-option input:checked + span { color: var(--ink); background: #e5ebef; font-weight: 700; }
.ingredient-option input:focus-visible + span { outline: 3px solid rgba(55,111,138,.22); outline-offset: 1px; }

.ingredient-option-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  object-fit: contain;
}
.ingredient-option-name { min-width: 0; }

.results-toolbar { align-items: flex-end; }
.toolbar-actions { display: flex; align-items: flex-end; gap: 18px; }
.mode-group { display: flex; align-items: center; gap: 8px; }
.control-label { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }

.mode-control {
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: 4px;
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background: var(--soft-strong);
}
.mode-control label { position: relative; }
.mode-control input { position: absolute; opacity: 0; pointer-events: none; }
.mode-control span {
  min-width: 68px;
  height: 34px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.mode-control input:checked + span { color: #fff; background: var(--ink); }
.mode-control input:focus-visible + span { outline: 3px solid rgba(55,111,138,.28); outline-offset: 1px; }

.select-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.select-field select {
  height: 40px;
  min-width: 150px;
  padding: 0 30px 0 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  text-transform: none;
  outline: none;
}
.select-field select:focus { border-color: #7e8c97; box-shadow: 0 0 0 3px rgba(55,111,138,.13); }

.result-meta { align-items: flex-start; margin: 30px 0 20px; }
.result-count { margin: 0; font-size: 15px; }
.result-count strong { font-size: inherit; }
.result-summary { min-height: 20px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.result-summary strong { color: var(--accent); }
.copy-button { margin-top: 2px; }
.data-freshness { margin: -14px 0 18px; color: #8b8f87; font-size: 10px; }

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

.recipe-card {
  position: relative;
  min-width: 0;
  min-height: 252px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(29,45,57,.08);
  transition: box-shadow .16s ease, transform .16s ease;
}
.recipe-card:hover { box-shadow: 0 10px 24px rgba(29,45,57,.09); transform: translateY(-1px); }

.recipe-card-header {
  min-height: 116px;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding-right: 62px;
}

.recipe-visual,
.detail-recipe-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}
.recipe-visual { width: 132px; min-height: 98px; }
.recipe-visual-ingredient {
  width: 90px;
  height: 90px;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(23,25,22,.14));
}
.recipe-visual[data-count="2"] .recipe-visual-ingredient,
.detail-recipe-visual[data-count="2"] .recipe-visual-ingredient { width: 76px; height: 76px; }
.recipe-visual[data-count="2"] .recipe-visual-ingredient + .recipe-visual-ingredient,
.detail-recipe-visual[data-count="2"] .recipe-visual-ingredient + .recipe-visual-ingredient { margin-left: -20px; }
.recipe-visual[data-count="3"] .recipe-visual-ingredient,
.detail-recipe-visual[data-count="3"] .recipe-visual-ingredient { width: 62px; height: 62px; }
.recipe-visual[data-count="3"] .recipe-visual-ingredient + .recipe-visual-ingredient,
.detail-recipe-visual[data-count="3"] .recipe-visual-ingredient + .recipe-visual-ingredient { margin-left: -27px; }
.recipe-visual-ingredient:nth-child(1) { z-index: 3; }
.recipe-visual-ingredient:nth-child(2) { z-index: 2; }
.recipe-visual-ingredient:nth-child(3) { z-index: 1; }

.recipe-identity { min-width: 0; }
.recipe-card h3 { margin: 0 0 16px; font-size: 18px; line-height: 1.22; overflow-wrap: anywhere; }
.match-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 5px 7px;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: var(--soft);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.makeable .match-badge,
.one-away .match-badge { color: #4c5660; background: var(--soft); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-grid div { min-width: 0; padding: 0 4px; text-align: center; border-right: 0; }
.stat-grid div:first-child { padding-left: 0; }
.stat-grid div:last-child { padding-right: 0; border-right: 0; }
.stat-grid strong, .stat-grid span { display: block; }
.stat-grid strong { font-size: 16px; }
.stat-grid span { margin-top: 2px; color: var(--muted); font-size: 8px; text-transform: uppercase; }

.ingredient-stack {
  margin-top: 10px;
  padding-top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 0;
}
.ingredient-tag {
  min-height: 29px;
  padding: 4px 8px 4px 5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 4px;
  color: #484c46;
  background: var(--soft);
  font-size: 10px;
}
.ingredient-tag-icon { width: 21px; height: 21px; object-fit: contain; }
.ingredient-tag.have,
.ingredient-tag.missing { color: #4c5660; background: var(--soft); }

.recipe-card-footer {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.buff-line { min-height: 28px; display: flex; flex-wrap: wrap; gap: 5px; color: #555b55; font-size: 11px; }
.buff-line > span { display: inline-flex; align-items: center; gap: 6px; }
.buff-icon { width: 24px; height: 24px; object-fit: contain; }
.muted-buff { color: var(--muted); }
.details-button {
  height: 38px;
  flex: 0 0 auto;
  padding: 0 13px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.details-button:hover { background: #333731; }
.details-button:focus-visible,
.dialog-close:focus-visible { outline: 3px solid rgba(55,111,138,.28); outline-offset: 2px; }

.icon-fallback { display: grid; place-items: center; border: 0; border-radius: 4px; color: var(--muted); background: var(--soft); font-weight: 800; }

.recipe-dialog {
  inset: 0 0 0 auto;
  width: min(560px, 100%);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: -18px 0 48px rgba(23,25,21,.2);
}
.recipe-dialog::backdrop { background: rgba(15,17,14,.58); }
.dialog-surface { min-height: 100%; padding: 42px 36px 36px; }
.dialog-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: var(--soft);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}
.dialog-close:hover { background: #e5e7e1; }
.detail-hero {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding-bottom: 24px;
  border-bottom: 0;
}
.detail-recipe-visual { width: 132px; min-height: 112px; }
.detail-recipe-visual[data-count="1"] .recipe-visual-ingredient { width: 100px; height: 100px; }
.detail-hero p { margin: 0 0 5px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.detail-hero h2 { font-size: 26px; line-height: 1.15; }
.detail-status {
  display: inline-flex;
  margin-top: 10px;
  padding: 5px 8px;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 800;
}
.detail-status.makeable,
.detail-status.one-away { color: #4c5660; background: var(--soft); }
.detail-stats { margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 0; border-radius: 5px; background: var(--soft); }
.detail-stats div { padding: 17px 8px; border-right: 0; text-align: center; }
.detail-stats div:last-child { border-right: 0; }
.detail-stats dt { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.detail-stats dd { margin: 4px 0 0; font-size: 16px; font-weight: 900; }
.detail-section { padding-top: 26px; }
.detail-section-heading { margin-bottom: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.detail-section-heading h3 { margin: 0; font-size: 17px; }
.detail-section-heading > span { color: var(--muted); font-size: 11px; }
.detail-list { display: grid; gap: 7px; }
.detail-ingredient,
.detail-buff {
  min-height: 58px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 4px;
  background: var(--soft);
}
.detail-ingredient.have { background: var(--soft); }
.detail-item-icon,
.detail-buff-icon { width: 42px; height: 42px; object-fit: contain; }
.detail-ingredient strong,
.detail-ingredient small,
.detail-buff strong,
.detail-buff small { display: block; }
.detail-ingredient strong,
.detail-buff strong { font-size: 13px; }
.detail-ingredient small,
.detail-buff small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.availability-mark {
  padding: 4px 7px;
  border: 0;
  border-radius: 3px;
  color: #4c5660;
  background: var(--soft-strong);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.detail-ingredient.have .availability-mark { color: #4c5660; background: var(--soft-strong); }
.detail-empty { margin: 0; color: var(--muted); font-size: 13px; }
.detail-source { margin-top: 28px; padding: 16px; background: var(--soft); }
.detail-source > strong { font-size: 13px; }
.detail-source dl { margin: 10px 0 0; }
.detail-source dl div { padding: 5px 0; display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 10px; border-top: 1px solid var(--line); }
.detail-source dt,
.detail-source dd { margin: 0; font-size: 10px; }
.detail-source dt { color: var(--muted); }
.detail-source dd { text-align: right; overflow-wrap: anywhere; }
.detail-source p { margin: 10px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

.empty-state { padding: 72px 20px; text-align: center; border: 0; border-radius: 6px; background: #fff; }
.empty-state p { margin: 7px 0 0; color: var(--muted); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; padding: 10px 14px; border-radius: 4px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 13px; }

.site-footer {
  width: min(1480px, calc(100% - 48px));
  margin: 20px auto 38px;
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.site-footer strong,
.site-footer span { display: block; }
.site-footer span { margin-top: 3px; }
.site-footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

.legal-page { width: min(780px, calc(100% - 40px)); margin: 44px auto; padding: 32px; border: 0; background: #fff; box-shadow: 0 1px 2px rgba(29,45,57,.08); }
.legal-page h1 { font-size: 28px; }
.legal-page h2 { margin-top: 28px; font-size: 18px; }
.legal-page p,
.legal-page li { color: #474a43; line-height: 1.65; }
.legal-page .back-link { display: inline-block; margin-bottom: 24px; color: var(--cyan); font-weight: 700; }
.source-record { margin: 20px 0 0; border-top: 1px solid var(--line); }
.source-record div { padding: 11px 0; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; border-bottom: 1px solid var(--line); }
.source-record dt,
.source-record dd { margin: 0; }
.source-record dt { color: var(--muted); font-weight: 700; }
.source-record dd { overflow-wrap: anywhere; }

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

@media (max-width: 1180px) {
  .tool-shell { grid-template-columns: 290px minmax(0, 1fr); gap: 28px; }
  .recipe-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .header-inner,
  .tool-shell,
  .site-footer { width: min(100% - 28px, 720px); }
  .source-status { display: none; }
  .tool-shell { display: block; }
  .inventory-panel { position: static; max-height: none; margin-bottom: 34px; }
  .ingredient-list { max-height: 330px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results-toolbar { align-items: flex-start; }
  .toolbar-actions { align-items: flex-start; }
  .mode-group { display: grid; }
  .select-field { display: grid; gap: 5px; }
}

@media (max-width: 620px) {
  .site-header,
  .header-inner { min-height: 66px; }
  .brand strong { font-size: 16px; }
  .brand-mark { width: 30px; height: 30px; font-size: 10px; }
  .tool-shell { margin-top: 14px; }
  .inventory-panel { padding: 18px 14px; }
  .ingredient-list { grid-template-columns: 1fr; }
  .results-toolbar { display: block; }
  .toolbar-actions { margin-top: 16px; display: grid; grid-template-columns: 1fr; gap: 12px; }
  .mode-group,
  .select-field { display: flex; justify-content: space-between; }
  .mode-control { flex: 1; }
  .mode-control span { min-width: 0; padding: 0 7px; }
  .select-field select { width: min(200px, 70%); }
  .result-meta { margin-top: 24px; }
  .data-freshness { margin-top: -13px; }
  .recipe-card { min-height: 0; padding: 15px; }
  .recipe-card-header { grid-template-columns: 106px minmax(0, 1fr); gap: 11px; padding-right: 0; padding-top: 24px; }
  .recipe-visual { width: 106px; }
  .recipe-visual[data-count="1"] .recipe-visual-ingredient { width: 76px; height: 76px; }
  .recipe-visual[data-count="2"] .recipe-visual-ingredient,
  .detail-recipe-visual[data-count="2"] .recipe-visual-ingredient { width: 64px; height: 64px; }
  .recipe-visual[data-count="2"] .recipe-visual-ingredient + .recipe-visual-ingredient,
  .detail-recipe-visual[data-count="2"] .recipe-visual-ingredient + .recipe-visual-ingredient { margin-left: -22px; }
  .recipe-visual[data-count="3"] .recipe-visual-ingredient,
  .detail-recipe-visual[data-count="3"] .recipe-visual-ingredient { width: 52px; height: 52px; }
  .recipe-visual[data-count="3"] .recipe-visual-ingredient + .recipe-visual-ingredient,
  .detail-recipe-visual[data-count="3"] .recipe-visual-ingredient + .recipe-visual-ingredient { margin-left: -25px; }
  .recipe-card h3 { margin-bottom: 13px; font-size: 16px; }
  .match-badge { top: 12px; right: 12px; }
  .stat-grid div { padding: 0 6px; }
  .stat-grid strong { font-size: 14px; }
  .recipe-card-footer { align-items: flex-end; }
  .site-footer { display: block; }
  .site-footer nav { margin-top: 14px; }
  .recipe-dialog { inset: auto 0 0; width: 100%; height: min(88dvh, 760px); border-radius: 8px 8px 0 0; }
  .dialog-surface { padding: 42px 20px 24px; }
  .detail-hero { grid-template-columns: 100px minmax(0, 1fr); gap: 12px; }
  .detail-recipe-visual { width: 100px; }
  .detail-recipe-visual[data-count="1"] .recipe-visual-ingredient { width: 78px; height: 78px; }
  .detail-hero h2 { font-size: 21px; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
  .detail-stats div:nth-child(2) { border-right: 0; }
  .detail-stats div:nth-child(-n+2) { border-bottom: 0; }
  .detail-source dl div { grid-template-columns: 94px minmax(0, 1fr); }
  .source-record div { grid-template-columns: 1fr; gap: 3px; }
}
