/* Freezer Meals — browse app styles. Vanilla CSS, no build step. */

:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f2ece2;
  --text: #2a2521;
  --text-muted: #7c7268;
  --border: #e6ddd0;
  --accent: #b5451b;
  --accent-text: #ffffff;
  --accent-weak: #f7e6db;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 16px rgba(40, 30, 20, .06);
  --radius: 12px;
  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191512;
    --surface: #241f1b;
    --surface-2: #2f2822;
    --text: #ece4d9;
    --text-muted: #a89d90;
    --border: #3a322b;
    --accent: #e07a44;
    --accent-text: #1a1210;
    --accent-weak: #38271d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.25; }

button { font: inherit; cursor: pointer; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
  font-size: .9em;
}

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.search {
  flex: 1;
  min-width: 200px;
}
.search input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: .95rem;
}
.search input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---- layout ---- */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 28px;
  align-items: start;
}

.filter-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.badge {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  font-size: .75rem;
  padding: 1px 7px;
  font-weight: 700;
}

/* ---- filters ---- */
.filters {
  position: sticky;
  top: 76px;
}
.filters-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.filters-head h2 { margin: 0; font-size: 1rem; }

.facet { border-top: 1px solid var(--border); }
.facet:first-child { border-top: none; }
.facet > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 0;
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::after {
  content: "▸";
  color: var(--text-muted);
  transition: transform .15s;
}
.facet[open] > summary::after { transform: rotate(90deg); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 12px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .82rem;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.chip .c-count { color: var(--text-muted); font-size: .92em; }
.chip[aria-pressed="true"] .c-count { color: var(--accent-text); opacity: .8; }

/* ---- results ---- */
.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
#count { color: var(--text-muted); font-size: .9rem; }
.sort {
  font-size: .85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sort select {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
}

.card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  color: inherit;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.card .c-book {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.card .c-meta {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: auto;
}
.card .c-match {
  font-size: .78rem;
  color: var(--accent);
  font-style: italic;
}
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: .72rem;
  background: var(--accent-weak);
  color: var(--accent);
  border-radius: 6px;
  padding: 2px 7px;
  font-weight: 600;
}
.tag.method {
  background: var(--surface-2);
  color: var(--text-muted);
}

.empty {
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
}

/* ---- modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  overflow-y: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 10, .55);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: 640px;
  width: 100%;
  padding: 28px;
}
.modal-card:focus-visible { outline: none; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }

.d-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.d-book {
  font-size: .8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 4px;
}
.d-copy-link {
  flex: none;
  border: none;
  background: none;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 600;
  padding: 2px 0;
  margin-right: 26px;
}
.d-copy-link:hover { text-decoration: underline; }
#detail h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  letter-spacing: -.01em;
}
.d-meta { color: var(--text-muted); margin: 0 0 12px; font-size: .9rem; }
#detail h3 {
  font-size: .95rem;
  margin: 22px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
#detail h4 {
  font-size: .85rem;
  margin: 12px 0 3px;
  color: var(--accent);
}
.d-serve { margin: 12px 0 0; }
.d-ings { margin: 0; padding-left: 0; list-style: none; }
.d-ings li {
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
}
.d-ings li:last-child { border-bottom: none; }
.d-ings .q { font-weight: 600; margin-right: 6px; }
.d-ings .prep { color: var(--text-muted); }
#detail p { margin: 0 0 6px; }
.d-method p { font-size: .92rem; }
.d-notes p { color: var(--text-muted); font-size: .9rem; }

/* ---- mode nav ---- */
.modenav {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
}
.modenav button {
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .88rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.modenav button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ---- plan view ---- */
.planview {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px;
}
.plan-intro h2 { margin: 4px 0 4px; font-size: 1.3rem; }
.plan-intro p { color: var(--text-muted); margin: 0 0 18px; max-width: 60ch; }

.plan-people {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.people-list { display: flex; flex-wrap: wrap; gap: 8px; }
.person-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.person-chip.active { border-color: var(--accent); background: var(--accent-weak); }
.person-name { border: none; background: none; color: var(--text); padding: 6px 4px 6px 13px; font-weight: 600; font-size: .88rem; }
.person-chip.active .person-name { color: var(--accent); }
.person-x { border: none; background: none; color: var(--text-muted); padding: 6px 10px 6px 6px; font-size: 1rem; line-height: 1; }
.person-x:hover { color: var(--accent); }
.add-person { display: flex; gap: 6px; }
.add-person input {
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg);
  color: var(--text); padding: 7px 14px; font-size: .88rem; width: 150px;
}
.add-person button {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 999px; padding: 7px 16px; font-weight: 600; font-size: .88rem;
}

.plan-body {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.plan-picker-head { margin-bottom: 12px; }
.plan-picker-head input {
  width: 100%; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--text); padding: 9px 14px; font-size: .92rem;
}
.picking-for { margin: 8px 2px 0; font-size: .85rem; color: var(--text-muted); }

.plan-reclist {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 70vh;
  overflow-y: auto;
}
.prow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
}
.prow:first-child { border-top: none; }
.prow.picked { background: var(--accent-weak); }
.prow-toggle {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}
.prow-toggle.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.prow-toggle:disabled { opacity: .4; }
.prow-toggle {
  width: auto;
  border-radius: 999px;
  padding: 0 12px;
  font-size: .82rem;
  font-weight: 600;
}
.qty-stepper {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--accent);
  border-radius: 999px;
  overflow: hidden;
}
.qty-stepper button {
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  width: 24px; height: 24px;
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
}
.qty-stepper button:disabled { opacity: .5; }
.qty-n {
  min-width: 22px;
  text-align: center;
  font-size: .85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: var(--accent-weak);
  align-self: stretch;
  display: grid;
  place-items: center;
}
.prow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.prow-name { font-weight: 600; font-size: .9rem; }
.prow-meta { font-size: .78rem; color: var(--text-muted); }
.prow-who { display: flex; gap: 3px; flex: none; }
.who-badge {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-muted);
  font-size: .68rem; font-weight: 700;
  display: grid; place-items: center;
}
.who-badge.me { background: var(--accent); color: var(--accent-text); }

.plan-summary {
  position: sticky;
  top: 76px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; background: var(--surface-2); border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.seg button {
  border: none; background: none; color: var(--text-muted);
  padding: 6px 6px; border-radius: 6px; font-weight: 600; font-size: .78rem;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.cost-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.cost-head { display: flex; justify-content: space-between; align-items: baseline; }
.cost-total { font-weight: 700; color: var(--accent); }
.cost-meals { list-style: none; margin: 6px 0 4px; padding: 0; }
.cost-meals li, .cost-line {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: .84rem; padding: 2px 0; color: var(--text-muted);
}
.cost-line { border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 5px; }
.cost-amt { flex: none; font-variant-numeric: tabular-nums; }
.cost-none { font-size: .82rem; color: var(--text-muted); margin: 4px 0 0; }
.cost-grand {
  display: flex; justify-content: space-between;
  font-weight: 700; font-size: 1rem;
  border-top: 2px solid var(--border); padding-top: 10px; margin-top: 4px;
}

.list-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; color: var(--text-muted); margin: 0 0 8px; }
#planList h4, #planPrep h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 14px 0 4px; }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.shop-list li:last-child { border-bottom: none; }
.shop-qty { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.shop-cost { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.shop-list li.is-staple .shop-name { color: var(--text-muted); }
.prep-for { color: var(--text-muted); font-size: .82em; }

.table-wrap { overflow-x: auto; }
.recipes-table { border-collapse: collapse; width: 100%; font-size: .84rem; }
.recipes-table th, .recipes-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.recipes-table th { text-align: left; color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }
.recipes-table td:first-child, .recipes-table th:first-child { white-space: normal; }
.recipes-table .num { text-align: center; font-variant-numeric: tabular-nums; }
.recipes-table .num.total { font-weight: 700; color: var(--accent); }
.recipes-table .num.zero { color: var(--text-muted); opacity: .5; }

.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.plan-actions button {
  flex: 1 1 calc(50% - 4px); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px; font-size: .82rem; font-weight: 600;
}
.plan-actions button.danger { color: var(--accent); }
.plan-actions button:hover { border-color: var(--accent); }
.plan-disclaimer { font-size: .74rem; color: var(--text-muted); margin: 12px 0 0; line-height: 1.4; }
.plan-empty, .plan-note { color: var(--text-muted); font-size: .85rem; padding: 8px 0; }
.plan-note { border-top: 1px solid var(--border); margin-top: 8px; }

/* ---- mobile ---- */
@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .plan-body { grid-template-columns: 1fr; gap: 18px; }
  .plan-summary { position: static; }
  .topbar-inner { gap: 12px; }
  .modenav { order: 3; width: 100%; }
  .modenav button { flex: 1; justify-content: center; }
  .filter-toggle { display: inline-flex; margin-bottom: 14px; }
  .filters {
    position: static;
    display: none;
    margin-bottom: 20px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .filters.open { display: block; }
  .modal { padding: 0; }
  .modal-card {
    border-radius: 0;
    min-height: 100%;
    max-width: none;
    padding: 22px 18px 40px;
  }
}

/* ---- printable meal labels ---- */
#labelSheet { display: none; }

.label {
  width: 4in;
  min-height: 6in;
  box-sizing: border-box;
  padding: 0.25in;
  color: #1a1a1a;
  background: #fff;
  font: 11px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.label h2 { margin: 0 0 3px; font-size: 17px; letter-spacing: -.01em; }
.label-meta { margin: 0 0 10px; color: #555; font-size: 10px; }
.label h3 {
  margin: 10px 0 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #555;
  border-bottom: 1px solid #ccc;
  padding-bottom: 2px;
}
.label-ings { margin: 0; padding-left: 14px; }
.label-ings li { margin-bottom: 1px; }
.label-method { margin-bottom: 4px; }
.label-date { margin-top: 14px; font-size: 10px; }
.label-line { display: inline-block; width: 2in; border-bottom: 1px solid #1a1a1a; }

@media print {
  body * { visibility: hidden; }
  #labelSheet, #labelSheet * { visibility: visible; }
  #labelSheet {
    display: block;
    position: absolute;
    left: 0; top: 0;
  }
  @page { size: 4in 6in; margin: 0; }
  .label { page-break-after: always; }
  .label:last-child { page-break-after: auto; }
}
