/* ===================== Theme tokens ===================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --surface-3: #e9eaf2;
  --border: #e7e8f0;
  --border-strong: #d6d8e4;
  --text: #131320;
  --muted: #6a6b82;
  --accent: #6d5efc;
  --accent-2: #d946ef;
  --accent-hover: #5b4cf0;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(109, 94, 252, 0.10);
  --success: #0a7c52;
  --success-soft: #e7f7ef;
  --warn: #b15c00;
  --warn-soft: #fdf2e2;
  --danger: #d92d20;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(18, 18, 40, 0.05);
  --shadow: 0 2px 8px rgba(18, 18, 40, 0.07), 0 1px 2px rgba(18, 18, 40, 0.04);
  --shadow-lg: 0 18px 48px rgba(18, 18, 40, 0.14);
  --ring: 0 0 0 3px var(--accent-soft);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #0a0a12;
  --surface: #14141f;
  --surface-2: #1b1b29;
  --surface-3: #242436;
  --border: #262635;
  --border-strong: #34344a;
  --text: #f3f3f9;
  --muted: #9b9cb6;
  --accent: #8b7cff;
  --accent-2: #e879f9;
  --accent-hover: #9d90ff;
  --accent-contrast: #0a0a12;
  --accent-soft: rgba(139, 124, 255, 0.16);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf57;
  --warn-soft: rgba(251, 191, 87, 0.14);
  --danger: #ff6b5e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* The cart drawer/chat sit off-canvas to the right; clip the horizontal axis
   so they can't create page-wide horizontal scroll on mobile. `clip` (not
   `hidden`) avoids creating a scroll container, so the sticky topbar still works. */
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.025em; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }

/* ===================== Icons ===================== */
.icon { display: inline-block; vertical-align: -0.18em; flex: none; }
.icon-btn {
  align-items: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  padding: 0;
  width: 40px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.08s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }

/* ===================== Buttons & inputs ===================== */
button {
  align-items: center;
  background: var(--accent);
  background-image: var(--grad);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 600;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  transition: filter 0.18s ease, transform 0.08s ease, box-shadow 0.18s ease, background 0.18s ease;
}
button:hover { filter: brightness(1.05); box-shadow: 0 6px 18px var(--accent-soft); }
button:active { transform: translateY(1px) scale(0.99); }
button:disabled { background: var(--surface-2); background-image: none; color: var(--muted); cursor: not-allowed; border-color: var(--border); box-shadow: none; filter: none; }

button.secondary {
  background: var(--surface);
  background-image: none;
  border-color: var(--border-strong);
  color: var(--text);
}
button.secondary:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }
button.secondary.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

button.ghost {
  background: transparent;
  background-image: none;
  border-color: transparent;
  color: var(--muted);
  min-height: 36px;
  padding: 0 10px;
}
button.ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  min-height: 44px;
  padding: 11px 13px;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
textarea { min-height: 110px; resize: vertical; }
label { color: var(--text); font-size: 0.85rem; font-weight: 600; }

/* ===================== Top bar ===================== */
.topbar {
  align-items: center;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 13px clamp(16px, 4vw, 48px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { align-items: center; color: var(--text); display: inline-flex; font-weight: 700; gap: 11px; }
.brand-logo { display: block; height: 42px; width: 42px; }
.brand-name { font-size: 1.5rem; letter-spacing: -0.03em; }
.brand-dot { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tag {
  background: var(--accent-soft); border-radius: 6px; color: var(--accent);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.07em; margin-left: 5px; padding: 3px 7px; text-transform: uppercase;
}
.topbar-actions { align-items: center; display: flex; gap: 12px; }
.link-muted { align-items: center; color: var(--muted); display: inline-flex; font-size: 0.92rem; font-weight: 600; gap: 6px; }
.link-muted:hover { color: var(--text); }

/* Square icon button matching .icon-btn; the count rides as a corner badge. */
.cart-btn {
  background: var(--surface); background-image: none; border: 1px solid var(--border-strong); color: var(--text);
  height: 40px; width: 40px; min-height: 40px; padding: 0; position: relative;
}
.cart-btn:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); filter: none; }
.cart-count {
  position: absolute; top: -5px; right: -5px;
  background: var(--grad); border-radius: 999px; box-shadow: 0 0 0 2px var(--surface); color: #fff;
  display: grid; place-items: center; font-size: 0.62rem; font-weight: 700; height: 17px; line-height: 1; min-width: 17px; padding: 0 4px;
}
.cart-count:not(.has-items) { display: none; }

/* ===================== Storefront ===================== */
.shop { display: grid; gap: 34px; margin: 0 auto; max-width: 1140px; padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 64px; }

.shop-hero {
  text-align: center;
  position: relative;
  padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 32px);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}
.shop-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(90% 120% at 50% -10%, var(--accent-soft), transparent 60%);
}
.shop-hero > * { position: relative; }
.shop-hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.08; margin: 0 auto; max-width: 820px; }
.shop-hero h1 .accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--muted); font-size: 1.06rem; margin: 16px auto 0; max-width: 580px; }

.store-finder { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 22px auto 0; max-width: 660px; color: var(--muted); }
.store-finder > .icon { color: var(--accent); flex: none; }
.store-finder label { align-items: center; display: flex; gap: 8px; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.store-finder select { min-height: 40px; min-width: 0; }
.searchbar { display: flex; gap: 10px; margin: 18px auto 0; max-width: 660px; }
.searchbar .input-wrap { flex: 1; position: relative; }
.searchbar .input-wrap .icon { color: var(--muted); left: 14px; pointer-events: none; position: absolute; top: 50%; transform: translateY(-50%); }
.searchbar input { min-height: 52px; padding-left: 44px; }
.searchbar button { min-height: 52px; white-space: nowrap; }

.recipe-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); display: grid; gap: 12px; margin: 16px auto 0; max-width: 660px; padding: 22px; text-align: left;
  animation: fadeInUp 0.3s ease;
}

/* Feature tiles (hero) */
.feature-tiles { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); margin: 18px auto 0; max-width: 760px; }
.feature-tile {
  align-items: center; background: var(--surface); background-image: none; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); cursor: pointer; display: flex; gap: 12px; justify-content: flex-start;
  min-height: 64px; padding: 14px 16px; text-align: left; transition: border-color 0.18s ease, box-shadow 0.2s ease, transform 0.18s ease;
}
.feature-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); filter: none; }
.feature-tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.ft-icon { align-items: center; background: var(--grad); border-radius: 11px; color: #fff; display: inline-flex; flex: none; height: 40px; justify-content: center; width: 40px; }
.ft-text { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; min-width: 0; }
.ft-text strong { font-size: 0.96rem; }
.ft-text span { color: var(--muted); font-size: 0.8rem; }

/* Inline tool panel opened by a tile */
.tool-panel { animation: fadeInUp 0.22s ease; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); display: grid; gap: 14px; margin: 14px auto 0; max-width: 660px; padding: 22px; text-align: left; }
.tool { display: grid; gap: 12px; }
.tool label[for] { font-size: 0.85rem; }

.creator-row { display: flex; gap: 10px; }
.creator-row input { flex: 1; min-height: 48px; }
.creator-row button { min-height: 48px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface-2); background-image: none; border: 1px solid var(--border-strong);
  border-radius: 999px; color: var(--text); font-size: 0.85rem; font-weight: 500;
  min-height: 34px; padding: 0 14px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); box-shadow: none; filter: none; }
.link-btn { background: transparent; background-image: none; border: none; color: var(--accent); font-weight: 600; justify-content: flex-start; min-height: auto; padding: 2px 0; }
.link-btn:hover { filter: none; box-shadow: none; text-decoration: underline; }

/* Meal planner controls + cards */
.meal-controls { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 12px; padding: 14px; animation: fadeInUp 0.2s ease; }
.meal-controls-row { display: flex; flex-wrap: wrap; gap: 12px; }
.meal-controls-row label { align-items: center; color: var(--muted); display: flex; flex: 1; font-size: 0.8rem; gap: 8px; min-width: 120px; text-transform: uppercase; letter-spacing: 0.04em; }
.meal-controls-row select, .meal-controls-row input { min-height: 40px; flex: 1; }
.meal-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.meal-card-head { align-items: center; display: flex; gap: 12px; justify-content: space-between; }
.meal-card-head button { min-height: 34px; padding: 0 14px; white-space: nowrap; }
.meal-recipe:not(:empty) { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }

/* Recipe creator result card */
.recipe-result { animation: fadeInUp 0.25s ease; display: grid; gap: 6px; }
.recipe-head { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.recipe-head h3 { font-size: 1.2rem; }
.recipe-steps { color: var(--text); display: grid; gap: 8px; margin: 4px 0 0; padding-left: 20px; }
.recipe-steps li { font-size: 0.92rem; line-height: 1.5; padding-left: 4px; }
.recipe-steps li::marker { color: var(--accent); font-weight: 700; }
.nutri-grid { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); }
.nutri { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; }
.nutri span { display: block; font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }
.nutri small { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

.results-head { align-items: baseline; border-bottom: 1px solid var(--border); display: flex; gap: 12px; justify-content: space-between; margin-bottom: 20px; padding-bottom: 14px; }
.results-head h2 { font-size: 1.25rem; }

.shop-footer { align-items: center; border-top: 1px solid var(--border); display: flex; justify-content: space-between; padding-top: 22px; flex-wrap: wrap; gap: 10px; }

/* ===================== Shared bits ===================== */
.eyebrow { color: var(--accent); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.09em; margin: 0 0 10px; text-transform: uppercase; }
.meta { color: var(--muted); font-size: 0.86rem; }
.muted { color: var(--muted); }
.muted-empty { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); font-size: 0.9rem; padding: 22px; text-align: center; }
.stack { display: grid; gap: 12px; }
.button-row, .search-row, .total-row { align-items: center; display: flex; gap: 12px; }

/* ===================== Cards & product grid ===================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: border-color 0.18s ease, box-shadow 0.2s ease, transform 0.2s ease; }
.card h3 { font-size: 0.98rem; }

.product-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.product-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; animation: fadeInUp 0.32s ease both; }
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.product-thumb { aspect-ratio: 4 / 3; background: var(--surface-2); object-fit: cover; width: 100%; transition: transform 0.4s ease; }
.product-card:hover .product-thumb { transform: scale(1.04); }
.product-thumb.placeholder { align-items: center; color: #fff; display: flex; flex-direction: column; gap: 7px; justify-content: center; }
.product-thumb.placeholder .icon { opacity: 0.96; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18)); }
.product-thumb.placeholder span { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.07em; opacity: 0.92; text-transform: uppercase; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.product-body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 15px 16px 16px; }
.product-body h3 { font-size: 0.98rem; }
.product-foot { align-items: center; display: flex; gap: 8px; justify-content: space-between; margin: 8px 0 12px; }
.product-body button { margin-top: auto; }
.product-admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.product-admin-actions button { flex: 1; margin-top: 0; min-height: 38px; min-width: 0; padding: 0 10px; }
.product-admin-actions .ghost { flex: none; }
.product-card.is-hidden { opacity: 0.62; }
.price { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; }
.price-large { font-size: 2.3rem; font-weight: 800; letter-spacing: -0.03em; margin: 8px 0; }

/* ===================== Badges ===================== */
.badge { align-items: center; border-radius: 999px; display: inline-flex; font-size: 0.74rem; font-weight: 600; gap: 4px; padding: 3px 10px; }
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ===================== Recipe matches / AI lists ===================== */
.match-card { background: var(--surface-2); border-radius: var(--radius); display: grid; gap: 10px; padding: 14px; }
.match-item { align-items: center; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: space-between; padding-top: 10px; }
.match-item:first-of-type { border-top: none; padding-top: 0; }
.match-item button { min-height: 36px; padding: 0 14px; flex: none; }
/* Long product names must wrap, not force horizontal overflow. */
.match-item > div:first-child, .cart-item > div:first-child { min-width: 0; }
.match-item strong, .cart-item h3 { overflow-wrap: anywhere; }
.split-label { color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; margin-top: 10px; text-transform: uppercase; }
.split-row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 3px 0; }
.ai-sub-btn { margin-top: 8px; }
.ai-subs:not(:empty) { margin-top: 10px; }

/* ===================== Cart drawer ===================== */
.overlay { background: rgba(8, 8, 16, 0.5); inset: 0; position: fixed; z-index: 40; animation: fade 0.2s ease; }
.drawer {
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; height: 100dvh; max-width: 92vw; position: fixed; right: 0; top: 0;
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1); width: 420px; z-index: 50;
}
.drawer.open { transform: translateX(0); }
.drawer-head { align-items: center; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; padding: 18px 22px; }
.drawer-head h2 { font-size: 1.15rem; }
.drawer-body { align-content: start; display: grid; flex: 1; gap: 2px; overflow-y: auto; padding: 8px 22px; }
.drawer-foot { border-top: 1px solid var(--border); display: grid; gap: 12px; padding: 18px 22px; }
.drawer-foot > button { width: 100%; }
.cart-item { align-items: center; border-bottom: 1px solid var(--border); display: flex; gap: 12px; justify-content: space-between; padding: 14px 0; animation: fadeInUp 0.2s ease; }
.cart-item h3 { font-size: 0.95rem; }
.cart-line-actions { align-items: center; display: flex; gap: 8px; flex: none; }
.qty { align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); display: inline-flex; overflow: hidden; }
.qty button { background: var(--surface); background-image: none; border: none; border-radius: 0; color: var(--text); min-height: 34px; min-width: 34px; padding: 0; }
.qty button:hover { background: var(--surface-2); box-shadow: none; filter: none; }
.qty span { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 30px; text-align: center; }
.total-row { align-items: center; display: flex; font-size: 1.05rem; justify-content: space-between; }
.total-row strong { font-size: 1.4rem; letter-spacing: -0.02em; }
.checkout-form { display: grid; gap: 10px; }
.checkline { align-items: center; color: var(--text); display: flex; font-weight: 500; gap: 10px; }
.checkline input { min-height: auto; width: auto; }
.notice-warn { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: var(--radius-sm); color: var(--warn); font-size: 0.86rem; font-weight: 600; padding: 10px 12px; }
.notice-ok { background: var(--success-soft); border: 1px solid var(--success); border-radius: var(--radius-sm); color: var(--success); font-size: 0.86rem; font-weight: 600; padding: 10px 12px; }
.message { color: var(--success); font-size: 0.9rem; font-weight: 600; min-height: 1.1em; }
.message.error { color: var(--danger); }

/* ===================== Auth gate ===================== */
.auth-gate { align-items: center; display: flex; justify-content: center; min-height: calc(100dvh - 130px); padding: 24px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); max-width: 400px; padding: 34px; width: 100%; animation: fadeInUp 0.3s ease; }
.auth-card h1 { font-size: 1.55rem; margin-bottom: 6px; }
.auth-card .form-grid { margin-top: 22px; }

/* ===================== Admin ===================== */
.admin { display: grid; gap: 24px; margin: 0 auto; max-width: 1140px; padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 64px; }
.admin-head { align-items: center; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; }
.admin-head h1 { font-size: 1.6rem; }
.stat-row { display: flex; gap: 12px; }
.stat-mini { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 20px; text-align: center; box-shadow: var(--shadow-sm); }
.stat-mini span { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; }
.stat-mini small { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
.tabs { border-bottom: 1px solid var(--border); display: flex; gap: 4px; overflow-x: auto; }
.tab { background: transparent; background-image: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); font-weight: 600; min-height: 42px; padding: 0 16px; white-space: nowrap; }
.tab:hover { background: transparent; color: var(--text); box-shadow: none; filter: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-badge { background: var(--grad); border-radius: 999px; color: #fff; font-size: 0.7rem; font-weight: 700; margin-left: 4px; padding: 1px 7px; }
.analytics { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 8px; margin-bottom: 18px; padding: 16px 18px; }
.analytics:empty { display: none; }
.analytics-row { display: flex; gap: 12px; }
.analytics-row .stat-mini { flex: 1; }
.tab-panel { display: grid; gap: 18px; animation: fade 0.25s ease; }
.add-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.add-card summary { cursor: pointer; font-weight: 600; list-style: none; padding: 16px 18px; }
.add-card summary::-webkit-details-marker { display: none; }
.add-card[open] summary { border-bottom: 1px solid var(--border); }
.add-card form, .add-card .form-grid { padding: 18px; }
.form-grid, .form-grid.two { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.two button { grid-column: 1 / -1; }
.search-row { align-items: center; display: flex; gap: 12px; }
.file-field { display: grid; gap: 6px; }
.file-field input[type="file"] { background: var(--surface-2); border: 1px dashed var(--border-strong); cursor: pointer; padding: 10px 12px; }
.file-field input[type="file"]::file-selector-button { background: var(--accent-soft); border: none; border-radius: var(--radius-sm); color: var(--accent); cursor: pointer; font-weight: 600; margin-right: 10px; padding: 6px 12px; }
.sub-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 12px; }
.sub-block summary { cursor: pointer; font-size: 14px; font-weight: 600; list-style: none; padding: 8px 0; }
.sub-block summary::-webkit-details-marker { display: none; }
.sub-block[open] { padding-bottom: 12px; }
.sub-block > * + * { margin-top: 8px; }
.icon-btn.signed-in { border-color: var(--accent); color: var(--accent); }
.order-line { align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); display: flex; gap: 10px; justify-content: space-between; padding: 12px 14px; transition: border-color 0.18s ease; }
.order-line:hover { border-color: var(--accent); }
.order-card { display: grid; gap: 6px; }
.order-card .order-id { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; }
.order-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.order-actions button { min-height: 38px; padding: 0 14px; }

/* Order fulfillment step indicator (shopper order-status page) */
.order-steps { display: flex; flex-wrap: wrap; gap: 6px 4px; list-style: none; margin: 14px 0 4px; padding: 0; }
.order-steps .step { align-items: center; color: var(--muted); display: flex; flex: 1; gap: 7px; font-size: 0.82rem; font-weight: 600; min-width: 120px; }
.order-steps .dot { align-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 999px; color: #fff; display: inline-flex; flex: none; height: 22px; justify-content: center; width: 22px; }
.order-steps .step.done { color: var(--text); }
.order-steps .step.done .dot, .order-steps .step.current .dot { background: var(--grad); border-color: transparent; }
.order-steps .step.current { color: var(--text); }
.order-steps .step.current .dot { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ===================== Product detail / docs ===================== */
.page-narrow { display: grid; margin: 0 auto; max-width: 880px; padding: clamp(20px, 4vw, 40px); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 28px; }
.button-link { background: var(--accent); background-image: var(--grad); border-radius: var(--radius-sm); color: #fff; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 16px; padding: 12px 18px; transition: filter 0.18s ease, box-shadow 0.18s ease; }
.button-link:hover { filter: brightness(1.05); box-shadow: 0 6px 18px var(--accent-soft); }
.product-detail { align-items: center; display: grid; gap: 32px; grid-template-columns: minmax(240px, 0.5fr) minmax(0, 1fr); }
.product-detail img, .product-placeholder { aspect-ratio: 1 / 1; border: 1px solid var(--border); border-radius: var(--radius); object-fit: cover; width: 100%; }
.product-placeholder { align-items: center; background: var(--surface-2); color: var(--muted); display: flex; justify-content: center; }
.endpoint-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-top: 8px; }
code { background: var(--surface-3); border-radius: var(--radius-sm); color: var(--text); display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; overflow-wrap: anywhere; padding: 12px 14px; }
code .verb { color: var(--accent); font-weight: 700; margin-right: 8px; }
.inline-link { color: var(--accent); font-size: 0.85rem; font-weight: 600; }

/* ===================== AI assistant ===================== */
.chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 45; border-radius: 999px; box-shadow: var(--shadow-lg); min-height: 50px; padding: 0 20px; font-weight: 700; animation: fadeInUp 0.3s ease; }
.chat-panel { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: min(390px, calc(100vw - 40px)); height: min(580px, calc(100dvh - 40px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; animation: scaleIn 0.22s cubic-bezier(0.32, 0.72, 0, 1); transform-origin: bottom right; }
.chat-head { align-items: center; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; padding: 15px 16px; }
.chat-head .chat-title { align-items: center; display: flex; gap: 9px; }
.chat-head .chat-avatar { align-items: center; background: var(--grad); border-radius: 9px; color: #fff; display: inline-flex; height: 30px; justify-content: center; width: 30px; }
.chat-log { display: flex; flex: 1; flex-direction: column; gap: 10px; overflow-y: auto; padding: 16px; }
.chat-msg { border-radius: 14px; font-size: 0.92rem; line-height: 1.5; max-width: 90%; padding: 10px 13px; animation: fadeInUp 0.2s ease; }
.chat-user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 4px; }
.chat-assistant { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.chat-assistant .match-item { border-top-color: var(--border-strong); }
.chat-assistant .match-item button { min-height: 32px; padding: 0 12px; }
.chat-input { border-top: 1px solid var(--border); display: flex; gap: 8px; padding: 12px; }
.chat-input input { min-height: 44px; }
.chat-input button { flex: none; min-width: 48px; padding: 0 14px; }
.chat-add-all { width: 100%; margin-top: 8px; min-height: 38px; }
.chat-assistant .match-item:first-of-type { border-top: 1px solid var(--border-strong); margin-top: 8px; padding-top: 10px; }

/* ===================== Animations ===================== */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ===================== Landing page ===================== */
.landing { margin: 0 auto; max-width: 1100px; padding: 0 clamp(16px, 4vw, 40px) 40px; }
/* Link styled as a button (CTAs are <a>, not <button>). */
.lp-btn { align-items: center; background: var(--accent); background-image: var(--grad); border: 1px solid transparent; border-radius: var(--radius-sm); color: #fff; cursor: pointer; display: inline-flex; font-weight: 600; gap: 8px; justify-content: center; min-height: 40px; padding: 0 18px; text-decoration: none; transition: filter 0.18s ease, box-shadow 0.18s ease, transform 0.08s ease; }
.lp-btn:hover { filter: brightness(1.05); box-shadow: 0 6px 18px var(--accent-soft); }
.lp-btn:active { transform: translateY(1px); }
.lp-btn-lg { min-height: 52px; padding: 0 28px; font-size: 1.02rem; border-radius: var(--radius); }
.lp-btn-ghost { background: var(--surface); background-image: none; border-color: var(--border-strong); color: var(--text); }
.lp-btn-ghost:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }

.lp-hero { text-align: center; position: relative; overflow: hidden; padding: clamp(40px, 8vw, 92px) clamp(16px, 4vw, 32px) clamp(28px, 5vw, 52px); }
.lp-hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(80% 90% at 50% -10%, var(--accent-soft), transparent 62%); }
.lp-hero > * { position: relative; }
.lp-hero h1 { font-size: clamp(2.3rem, 6vw, 4rem); line-height: 1.05; margin: 6px auto 0; max-width: 16ch; }
.lp-hero h1 .accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-lede { color: var(--muted); font-size: 1.12rem; margin: 18px auto 0; max-width: 600px; }
.lp-hero-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 28px; }
.lp-hero-note { color: var(--muted); font-size: 0.85rem; margin-top: 16px; }

.lp-section { padding: clamp(40px, 7vw, 72px) 0; border-top: 1px solid var(--border); }
.lp-section-head { text-align: center; max-width: 640px; margin: 0 auto clamp(24px, 4vw, 40px); }
.lp-section-head h2 { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -0.03em; }
.lp-sub { color: var(--muted); font-size: 1.05rem; margin-top: 10px; }

.lp-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.lp-feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; transition: border-color 0.18s ease, box-shadow 0.2s ease, transform 0.2s ease; }
.lp-feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.lp-feature h3 { font-size: 1.05rem; margin-top: 14px; }
.lp-feature p { color: var(--muted); font-size: 0.92rem; margin-top: 6px; line-height: 1.5; }
.lp-ficon { align-items: center; background: var(--accent-soft); border-radius: 12px; color: var(--accent); display: inline-flex; height: 46px; justify-content: center; width: 46px; }
.lp-ficon svg { width: 24px; height: 24px; }

.lp-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.lp-steps li { display: flex; gap: 14px; align-items: flex-start; }
.lp-step-n { align-items: center; background: var(--grad); border-radius: 999px; color: #fff; display: inline-flex; flex: none; font-weight: 800; height: 34px; justify-content: center; width: 34px; }
.lp-steps h3 { font-size: 1.02rem; }
.lp-steps p { color: var(--muted); font-size: 0.92rem; margin-top: 3px; }
.lp-center { text-align: center; margin-top: 32px; }

.lp-agent-inner { align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); display: grid; grid-template-columns: 1.5fr 0.5fr; gap: 24px; padding: clamp(24px, 4vw, 44px); }
.lp-agent h2 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
.lp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.lp-agent-links { margin-top: 16px; font-size: 0.88rem; }
.lp-agent-art { align-items: center; color: var(--accent); display: flex; justify-content: center; }
.lp-agent-art svg { width: clamp(90px, 16vw, 150px); height: auto; opacity: 0.9; filter: drop-shadow(0 10px 26px var(--accent-soft)); }

.lp-cta { text-align: center; position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); margin: clamp(30px, 5vw, 50px) 0; padding: clamp(36px, 6vw, 64px) 24px; }
.lp-cta::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(70% 120% at 50% 0%, var(--accent-soft), transparent 60%); }
.lp-cta > * { position: relative; }
.lp-cta h2 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); letter-spacing: -0.03em; }
.lp-cta p { color: var(--muted); margin-top: 10px; }
.lp-cta .lp-hero-cta { margin-top: 24px; }

.lp-footer { border-top: 1px solid var(--border); margin-top: 20px; padding: 28px clamp(16px, 4vw, 40px) 40px; }
.lp-footer-inner { align-items: center; display: flex; flex-wrap: wrap; gap: 16px 24px; justify-content: space-between; margin: 0 auto; max-width: 1100px; }
.lp-footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.lp-footer-links a { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.lp-footer-links a:hover { color: var(--text); }
.lp-footer-tag { color: var(--muted); font-size: 0.8rem; margin: 16px auto 0; max-width: 1100px; }

/* ===================== Developer portal ===================== */
.dev-hero { padding-bottom: 30px; }
.dev-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; max-width: 1100px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 20px; }
.dev-toc { position: sticky; top: 86px; align-self: start; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 110px); overflow: auto; }
.dev-toc-title { color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 8px 10px; }
.dev-toc a { color: var(--muted); font-size: 0.9rem; font-weight: 500; padding: 7px 10px; border-radius: var(--radius-sm); border-left: 2px solid transparent; }
.dev-toc a:hover { color: var(--text); background: var(--surface-2); }
.dev-content { min-width: 0; }
.dev-section { padding: 22px 0 6px; border-top: 1px solid var(--border); }
.dev-section:first-child { border-top: 0; padding-top: 4px; }
.dev-section > h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 0 0 10px; scroll-margin-top: 90px; }
.dev-section h3 { font-size: 1.05rem; margin: 22px 0 8px; display: flex; align-items: center; gap: 9px; }
.dev-section p { line-height: 1.6; }
.dev-list { margin: 10px 0; padding-left: 20px; display: grid; gap: 9px; }
.dev-list li { line-height: 1.55; }
.dev-step { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 0.85rem; font-weight: 700; flex: none; }
.dev-note { font-size: 0.88rem; color: var(--muted); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 14px; }
.dev-codewrap { position: relative; margin: 12px 0; }
.dev-pre { white-space: pre-wrap; line-height: 1.5; padding: 16px 16px; }
code.ic { display: inline; white-space: normal; padding: 0.08em 0.42em; font-size: 0.86em; background: var(--surface-3); border-radius: 6px; overflow-wrap: anywhere; }
.dev-copy { position: absolute; top: 8px; right: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); border-radius: var(--radius-sm); font-size: 0.74rem; font-weight: 600; padding: 4px 10px; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.dev-codewrap:hover .dev-copy { opacity: 1; }
.dev-copy:hover { color: var(--text); border-color: var(--accent); }
.dev-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 12px 0; }
.dev-two .panel { padding: 20px; }
.dev-two h3 { margin: 4px 0 6px; }
.dev-eps { display: grid; gap: 8px; margin: 12px 0 18px; }
.dev-ep { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.dev-ep code.ic { background: transparent; padding: 0; font-weight: 600; color: var(--text); }
.dev-ep-desc { color: var(--muted); font-size: 0.86rem; margin-left: auto; text-align: right; }
.dev-ep-desc code.ic { font-size: 0.95em; }
.dev-method { flex: none; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 6px; min-width: 52px; text-align: center; color: #fff; }
.dev-method.get { background: #0a7c52; }
.dev-method.post { background: var(--accent); }
.dev-method.patch { background: #b15c00; }
.dev-method.del { background: var(--danger); }
.dev-try { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin: 12px 0; }
.dev-try-row { display: flex; gap: 10px; flex-wrap: wrap; }
.dev-try-row input { flex: 1 1 220px; }
.dev-try-meta { color: var(--muted); font-size: 0.82rem; margin: 12px 0 6px; min-height: 1em; }
.dev-try-out { display: grid; gap: 8px; }
.dev-try-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius); }
.dev-try-sub { margin-top: 3px; }
.dev-try-price { font-weight: 700; white-space: nowrap; }

/* ===================== Responsive ===================== */
@media (max-width: 720px) {
  .lp-agent-inner { grid-template-columns: 1fr; }
  .lp-agent-art { order: -1; }
  .lp-agent-art svg { width: 92px; }
  /* Dev portal: TOC moves above content; sections go single column. */
  .dev-layout { grid-template-columns: 1fr; gap: 18px; }
  .dev-toc { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; max-height: none; overflow: visible; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
  .dev-toc-title { width: 100%; margin-left: 0; }
  .dev-toc a { border: 1px solid var(--border); border-left: 1px solid var(--border); font-size: 0.82rem; padding: 5px 10px; }
  .dev-two { grid-template-columns: 1fr; }
  .dev-ep-desc { margin-left: 0; text-align: left; flex-basis: 100%; }
  .dev-copy { opacity: 1; }
  /* 16px inputs stop iOS Safari from auto-zooming when a field is focused. */
  input, select, textarea { font-size: 16px; }
  .shop { gap: 26px; }
  .product-detail { grid-template-columns: 1fr; }
  .form-grid.two { grid-template-columns: 1fr; }
  .searchbar { flex-direction: column; }
  .drawer { width: 100vw; max-width: 100vw; }
  /* Feature tiles stack full-width so they stay tappable and never clip. */
  .feature-tiles { grid-template-columns: 1fr; gap: 10px; }
  .feature-tile { min-height: 56px; padding: 12px 14px; }
  .ft-text strong { font-size: 0.95rem; }
  .ft-text span { font-size: 0.82rem; }
  .lede { font-size: 0.98rem; }
  .store-finder label { flex: 1; }
  .store-finder select { flex: 1; }
  .tool-panel { padding: 16px; }
  .creator-row { flex-direction: column; }
  .creator-row button { width: 100%; }
  .price-large { font-size: 2rem; }
  .product-grid { gap: 14px; }
}
@media (max-width: 520px) {
  /* Admin top bar has more items — let it wrap. */
  .topbar { flex-wrap: wrap; gap: 10px 12px; padding-left: 14px; padding-right: 14px; }
  /* Storefront + admin top bars stay on ONE row: brand left, compact icon actions right. */
  .shop-topbar, .admin-topbar { flex-wrap: nowrap; gap: 8px; }
  /* Landing: drop secondary text links on phones; keep theme + "Shop now". */
  .lp-hide-sm { display: none; }
  .topbar-actions { gap: 6px; }
  /* Size the brand to align with the topbar's button height on phones. */
  .brand-logo { height: 38px; width: 38px; }
  .brand-name { font-size: 1.25rem; }
  /* Save room on small screens: drop the brand tag + the username text. */
  .brand-tag { display: none; }
  .admin-topbar #whoami { display: none; }
  /* Beat button.ghost's transparent border so the logout icon matches the others. */
  .admin-topbar .topbar-link { border-color: var(--border-strong); color: var(--text); }
  /* All four top-bar controls are the same 38px square on mobile. */
  .icon-btn, .cart-btn, .topbar-link { height: 38px; width: 38px; min-height: 38px; padding: 0; }
  /* "For retailers" becomes an icon-only button matching the others. */
  .topbar-link {
    align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    display: inline-flex; height: 38px; justify-content: center; width: 38px; flex: none;
  }
  .topbar-link .label { display: none; }
  .stat-row { width: 100%; }
  .stat-mini { flex: 1; padding: 10px; min-width: 0; }
  .stat-mini span { font-size: 1.35rem; }
  /* Compact the floating assistant so it doesn't cover product cards. */
  .chat-fab { right: 14px; bottom: 14px; min-height: 46px; padding: 0 16px; }
  /* Stack each label above its full-width field so every dropdown/input
     shares one left edge (labels have different widths otherwise). */
  .meal-controls-row { flex-direction: column; gap: 12px; }
  .meal-controls-row label { flex-direction: column; align-items: stretch; gap: 6px; min-width: 0; }
  .meal-controls-row select, .meal-controls-row input { flex: none; width: 100%; }
  .store-finder { gap: 12px; text-align: left; }
  .store-finder > .icon { display: none; }
  .store-finder label { flex-direction: column; align-items: stretch; gap: 6px; flex-basis: 100%; text-align: left; }
  .store-finder select { flex: none; width: 100%; }
  /* Nutrition tiles: 4-up is too cramped on a phone. */
  .nutri-grid { grid-template-columns: repeat(2, 1fr); }
  /* Admin catalog search stacks the button under the field. */
  .search-row { flex-wrap: wrap; }
  .search-row input { flex: 1 1 100%; }
  .search-row button { flex: 1 1 100%; }
  .admin-head h1 { font-size: 1.35rem; }
  .shop-hero h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); }
  .add-card summary { padding: 14px 16px; }
  .add-card form, .add-card .form-grid { padding: 16px; }
  /* Shopping assistant becomes a full-screen sheet on phones. */
  .chat-panel { inset: 0; right: auto; bottom: auto; width: 100vw; height: 100dvh; max-width: none; border-radius: 0; border: none; }
  .chat-msg { max-width: 92%; }
}
