@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/source-sans-3-latin.woff2") format("woff2");
}

:root {
  /* Aldi orange and blue. --green is the action color, kept as a name so existing rules pick it up. */
  --blue: #001e78;
  --blue-bright: #003da5;
  --blue-bar: #001e78;
  --green: #ff6600;
  --green-dark: #d44e00;
  --green-soft: #fff1e6;
  --tomato: #c8102e;
  --amber: #ff6600;
  --ink: #16181d;
  --muted: #5c6570;
  --line: #e3e6ea;
  --bg: #f4f6f8;
  --card: #ffffff;
  --radius: 14px;
  --tap: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #8eb0ff;
    --blue-bright: #b9ccff;
    --blue-bar: #0a1748;
    --green: #ff7a26;
    --green-dark: #ffb088;
    --green-soft: #3a2418;
    --ink: #f4f6f8;
    --muted: #a7b0bc;
    --line: #2a3142;
    --bg: #0e1220;
    --card: #171c2c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}

h1, h2 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.hint, .empty { color: var(--muted); text-align: center; padding: 1.5rem 1rem; margin: 0; }
.notice {
  background: var(--green-soft);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}

button, input, select { font: inherit; color: inherit; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  min-height: var(--tap);
  padding: 0 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
}
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-secondary { background: var(--green-soft); border-color: transparent; color: var(--green-dark); }
.btn-danger { color: var(--tomato); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn-icon {
  min-width: var(--tap);
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 1.4rem;
}

/* ---- Home ------------------------------------------------------------- */
.home {
  max-width: 560px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem calc(2rem + var(--safe-bottom));
}
.home-header h1 { font-size: 2.2rem; }
.home-header p { margin: 0.25rem 0 1.75rem; }
.home-tiles { display: grid; gap: 1rem; }
.tile {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 1rem;
  align-items: center;
  padding: 1.4rem 1.25rem;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.tile:active { transform: scale(0.99); }
.tile-icon { grid-row: span 2; font-size: 2.4rem; }
.tile-title { font-size: 1.4rem; font-weight: 700; }
.tile-sub { color: var(--muted); }
.tile-shop { border-left: 6px solid var(--green); }
.tile-organize { border-left: 6px solid var(--blue); }
.tile-cook { border-left: 6px solid var(--blue-bright); }
.home-header h1 { color: var(--blue); }

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  display: grid;
  grid-template-columns: var(--tap) 1fr auto;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  padding-top: max(0.25rem, env(safe-area-inset-top));
  background: var(--bg);
}
.topbar-back {
  min-height: var(--tap);
  display: grid;
  place-items: center;
  color: inherit;
  text-decoration: none;
  font-size: 1.5rem;
}
.topbar-title { font-size: 1.35rem; }

/* ---- Search ----------------------------------------------------------- */
.sticky-search {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.5rem 1rem 0.75rem;
  background: var(--bg);
}
.search { position: relative; flex: 1; }
.search-input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 1.05rem;
}
.search-input:focus { outline: none; border-color: var(--green); }
.search-results:empty { display: none; }
.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  max-height: 60dvh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.15);
}
.sheet .search-results { position: static; box-shadow: none; margin-top: 0.5rem; }
.results { list-style: none; margin: 0; padding: 0.25rem 0; }
.results-static { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.results form { margin: 0; }
.result {
  width: 100%;
  min-height: var(--tap);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.result:active, .result:focus-visible { background: var(--green-soft); }
.result-name { flex: 1 1 auto; min-width: 0; }
.result-cat { flex: 0 1 auto; max-width: 42%; color: var(--muted); font-size: 0.82rem; text-align: right; }
.result-new .result-name { color: var(--green); font-weight: 600; }
.result-best { background: var(--green-soft); }

/* ---- Shop list -------------------------------------------------------- */
.shop {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1rem calc(6.5rem + var(--safe-bottom));
}
.organize, .cook {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem calc(2.5rem + var(--safe-bottom));
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--radius);
  background: var(--line);
  margin-bottom: 0.5rem;
}
.tab {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.08);
  font-size: 0.85em;
}
.panel { display: none; }
[data-view="needed"] [data-tab="needed"],
[data-view="in_cart"] [data-tab="in_cart"] { background: var(--card); color: var(--ink); }
[data-view="needed"] [data-panel="needed"],
[data-view="in_cart"] [data-panel="in_cart"] { display: block; }

.section-title {
  margin: 1.1rem 0.25rem 0.4rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.items {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 58px;
  padding: 0.5rem 0.25rem 0.5rem 1rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.item-static { cursor: default; }
.item-text { display: grid; }
.item-meta { color: var(--muted); font-size: 0.88rem; }
.check {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
}
.item-done .check { background: var(--green); border-color: var(--green); position: relative; }
.item-done .check::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 3px;
  width: 6px;
  height: 12px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.item-done .item-name { text-decoration: line-through; color: var(--muted); }

.item-more { display: contents; }
.item-more summary {
  list-style: none;
  min-width: var(--tap);
  min-height: 58px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
}
.item-more summary::-webkit-details-marker { display: none; }
.item-edit {
  flex-basis: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0 1rem 1rem;
}
.item-edit label { display: grid; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.item-edit .wide { grid-column: span 2; }
.item-edit input {
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.item-edit-actions { grid-column: span 2; display: flex; justify-content: space-between; }

/* ---- Bottom bar ------------------------------------------------------- */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}

/* ---- Sheet (bottom dialog) ---------------------------------------------- */
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0.5rem 1.1rem calc(1.25rem + var(--safe-bottom));
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--card);
  color: var(--ink);
  overflow-y: auto;
}
.sheet[open] { animation: sheet-up 0.22s ease-out; }
.sheet::backdrop { background: rgb(0 0 0 / 0.35); }
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 0.5rem; }
.sheet-close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: 1.7rem;
  color: var(--muted);
  cursor: pointer;
}
.sheet-title { font-size: 1.3rem; margin: 0.5rem 2.5rem 0.25rem 0; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.6; } }

.quick-add { display: flex; gap: 0.5rem; align-items: flex-start; margin-top: 0.75rem; }
.quick-add .btn-icon { border: 1px solid var(--line); background: var(--bg); }

.checkout-items { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.checkout-item { padding: 0.7rem 0; border-top: 1px solid var(--line); display: grid; gap: 0.5rem; }
.checkout-name { font-weight: 600; display: flex; gap: 0.5rem; align-items: baseline; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  cursor: pointer;
}
.segmented input:checked + span { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- Scanner ---------------------------------------------------------- */
.scanner {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
}
.scanner[open] { display: grid; grid-template-rows: 1fr auto auto auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; grid-row: 1; grid-column: 1; }
.scanner-frame {
  grid-row: 1;
  grid-column: 1;
  place-self: center;
  width: min(78vw, 360px);
  height: 150px;
  border: 3px solid rgb(255 255 255 / 0.85);
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.35);
}
.scanner-status { text-align: center; margin: 0.75rem 1rem; }
.scanner-manual { display: flex; gap: 0.5rem; padding: 0 1rem; }
.scanner-manual input {
  flex: 1;
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 0;
  color: #111;
}
.scanner-cancel { color: #fff; margin: 0.5rem auto calc(1rem + var(--safe-bottom)); }

/* ---- Toasts ----------------------------------------------------------- */
.toasts {
  position: fixed;
  inset: auto 0 calc(5.5rem + var(--safe-bottom)) 0;
  z-index: 100;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  pointer-events: none;
}
.toasts:not(:popover-open) { display: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: calc(100% - 2rem);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: #222a26;
  color: #fff;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast-out { opacity: 0; transform: translateY(8px); }
.toast-undo { border: 0; background: transparent; color: #9fe0bd; font-weight: 700; cursor: pointer; text-decoration: none; }
.tile-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: var(--amber);
  color: #1b1408;
  font-size: 0.85rem;
  vertical-align: 0.15rem;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* HTMX request indicator on tapped rows */
.htmx-request.item-main, .htmx-request.result { opacity: 0.55; }

/* ---- Organize --------------------------------------------------------- */
.page-organize .topbar {
  background: var(--blue-bar);
  color: #fff;
  padding: 0.45rem 1.25rem 0.7rem;
  margin-bottom: 0.75rem;
}
.page-organize .topbar-back,
.page-organize .btn-icon { color: #fff; }
.page-organize .topbar-title { font-weight: 700; letter-spacing: -0.01em; }
.page-organize .btn { min-height: 40px; border-radius: 10px; }
.page-organize input[type="checkbox"] { accent-color: var(--green); width: 1.05rem; height: 1.05rem; }

.organize-layout { display: grid; gap: 1rem; }
.organize-layout > * { min-width: 0; }
.dish-panel { min-width: 0; }
.kitchen-pane { min-width: 0; }
.kitchen-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.kitchen-bar .kitchen-heading { margin: 0; }
.kitchen-bar .filters { margin: 0; }
@media (min-width: 1100px) {
  body.page-organize { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
  body.page-organize .organize {
    flex: 1;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0 1rem 0.7rem;
    display: flex;
    flex-direction: column;
  }
  .organize-layout {
    flex: 1;
    min-height: 0;
    grid-template-columns: 280px minmax(0, 1fr) minmax(18rem, 24rem);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0.75rem 1rem;
    align-items: stretch;
  }
  .page-organize .add-panel { grid-column: 1; grid-row: 1; overflow: auto; }
  .page-organize .organize-main {
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .page-organize .checks { max-height: 38%; overflow: auto; }
  .page-organize .kitchen-pane {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .page-organize #inventory-table {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .page-organize .table-wrap { flex: 1; min-height: 0; overflow: auto; }
  .page-organize .inv-table th { position: sticky; top: 0; z-index: 1; }
  .page-organize .dish-panel { grid-column: 3; grid-row: 1; min-height: 0; overflow: auto; }
  .page-organize .always-slot { grid-column: 1 / -1; grid-row: 2; }
  .page-organize .always-slot .always-card { margin: 0; padding: 0.55rem 1rem; }
  .page-organize .always-slot .always-details[open] {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.45rem 1rem;
    align-items: center;
  }
  .page-organize .always-slot .always-body {
    display: grid;
    grid-template-columns: minmax(14rem, 22rem) minmax(0, 1fr);
    gap: 0.45rem 1rem;
    align-items: center;
    min-width: 0;
  }
  .page-organize .always-slot .always-note { display: none; }
  .page-organize .always-slot h2 { margin: 0; }
  .page-organize .always-slot .search { margin: 0; }
  .page-organize .always-slot .search-results { top: auto; bottom: calc(100% + 6px); }
  .page-organize .always-slot .always-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    min-width: 0;
  }
  .page-organize .always-slot .always-list li {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.05rem 0.2rem 0.05rem 0.7rem;
  }
  .page-organize .always-slot .hint { margin: 0; }
  .page-organize .saved-recipes { max-height: none; height: 100%; margin: 0; }
}
.add-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem 1.15rem 1.3rem;
  box-shadow: 0 1px 2px rgb(0 30 120 / 0.05);
}
.add-panel h2, .checks h2, .always-card h2, .kitchen-heading {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin: 1.2rem 0 0.5rem;
}
.add-panel h2:first-child { margin-top: 0; }
.filters input, .filters select, .edit-grid input, .edit-grid select {
  min-height: 42px;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.filters input:focus, .filters select:focus, .edit-grid input:focus, .edit-grid select:focus,
.search-input:focus {
  outline: none;
  border-color: var(--blue-bright);
  box-shadow: 0 0 0 3px rgb(0 61 165 / 0.15);
}
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.recent-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.9rem;
  padding: 0.7rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.filters > input { flex: 1 1 180px; }
.checks {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.1rem;
  margin-bottom: 0.9rem;
}
.checks-head, .check-row, .check-actions, .paste-actions, .cook-tools { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.checks-head { justify-content: space-between; margin-bottom: 0.35rem; }
.checks-head h2 { margin: 0; }
.kitchen-heading { margin: 0 0 0.55rem; }
.always-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.15rem;
  margin: 1.35rem 0 0.4rem;
}
.always-card h2 { margin-top: 0; }
.always-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  list-style: none;
}
.always-summary::-webkit-details-marker { display: none; }
.always-summary::before { content: "▸"; color: var(--blue); font-size: 0.9rem; }
.always-details[open] > .always-summary::before { content: "▾"; }
.always-summary h2 { margin: 0; }
.always-count {
  min-width: 1.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 0.8rem;
  font-weight: 700;
}
.always-note { color: var(--muted); margin: 0.35rem 0 0.75rem; font-size: 0.95rem; }
.always-list { list-style: none; margin: 0.7rem 0 0; padding: 0; }
.always-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--line);
  font-weight: 650;
}
.always-card .hint { margin: 0.7rem 0 0; }
.check-list { list-style: none; margin: 0.35rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.check-row { justify-content: space-between; align-items: flex-start; padding: 0.7rem 0; border-top: 1px solid var(--line); min-width: 0; }
.check-row > div:first-child { min-width: 0; }
.check-actions { flex: 1 1 12rem; justify-content: flex-end; }
.checks .count { background: var(--green); color: #fff; }
.badge { display: inline-block; max-width: 100%; margin-left: 0.45rem; padding: 0.12rem 0.55rem; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 0.8rem; font-weight: 600; line-height: 1.35; vertical-align: middle; }
.bulk-bar { display: none; gap: 0.45rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.7rem; padding: 0.55rem 0.7rem; background: var(--green-soft); border-radius: 12px; }
.bulk-bar.is-active { display: flex; }
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgb(0 30 120 / 0.05);
}
.inv-table { width: 100%; border-collapse: collapse; background: var(--card); }
.inv-table th {
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  font-weight: 700;
  padding: 0.7rem 0.9rem;
  background: var(--blue-bar);
}
.inv-table td { padding: 0.8rem 0.9rem; border-top: 1px solid var(--line); vertical-align: middle; }
.inv-table tbody tr:hover td { background: #fff8f3; }
.inv-name { font-weight: 700; }
.inv-note { color: var(--muted); max-width: 14rem; }
.inv-actions { text-align: right; position: relative; }
.inv-actions .btn { margin: 0.1rem 0 0.1rem 0.15rem; }
.row-menu-btn {
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.row-menu-btn:hover { background: var(--green-soft); color: var(--ink); }
.row-menu {
  inset: auto;
  margin: 0;
  padding: 0.3rem;
  min-width: 14rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 10px 28px rgb(0 30 120 / 0.16);
}
.row-menu button {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.row-menu button:hover { background: var(--green-soft); }
.row-menu button.is-danger { color: var(--tomato); }
.edit-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding: 0.35rem 0; }
.use-match { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; padding: 0.55rem 0.85rem; }
.use-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-left: auto; }
@media (max-width: 899px) {
  .inv-table thead { display: none; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .inv-table, .inv-table tbody, .inv-table tr, .inv-table td { display: block; }
  .inv-table tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.55rem 0.35rem;
    margin-bottom: 0.55rem;
  }
  .inv-table td { border: 0; padding: 0.2rem 0.55rem; }
  .inv-table tbody tr:hover td { background: transparent; }
  .inv-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
  .inv-actions { text-align: left; padding-top: 0.35rem; }
}
@media (prefers-color-scheme: dark) {
  .inv-table tbody tr:hover td { background: #221c18; }
  .page-organize .topbar { background: #0a1748; }
}

/* ---- Cook ------------------------------------------------------------- */
.cook-layout { display: grid; min-height: calc(100dvh - 5rem); }
.cook-sessions { display: none; }
@media (min-width: 900px) {
  .cook-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .cook-sessions { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.5rem 0.75rem 0 0; border-right: 1px solid var(--line); }
}
.cook-sessions a { color: inherit; text-decoration: none; padding: 0.45rem 0.6rem; border-radius: 10px; }
.cook-sessions a.is-current, .cook-sessions a:hover { background: var(--green-soft); }
.cook-chat { display: flex; flex-direction: column; min-width: 0; padding-left: 0.75rem; }
.plan-board { margin: 0 0 1.25rem; }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 1.2rem 0 0.45rem; }
.plan-head h2 { margin: 0; }
.page-organize .plan-head .btn {
  min-height: 32px;
  padding: 0 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
}
.plan-chats { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.chat-row { display: flex; align-items: center; gap: 0.2rem; min-width: 0; }
.chat-row a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.35rem 0.15rem;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.chat-x {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.chat-x:hover { color: var(--tomato); background: var(--green-soft); }
.plan-split { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 800px) {
  .plan-split { grid-template-columns: minmax(14rem, 0.8fr) minmax(0, 1.4fr); }
}
.side-label { margin: 0.8rem 0.6rem 0.2rem; color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.recipe-card h3 a { color: inherit; text-decoration: none; }
.recipe-from { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-recipes { max-height: 22rem; overflow: auto; margin: 0 0.15rem 0.75rem 0; }
.saved-recipes h2 { margin: 0 0 0.45rem; font-size: 1.05rem; }
.dish-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.dish-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.dish-row.is-on { border-left: 4px solid var(--green); }
.dish-main a, .dish-main > span { font-weight: 700; color: inherit; text-decoration: none; }
.dish-main p { margin: 0.1rem 0 0; }
.dish-actions { display: flex; flex-wrap: wrap; gap: 0.15rem; }
.dish-actions .btn { min-height: 40px; width: auto; padding: 0 0.7rem; }
.dish-pick { display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem 1.25rem 0; }
.dish-pick select {
  flex: 1;
  min-height: var(--tap);
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font: inherit;
  font-weight: 700;
}
.recipe-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.65rem; }
.recipe-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.recipe-card h3 { margin: 0; font-size: 1.08rem; line-height: 1.25; }
.recipe-card p { margin: 0; color: var(--muted); font-size: 0.95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recipe-card .recipe-items { font-weight: 600; color: var(--ink); }
.recipe-card .btn { min-height: var(--tap); width: 100%; }
.transcript { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; overflow: auto; padding: 0.5rem 0 1rem; }
.bubble { max-width: 42rem; padding: 0.75rem 0.9rem; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.bubble-user { align-self: flex-end; background: var(--green-soft); }
.bubble-paste, .bubble-error { border-color: var(--amber); }
.bubble p { margin: 0.3rem 0; }
.markdown :first-child { margin-top: 0; }
.markdown :last-child { margin-bottom: 0; }
.used-line { color: var(--muted); font-size: 0.92rem; }
.shop-plan { margin-top: 0.6rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
.draft-offer { position: sticky; bottom: 0; z-index: 1; margin-top: 0.75rem; padding: 0.7rem 0.15rem 0.15rem; background: var(--card); }
.draft-offer .btn { min-height: var(--tap); }
.draft-old { margin-top: 0.45rem; }
.recipe-live { display: inline-block; margin-left: 0.35rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--green); }
.used-have { color: var(--ink); font-weight: 600; }
.used-missing { opacity: 0.55; text-decoration: line-through; }
.cook-note { color: var(--muted); font-size: 0.9rem; margin: 0; }
.composer { display: flex; gap: 0.5rem; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 52px; padding: 0.6rem 0.8rem; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.cook .chips { margin: 0.6rem 0 0; }
.cook .chips button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 0.3rem 0.7rem; cursor: pointer; }
.status-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.is-on { background: var(--green); }
.paste-actions { margin: 0.4rem 0; }
.bubble textarea { width: 100%; min-height: 90px; margin-top: 0.4rem; }
.page-cooking { min-height: 100dvh; }
.cook-now { display: flex; flex-direction: column; width: 100%; min-height: calc(100dvh - 4.2rem); }
.dish-switch { display: flex; gap: 0.5rem; overflow: auto; padding: 0.35rem 1.25rem 0; }
.dish-switch a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0.45rem 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: inherit; text-decoration: none; font-weight: 700; }
.dish-switch a.is-current { background: var(--green); border-color: var(--green); color: #fff; }
.cook-sheet { flex: 1; overflow: auto; width: 100%; box-sizing: border-box; padding: 0.5rem 1.25rem 1rem; }
.cook-recipe { width: 100%; max-width: none; font-size: 1.15rem; line-height: 1.45; }
.cook-lead h1, .cook-lead h2, .cook-lead h3,
.cook-recipe h1, .cook-recipe h2, .cook-recipe h3 { font-size: clamp(1.8rem, 3vw, 2.5rem); line-height: 1.15; margin: 0 0 0.45rem; }
.cook-lead p { margin: 0.2rem 0 0.85rem; color: var(--muted); }
.cook-columns { display: grid; grid-template-columns: minmax(15rem, 0.7fr) minmax(0, 1.6fr); gap: 1.25rem 2.25rem; align-items: start; }
.cook-ingredients h4 { margin: 0.85rem 0 0.3rem; font-size: 0.95rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }
.cook-ingredients h4:first-child { margin-top: 0; }
.cook-ingredients ul { margin: 0; padding-left: 1.15rem; }
.cook-ingredients li { margin: 0.35rem 0; }
.cook-steps { font-size: clamp(1.2rem, 1.8vw, 1.45rem); }
.cook-steps h3 { font-size: 1.15rem; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
.cook-steps ol { margin: 0.2rem 0 0; padding-left: 1.4rem; }
.cook-steps li { margin: 0.75rem 0; }
.cook-ask { position: sticky; bottom: 0; padding: 0.65rem 1.25rem calc(0.65rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.advice { max-width: none; margin-top: 1.1rem; }
@media (max-width: 760px) {
  .cook-columns { grid-template-columns: 1fr; gap: 0.5rem; }
  .cook-sheet { padding-inline: 0.9rem; }
}
.advice-user p { margin: 0; color: var(--muted); }
.page-cooking .cook-empty { padding: 2rem 1.1rem; font-size: 1.15rem; }
