/* Pantry web app. One column up to 760px wide, sticky large-title header, tab bar fixed to the bottom.
   System fonts only, so the app looks native and works fully offline. */
:root {
  --ground: #eef2ec;
  --surface: #f8faf6;
  --card: #ffffff;
  --ink: #1d2a22;
  --muted: #5d6c63;
  --faint: #8a978f;
  --line: #dbe3db;
  --chip: #e5ede7;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe2;
  --saffron: #f2b632;
  --tomato: #c9503a;
  --shadow: 0 10px 30px -18px rgba(20, 45, 30, 0.45);
  --scrim: rgba(12, 22, 16, 0.42);

  --display: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --radius: 16px;
  --tabbar-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0d120f; --surface: #121915; --card: #1a231e; --ink: #e8efea; --muted: #a0aea5; --faint: #7a887f;
    --line: #2a3630; --chip: #232e28; --accent: #79c29b; --accent-ink: #0d120f; --accent-soft: #20352a;
    --saffron: #f2c45a; --tomato: #e57a62; --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8); --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0d120f; --surface: #121915; --card: #1a231e; --ink: #e8efea; --muted: #a0aea5; --faint: #7a887f;
  --line: #2a3630; --chip: #232e28; --accent: #79c29b; --accent-ink: #0d120f; --accent-soft: #20352a;
  --saffron: #f2c45a; --tomato: #e57a62; --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8); --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 800px) { body { background: var(--ground); } }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--surface);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px);
}
@media (min-width: 800px) { .app { box-shadow: 0 0 0 1px var(--line); } }

.gutter {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-row { display: flex; align-items: center; gap: 4px; min-height: 52px; }
.topbar-row .spacer { flex: 1; }
.page-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 34px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 2px 0 12px;
  text-wrap: balance;
}
.icon-btn {
  width: 42px; height: 42px;
  display: inline-grid; place-items: center;
  border-radius: 12px;
  color: var(--accent);
}
.icon-btn:active { background: var(--chip); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.solid { background: var(--accent); color: var(--accent-ink); }
.icon-btn.solid:active { filter: brightness(0.92); }
.text-btn { color: var(--accent); font-weight: 600; padding: 8px 4px; display: inline-flex; align-items: center; gap: 2px; }
.text-btn svg { width: 20px; height: 20px; }

/* Search and chips */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--chip); border-radius: 12px; padding: 0 12px; height: 42px;
}
.search svg { width: 18px; height: 18px; color: var(--faint); flex-shrink: 0; }
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; height: 100%; font-size: 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border-radius: 999px; padding: 7px 14px;
  background: var(--chip); font-size: 14px; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* Recipe grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 14px; padding-top: 12px; }
.rcard {
  text-align: left; background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 0 1px var(--line); display: flex; flex-direction: column;
}
.rcard:active { transform: scale(0.985); }
.thumb { aspect-ratio: 4 / 3; width: 100%; max-width: 100%; position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile {
  width: 100%; height: 100%; display: flex; align-items: flex-end; padding: 12px;
  font-family: var(--display); font-weight: 800; font-size: 30px; color: #fff; letter-spacing: -0.02em;
}
.thumb .fav { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.rcard .meta { padding: 10px 12px 12px; display: grid; gap: 3px; }
.rcard b { font-weight: 650; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard small { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; background: var(--saffron); color: #1d2a22; border-radius: 6px; padding: 1px 6px; vertical-align: 1px; }

.empty { text-align: center; color: var(--muted); padding: 48px 12px; display: grid; gap: 10px; justify-items: center; }
.empty svg { width: 44px; height: 44px; color: var(--faint); }
.empty h2 { margin: 0; font-family: var(--display); font-size: 21px; color: var(--ink); }
.empty p { margin: 0; max-width: 32ch; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; font-weight: 650;
  background: var(--chip); color: var(--ink);
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--tomato); }
.btn.wide { width: 100%; }
.btn:active { filter: brightness(0.94); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Recipe detail */
.hero { aspect-ratio: 16 / 10; max-width: 100%; border-radius: 20px; overflow: hidden; margin-top: 4px; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero .tile { font-size: 46px; padding: 18px; }
.detail-title { font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1.12; letter-spacing: -0.02em; margin: 16px 0 6px; text-wrap: balance; }
.summary { color: var(--muted); margin: 0 0 10px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }
.fact { display: inline-flex; align-items: center; gap: 5px; background: var(--chip); border-radius: 9px; padding: 6px 10px; font-size: 14px; font-weight: 500; max-width: 100%; }
.fact svg { width: 16px; height: 16px; flex-shrink: 0; }
.fact span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.fact { color: inherit; text-decoration: none; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 26px 0 8px; }
.section-head h2 { margin: 0; font-family: var(--display); font-size: 21px; font-weight: 750; flex: 1; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; background: var(--chip); display: grid; place-items: center; }
.stepper button svg { width: 18px; height: 18px; }
.stepper output { min-width: 86px; text-align: center; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ing { list-style: none; margin: 0; padding: 0; }
.ing li { display: flex; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.ing .q { min-width: 76px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ing .n { min-width: 0; overflow-wrap: anywhere; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.steps button { display: flex; gap: 12px; text-align: left; width: 100%; padding: 8px 0; align-items: flex-start; }
.steps .num {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--chip); font-weight: 700; font-size: 14px;
}
.steps .done .num { background: var(--accent); color: var(--accent-ink); }
.steps .done .t { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line); }
.steps .t { padding-top: 3px; overflow-wrap: anywhere; }
.hint { font-size: 13px; color: var(--faint); margin: 6px 0 0; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Lists (plan, groceries, pickers) */
.group-label {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 22px 0 6px; display: flex; align-items: center; gap: 8px;
}
.group-label .today { letter-spacing: .02em; text-transform: none; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 52px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--muted); }
.row .mini { width: 46px; height: 46px; border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.row .mini .tile { font-size: 15px; padding: 6px; }
.row .mini img { width: 100%; height: 100%; object-fit: cover; }
.row.add { color: var(--accent); font-weight: 600; }
.row.add svg { width: 20px; height: 20px; }
button.row { width: 100%; text-align: left; }
.serv { display: inline-flex; align-items: center; gap: 2px; }
.serv button { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.serv button svg { width: 16px; height: 16px; }
.serv span { font-size: 13px; color: var(--muted); min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.x { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--faint); flex-shrink: 0; }
.x svg { width: 18px; height: 18px; }

.weekbar { display: flex; align-items: center; gap: 8px; background: var(--card); box-shadow: 0 0 0 1px var(--line); border-radius: var(--radius); padding: 6px; }
.weekbar .label { flex: 1; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.weekbar .label small { display: block; font-weight: 500; }

.add-bar { display: flex; gap: 8px; }
.add-bar input { flex: 1; min-width: 0; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; font-size: 16px; }
.add-bar .icon-btn { width: 46px; height: 46px; }

.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--faint); display: grid; place-items: center; flex-shrink: 0; color: transparent; }
.check svg { width: 16px; height: 16px; }
.checked .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.checked .title { color: var(--faint); text-decoration: line-through; }
.gitem { cursor: pointer; }
.gitem .qty { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; max-width: 40%; overflow-wrap: anywhere; }

/* Forms */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 650; color: var(--muted); }
.field input[type="text"], .field input[type="url"], .field input[type="number"], .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 11px 13px; font-size: 16px; outline: none;
}
.field textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .help { font-size: 13px; color: var(--faint); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two > * { min-width: 0; }
.photo-pick { display: flex; gap: 12px; align-items: center; }
.photo-pick .preview { width: 88px; height: 66px; border-radius: 10px; overflow: hidden; background: var(--chip); flex-shrink: 0; }
.photo-pick .preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-pick label.btn { min-height: 40px; font-size: 15px; }
.photo-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.notice { border-radius: 14px; padding: 14px; background: var(--accent-soft); display: grid; gap: 6px; font-size: 15px; }
.notice.warn { background: color-mix(in srgb, var(--tomato) 14%, var(--card)); }
.notice strong { font-weight: 650; }
.preview-card { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.preview-card img { width: 100%; max-height: 220px; object-fit: cover; }
.preview-card .body { padding: 14px; display: grid; gap: 6px; }
.preview-card p { margin: 0; color: var(--muted); font-size: 14px; white-space: pre-wrap; max-height: 9em; overflow: hidden; }

/* Sheets */
.scrim {
  position: fixed; inset: 0; z-index: 20; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; max-height: 94dvh;
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 700px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { border-radius: 22px; max-height: 88dvh; }
}
.sheet-head {
  display: flex; align-items: center; gap: 8px; min-height: 56px; border-bottom: 1px solid var(--line);
  padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
}
.sheet-head h2 { flex: 1; margin: 0; text-align: center; font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .text-btn { min-width: 64px; }
.sheet-head .text-btn.end { justify-content: flex-end; }
.sheet-body { overflow-y: auto; padding-block: 18px 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@media (prefers-reduced-motion: no-preference) {
  .scrim { animation: fade .18s ease-out; }
  .sheet { animation: rise .24s cubic-bezier(.2,.8,.2,1); }
  @keyframes fade { from { opacity: 0; } }
  @keyframes rise { from { transform: translateY(40px); opacity: .5; } }
}

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tabbar nav { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); height: var(--tabbar-h); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 650; color: var(--faint); text-decoration: none; }
.tab svg { width: 25px; height: 25px; }
.tab[aria-current="page"] { color: var(--accent); }

/* Toast */
.toast {
  position: fixed; left: 50%; z-index: 30; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center;
}
.spinner { width: 22px; height: 22px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); padding: 28px; }

.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.install-steps { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.kbd { display: inline-flex; vertical-align: -4px; width: 20px; height: 20px; color: var(--accent); }
