/* Phone-first. The old stylesheet centred a 520px column and put a 5x5 grid of
   25 tap targets inside it — a desktop layout wearing a phone's clothes. This
   one is built for a 360px screen held one-handed, and widens on a laptop.

   Tokens only. No hex values in this file. */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--deep);
  color: var(--milk);
  font-family: var(--body);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
h1, h2, h3, p { margin: 0; }

.sr {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--rim); outline-offset: 2px; }

#lb {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--gutter);
  padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 12px);
}

/* ---------- header ---------- */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 0 10px;
  background: linear-gradient(var(--deep) 72%, transparent);
}

.mark {
  font-family: var(--display); font-weight: 800;
  font-size: 19px; letter-spacing: -.02em;
}
.mark span { color: var(--rim); }

.spaces {
  margin-left: auto;
  display: flex; gap: 3px;
  background: var(--tray); border-radius: 999px; padding: 3px;
}
.spaces button {
  min-height: 34px; padding: 0 13px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--dim);
  max-width: 10ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spaces button[aria-pressed="true"] { background: var(--raised); color: var(--milk); }

/* ---------- shared bits ---------- */

.page { padding-bottom: 18px; }

.h {
  display: flex; align-items: baseline; gap: 8px;
  margin: 22px 0 8px;
  font-family: var(--display); font-weight: 600; font-size: 15px;
  letter-spacing: .01em;
}
.h em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--dim); }

.note { margin: 12px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.5; }
.note.warn { color: var(--warn); }

.blank {
  padding: 40px 20px; text-align: center;
  color: var(--dim); font-size: 14px; line-height: 1.6;
}

.grow { flex: 1; min-width: 0; }

.flag {
  margin: 14px 0 0; padding: 11px 13px;
  background: color-mix(in srgb, var(--warn) 18%, var(--tray));
  border-left: 3px solid var(--warn);
  border-radius: var(--r-sm);
  font-size: 13px; line-height: 1.5;
}

.banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 11px 13px;
  border-radius: var(--r-md); font-size: 13.5px; line-height: 1.45;
}
.banner.error { background: color-mix(in srgb, var(--warn) 22%, var(--tray)); }
.banner.info  { background: var(--raised); }
.banner .x {
  margin-left: auto; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  color: var(--dim); font-size: 13px;
}

/* ---------- buttons ---------- */

.btn {
  min-height: var(--tap); padding: 0 16px;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.ghost { background: var(--tray); color: var(--milk); }
.btn.primary { background: var(--rim); color: var(--milk); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .38; cursor: default; }

.bar { display: flex; gap: 8px; margin-top: 14px; }
.bar .btn { flex: 1; }
.bar.rolls { margin-top: 12px; }

.reset {
  display: block; width: 100%; margin: 30px 0 0;
  min-height: var(--tap);
  color: var(--warn); font-size: 13px; font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: var(--r-md);
}

/* ---------- rows (pantry, inbox, shop, combos, people) ---------- */

.row {
  display: flex; align-items: center; gap: 11px;
  min-height: 52px; padding: 9px 12px;
  margin-bottom: 5px;
  background: var(--tray); border-radius: var(--r-md);
}
.row.stack { flex-direction: column; align-items: stretch; gap: 9px; }
.row .rowtop { display: flex; align-items: center; gap: 11px; }
.row .rowbtns { display: flex; gap: 7px; }
.row .rowbtns .btn { flex: 1; }
/* Three actions do not fit side by side at 360px without truncating. */
.row .rowbtns.three { flex-wrap: wrap; }
.row .rowbtns.three .btn { flex: 1 1 30%; padding: 0 8px; font-size: 13px; }
.row.out { opacity: .5; }
.row .g { font-size: 19px; flex: none; }
.row .n { font-size: 14px; font-weight: 600; }
.row .meta { font-size: 12px; color: var(--dim); margin-top: 2px; }
.row .count { font-size: 13px; font-weight: 700; color: var(--dim); }

.del {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  color: var(--dim); font-size: 13px;
}

/* A pantry row swapped into edit mode. Outlined so it is obviously the one row
   you are changing, and so the surrounding rows still read as a list. */
.row.editing { outline: 1px solid var(--rim); outline-offset: -1px; gap: 7px; }
.row.editing input {
  min-height: 38px; padding: 8px 10px;
  background: var(--deep); border: 1px solid var(--faint);
  border-radius: var(--r-sm); font-size: 15px;
}
.row.editing .emoji { flex: none; width: 54px; text-align: center; }
.row.editing .btn { min-height: 38px; padding: 0 12px; font-size: 13px; }
/* A combo's edit row carries the same select-per-slot the new-combo form does. */
.row.editing select {
  min-height: 38px; padding: 8px 10px;
  background: var(--deep); border: 1px solid var(--faint);
  border-radius: var(--r-sm); font-size: 15px;
  flex: 1; min-width: 0;
}
.row.stack.editing .rowbtns { gap: 7px; }

/* The stock switch. This control is the permission system, so it is large,
   unambiguous, and reads as on/off at a glance from across a kitchen. */
.tog {
  flex: none; width: 50px; height: 30px; border-radius: 999px;
  background: var(--faint); position: relative;
  transition: background .15s;
}
.tog::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--dim); transition: transform .15s, background .15s;
}
.tog[aria-checked="true"] { background: color-mix(in srgb, var(--good) 55%, transparent); }
.tog[aria-checked="true"]::after { transform: translateX(20px); background: var(--milk); }

.pill {
  flex: none; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: var(--faint); color: var(--dim);
}
.p-new, .p-want { background: color-mix(in srgb, var(--snack) 30%, transparent); color: var(--milk); }
.p-out  { background: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--milk); }
.p-done { background: color-mix(in srgb, var(--good) 30%, transparent); color: var(--milk); }
/* Bought-but-not-pickable: distinct from p-done so the two outcomes are
   tellable apart at a glance in the handled list. */
.p-bought { background: color-mix(in srgb, var(--snack) 26%, transparent); color: var(--milk); }
.p-no   { background: var(--faint); }
.p-today { background: var(--rim); color: var(--milk); }

.minis { display: flex; flex-wrap: wrap; gap: 5px; }
.mini {
  padding: 4px 9px; border-radius: 999px;
  background: var(--faint); font-size: 12px;
}
.mini.out { opacity: .45; text-decoration: line-through; }

/* ---------- home: everyone, every day ---------- */

.days { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.day {
  background: var(--tray);
  border-radius: var(--r-lg);
  padding: 12px 13px 11px;
  border: 1px solid transparent;
}
.day.today { border-color: var(--rim); background: var(--raised); }

.dayhead { display: flex; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.dayhead h2 {
  font-family: var(--display); font-weight: 800;
  font-size: 13px; letter-spacing: .09em;
}
.dayhead .date { font-size: 12px; color: var(--dim); }
.dayhead .pill { margin-left: auto; }

/* One person's lunch for one day. The label column is fixed so three kids'
   worth of rows form a readable column rather than ragged text. */
.prow {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--faint);
}
.prow:first-of-type { border-top: 0; }

.pname {
  flex: none; width: 5.5em;
  font-size: 12.5px; font-weight: 600; color: var(--dim);
  padding-top: 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prow.me .pname { color: var(--milk); }

.pitems {
  flex: 1; min-width: 0;
  font-size: 13.5px; line-height: 1.45;
  padding: 6px 0;
  text-align: left;
}
.pitems.none { color: var(--ghost); font-style: italic; }

/* Your own row is a button; everyone else's is text. Underline-on-tap rather
   than a boxed button keeps five days of rows from looking like a form. */
.pitems.edit {
  min-height: var(--tap);
  padding: 6px 9px; margin: 0 -9px;
  border-radius: var(--r-sm);
  background: var(--faint);
}
.pitems.edit:active { background: var(--rim); }

.roll {
  flex: none; width: 38px; height: 38px; margin-top: 2px;
  border-radius: 50%;
  background: var(--faint); color: var(--dim);
  font-size: 16px;
}
.roll:active { background: var(--rim); color: var(--milk); }

/* A provisional suggestion, shown in place. Dashed because it is not yet real —
   nothing here has been written to the database. */
.draft {
  margin-top: 9px; padding: 11px;
  border: 1px dashed var(--rim); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--rim) 12%, transparent);
}
.draft.empty { border-style: solid; border-color: var(--faint); }
.draft p { font-size: 12px; color: var(--dim); }

.dsrc { font-size: 12px; color: var(--dim); margin-bottom: 7px; }

.dline {
  display: flex; gap: 10px; align-items: baseline;
  padding: 3px 0; font-size: 13.5px;
}
.dslot {
  flex: none; width: 4.5em;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim);
}
.dname { flex: 1; }

.draftbar { display: flex; gap: 7px; margin-top: 10px; }
.draftbar .btn { flex: 1; min-height: 38px; padding: 0 10px; font-size: 13px; }
.draftbar.inline { align-items: center; margin-top: 12px; }
.draftbar.inline .dsrc { flex: 1; margin: 0; }
.draftbar.inline .btn { flex: none; }

/* ---------- day: the tray ---------- */

.dayhead.big { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.dayhead.big h2 {
  font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -.01em;
}
.dayhead.big .date { font-size: 14px; color: var(--dim); font-weight: 400; }
.dayhead.big .sub { font-size: 12.5px; color: var(--dim); }

.back {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--tray); font-size: 17px;
}

/* Five compartments. Coupled to SLOTS in seed.js by design — a lunchbox has a
   physical shape, and the grid says so: one wide main, four smaller around it. */
.tray {
  display: grid; gap: 7px;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    'main  main'
    'fruit veg'
    'snack treat';
}
.a-main  { grid-area: main; }
.a-fruit { grid-area: fruit; }
.a-veg   { grid-area: veg; }
.a-snack { grid-area: snack; }
.a-treat { grid-area: treat; }

.slot {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 3px; padding: 14px 10px; min-height: 92px;
  border-radius: var(--r-lg);
  background: var(--tray);
  text-align: center;
}
.a-main.slot { min-height: 104px; }

.slot .g { font-size: 26px; line-height: 1; }
.slot .n { font-size: 14px; font-weight: 700; line-height: 1.25; }
.slot .s {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--dim); font-weight: 600;
}

.slot.full { color: var(--onfood); }
.slot.full .s { color: color-mix(in srgb, var(--onfood) 62%, transparent); }
.slot.full.a-main  { background: var(--main); }
.slot.full.a-fruit { background: var(--fruit); }
.slot.full.a-veg   { background: var(--veg); }
.slot.full.a-snack { background: var(--snack); }
.slot.full.a-treat { background: var(--treat); }

/* Empty is a resting state, not an error. Nobody has to fill five. */
.slot.empty { border: 1px dashed var(--faint); }
.slot.empty .g { opacity: .35; }

/* A suggested item is visibly not yet committed. */
.slot.suggested { outline: 2px dashed var(--rim); outline-offset: -2px; opacity: .82; }

.slot.gone { position: relative; }
.slot.gone::after {
  content: 'out of stock';
  position: absolute; inset-inline: 0; bottom: 6px;
  font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--warn);
}

/* Saved combos */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 13px;
  border-radius: 999px; background: var(--tray);
  font-size: 13px; font-weight: 600;
}
.chip .short { font-size: 11px; color: var(--dim); font-weight: 700; }

/* ---------- forms ---------- */

.form {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 12px; background: var(--tray); border-radius: var(--r-md);
}
.form input, .form select, .form textarea {
  min-height: var(--tap); padding: 10px 12px;
  background: var(--deep); border: 1px solid var(--faint);
  border-radius: var(--r-sm); font-size: 15px;   /* 15px+ stops iOS zooming on focus */
  flex: 1; min-width: 0;
}
.form .wide { flex-basis: 100%; }
.form .emoji { flex: none; width: 62px; text-align: center; }
.form textarea { min-height: 70px; resize: vertical; }

.fields { display: flex; flex-wrap: wrap; gap: 7px; flex-basis: 100%; }
.field { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; }
.field > span {
  flex: none; width: 4.5em;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim);
}

.pinbox {
  flex: 1; min-height: 40px; padding: 8px 12px;
  background: var(--deep); border: 1px solid var(--faint);
  border-radius: var(--r-sm); font-size: 15px;
  letter-spacing: .3em;
}

/* ---------- bottom nav ---------- */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--deep) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--faint);
}
.tab {
  position: relative;
  flex: 1; max-width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 50px; padding: 5px 2px;
  border-radius: var(--r-sm);
  color: var(--dim);
}
.tab[aria-pressed="true"] { color: var(--milk); background: var(--tray); }
.tab .g { font-size: 15px; line-height: 1.1; }
.tab .l { font-size: 10.5px; font-weight: 600; letter-spacing: .01em; }
.tab .badge {
  position: absolute; top: 2px; right: 50%; transform: translateX(15px);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--warn); color: var(--milk);
  font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
}

/* ---------- picker sheet ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: var(--shell); margin: 0 auto;
  max-height: 82vh; overflow-y: auto;
  padding: 8px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  background: var(--raised);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  transform: translateY(101%); transition: transform .22s cubic-bezier(.32, .72, 0, 1);
}
.sheet.open { transform: none; }

.grip {
  width: 38px; height: 4px; margin: 0 auto 12px;
  border-radius: 999px; background: var(--ghost);
}
.sheet h2 { font-family: var(--display); font-weight: 700; font-size: 17px; }
.sheet .sub { font-size: 12px; color: var(--dim); margin: 2px 0 12px; }

.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 7px; }
.opt {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 84px; padding: 11px 8px;
  background: var(--tray); border-radius: var(--r-md);
  text-align: center;
}
.opt.picked { outline: 2px solid var(--rim); outline-offset: -2px; }
.opt .g { font-size: 23px; line-height: 1; }
.opt .n { font-size: 12.5px; font-weight: 600; line-height: 1.25; }

/* Repeat tag: a nudge, never a block. They can eat grapes five days running. */
.opt .tag {
  position: absolute; top: 5px; right: 5px;
  padding: 1px 6px; border-radius: 999px;
  background: var(--fruit); color: var(--onfood);
  font-size: 9px; font-weight: 800; letter-spacing: .03em;
}

.sheet .btn.wide { margin-top: 9px; }

/* ---------- lock screen ---------- */

body.locked { overflow: hidden; }

.lock {
  min-height: 100dvh;
  max-width: 340px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px 0;
  text-align: center;
}
.lockhead .mark { font-size: 26px; margin-bottom: 8px; }
.lockmsg { font-size: 13.5px; color: var(--dim); line-height: 1.5; }

.dots { display: flex; gap: 11px; height: 14px; align-items: center; }
.dot {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1.5px solid var(--ghost); transition: background .12s, border-color .12s;
}
.dot.on { background: var(--milk); border-color: var(--milk); }

.dots.shake { animation: shake .32s; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.err { min-height: 34px; font-size: 12.5px; color: var(--warn); line-height: 1.4; padding: 0 10px; }

.pad { display: grid; grid-template-columns: repeat(3, 74px); gap: 12px; }
.key {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--tray);
  font-size: 25px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.key:active { background: var(--raised); }
.key.aux { background: none; font-size: 21px; color: var(--dim); }
.key.go { background: var(--rim); font-size: 24px; }
.key.go.off { opacity: .3; }
.key[disabled] { opacity: .4; }

.locknote { font-size: 11.5px; color: var(--ghost); }

/* ---------- wider screens ---------- */
/* Phones are the target. A laptop gets more air and a two-column week, but the
   layout is never re-thought for it — nobody plans lunches at a desk. */

@media (min-width: 560px) {
  /* Days stay full width at every size. A two-column grid fitted more days on
     screen but squeezed each row's item list, which is the actual content —
     you open this to read what everyone is eating, so horizontal room for the
     list beats seeing five cards at once. */
  .tray { grid-template-columns: repeat(3, 1fr);
    grid-template-areas: 'main main fruit' 'veg snack treat'; }
  .nav { border-radius: var(--r-lg) var(--r-lg) 0 0; max-width: var(--shell); margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
