/* ── DESIGN TOKENS — Silver Mist light theme ── */
:root {
  --bg:      #f4f5f7;
  --header:  #ffffff;
  --card:    #ffffff;
  --border:  rgba(0,0,0,0.08);
  --hborder: rgba(0,0,0,0.09);
  --teal:    #3b5bdb;
  --text:    #1a1a2e;
  --dim:     rgba(26,26,46,0.64);
  --muted:   rgba(26,26,46,0.52);
  --red:     #c92a2a;
  --input:   #f4f5f7;
  --fill:    rgba(0,0,0,0.04);   /* subtle surface tint (pills, thumbs, hovers) */
  --fill-2:  rgba(0,0,0,0.08);   /* stronger tint (hover on tinted controls) */
  --line:    rgba(0,0,0,0.13);   /* control borders */
  --toast-bg: #1a1a2e;
  --toast-fg: #ffffff;
  --avatar-bg: #dde8ff;
}

body.dark {
  --bg:      #0f1117;
  --header:  #1a1d27;
  --card:    #1e2130;
  --border:  rgba(255,255,255,0.08);
  --hborder: rgba(255,255,255,0.09);
  --text:    #e8eaf0;
  --dim:     rgba(232,234,240,0.66);
  --muted:   rgba(232,234,240,0.52);
  --red:     #ff6b6b;
  --input:   #252836;
  --fill:    rgba(255,255,255,0.05);
  --fill-2:  rgba(255,255,255,0.1);
  --line:    rgba(255,255,255,0.16);
  --toast-bg: #e8eaf0;
  --toast-fg: #1a1a2e;
  --avatar-bg: rgba(59,91,219,0.3);
}
body.dark .btn-danger { background: rgba(255,107,107,0.12); color: #ff6b6b; border-color: rgba(255,107,107,0.3); }
body.dark .btn-danger:hover { background: rgba(255,107,107,0.2); }

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
}

/* ══ SCREENS ═════════════════════════════════════════════════ */
.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ══ LOGIN SCREEN ════════════════════════════════════════════ */
#screen-login {
  background: var(--bg);
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}
.login-app-title {
  font-size: 22px; font-weight: 700;
  margin-bottom: 32px; text-align: center; width: 100%;
}
.login-card {
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--hborder);
  padding: 28px 20px;
  width: 100%; text-align: center;
}
.login-card-icon { font-size: 32px; margin-bottom: 10px; }
.login-card-head { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.login-card-sub  { font-size: 13px; color: var(--dim); margin-bottom: 20px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--fill);
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.google-btn:hover { background: var(--fill-2); }
.login-error {
  font-size: 12px; color: var(--red);
  margin-top: 10px; display: none;
}
.login-restricted { font-size: 11px; color: var(--muted); margin-top: 14px; }

/* ══ LOADING SCREEN ══════════════════════════════════════════ */
#screen-loading {
  background: var(--bg);
  align-items: center; justify-content: center;
  padding: 20px; gap: 14px; text-align: center;
}
.loading-logo { width: 56px; height: 56px; border-radius: 13px; }
.loading-text { font-size: 13px; color: var(--dim); max-width: 260px; line-height: 1.5; }

/* ══ UNAUTHORIZED SCREEN ═════════════════════════════════════ */
#screen-unauth {
  background: var(--bg);
  align-items: center; justify-content: center;
  padding: 20px; gap: 12px; text-align: center;
}

/* ══ HEADER ══════════════════════════════════════════════════ */
.header {
  background: var(--header);
  padding: calc(12px + env(safe-area-inset-top)) 16px 0;
  border-bottom: 1px solid var(--hborder);
  position: relative;   /* anchor for dropdown */
  flex-shrink: 0;
}
.header-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.app-title { font-size: 20px; font-weight: 700; }

/* User chip */
.user-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--fill);
  cursor: pointer; user-select: none;
}
.avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--avatar-bg); color: var(--teal);
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chip-name { font-size: 12px; }
.chevron   { font-size: 10px; color: var(--dim); }

/* Dropdown */
.dropdown {
  position: absolute; right: 16px; top: calc(48px + env(safe-area-inset-top));
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  border-radius: 10px; min-width: 180px;
  z-index: 50; display: none;
}
.dropdown.open { display: block; }
.dd-head  { padding: 12px 14px; border-bottom: 1px solid var(--hborder); }
.dd-name  { font-size: 13px; font-weight: 500; margin-bottom: 2px; color: var(--text); }
.dd-email { font-size: 11px; color: var(--dim); }
.dd-household { font-size: 11px; color: var(--teal); margin-top: 3px; }
.dd-item  {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; font-size: 13px; color: var(--dim);
  cursor: pointer; transition: background 0.1s;
}
.dd-item:hover { background: rgba(128,128,128,0.1); }
.dd-item:last-child { border-radius: 0 0 10px 10px; }

/* Install banner — sits between header-row and tabs */
.install-banner {
  display: none; align-items: center; gap: 10px; /* shown from JS (style.display) when an install prompt exists */
  padding: 8px 0 10px;
  font-size: 12px; color: var(--dim);
}
.install-btn {
  margin-left: auto;
  background: var(--teal); color: var(--header);
  border: none; border-radius: 20px;
  padding: 5px 12px; font-size: 11px; font-weight: 700;
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.dismiss-btn {
  background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: 14px;
  width: 32px; height: 32px; flex-shrink: 0;
}

/* Tabs — immediately below install banner */
.tabs { display: flex; }
.tab {
  flex: 1; text-align: center; padding: 10px 0;
  font-size: 13px; font-weight: 500; color: var(--dim);
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: color 0.15s;
}
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ══ SCROLL BODY ═════════════════════════════════════════════ */
.scroll-body {
  flex: 1; overflow-y: auto;
  background: var(--bg);
}
.tab-pane { display: none; padding: 12px; }
.tab-pane.active { display: block; }

/* Spacing between top-level pane children */
.tab-pane > * + * { margin-top: 10px; }

/* ══ SYNC FOOTER ═════════════════════════════════════════════ */
.sync-row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px calc(7px + env(safe-area-inset-bottom));
  background: rgba(59,91,219,0.05);
  border-top: 1px solid var(--hborder);
  flex-shrink: 0;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; }
.sync-dot.connected { background: #22c55e; }
.sync-dot.saving    { background: #eab308; animation: blink 1s infinite; }
.sync-dot.offline,
.sync-dot.error     { background: var(--red); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.sync-text { font-size: 11px; color: var(--muted); }

/* ══ CARDS ═══════════════════════════════════════════════════ */
.card {
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ══ BUTTONS ═════════════════════════════════════════════════ */
.btn {
  padding: 9px 14px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-family: inherit; white-space: nowrap; transition: all 0.15s;
}
.btn-teal   { background: var(--teal); color: #fff; }
.btn-teal:hover { opacity: 0.88; }
.btn-teal:disabled { opacity: 0.5; cursor: default; }
.btn-ghost  { background: var(--fill); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--fill-2); }
.btn-danger { background: rgba(201,42,42,0.08); color: var(--red); border: 1px solid rgba(201,42,42,0.2); }
.btn-danger:hover { background: rgba(201,42,42,0.15); }
.btn-danger:disabled { opacity: 0.35; cursor: default; }
.btn-danger:disabled:hover { background: rgba(239,68,68,0.12); }
.btn-sm { padding: 8px 12px; font-size: 12px; min-height: 34px; }
.btn-wrap { white-space: normal; text-align: center; line-height: 1.25; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 13px; transition: all 0.15s; flex-shrink: 0;
}
.icon-btn:hover   { background: var(--fill-2); color: var(--text); }
.icon-btn:disabled { opacity: 0.2; cursor: default; }
.icon-btn.teal:hover   { background: rgba(59,91,219,0.1); color: var(--teal); }
.icon-btn.danger:hover { background: rgba(201,42,42,0.1); color: var(--red); }

/* ══ INPUTS ══════════════════════════════════════════════════ */
input[type="text"], input[type="email"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px; color: var(--text);
  outline: none; font-family: inherit;
  transition: border-color 0.15s;
  -webkit-appearance: none; appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231a1a2e80' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px;
}
body.dark select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23e8eaf080' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
select option { background: var(--card); color: var(--text); }
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

/* ══ AUTOCOMPLETE ════════════════════════════════════════════ */
.ac-wrap { position: relative; flex: 2 1 0; min-width: 0; }
.add-row #item-amount { flex: 1 1 0; min-width: 0; width: auto; }
.add-row #item-unit  { flex: 1 1 0; min-width: 0; }
.ac-dd {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 200px; overflow-y: auto;
  z-index: 200; display: none;
}
.ac-dd.open { display: block; }
.ac-row {
  display: flex; align-items: center;
  padding: 9px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.ac-row:last-child { border-bottom: none; }
.ac-row:hover { background: var(--fill); }
.ac-row.active { background: rgba(59,91,219,0.1); }
.ac-name { flex: 1; }
.ac-forget {
  width: 36px; height: 36px; margin: -6px -6px -6px 0; flex-shrink: 0; border: none; background: transparent;
  cursor: pointer; color: var(--dim); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.ac-forget:hover { color: var(--red); background: rgba(201,42,42,0.1); }

/* ══ SECTION ROW ═════════════════════════════════════════════ */
.section-row {
  display: flex; flex-direction: row; align-items: center; justify-content: space-between;
}
.section-btns {
  display: flex; flex-direction: row; gap: 6px; align-items: center; flex-shrink: 0;
}
.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
}

/* ══ SHOPPING ════════════════════════════════════════════════ */
.add-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.add-row { display: flex; gap: 8px; align-items: flex-start; }
.cat-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  padding: 8px 2px 4px;
  display: flex; align-items: center; gap: 6px;
}
.cat-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  display: inline-block;
}
.s-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 52px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
.s-item:last-child { border-bottom: none; }
.s-item:hover { background: var(--fill); }
.s-item.done { opacity: 0.4; }
.check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0; transition: all 0.15s;
}
.check.done { background: var(--teal); border-color: var(--teal); color: var(--header); }
.s-name { font-size: 14px; flex: 1; min-width: 0; }
.s-name.done { text-decoration: line-through; }
.s-amount { font-size: 12px; color: var(--dim); margin-top: 2px; }
.s-more { margin: -8px -8px -8px 0; font-size: 18px; letter-spacing: 1px; }

/* ══ RECIPES ═════════════════════════════════════════════════ */
.recipe-grid { display: flex; flex-direction: column; gap: 6px; }
.recipe-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer; transition: background 0.1s;
  display: flex; align-items: center; gap: 0; overflow: hidden;
}
.recipe-card:hover { background: var(--fill); }
.recipe-thumb {
  width: 56px; height: 56px; flex-shrink: 0;
  background: var(--fill);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; overflow: hidden;
}
.recipe-thumb img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card-body { padding: 10px 12px; flex: 1; min-width: 0; }
.recipe-card-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.recipe-card-meta { font-size: 11px; color: var(--dim); margin-top: 2px; }

/* ══ WEEKLY PLAN ═════════════════════════════════════════════ */
.week-chips { display: flex; gap: 6px; }
.week-chip {
  flex: 1; position: relative;
  padding: 8px 0; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.week-chip.past { color: var(--muted); }
.week-chip.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip-dot { position: absolute; top: 4px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--teal); }
.week-chip.active .chip-dot { background: #fff; }
.week-head {
  background: var(--card); border-radius: 14px;
  border: 1px solid var(--border); padding: 10px 8px 8px;
}
.week-label { text-align: center; font-size: 13px; font-weight: 600; color: var(--dim); margin-bottom: 6px; }
.day-strip { display: flex; }
.strip-day {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border: none; border-radius: 10px; background: none;
  color: var(--text); font: inherit; cursor: pointer;
}
.strip-day.past { color: var(--muted); }
.strip-day.today { background: var(--fill); color: var(--teal); }
.strip-name { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.strip-num  { font-size: 15px; font-weight: 700; }
.strip-dot  { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--border); }
.strip-dot.on { background: var(--teal); border-color: var(--teal); }
.past-toggle {
  width: 100%; padding: 8px; border: none; background: none;
  color: var(--dim); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.day-card { scroll-margin-top: 12px; }
.day-add { display: flex; justify-content: flex-end; padding: 6px 12px; }
.day-empty-add {
  width: 100%; padding: 12px; border: none; background: none;
  color: var(--teal); font: inherit; font-size: 13px; font-weight: 600;
  text-align: left; cursor: pointer;
}
.week-footer {
  position: sticky; bottom: 0;
  padding: 8px 0; background: var(--bg);
}
.day-card {
  background: var(--card); border-radius: 12px;
  border: 1px solid var(--border); overflow: hidden;
}
.day-head {
  padding: 8px 12px;
  background: var(--fill);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.day-name { font-size: 13px; font-weight: 700; }
.day-card.day-today { border: 1.5px solid var(--teal); }
.day-today .day-name { color: var(--teal); }
.today-badge { font-size: 10px; font-weight: 700; color: #fff; background: var(--teal); border-radius: 10px; padding: 2px 7px; }
.day-past .day-name, .day-past .day-date { text-decoration: line-through; color: var(--muted); }
.day-date { font-size: 11px; color: var(--dim); }
.meal-row {
  display: flex; align-items: center;
  padding: 9px 12px; gap: 8px;
  border-bottom: 1px solid var(--border);
  min-height: 46px;
}
.meal-row:last-child { border-bottom: none; }
.meal-lbl {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
  width: 44px; flex-shrink: 0;
}

/* ══ EMPTY STATES ════════════════════════════════════════════ */
.empty { text-align: center; padding: 40px 16px; color: var(--dim); }
.empty-icon  { font-size: 38px; margin-bottom: 10px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-sub   { font-size: 13px; line-height: 1.5; }

/* ══ MODALS ══════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,26,46,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card);
  border-radius: 14px;
  width: calc(100% - 32px); max-width: 568px; min-width: 0;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  animation: fadeIn 0.2s ease;
}
.modal > * { flex-shrink: 0; }
.modal > .modal-body { flex: 1 1 auto; overflow-y: auto; }
/* Constant-height modal (settings tabs, recipe views): the body scrolls instead of the box resizing. */
.modal.modal-fixed { height: min(640px, calc(100vh - 32px)); height: min(640px, calc(100dvh - 32px)); }
@keyframes fadeIn  { from{opacity:0;transform:scale(0.97)} to{opacity:1;transform:scale(1)} }
.modal-head {
  display: flex; align-items: center;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 700; flex: 1; }
.modal-body  { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot  {
  display: flex; gap: 8px;
  padding: 10px 14px 18px;
  border-top: 1px solid var(--border);
}
.form-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--dim);
  display: block; margin-bottom: 6px;
}

/* ══ CATEGORY SETTINGS ═══════════════════════════════════════ */
.cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  transition: background 0.1s; border-radius: 6px;
}
.cat-row:last-child { border-bottom: none; }
.cat-row.dragging   { opacity: 0.35; }
.cat-row.drop-above { border-top: 2.5px solid var(--teal) !important; }
.cat-row.drop-below { border-bottom: 2.5px solid var(--teal) !important; }
.cat-row-name  { flex: 1; font-size: 14px; }
.cat-color {
  width: 26px; height: 26px; flex-shrink: 0; padding: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: none; cursor: pointer;
}
.cat-color::-webkit-color-swatch-wrapper { padding: 2px; }
.cat-color::-webkit-color-swatch { border: none; border-radius: 4px; }
.cat-row { flex-wrap: wrap; }
.cat-palette {
  flex-basis: 100%;
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px;
  padding: 8px 0 2px;
}
.cat-swatch {
  aspect-ratio: 1; min-width: 0; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.cat-swatch.selected { outline: 2.5px solid var(--text); outline-offset: 1px; }
.cat-custom {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  font-size: 13px; color: var(--dim); cursor: pointer;
}
.drag-handle {
  width: 28px; height: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: grab; touch-action: none;
  font-size: 16px; user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.saved-item-row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.saved-item-row:last-child { border-bottom: none; }
.saved-item-row input, .saved-item-row select { font-size: 13px; padding: 5px 6px; }
.default-badge {
  font-size: 10px; color: var(--muted);
  background: var(--fill);
  border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 4px;
}

/* ══ IMAGE UPLOAD ════════════════════════════════════════════ */
.img-zone {
  border: 2px dashed var(--line); border-radius: 10px;
  padding: 20px; text-align: center; cursor: pointer;
  transition: border-color 0.15s;
}
.img-zone:hover { border-color: var(--teal); }
.img-preview    { width: 100%; max-height: 160px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; display: none; }
.img-zone-text  { font-size: 13px; color: var(--muted); }

/* ══ WEEK INGREDIENTS ═══════════════════════════════════════ */
.wi-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.wi-row:last-child { border-bottom: none; }

/* ══ RECIPE CATEGORY FILTER ═════════════════════════════════ */
.recipe-cat-tabs { display: flex; gap: 6px; flex: 1; }
.recipe-cat-tab {
  padding: 8px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--card); color: var(--dim);
  transition: all 0.15s; white-space: nowrap;
}
.recipe-cat-tab.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.search-scope-hint { font-size: 12px; color: var(--dim); padding: 2px 4px 8px; }

/* ══ RECIPE DETAIL ═══════════════════════════════════════════ */
.recipe-hero {
  width: 100%; aspect-ratio: 16/9; max-height: 30vh;
  background: var(--fill);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; overflow: hidden;
}
.recipe-hero img { width: 100%; height: 100%; object-fit: cover; }
.recipe-sec { display: flex; flex-direction: column; gap: 8px; }
.recipe-sec-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.ing-lines { display: grid; grid-template-columns: max-content 1fr; font-size: 14px; line-height: 1.4; }
.ing-line-amt, .ing-line-name { padding: 7px 0; border-bottom: 1px solid var(--border); }
.ing-line-amt { padding-right: 12px; text-align: right; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ing-lines > :nth-last-child(-n+2) { border-bottom: none; }
.instructions { font-size: 13px; line-height: 1.8; color: var(--text); white-space: pre-wrap; }

/* ══ TOAST ═══════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: calc(40px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--toast-bg);
  color: var(--toast-fg); padding: 9px 18px;
  border-radius: 20px; font-size: 13px; font-weight: 500;
  opacity: 0; transition: all 0.25s; z-index: 900;
  display: flex; align-items: center;
  width: max-content; max-width: calc(100vw - 32px);
  text-align: center; line-height: 1.4; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-undo {
  margin-left: 12px; flex-shrink: 0; padding: 3px 12px; border: none; border-radius: 14px;
  background: var(--teal); color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
#confirm-dialog::backdrop { background: rgba(0,0,0,0.45); }

/* ══ MISC ════════════════════════════════════════════════════ */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

/* ══ UNIT SELECT (shopping add row) ════════════════════════ */
.unit-sel { flex: 1 1 0; min-width: 0; max-width: none; font-size: 12px; padding: 9px 24px 9px 8px; }

/* ══ BROWSE-ALL BUTTON ══════════════════════════════════════ */
.browse-btn {
  position: absolute; right: 0; top: 0; height: 38px; width: 34px;
  background: none; border: none; cursor: pointer;
  color: var(--dim); font-size: 14px; line-height: 1;
}
.browse-btn:hover { color: var(--text); }

/* ══ INGREDIENT LIST (recipe form) ═════════════════════════ */
.ing-list-row {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ing-list-row:last-child { border-bottom: none; }
.ing-list-row.ing-editing { background: rgba(59,91,219,0.06); border-radius: 6px; padding: 6px 6px; margin: 0 -6px; }
.ing-list-text { flex: 1; }

/* ══ CATEGORY NAME INLINE EDIT ══════════════════════════════ */
.cat-name-edit {
  border: 1px solid var(--teal); border-radius: 6px;
  padding: 4px 8px; font-size: 13px; font-family: inherit;
  outline: none; flex: 1; background: var(--input); color: var(--text);
}

/* ══ MEAL MULTIPLE ENTRIES ══════════════════════════════════ */
.meal-entry-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
}
.meal-entry-text { flex: 1; font-size: 13px; }
.meal-entry-recipe { flex: 1; font-size: 13px; color: var(--teal); }

/* ══ RECIPE PICKER MODAL ════════════════════════════════════ */
.recipe-pick-row {
  display: flex; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 14px; gap: 8px;
}
.recipe-pick-row:last-child { border-bottom: none; }
.recipe-pick-row:hover { background: var(--fill); }
.recipe-pick-row.selected { background: rgba(59,91,219,0.12); color: var(--teal); font-weight: 600; }
.recipe-pick-row.selected::after { content: '✓'; margin-left: auto; }

/* ══ CSP-SAFE HELPERS ═══════════════════════════════════════
   The Content-Security-Policy (style-src 'self') blocks inline style=""
   attributes and on*="" handlers. Use these classes instead; set dynamic
   values (e.g. category colors) from JS via element.style. */
.u-flex    { display: flex; }
.u-col     { display: flex; flex-direction: column; }
.u-center  { align-items: center; }
.u-start   { align-items: flex-start; }
.u-gap4    { gap: 4px; }
.u-gap6    { gap: 6px; }
.u-gap8    { gap: 8px; }
.u-gap10   { gap: 10px; }
.u-flex1   { flex: 1; }
.u-flex2   { flex: 2; }
.u-min0    { min-width: 0; }
.u-noshrink { flex-shrink: 0; }
.u-ml-auto { margin-left: auto; }
.u-mt4     { margin-top: 4px; }
.u-mb0     { margin-bottom: 0; }
.u-mb6     { margin-bottom: 6px; }
.u-mb8     { margin-bottom: 8px; }
.u-mb12    { margin-bottom: 12px; }
.u-w100    { width: 100%; }
.u-rel     { position: relative; }
input.u-pr28 { padding-right: 28px; }
.u-spacer  { height: 16px; }
.u-hidden  { display: none !important; }
.u-text-center { text-align: center; }
.u-pointer { cursor: pointer; }
.u-fs11    { font-size: 11px; }
.u-fs13    { font-size: 13px; }
.u-fs14    { font-size: 14px; }
.u-fs20    { font-size: 20px; }

.login-logo { width: 22px; height: 22px; border-radius: 5px; vertical-align: middle; margin-right: 4px; }
.unauth-icon  { font-size: 36px; }
.unauth-title { font-size: 16px; font-weight: 600; }
.unauth-text  { font-size: 13px; color: var(--dim); max-width: 240px; line-height: 1.5; }
#recipe-sort  { flex-shrink: 0; width: 110px; font-size: 12px; padding: 9px 24px 9px 8px; }

.stepper-btn  { font-size: 20px; border: 1px solid var(--line); }
.stepper-btn-sm { width: 36px; height: 36px; font-size: 16px; border: 1px solid var(--line); }
.stepper-val  { font-size: 16px; font-weight: 700; min-width: 24px; text-align: center; }
.stepper-val-sm { font-size: 14px; font-weight: 700; min-width: 18px; text-align: center; }
.text-dim-12  { font-size: 12px; color: var(--dim); }
.text-dim-13  { font-size: 13px; color: var(--dim); }
.hint         { font-size: 12px; color: var(--muted); }
.hint-13      { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.empty-note   { color: var(--muted); text-align: center; padding: 20px 0; }
.small-badge  { font-size: 10px; color: var(--muted); background: var(--fill); border-radius: 4px; padding: 1px 5px; flex-shrink: 0; }
.in-list-hint { font-size: 11px; color: var(--teal); margin-top: 2px; display: block; }
.item-title   { font-size: 14px; font-weight: 600; }

.meal-row.meal-row-stack { flex-direction: column; align-items: stretch; padding: 8px 12px; gap: 4px; }
.meal-row.meal-row-stack:last-child { border-bottom: 1px solid var(--border); } /* matches the pre-CSP inline style */
.meal-lbl.meal-lbl-wide  { width: 52px; }
.meal-past { text-decoration: line-through; color: var(--muted); }
.recipe-list-box { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.recipe-list-empty { padding: 12px; font-size: 13px; color: var(--dim); }

.wi-amt  { width: 60px; flex-shrink: 0; font-size: 13px; padding: 5px 8px; text-align: center; }
input[type="text"].wi-amt { width: 60px; font-size: 13px; padding: 5px 8px; }
select.wi-unit { width: 90px; flex-shrink: 0; font-size: 12px; padding: 5px 4px; }
.modal-body.tight { gap: 8px; }
.modal-head.bordered { border-top: 1px solid var(--border); }
.saved-item-row.stack { flex-direction: column; align-items: stretch; gap: 6px; }

.ing-add-box { margin-top: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ing-amt-fixed { flex: 0 0 62px; }
.import-box { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.source-link { display: inline-block; font-size: 13px; color: var(--teal); text-decoration: none; }
.check-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); cursor: pointer; user-select: none; }
.check-label input[type="checkbox"] { width: auto; accent-color: var(--teal); }
.ing-amt-unit { color: var(--dim); font-size: 12px; }
.img-preview.has-img { display: block; }

.confirm-body    { padding: 24px 20px 16px; }
.confirm-msg     { margin: 0; font-size: 15px; line-height: 1.5; color: var(--text); }
.confirm-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.btn-solid-red   { background: var(--red); color: #fff; }

/* ══ SHOPPING MODE ═══════════════════════════════════════════ */
.icon-btn.on { background: rgba(59,91,219,0.14); color: var(--teal); }
.done-toggle {
  text-align: center; padding: 10px; font-size: 12px; color: var(--dim);
  cursor: pointer; user-select: none;
}
.done-toggle:hover { color: var(--text); }

/* ══ FOCUS (keyboard users) ══════════════════════════════════ */
[role="button"]:focus-visible, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ══ HOUSEHOLD MEMBERS ═══════════════════════════════════════ */
.member-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: none; }

a.btn { text-decoration: none; }

/* ══ TOUCH: 16px inputs so iOS doesn't auto-zoom on focus (pinch-zoom is allowed) ══ */
@media (pointer: coarse) {
  input[type="text"], input[type="email"], input[type="url"], input[type="number"], select, textarea,
  input[type="text"].wi-amt, select.wi-unit, .unit-sel, #recipe-sort, .cat-name-edit,
  .saved-item-row input, .saved-item-row select { font-size: 16px; }
}

/* ══ SHOPPING: new items from others, swipe to delete ═══════ */
.s-item.s-new { box-shadow: inset 3px 0 0 var(--teal); }
.new-badge {
  font-size: 10px; font-weight: 700; color: #fff; background: var(--teal);
  border-radius: 8px; padding: 1px 6px; margin-left: 4px; vertical-align: 2px;
}
.s-item { touch-action: pan-y; }
.s-item.swiping { position: relative; background: var(--card); }
.s-item.swiping::after {
  content: 'Ta bort'; position: absolute; top: 0; bottom: 0; left: 100%; width: 100%;
  display: flex; align-items: center; padding-left: 18px;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 600;
}
.s-item.swipe-settle { transition: transform 0.15s ease-out; }

/* ══ WEEKLY: leftovers, suggestions ══════════════════════════ */
.meal-leftover-from { font-size: 11px; color: var(--muted); }
.suggest-btn { margin-top: 10px; }
.sg-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.sg-row:last-child { border-bottom: none; }
.sg-day { width: 96px; flex-shrink: 0; font-size: 13px; color: var(--text); }
.sg-name { flex: 1; min-width: 0; font-size: 14px; color: var(--teal); }
