/* ------------------------------------------------------------------
   Grocery planner — a quiet, paper-like interface.
   No boxed inputs, no visible field borders; type size and spacing
   carry the hierarchy instead.
   ------------------------------------------------------------------ */

:root {
  --paper: #fdfcf8;
  --paper-raised: #ffffff;
  --ink: #1c1c1e;
  --ink-soft: #5f5f66;
  --ink-faint: #9a9aa2;
  --rule: #e6e4dd;
  --rule-strong: #d3d1c8;

  --include: #c99a2e;   /* editor: include / exclude          */
  --pick: #3b7ddd;      /* picker: this week's meals          */
  --got: #43a047;       /* shopping list: got it              */
  --danger: #d9483f;

  --tap: 44px;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(28, 28, 30, 0.14);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16161a;
    --paper-raised: #232329;
    --ink: #f2f2f4;
    --ink-soft: #a8a8b0;
    --ink-faint: #6e6e78;
    --rule: #2e2e35;
    --rule-strong: #3d3d46;
    --include: #e0b44d;
    --pick: #6ea8ff;
    --got: #66bb6a;
    --danger: #ff6b5e;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; background: none; border: 0; outline: none; }
input::placeholder { color: var(--ink-faint); }

/* ---------------- shell ---------------- */

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 18px 10px;
  min-height: 52px;
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__action {
  color: var(--pick);
  font-size: 16px;
  padding: 6px 4px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.topbar__action--muted { color: var(--ink-soft); }
.topbar__action:disabled { opacity: 0.35; cursor: default; }

.screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 120px;
}

.tabbar {
  position: sticky;
  bottom: 0;
  display: flex;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tabbar__item {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.01em;
  padding: 6px 0;
}
.tabbar__item.is-active { color: var(--pick); }
.tabbar__glyph { font-size: 17px; line-height: 1; }
.tabbar__badge {
  position: absolute;
  transform: translate(14px, -10px);
  background: var(--pick);
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  line-height: 1.4;
}

/* ---------------- generic rows ---------------- */

.section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 22px 20px 6px;
}

.row {
  position: relative;
  overflow: hidden;
}
.row__slide {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 20px;
  min-height: var(--tap);
  background: var(--paper);
  transition: transform 0.18s cubic-bezier(0.2, 0, 0.2, 1);
  will-change: transform;
}
.row--tappable .row__slide { cursor: pointer; }
.row + .row .row__slide::before {
  content: "";
  position: absolute;
  left: 20px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--rule);
}
.row--indent-1 .row__slide { padding-left: 52px; }
.row--indent-1 .row__slide::before { left: 52px; }
.row--indent-2 .row__slide { padding-left: 84px; }
.row--indent-2 .row__slide::before { left: 84px; }

.row__body { flex: 1; min-width: 0; }
.row__title {
  font-size: 17px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.row__meta {
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__chevron { color: var(--ink-faint); font-size: 15px; align-self: center; }

.row__delete {
  position: absolute;
  inset: 0 0 0 auto;
  width: 50%;
  /* Hidden until a swipe is actually under way. */
  opacity: 0;
  background: var(--danger);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 24px;
  font-size: 15px;
  font-weight: 500;
}
.row.is-swiping .row__delete { opacity: 1; }

.row.is-dragging { z-index: 5; }
.row.is-dragging .row__slide {
  background: var(--paper-raised);
  box-shadow: var(--shadow);
  border-radius: 10px;
  transition: none;
}
.row.is-drop-target .row__slide { background: color-mix(in srgb, var(--pick) 8%, var(--paper)); }
.rows.is-reordering .row__slide { transition: transform 0.16s ease; }

/* ---------------- the three dot styles ----------------
   circle          = include / exclude   (recipe editor)
   ringed circle   = on the plan         (recipe picker)
   rounded square  = got it              (shopping list)
   ------------------------------------------------------ */

.dot {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border: 1.5px solid var(--rule-strong);
  background: transparent;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
  touch-action: none;
}
.dot:active { transform: scale(0.9); }
.dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 47%;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -55%) rotate(45deg) scale(0.4);
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.dot.is-on::after { opacity: 1; transform: translate(-50%, -55%) rotate(45deg) scale(1); }

.dot--include { border-radius: 50%; }
.dot--include.is-on { background: var(--include); border-color: var(--include); }

.dot--pick { border-radius: 50%; width: 24px; height: 24px; border-width: 2px; }
.dot--pick.is-on { background: var(--pick); border-color: var(--pick); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pick) 18%, transparent); }

.dot--got { border-radius: 7px; }
.dot--got.is-on { background: var(--got); border-color: var(--got); }

/* ---------------- photos ---------------- */

/* Thumbnails: a photo when there is one, otherwise a coloured monogram. */
.thumb {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  object-fit: cover;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink-faint);
  font-weight: 600;
  overflow: hidden;
}
.thumb--sm { width: 30px; height: 30px; font-size: 13px; border-radius: 7px; }
.thumb--md { width: 44px; height: 44px; font-size: 17px; align-self: center; }
.thumb--placeholder {
  background: hsl(var(--thumb-hue, 210) 42% 88%);
  color: hsl(var(--thumb-hue, 210) 38% 32%);
}
@media (prefers-color-scheme: dark) {
  .thumb--placeholder {
    background: hsl(var(--thumb-hue, 210) 26% 26%);
    color: hsl(var(--thumb-hue, 210) 40% 78%);
  }
}

/* Editor / detail photo: capped so the ingredients stay on screen. */
.note__photo { padding: 4px 20px 8px; }
.note__photo.is-empty { padding-bottom: 2px; }

.photo__frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  /* A neutral mat, so letterboxing on tall or wide photos reads as deliberate
     rather than as a gap. */
  background: color-mix(in srgb, var(--ink) 8%, var(--paper));
  cursor: zoom-in;
  display: flex;
  justify-content: center;
  align-items: center;
}
.photo {
  display: block;
  /* The element hugs the picture: width and height both follow the photo's
     own aspect ratio, bounded by the frame and the height cap. A tall photo
     therefore sits centred on the mat rather than being cut to fit. */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 40vh;      /* capped so the ingredient list stays reachable */
  /* contain, never cover: the whole dish must be visible. Scaling down to
     reach the cap is fine; cropping to reach it is not. */
  object-fit: contain;
  object-position: center;
}
.photo__menu {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 15px;
  line-height: 1;
}
.photo__menu:hover { background: rgba(0, 0, 0, 0.6); }

/* Quiet affordance, not a big grey box. */
.photo-add {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 9px;
  border-radius: 999px;
  border: 1px dashed var(--rule-strong);
  color: var(--ink-faint);
  font-size: 13px;
  min-height: 34px;
}
.photo-add:hover { color: var(--pick); border-color: var(--pick); }
.photo-add__icon { font-size: 15px; line-height: 1; }

/* ---------------- recipe editor ---------------- */

.note { padding: 4px 0 40px; }

.note__title {
  display: block;
  width: 100%;
  padding: 6px 20px 2px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.note__sub {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 2px 20px 10px;
  font-size: 13px;
  color: var(--ink-faint);
}
.note__servings {
  width: 2.4em;
  text-align: center;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: 1px 2px;
}
.note__hint { padding: 4px 20px 14px; font-size: 13px; color: var(--ink-faint); }

.ing-row .row__slide { align-items: flex-start; padding-top: 7px; padding-bottom: 7px; }
.ing-row .dot { margin-top: 6px; }
.ing-row.is-excluded .ing-line { color: var(--ink-faint); }

.ing-main { flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ing-line {
  flex: 1;
  min-width: 0;
  display: block;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.65;
  padding: 2px 0;
  letter-spacing: -0.01em;
  resize: none;          /* it grows to fit its own text instead */
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chip {
  flex: 0 0 auto;
  align-self: center;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 999px;
  padding: 2px 9px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}
.chip:hover, .chip:focus-visible { color: var(--ink-soft); }
.chip--empty { opacity: 0; pointer-events: none; }
.ing-row:hover .chip--empty, .ing-row:focus-within .chip--empty { opacity: 0.55; pointer-events: auto; }

/* Category subhead inside the note — a quiet label, clearly not a row. */
.ing-heading {
  padding: 18px 20px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.ing-heading:first-child { padding-top: 6px; }

.chip--cat { background: none; border: 1px solid var(--rule); color: var(--ink-faint); }
.chip--cat:hover { border-color: var(--pick); color: var(--pick); }
.chip--cat.is-set { border-color: transparent; background: color-mix(in srgb, var(--include) 18%, transparent); color: var(--include); }

.view-toggle {
  font-size: 12px;
  color: var(--pick);
  padding: 2px 6px;
  border-radius: 6px;
}
.view-toggle:hover { background: color-mix(in srgb, var(--pick) 10%, transparent); }

/* Collapsible category heading on the shopping list. */
.cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 20px 20px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.cat-head__twisty {
  display: inline-block;
  transform: rotate(90deg);
  transition: transform 0.15s ease;
  font-size: 13px;
  /* Stays at full contrast even when the heading text is muted, so a finished
     category still reads as tappable rather than disabled. */
  color: var(--ink-soft);
  opacity: 1;
}
.cat-head.is-collapsed .cat-head__twisty { transform: rotate(0deg); }
.cat-head__count { font-weight: 500; letter-spacing: 0.02em; }

/* A finished category is muted, never disabled: the tap target is the whole
   heading and the chevron keeps its contrast. */
.cat-head.is-done .cat-head__name,
.cat-head.is-done .cat-head__count { opacity: 0.5; }
.cat-head.is-done .cat-head__twisty { color: var(--got); }
.cat-head:hover { color: var(--ink-soft); }
.cat-head:hover .cat-head__name,
.cat-head:hover .cat-head__count { opacity: 1; }
.cat-head:focus-visible { outline: 2px solid var(--pick); outline-offset: -2px; border-radius: 6px; }

/* ---------------- show checked items ---------------- */

.scope--reveal { padding-top: 10px; padding-bottom: 2px; }
.reveal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink-soft);
  min-height: 34px;
  padding: 2px 4px 2px 0;
}
.reveal-toggle__box {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--rule-strong);
  position: relative;
  transition: background-color 0.15s ease;
  flex: 0 0 auto;
}
.reveal-toggle__box::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.reveal-toggle.is-on { color: var(--ink); }
.reveal-toggle.is-on .reveal-toggle__box { background: var(--pick); }
.reveal-toggle.is-on .reveal-toggle__box::after { transform: translateX(14px); }
.reveal-toggle__count { color: var(--ink-faint); font-size: 12px; }

.tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 20px 8px;
  border-top: 1px solid var(--rule);
  margin-top: 18px;
}
.tag {
  font-size: 13px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 999px;
  padding: 5px 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tag--filter.is-on { background: var(--pick); color: #fff; }
/* A long tag ("menu-2026-08-04") must not be squeezed into a circle by the
   horizontally scrolling filter bar. */
.filterbar .tag { flex: 0 0 auto; white-space: nowrap; }
.tag__x { color: inherit; opacity: 0.5; font-size: 14px; line-height: 1; }
.tag--add { color: var(--pick); background: none; padding-left: 4px; }
.tag__input { width: 8em; border-bottom: 1px solid var(--rule); }

/* ---------------- library ---------------- */

.searchbar { padding: 4px 20px 10px; display: flex; align-items: center; gap: 10px; }
.searchbar__field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 38px;
}
.searchbar__field input { flex: 1; min-width: 0; }
.searchbar__icon { color: var(--ink-faint); font-size: 14px; }
.filterbar { display: flex; gap: 8px; padding: 0 20px 10px; overflow-x: auto; scrollbar-width: none; }
.filterbar::-webkit-scrollbar { display: none; }

.empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 64px 40px;
  font-size: 15px;
  line-height: 1.6;
}
.empty strong { display: block; color: var(--ink-soft); font-size: 17px; margin-bottom: 6px; font-weight: 600; }

/* ---------------- plan ---------------- */

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  border-radius: 999px;
  padding: 2px;
}
.stepper button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  color: var(--pick);
}
.stepper button:disabled { color: var(--ink-faint); }
.stepper__value { min-width: 2.6em; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }

.plan-summary {
  padding: 14px 20px;
  font-size: 13px;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
}

/* ---------------- weekly plan grid ---------------- */

.week { display: block; }

.day { padding-bottom: 6px; }
.day + .day { border-top: 1px solid var(--rule); }

.day__head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 20px 8px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.day__name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.day__count { flex: 1; font-size: 12px; color: var(--ink-faint); }
.day.is-empty .day__name { color: var(--ink-soft); font-weight: 500; }
.day__menu {
  color: var(--ink-faint);
  font-size: 15px;
  padding: 0 4px;
  min-height: 32px;
  align-self: center;
}

.meal {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: start;
  gap: 8px;
  padding: 2px 20px 2px 20px;
}
.meal__label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 12px;
}
.meal.is-filled .meal__label { color: var(--ink-soft); }
.meal__slots { min-width: 0; padding: 4px 0; }
.meal.is-drop-target .meal__slots {
  background: color-mix(in srgb, var(--pick) 10%, transparent);
  border-radius: 10px;
  outline: 2px dashed var(--pick);
  outline-offset: 2px;
}

/* An empty slot is a quiet dashed placeholder; a filled one reads as solid. */
.slot-add {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px dashed var(--rule-strong);
  border-radius: 10px;
  color: var(--ink-faint);
  font-size: 14px;
  background: transparent;
}
.slot-add:hover { color: var(--pick); border-color: var(--pick); }
/* A filled slot can still take a second dish (a main plus a side), so the
   extra + stays reachable on touch — quiet, but never hover-only. */
.meal.is-filled .slot-add {
  min-height: 30px;
  opacity: 0.45;
  margin-top: 4px;
  justify-content: center;
}
.meal.is-filled:hover .slot-add,
.meal.is-filled:focus-within .slot-add { opacity: 1; }

.slot-row { border-radius: 10px; overflow: hidden; }
.slot-row + .slot-row { margin-top: 4px; }
.slot-row .row__slide {
  padding: 8px 10px;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  /* Opaque on purpose: it slides over the red delete backdrop. */
  background: color-mix(in srgb, var(--ink) 4%, var(--paper));
  border-radius: 10px;
  cursor: pointer;
}
.slot-row + .slot-row .row__slide::before { display: none; }
.slot-row .row__title { font-size: 15px; }
.slot-row .row__meta { font-size: 12px; }
.slot-row.is-dragging { opacity: 0.4; }
.slot-row__x {
  color: var(--ink-faint);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  align-self: center;
}
.slot-row__x:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* Wide screens: the week as seven columns, meals aligned across days. */
@media (min-width: 900px) {
  #app { max-width: 1180px; }
  .week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: auto repeat(3, auto);
    gap: 0 1px;
    background: var(--rule);
    border-top: 1px solid var(--rule);
  }
  .day {
    display: grid;
    grid-row: 1 / -1;
    grid-template-rows: subgrid;
    background: var(--paper);
    padding-bottom: 12px;
  }
  .day + .day { border-top: 0; }
  .day__head {
    position: static;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 12px 10px 6px;
    background: none;
    backdrop-filter: none;
  }
  .day__name { font-size: 14px; }
  .day__count { font-size: 11px; }
  .day__menu { position: absolute; right: 4px; top: 8px; }
  .day { position: relative; }
  .meal {
    display: block;
    padding: 0 8px 6px;
  }
  .meal__label { padding-top: 4px; font-size: 10px; }
  .slot-row .row__slide { padding: 6px 8px; }
  .slot-row .row__title { font-size: 13px; }
  .slot-add { font-size: 12px; padding: 4px 8px; min-height: 32px; }
}

/* Without subgrid the columns still work, just without row alignment. */
@supports not (grid-template-rows: subgrid) {
  @media (min-width: 900px) {
    .day { display: block; }
  }
}

/* Meal type label doubles as its menu button. */
.meal__label {
  text-align: left;
  border-radius: 6px;
  padding-right: 4px;
}
.meal__label:hover { color: var(--pick); }

.day__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 20px 10px 20px;
}
.day__empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px 14px;
  font-size: 13px;
  color: var(--ink-faint);
}
.linkish {
  font-size: 13px;
  color: var(--pick);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.linkish--quiet { color: var(--ink-faint); }
.day__aside {
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}

/* Seven per-day toggles under a meal type in Settings. */
.daytoggle { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.daytoggle__day {
  min-width: 38px;
  min-height: 30px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  background: transparent;
}
.daytoggle__day.is-on {
  background: color-mix(in srgb, var(--pick) 14%, transparent);
  border-color: transparent;
  color: var(--pick);
  font-weight: 600;
}
.daytoggle__day:hover { border-color: var(--pick); }
.linkish:hover { text-decoration: underline; }

/* ---------------- settings ---------------- */

.setting-group { padding: 6px 0 26px; }
.setting-group + .setting-group { border-top: 1px solid var(--rule); padding-top: 20px; }
.setting-group__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  padding: 14px 20px 2px;
}
.setting-group__note {
  margin: 0;
  padding: 0 20px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-faint);
  max-width: 46em;
}

/* Sync status: one quiet line that changes as sync runs. */
.sync-status {
  padding: 0 20px 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* Buttons under a settings section — sync, mainly. Wraps rather than
   squashing, so the labels stay readable on a phone. */
.setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
}

.setting-row .row__slide { align-items: center; gap: 10px; }
.setting-row__handle {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 15px;
  line-height: 1;
  padding: 6px 2px;
  cursor: grab;
  touch-action: none;
}
.setting-row__handle:active { cursor: grabbing; }

/* Holding a recipe row reorders it, so the row must not behave like text.
   Without this the press first selects the recipe's name — word by word, with
   the handles and the copy/lookup callout on iOS — and the drag begins
   underneath a selection nobody asked for.

   Scoped to the row, so the editor, the search field and everything else stay
   selectable as normal. */
.library-row .row__slide {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* A row being dragged into a new position. The grab cursor is a desktop
   affordance only; on touch the long press is the affordance. Scrolling is
   held off by a listener while a drag runs (see attachDragHandle), not by
   touch-action here — the row has to stay scrollable the rest of the time. */
.library-row.is-dragging .row__slide {
  cursor: grabbing;
  opacity: 0.92;
}
.setting-row__name {
  width: 100%;
  font-size: 16px;
  letter-spacing: -0.01em;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
}
.setting-row__name:focus { border-bottom-color: var(--pick); }
.setting-row__x {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 19px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.setting-row__x:hover:not(:disabled) { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.setting-row__x:disabled { opacity: 0.25; cursor: default; }

.setting-add {
  display: inline-flex;
  align-items: center;
  margin: 10px 20px 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px dashed var(--rule-strong);
  color: var(--pick);
  font-size: 14px;
  min-height: 38px;
}
.setting-add:hover { border-color: var(--pick); }

.dialog__input {
  width: 100%;
  font-size: 16px;
  padding: 9px 2px;
  border-bottom: 1.5px solid var(--rule-strong);
  margin-bottom: 18px;
}
.dialog__input:focus { border-bottom-color: var(--pick); }

.popover__note {
  padding: 4px 12px 10px;
  font-size: 13px;
  color: var(--ink-faint);
  max-width: 22em;
}

/* ---------------- day + meal chooser ---------------- */

.slot-grid__head,
.slot-grid {
  display: grid;
  grid-template-columns: 2.4em repeat(3, 1fr);
  gap: 4px;
  padding: 2px 6px;
}
.slot-grid__head {
  padding-bottom: 0;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-align: center;
}
.slot-grid__day {
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
}
.slot-grid__cell {
  min-height: 30px;
  border-radius: 7px;
  border: 1px dashed var(--rule-strong);
  color: var(--ink-faint);
  font-size: 12px;
  display: grid;
  place-items: center;
}
.slot-grid__cell.has-meals {
  border-style: solid;
  background: color-mix(in srgb, var(--pick) 14%, transparent);
  border-color: transparent;
  color: var(--pick);
  font-weight: 600;
}
.slot-grid__cell.is-source { outline: 2px solid var(--rule-strong); opacity: 0.5; }
.slot-grid__cell:hover { border-color: var(--pick); color: var(--pick); }

.popover__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px 10px;
}
.popover__rowlabel { font-size: 14px; color: var(--ink-soft); }

/* ---------------- bottom sheet (recipe picker) ---------------- */

.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.3);
}
.sheet {
  position: fixed;
  z-index: 46;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes sheet-in { from { transform: translate(-50%, 14px); opacity: 0; } }
.sheet__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 6px;
}
.sheet__title { flex: 1; font-size: 16px; font-weight: 600; }
.sheet__list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }

/* ---------------- shopping list scope ---------------- */

.scope { padding: 10px 20px 4px; }
.segmented {
  display: flex;
  gap: 2px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 9px;
  padding: 2px;
}
.segmented__opt {
  flex: 1;
  min-height: 32px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-soft);
}
.segmented__opt.is-on {
  background: var(--paper-raised);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.scope__days { display: flex; gap: 6px; padding: 10px 0 4px; flex-wrap: wrap; }
.scope__day {
  min-width: 42px;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  font-size: 12px;
  color: var(--ink-soft);
}
.scope__day.is-on { background: var(--got); border-color: var(--got); color: #fff; font-weight: 600; }
.scope__day.is-bare { opacity: 0.45; }

/* ---------------- shopping list ---------------- */

.list-row.is-done .row__title { color: var(--ink-faint); text-decoration: line-through; }
.list-row.is-done .row__meta { color: var(--ink-faint); opacity: 0.7; }
.list-row .row__amount {
  font-size: 15px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  align-self: center;
  padding-left: 8px;
}
.list-row.is-done .row__amount { color: var(--ink-faint); text-decoration: line-through; }

.progress {
  height: 2px;
  background: var(--rule);
  position: relative;
  overflow: hidden;
}
.progress__bar { height: 100%; background: var(--got); transition: width 0.25s ease; }

/* ---------------- household library ---------------- */

.scope--library, .scope--kind { padding-top: 8px; }
.library-body { flex: 1; min-height: 0; }

.household-row .row__slide { align-items: center; gap: 12px; }
.household-row.is-off .household-row__name { color: var(--ink-faint); }
.household-row__name {
  width: 100%;
  font-size: 17px;
  letter-spacing: -0.01em;
  padding: 1px 0;
  border-bottom: 1px solid transparent;
}
.household-row__name:focus { border-bottom-color: var(--pick); }
.household-row__meta {
  display: block;
  text-align: left;
  font-size: 12px;
  color: var(--ink-faint);
  padding: 2px 0 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.household-row__meta:hover { color: var(--pick); }
.household-row--new .household-row__name { color: var(--ink); }
.dot--ghost { opacity: 0.3; pointer-events: none; }

.badge {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  align-self: center;
}
.badge--due { background: color-mix(in srgb, var(--include) 22%, transparent); color: var(--include); }

.list-row--household .row__title::after {
  content: "·";
  color: var(--ink-faint);
  margin-left: 8px;
}

.scope__note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-faint);
  padding: 8px 0 2px;
  max-width: 42em;
}

.topbar__note {
  font-size: 12px;
  color: var(--include);
  background: color-mix(in srgb, var(--include) 18%, transparent);
  padding: 3px 8px;
  border-radius: 999px;
}

.popover__input { margin: 4px 10px 0; width: calc(100% - 20px); }
.menu__item { flex-direction: column; align-items: flex-start; gap: 1px; }
.menu__item-sub { font-size: 12px; color: var(--ink-faint); }
.menu__item.is-disabled { opacity: 0.4; cursor: default; }
.menu__item.is-disabled:hover { background: none; }

/* ---------------- popover ---------------- */

.scrim { position: fixed; inset: 0; z-index: 40; background: transparent; }
.popover {
  position: fixed;
  z-index: 41;
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--rule);
  padding: 8px;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 220px;
  max-width: min(340px, calc(100vw - 24px));
}
.popover__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 8px 10px 4px;
}
.popover__grid { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 8px; }
.popover__opt {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink-soft);
}
.popover__opt.is-on { background: var(--pick); color: #fff; }
.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 15px;
}
.menu__item:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.menu__item--danger { color: var(--danger); }
.menu__sep { height: 1px; background: var(--rule); margin: 6px 4px; }

/* ---------------- dialog ---------------- */

.dialog-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  padding: 24px;
}
.dialog {
  background: var(--paper-raised);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px 22px 16px;
  max-width: 360px;
  width: 100%;
}
.dialog__title { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.dialog__body { font-size: 15px; color: var(--ink-soft); margin: 0 0 18px; line-height: 1.45; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn {
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 15px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}
.btn--quiet { color: var(--ink-soft); }
/* Secondary action standing on its own in a settings body, where a bare text
   button does not read as tappable. */
.btn--outline {
  border: 1px solid var(--rule-strong);
  background: var(--paper-raised);
}
.btn--primary { background: var(--pick); color: #fff; font-weight: 500; }
.btn--danger { background: var(--danger); color: #fff; font-weight: 500; }

/* ---------------- toast ---------------- */

#toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.toast.is-leaving { animation: toast-out 0.18s ease forwards; }
.toast__action { color: #74b3ff; font-weight: 600; white-space: nowrap; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

.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 (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}


/* ---------------- full-screen photo viewer ---------------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  touch-action: none;          /* we handle pinch and pan ourselves */
  overscroll-behavior: contain;
  animation: viewer-in 0.16s ease;
}
.viewer.is-zoomed { cursor: grab; }
.viewer.is-zoomed:active { cursor: grabbing; }
@keyframes viewer-in { from { opacity: 0; } }

.viewer__stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.viewer__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;         /* full image, never cropped */
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.viewer__close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
}
.viewer__close:hover { background: rgba(0, 0, 0, 0.65); }
.viewer__hint {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  letter-spacing: 0.02em;
  pointer-events: none;
  white-space: nowrap;
}
.viewer.is-zoomed .viewer__hint { opacity: 0; }


/* ---------------- editor undo / redo ---------------- */

.undoredo { display: inline-flex; gap: 2px; }
.undoredo__btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  color: var(--pick);
}
.undoredo__btn:hover:not(:disabled) { background: color-mix(in srgb, var(--pick) 12%, transparent); }
.undoredo__btn:disabled { color: var(--ink-faint); opacity: 0.35; cursor: default; }
