/* PantrySync — MindTrip-style light theme.
   Clean, airy, left-sidebar SaaS shell. Soft purple accent. */
:root {
  --bg: #ffffff;
  --sidebar: #fbfbfd;
  --panel: #ffffff;
  --line: #ececef;
  --line2: #f3f3f5;
  --ink: #1d1d1f;
  --ink2: #3a3a3e;
  --muted: #86868b;
  --accent: #6d5efc;
  --accent-press: #5a4bf0;
  --accent-soft: #f1effe;
  --accent-grad: linear-gradient(135deg, #8b7cff 0%, #6d5efc 100%);
  --green: #2faa6a;
  --red: #e0533d;
  --r: 14px;
  --r-sm: 10px;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

/* ---- screens / views ---- */
.screen { display: none; }
body[data-view="loading"]   .screen[data-screen="loading"]   { display: grid; }
body[data-view="auth"]      .screen[data-screen="auth"]      { display: grid; }
body[data-view="household"] .screen[data-screen="household"] { display: grid; }
body[data-view="app"]       .screen[data-screen="app"]       { display: block; }

/* top header: slim, only inside app */
header { display: none; }
body[data-view="app"] header {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(255,255,255,.85); backdrop-filter: blur(10px); z-index: 20;
}
header h1 { display: none; }            /* brand lives in the sidebar */
header .tag { color: var(--muted); font-size: 13px; }
header .spacer { flex: 1; }
header .stat { font-size: 13px; color: var(--muted); }
header .stat b { color: var(--ink); font-weight: 600; }
.who { font-size: 13px; color: var(--muted); }
.who a { color: var(--accent); cursor: pointer; text-decoration: none; }

/* ---- app shell: sidebar + main ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
@media (max-width: 820px){ .shell { grid-template-columns: 1fr; } .sidebar { display: none; } }

.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: -.4px; padding: 4px 10px 16px; }
.brand .dot { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--ink2); font-size: 14px; font-weight: 500; cursor: pointer; user-select: none;
}
.nav-item:hover { background: #f1f1f4; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ic { width: 18px; text-align: center; }
.newchat {
  margin: 14px 0 8px; width: 100%; padding: 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.newchat:hover { background: #f6f6f8; }
.sb-spacer { flex: 1; }
.promo { background: var(--accent-grad); color: #fff; border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.promo-title { font-weight: 700; font-size: 13px; }
.promo-sub { font-size: 12px; opacity: .92; margin-top: 3px; line-height: 1.4; }
.profile { display: flex; align-items: center; gap: 9px; padding: 8px 6px; border-top: 1px solid var(--line); }
.profile .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-size: 15px; }
.profile .pname { font-size: 13px; font-weight: 600; }
.profile .psub { font-size: 11px; color: var(--muted); }

.main { min-width: 0; }

/* ---- content grid ---- */
.wrap { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; padding: 22px 28px 60px; align-items: start; }
@media (max-width: 1100px){ .wrap { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.panel h2 { margin: 0 0 3px; font-size: 15px; font-weight: 600; }
.panel .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; line-height: 1.45; }

/* ---- wheel ---- */
.wheelStage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.wheelHead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; width: 100%; }
.wheelBox { position: relative; width: 380px; max-width: 78vw; aspect-ratio: 1; }
canvas#wheel { width: 100%; height: 100%; display: block; filter: drop-shadow(0 10px 26px rgba(80,60,180,.13)); }
.pointer {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%); width: 0; height: 0; z-index: 3;
  border-left: 13px solid transparent; border-right: 13px solid transparent; border-top: 22px solid var(--accent);
}
.hub {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 2;
  width: 56px; height: 56px; border-radius: 50%; background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 20px; box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.btnRow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 16px; transition: background .12s, transform .06s, filter .12s;
}
button:hover { background: #f6f6f8; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button.primary:hover { background: var(--accent-press); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.big { width: 100%; padding: 13px; font-size: 15px; }

.genreSel {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; cursor: pointer; max-width: 46%;
}

/* craving */
.cravingBar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; width: 100%; }
.craveLabel { font-size: 13px; color: var(--muted); font-weight: 600; }
.craveInput {
  font: inherit; font-size: 13px; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; width: 140px;
}
.craveInput::placeholder { color: #b0b0b6; }

/* row / slider */
.row { display: flex; align-items: center; gap: 12px; margin: 8px 0 2px; width: 100%; }
.row label { font-size: 13px; color: var(--muted); }
input[type=range] { accent-color: var(--accent); flex: 1; }
.count-pill { font-size: 12px; color: var(--muted); }

/* result */
.result { width: 100%; margin-top: 6px; border-top: 1px solid var(--line2); padding-top: 16px; min-height: 40px; }
.result.empty { color: var(--muted); font-size: 14px; text-align: center; }
.result h3 { margin: 0 0 5px; font-size: 20px; font-weight: 700; }
.result .meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.result ul { margin: 6px 0 0; padding-left: 18px; columns: 2; gap: 18px; }
.result li { font-size: 13px; margin: 2px 0; break-inside: avoid; color: var(--ink2); }
.result li.missing { color: var(--red); }
.result li.missing::after { content: " — need"; font-size: 11px; opacity: .8; }
.resultActions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.result a.open, .result a.share { color: var(--accent); font-size: 13px; text-decoration: none; cursor: pointer; }
.result a.open:hover, .result a.share:hover { text-decoration: underline; }
button.cook { font-size: 14px; padding: 10px 18px; }

/* inputs */
.field { display: flex; gap: 8px; margin-bottom: 12px; }
.field input { flex: 1; font: inherit; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--accent); }
.field input::placeholder { color: #b0b0b6; }
textarea { width: 100%; min-height: 80px; font: inherit; font-size: 13px; resize: vertical; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; color: var(--ink); margin-bottom: 8px; }
textarea:focus { outline: none; border-color: var(--accent); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; background: #f5f5f7; border: 1px solid var(--line); color: var(--ink2); padding: 5px 10px; border-radius: 999px; }
.chip .q { color: var(--accent); font-weight: 600; margin-left: 2px; }
.chip.staple { background: #effbf3; border-color: #d4f0de; color: #1f7a47; }
.chip.groc { background: var(--accent-soft); border-color: #e2defb; color: #5a4bf0; }
.chip.groc .q { color: #6d5efc; }
.chip x { cursor: pointer; opacity: .5; font-weight: 700; }
.chip x:hover { opacity: 1; color: var(--red); }
.chip.crave { cursor: pointer; user-select: none; }
.chip.crave:hover { background: #ececef; }
.chip.crave.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.empty-chips { color: var(--muted); font-size: 13px; }
.section-gap { margin-top: 20px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* chat */
.messages { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding-right: 4px; }
.msg { background: #f5f5f7; border-radius: 12px; padding: 8px 11px; font-size: 14px; color: var(--ink2); max-width: 85%; }
.msg.mine { background: var(--accent-soft); align-self: flex-end; color: #4a3fd0; }
.msg .from { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg .recipe { display: inline-block; margin-top: 5px; font-size: 12px; color: var(--accent); border: 1px solid #e2defb; border-radius: 8px; padding: 2px 8px; }
.empty-chat { color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }

/* auth + household + loading */
.screen[data-screen="auth"], .screen[data-screen="household"], .screen[data-screen="loading"] {
  place-items: center; min-height: 100vh; padding: 30px; background: var(--sidebar);
}
.centerbox { color: var(--muted); padding: 80px; text-align: center; }
.authcard { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 36px; width: min(420px, 92vw); text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.06); }
.authcard h2 { margin: 0 0 6px; font-size: 26px; font-weight: 700; }
.authcard h2 .sync { color: var(--accent); }
.authcard .sub { color: var(--muted); margin-bottom: 22px; }
.authcard .field { margin-bottom: 10px; }
.authcard .field input { text-align: left; }
.or { color: var(--muted); font-size: 12px; margin: 14px 0; text-transform: uppercase; letter-spacing: 1px; }
.link-btn { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 12px 0 0; }
.link-btn:hover { color: var(--ink); background: none; }

/* banner toast */
.banner { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 13px; padding: 10px 18px; border-radius: 999px; z-index: 50; box-shadow: 0 8px 26px rgba(0,0,0,.18); }
.banner b { color: #c9bdff; }

/* ---- grocery cart rows + retailer deep-links ----------------------------- */
.grow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line2); }
.grow:last-child { border-bottom: 0; }
.gname { flex: 1; font-size: 14px; color: var(--ink); }
.gname .q { color: var(--accent); font-weight: 600; margin-left: 4px; }
.stores { display: flex; gap: 6px; flex-wrap: wrap; }
.store {
  font-size: 11px; font-weight: 600; text-decoration: none; color: var(--ink2);
  background: #f5f5f7; border: 1px solid var(--line); border-radius: 7px; padding: 3px 7px; white-space: nowrap;
}
.store:hover { background: #ececef; }
.store.amazon:hover    { border-color:#ff9900; color:#b66b00; }
.store.walmart:hover   { border-color:#0071dc; color:#0071dc; }
.store.instacart:hover { border-color:#0aad0a; color:#0a8a0a; }
.store.heb:hover       { border-color:#e2231a; color:#c81e16; }
.grow x { cursor: pointer; opacity: .45; font-weight: 700; font-size: 15px; }
.grow x:hover { opacity: 1; color: var(--red); }

/* install promo is clickable */
.promo { cursor: pointer; }
.promo:hover { filter: brightness(1.04); }

/* ================= MOBILE ================= */
/* bottom tab bar — hidden on desktop, shown on phones inside the app */
.mobnav { display: none; }
.mob-item .mi { font-size: 19px; line-height: 1; }

@media (max-width: 820px) {
  /* kill the desktop sidebar (this block is LAST so it wins the cascade) */
  .sidebar { display: none !important; }
  .shell { display: block; }
  .main { width: 100%; }

  /* header: show the brand, drop the clutter */
  body[data-view="app"] header { padding: 12px 16px; }
  header h1 { display: block !important; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
  header h1 .sync { color: var(--accent); }
  header .tag { display: none; }
  header .stat { font-size: 11px; }
  header .who { display: none; }

  /* single column, room for the bottom bar */
  .wrap { grid-template-columns: 1fr; gap: 14px; padding: 14px 14px 96px; }
  .panel { padding: 16px; border-radius: 16px; }

  /* wheel fills the screen width */
  .wheelBox { width: 86vw; max-width: 86vw; }
  .wheelHead { flex-direction: column; gap: 8px; }
  .genreSel { max-width: 100%; width: 100%; }
  .craveInput { width: 100%; }

  /* fat, thumb-friendly tap targets */
  button { padding: 13px 18px; font-size: 15px; }
  button.primary { padding: 15px 22px; }
  .btnRow { width: 100%; }
  .btnRow button { flex: 1; }
  .field input, textarea { font-size: 16px; }   /* 16px stops iOS auto-zoom */
  .chip { font-size: 14px; padding: 7px 12px; }
  .chip x { padding: 0 2px; font-size: 16px; }
  .store { font-size: 13px; padding: 6px 10px; }
  .result ul { columns: 1; }
  .result h3 { font-size: 22px; }

  /* show the bottom tab bar */
  body[data-view="app"] .mobnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mob-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none;
    padding: 6px 2px; border-radius: 10px; cursor: pointer; user-select: none;
  }
  .mob-item.active { color: var(--accent); }
  .mob-item.active .mi { transform: scale(1.08); }

  /* toast sits above the bar */
  .banner { bottom: 84px; max-width: 90vw; }
}

/* ---- full recipe modal --------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(20,18,30,.45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.sheet { background: #fff; border-radius: 18px; width: min(560px, 96vw); max-height: 88vh; overflow-y: auto; padding: 26px 26px 30px; position: relative; box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.modalClose { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; padding: 0; border-radius: 50%; background: #f5f5f7; border: 1px solid var(--line); font-size: 15px; line-height: 1; }
.mTop h2 { margin: 0 4px 4px 0; font-size: 24px; font-weight: 700; max-width: 92%; }
.mMeta { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
#modalBody h4 { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.mIng { margin: 0; padding-left: 18px; columns: 2; gap: 18px; }
.mIng li { font-size: 13px; margin: 3px 0; break-inside: avoid; }
.mIng li.miss { color: var(--red); }
.mIng li.miss::after { content: " — need"; font-size: 10px; opacity: .8; }
.mSteps { margin: 0; padding-left: 22px; }
.mSteps li { font-size: 15px; line-height: 1.55; margin: 0 0 12px; padding-left: 4px; }
.mSteps li::marker { color: var(--accent); font-weight: 700; }
.mTips { margin: 0; padding-left: 18px; }
.mTips li { font-size: 13px; line-height: 1.5; margin: 4px 0; color: var(--ink2); }
.mNone { color: var(--muted); font-size: 14px; }
.modalCook { margin-top: 22px; width: 100%; }
@media (max-width: 820px) {
  .modal { padding: 0; place-items: stretch; }
  .sheet { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; padding: 22px 18px 40px; }
  .mIng { columns: 1; }
  .mSteps li { font-size: 16px; }
}
