/* AskAngiiAI Meal Planner — calm cream by default, brand navy on toggle */
:root {
  /* cream / light (default) */
  --bg: #FAF6F0;
  --surface: #FFFFFF;
  --surface-2: #F3EDE3;
  --border: rgba(30, 50, 70, 0.12);
  --text: #22384A;
  --muted: #71838F;
  --teal: #1EB8CC;        /* brand primary accent */
  --teal-ink: #0E7C8D;    /* teal readable as text on light */
  --teal-dim: rgba(30, 184, 204, 0.12);
  --coral: #E8836A;       /* brand warm accent */
  --coral-ink: #C05A40;
  --coral-dim: rgba(232, 131, 106, 0.14);
  --ok: #2E9E6B;
  --warn: #B98518;
  --danger: #C74A4A;
  --btn-text: #FFFFFF;
  --radius: 16px;
  --mono: "DM Mono", ui-monospace, monospace;
}
html[data-theme="dark"] {
  /* AskAngiiAI brand sheet navy */
  --bg: #040E1A;
  --surface: #0A1C2E;
  --surface-2: #10263C;
  --border: rgba(255, 255, 255, 0.08);
  --text: #EDF5F8;
  --muted: #6BA8BC;
  --teal-ink: #5FD4E4;
  --teal-dim: rgba(30, 184, 204, 0.15);
  --coral-ink: #E8836A;
  --coral-dim: rgba(232, 131, 106, 0.15);
  --ok: #4CC98F;
  --warn: #E8B45A;
  --danger: #E86A6A;
  --btn-text: #040E1A;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.25s ease;
}

/* Brand type roles: DM Sans semibold = headings · Playfair italic = editorial accents · DM Mono = eyebrows/labels */
h1, h2, h3 { font-family: "DM Sans", system-ui, sans-serif; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.85rem; margin-bottom: 0.4em; }
h2 { font-size: 1.35rem; margin-bottom: 0.4em; }
h3 { font-size: 1.05rem; }
p.sub { color: var(--muted); margin-bottom: 1.3em; }

a { color: var(--teal-ink); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: "DM Sans", sans-serif; font-weight: 600; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; }
.brand .wm-accent { color: var(--coral); }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 0.7rem; margin-left: 4px; font-family: var(--mono); letter-spacing: 0.12em; }
#mainNav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#mainNav button {
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 0.92rem;
}
#mainNav button:hover { color: var(--text); }
#mainNav button.active { color: var(--teal-ink); border-color: var(--teal); background: var(--teal-dim); }
.theme-btn { font-size: 1rem; }

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 32px 20px 70px; }
.site-footer { padding: 22px; text-align: center; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 500; cursor: pointer;
  border: none; border-radius: 999px; padding: 13px 24px;
  background: var(--teal); color: var(--btn-text); font-size: 1rem;
  transition: transform 0.08s ease, opacity 0.15s;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn.coral { background: var(--coral); }
.btn.ghost { background: transparent; color: var(--teal-ink); border: 1px solid var(--teal); }
.btn.ghost.coral { color: var(--coral-ink); border-color: var(--coral); }
.btn.small { padding: 7px 14px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* Collapsible "more" menu — keeps screens calm */
.more-menu { margin-top: 14px; }
.more-menu summary {
  cursor: pointer; color: var(--muted); font-size: 0.9rem; list-style: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 999px; border: 1px dashed var(--border);
}
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu summary::after { content: "▾"; font-size: 0.8em; }
.more-menu[open] summary::after { content: "▴"; }
.more-menu summary:hover { color: var(--text); }
.more-menu .btn-row { margin-top: 12px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card.clickable { cursor: pointer; transition: border-color 0.15s; }
.card.clickable:hover { border-color: var(--teal); }

/* ---------- Forms ---------- */
label.fld { display: block; margin-bottom: 16px; }
label.fld span.lbl { display: block; font-weight: 500; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="number"], select, textarea {
  width: 100%; padding: 12px 14px; font: inherit;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
}
html[data-theme="dark"] input[type="text"], html[data-theme="dark"] input[type="email"], html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: var(--bg); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); border-color: transparent; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 9px 16px; border-radius: 999px; cursor: pointer; user-select: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 0.92rem;
}
html[data-theme="dark"] .chip { background: var(--bg); }
.chip.on { background: var(--teal-dim); border-color: var(--teal); color: var(--teal-ink); font-weight: 500; }
.chip.coral.on { background: var(--coral-dim); border-color: var(--coral); color: var(--coral-ink); }

/* ---------- Flags & badges ---------- */
.flag {
  display: inline-flex; align-items: center; font-size: 0.66rem; font-weight: 500;
  font-family: var(--mono);
  padding: 2px 8px; border-radius: 6px; letter-spacing: 0.06em;
  background: var(--teal-dim); color: var(--teal-ink); margin-right: 4px;
}
.flag.leftover { background: var(--coral-dim); color: var(--coral-ink); }
.headcount {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2); border-radius: 999px; padding: 3px 10px;
  font-size: 0.78rem; color: var(--muted);
}

/* ---------- Quiz ---------- */
.quiz-progress { display: flex; gap: 6px; margin-bottom: 26px; }
.quiz-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); }
.quiz-progress i.done { background: var(--teal); }
.quiz-step { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

/* Attendee grid */
.att-grid { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
.att-grid th { color: var(--muted); font-weight: 500; padding: 6px 4px; }
.att-grid td { padding: 3px; }
.att-cell {
  width: 100%; min-height: 44px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 0.78rem;
  padding: 6px 2px; line-height: 1.25;
}
.att-cell.filled { border-color: var(--teal); background: var(--teal-dim); color: var(--teal-ink); }
.att-cell.empty-cell { color: var(--muted); }
.grid-scroll { overflow-x: auto; }

/* ---------- Plan view ---------- */
.day-card { padding: 0; overflow: hidden; }
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; cursor: pointer;
}
.day-head:hover { background: var(--surface-2); }
.day-title { display: flex; flex-direction: column; gap: 2px; }
.day-title .dow, .prep-day .dow { font-size: 0.72rem; color: var(--coral-ink); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; font-family: var(--mono); }
.meal-line { display: flex; align-items: center; gap: 8px; padding: 11px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.meal-line .mtype { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; width: 84px; flex-shrink: 0; font-family: var(--mono); }
.meal-line .mname { font-weight: 500; flex: 1; min-width: 140px; }
.meal-line .mname.open-prep { cursor: pointer; }
.meal-line .mname.open-prep:hover { color: var(--teal-ink); }
.plan-warning {
  background: var(--coral-dim);
  border: 1px solid var(--coral);
  color: var(--coral-ink);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 0.92rem;
}

/* ---------- Prep ahead ---------- */
.prep-day .dow { margin-bottom: 8px; }
.prep-task { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; }
.prep-icon { flex-shrink: 0; }

/* ---------- Grocery ---------- */
.gsection h3 { color: var(--coral-ink); margin: 22px 0 8px; font-size: 0.82rem; font-family: var(--mono); font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; }
.gitem {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 6px;
}
.gitem input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--teal); flex-shrink: 0; cursor: pointer; }
.gitem.checked .gname { text-decoration: line-through; color: var(--muted); }
.gname { flex: 1; }
.gqty { color: var(--teal-ink); font-weight: 500; white-space: nowrap; }
.gprice { color: var(--muted); font-size: 0.85rem; width: 60px; text-align: right; }
.gsub { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px; }
.gsub:hover { color: var(--coral-ink); }

.budget-bar { position: sticky; top: 64px; z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.budget-bar .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.budget-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.budget-fill { height: 100%; border-radius: 4px; background: var(--ok); transition: width 0.3s; }
.budget-fill.near { background: var(--warn); }
.budget-fill.over { background: var(--danger); }
.budget-status { font-size: 0.85rem; margin-top: 6px; }
.budget-status.under { color: var(--ok); }
.budget-status.near { color: var(--warn); }
.budget-status.over { color: var(--danger); }
.price-note { color: var(--muted); font-size: 0.82rem; margin-top: 8px; }
.price-refresh { margin-top: 10px; }

/* ---------- Prep modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(10, 20, 32, 0.55); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 620px; padding: 26px;
  animation: fadeIn 0.15s ease;
}
.modal .close-x { float: right; background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.steps-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 6px; flex-wrap: wrap; }
.eli5-chip { font-size: 0.85rem; }
.step-line { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--teal-dim); color: var(--teal-ink); font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.step-body { flex: 1; padding-top: 3px; }
.step-text { display: block; }
.eli5-tip {
  background: var(--coral-dim); border-radius: 10px; padding: 8px 12px;
  font-size: 0.88rem; margin-top: 7px; color: var(--text);
}
.eli5-intro { margin: 4px 0 10px; }
.timer-btn {
  background: var(--coral-dim); color: var(--coral-ink); border: none; border-radius: 8px;
  padding: 5px 10px; cursor: pointer; font: inherit; font-size: 0.8rem; font-weight: 500; white-space: nowrap;
}
.timer-btn.running { background: var(--coral); color: #fff; }
.kid-note {
  background: var(--coral-dim); border-left: 3px solid var(--coral);
  padding: 10px 14px; border-radius: 0 10px 10px 0; margin: 14px 0; font-size: 0.92rem;
}
.kid-note.sensory-note { background: var(--teal-dim); border-left-color: var(--teal); }
.ing-line { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 0.95rem; border-bottom: 1px solid var(--border); }
.ing-name { flex: 1; }
.ing-line .no-have { background: none; border: none; color: var(--muted); font-size: 0.78rem; cursor: pointer; text-decoration: underline; }
.ing-line .no-have:hover { color: var(--coral-ink); }
.sub-tip { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: 0.85rem; color: var(--teal-ink); margin: 4px 0 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--text); border: 1px solid var(--teal);
  border-radius: 999px; padding: 12px 22px; z-index: 100; font-size: 0.92rem;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 30px rgba(10, 20, 32, 0.25);
  max-width: 92vw;
}
.toast[hidden] { display: none; }
.toast button { background: none; border: none; color: var(--coral-ink); font-weight: 700; cursor: pointer; font: inherit; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 34px 0 10px; }
.hero h1 { font-size: 2.3rem; }
.hero h1 em { color: var(--teal-ink); font-family: "Playfair Display", serif; font-style: italic; font-weight: 600; }
.hero .btn { margin-top: 18px; }
.steps-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 34px; text-align: left; }

/* ---------- Person cards ---------- */
.person-card { display: flex; align-items: center; gap: 14px; }
.person-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--teal); background: transparent;
  color: var(--teal-ink); font-weight: 600; font-size: 1.15rem; font-style: italic;
  display: flex; align-items: center; justify-content: center; font-family: "Playfair Display", serif;
}
.person-meta { flex: 1; }
.person-meta .tags { font-size: 0.8rem; color: var(--muted); }

.empty-state { text-align: center; color: var(--muted); padding: 44px 10px; }

/* ---------- Account sync ---------- */
.auth-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-color: var(--teal);
  background: var(--teal-dim);
}
.auth-banner p.sub { margin: 4px 0 0; }
.auth-banner .btn { flex-shrink: 0; }
.auth-btn.active { color: var(--teal-ink); border-color: var(--teal); background: var(--teal-dim); }

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #111; }
  .no-print, .topbar, .site-footer, .btn, .toast, #mainNav, .gsub, .no-have, .timer-btn, .more-menu, .eli5-chip { display: none !important; }
  main { max-width: 100%; padding: 0; }
  .card, .gitem, .budget-bar { background: #fff; border: 1px solid #ccc; color: #111; break-inside: avoid; }
  .day-title .dow, .prep-day .dow { color: #b3543b; }
  .gqty { color: #0a7c8c; }
  .gname, .mname, h1, h2, h3, .step-text, .mtype, .gprice, .headcount, .prep-task { color: #111 !important; }
  .flag { background: #eee; color: #333; }
  .kid-note, .eli5-tip { background: #fdf0ec; color: #333; }
  a { color: #111; text-decoration: none; }
}
/* ---------- Mobile-first / app mode ---------- */
.nav-ico { display: none; }

@media (max-width: 600px) {
  .hero h1 { font-size: 1.7rem; }
  .meal-line .mtype { width: 100%; }
  .gitem {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 6px 10px;
    padding: 10px 12px;
  }
  .gitem input[type="checkbox"] { grid-row: 1 / span 2; align-self: start; margin-top: 2px; }
  .gname { grid-column: 2 / 5; min-width: 0; overflow-wrap: anywhere; }
  .gqty { grid-column: 2; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .gprice { grid-column: 3; width: auto; justify-self: end; }
  .gsub { grid-column: 4; justify-self: end; padding: 0 2px; }

  /* App-style fixed bottom tab bar */
  main { padding: 22px 14px calc(82px + env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 14px calc(10px); }
  .topbar .brand em { display: none; }
  #mainNav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px rgba(10, 20, 32, 0.08);
  }
  #mainNav button {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 6px 2px; min-height: 52px; border-radius: 12px; font-size: 0.68rem;
    border: none;
  }
  #mainNav button.active { background: var(--teal-dim); border: none; }
  .nav-ico { display: block; font-size: 1.25rem; line-height: 1.2; }
  .theme-btn .nav-txt { display: none; }
  .theme-btn { font-size: 1.25rem; }
  .site-footer { display: none; }

  /* Comfortable thumb targets */
  .btn { padding: 14px 22px; }
  .chip { padding: 11px 16px; }
  .att-cell { min-height: 48px; }
  .gitem input[type="checkbox"] { width: 24px; height: 24px; }

  /* Prep sheet modal feels like an app screen */
  .modal-back { padding: 0; align-items: stretch; }
  .modal {
    max-width: none; min-height: 100%; border-radius: 0; border: none;
    padding: 22px 18px calc(28px + env(safe-area-inset-bottom));
  }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); width: max-content; max-width: 94vw; }
  .budget-bar { top: 58px; }
  .auth-banner { align-items: flex-start; flex-direction: column; }
}
/* No hover states on touch — active feedback instead */
@media (hover: none) {
  .btn:hover { opacity: 1; }
  .btn:active { opacity: 0.85; transform: scale(0.97); }
  .day-head:hover { background: inherit; }
}
