/* The `hidden` attribute must always win. Several elements (overlay, toast,
   footer, load-more) are shown/hidden by toggling `hidden` in JS; without this,
   a class rule such as `.overlay{display:flex}` overrides the UA `[hidden]`
   rule (equal specificity, author wins) and pins them permanently on screen. */
[hidden] { display: none !important; }

:root {
  /* Warm, hand-made palette — paper + terracotta, not corporate SaaS */
  --paper: #fbf6ec;
  --paper-edge: #f1e7d3;
  --card: #fffdf8;
  --ink: #2f261c;
  --muted: #6d6252;
  --line: #e8dcc4;
  --accent: #c85f36;      /* terracotta: numbers + primary actions only */
  --accent-deep: #a2481f;
  --accent-grad-a: #e07a50;
  --accent-grad-b: #cf5c34;
  --red: #c0492e;
  --shadow: 0 1px 2px rgba(90,70,45,.05), 0 10px 30px rgba(120,90,55,.09);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --serif: "Lora", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
  padding-bottom: calc(112px + var(--safe-b));   /* clears the tab bar */
  -webkit-font-smoothing: antialiased;
}

/* ---- Header / brand ---- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--paper) 72%, rgba(251,246,236,0));
  padding: 20px 20px 12px;
}
.brand { display: inline-flex; flex-direction: column; align-items: flex-start; }
.wordmark {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-style: italic;
  font-weight: 600;
  font-size: 30px;
  line-height: .9;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.squiggle { color: var(--accent); margin: 1px 0 0 2px; opacity: .85; }
.greet {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}
.streak { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); min-height: 17px; }

/* ---- Feed ---- */
.feed { padding: 0 15px; }
.muted { color: var(--muted); }

.empty { text-align: center; margin-top: 16vh; padding: 0 20px; }
.empty-mark { font-size: 40px; }
.empty-title { font-family: var(--serif); font-size: 21px; margin: 12px 0 6px; color: var(--ink); }
.empty .muted { font-size: 14.5px; line-height: 1.5; }

.day-group { margin: 20px 2px 4px; }
/* Quiet uppercase sans: italic serif is reserved for the wordmark, terracotta
   for numbers and primary actions. */
.day-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 20px 4px 9px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px 16px;
  margin-bottom: 11px;
  box-shadow: var(--shadow);
  animation: rise .28s ease both;
}
.card.new { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(210,104,62,.28), var(--shadow); animation: pop .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px);} to {opacity:1;transform:none;} }
@keyframes pop { 0%{transform:scale(.985);} 55%{transform:scale(1.012);} 100%{transform:scale(1);} }

.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meal { margin-top: 9px; }
.meal:first-of-type { margin-top: 4px; }
.chip {
  display: inline-block; font-size: 12px; font-weight: 700; text-transform: capitalize;
  letter-spacing: .01em; border-radius: 999px; padding: 3px 10px; margin-right: 7px;
  vertical-align: middle;
  color: #8f4620; background: #f4e2d2;              /* lunch / dinner (default) */
}
.chip.breakfast { color: #4d6140; background: #e5ead9; }
.chip.snack     { color: #6f5512; background: #f6eac9; }
.chip.unknown   { color: #63594a; background: #efe7d7; }
.dishes { font-size: 16px; font-weight: 550; color: var(--ink); }
.eaters { font-size: 13.5px; color: var(--muted); margin-top: 3px; }

.card details { margin-top: 11px; }
.card summary {
  font-size: 13.5px; color: var(--muted); cursor: pointer; list-style: none;
  text-decoration: underline; text-decoration-color: #d9cdb6;
}
.card summary::-webkit-details-marker { display: none; }
.edit-area {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 10px; font: inherit; font-size: 14px; margin-top: 9px; resize: vertical;
  background: #fffef9; color: var(--ink);
}
.edit-actions { display: flex; gap: 8px; margin-top: 9px; }
.btn { border: none; border-radius: 11px; padding: 9px 15px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--sans); }
.btn.save { background: var(--accent); color: #fff; }
.btn.ghost { background: #efe7d7; color: var(--ink); }

.sentinel { height: 1px; }
.loading-more { text-align: center; color: var(--muted); font-size: 13.5px; padding: 12px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; opacity: .85; padding: 18px 0 8px; }

/* ---- Bottom tab bar (mic lives in the middle) ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: flex-start;
  padding: 9px 6px calc(6px + var(--safe-b));
  background: rgba(251,246,236,.97);
  border-top: 1px solid var(--line);
  backdrop-filter: saturate(1.1) blur(6px);
  -webkit-backdrop-filter: saturate(1.1) blur(6px);
}
.tabgroup { flex: 1; display: flex; justify-content: space-around; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 62px; padding: 4px 6px 2px;
  color: #8d8271; font-size: 10.5px; font-weight: 600; text-decoration: none;
}
.tab.on { color: var(--accent-deep); }
.tab svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.micslot { width: 84px; display: flex; justify-content: center; }
.mic {
  width: 64px; height: 64px; margin-top: -19px; border-radius: 50%;
  background: linear-gradient(158deg, var(--accent-grad-a), var(--accent-grad-b));
  color: #fff; border: none; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 10px 26px rgba(207,92,52,.42), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s ease, filter .2s ease;
}
.mic:active { transform: scale(.93); }
.mic.recording { background: linear-gradient(158deg, #d8563a, #b23a22); animation: pulse 1.35s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(192,73,46,.42), 0 10px 26px rgba(207,92,52,.4); }
  70%  { box-shadow: 0 0 0 20px rgba(192,73,46,0), 0 10px 26px rgba(207,92,52,.4); }
  100% { box-shadow: 0 0 0 0 rgba(192,73,46,0), 0 10px 26px rgba(207,92,52,.4); }
}
/* Shown only while recording, so it costs no space the rest of the time. */
.hint {
  position: fixed; left: 0; right: 0; bottom: calc(96px + var(--safe-b)); z-index: 7;
  text-align: center; font-size: 13.5px; color: var(--muted);
}

/* ---- Kitchen ---- */
.sect { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 20px 4px 9px; }
.dish {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  padding: 11px 13px; margin-bottom: 7px;
}
.dish.faded { opacity: .72; }
.dish-name { font-size: 15px; font-weight: 550; }
.dish-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.count { font-family: var(--serif); font-weight: 600; font-size: 17px; color: var(--accent-deep); white-space: nowrap; }

/* ---- Ask ---- */
.catchup { background: #f7efe1; border: 1px solid #e6d8bd; border-radius: 16px; padding: 14px 15px; margin-bottom: 14px; }
.catchup-title { font-family: var(--serif); font-weight: 600; font-size: 16px; margin: 0 0 6px; color: var(--ink); }
.catchup-body { font-size: 14px; color: var(--muted); line-height: 1.5; margin: 0; }
.catchup-eg { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 5px; }
.catchup-quote { font-family: var(--serif); font-size: 14.5px; line-height: 1.55; color: var(--accent-deep); margin: 0; }

.askbox { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px 6px 13px; }
.askbox input { flex: 1; border: none; outline: none; background: transparent; font: inherit; font-size: 15.5px; color: var(--ink); padding: 9px 0; min-width: 0; }
.askbox input::placeholder { color: #a49a88; }
.askgo { border: none; border-radius: 11px; width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: linear-gradient(158deg, var(--accent-grad-a), var(--accent-grad-b)); cursor: pointer; flex: none; }
.askgo:disabled { opacity: .55; }

.qchips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.qchip { font: inherit; font-size: 13px; color: var(--accent-deep); background: #f7e7d7; border: none; border-radius: 999px; padding: 8px 12px; cursor: pointer; }

.qa { margin-top: 18px; }
.qa-q { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.qa-a { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; font-size: 14.5px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; }
.qa-err { color: var(--red); }

/* ---- You ---- */
.ptitle { font-family: var(--serif); font-weight: 600; font-size: 21px; margin: 0 0 3px; color: var(--ink); }
.psub { font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.45; }
.prow {
  display: flex; justify-content: space-between; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 13px; margin-bottom: 8px; font-size: 14.5px;
}
.plabel { color: var(--muted); }
.pbtn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font-family: var(--sans); font-size: 14.5px; font-weight: 600;
  color: var(--ink); background: var(--card); margin-top: 8px; cursor: pointer;
}
.pbtn:disabled { opacity: .6; cursor: default; }
.howto { background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; }
.howto summary { font-size: 14.5px; font-weight: 600; cursor: pointer; list-style: none; color: var(--accent-deep); }
.howto summary::-webkit-details-marker { display: none; }
.howto p { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 10px 0 0; }
.pnote { text-align: center; font-size: 13px; color: var(--muted); opacity: .85; margin: 20px 0 0; }

/* ---- Overlay + toast ---- */
.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(251,246,236,.88);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid #ece1cd; border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-text { color: var(--muted); font-size: 15px; }

.logout { position: absolute; top: 20px; right: 16px; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: none; cursor: pointer; padding: 4px 6px; }
.logout:hover { color: var(--accent-deep); }

.testpush { margin-top: 12px; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--accent-deep); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.testpush:hover { border-color: var(--accent); }
.testpush:disabled { opacity: .6; cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: calc(124px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ink); color: #fdf7ea; padding: 11px 17px; border-radius: 999px;
  font-size: 13.5px; z-index: 30; box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}
.toast.err { background: var(--red); color: #fff; }

/* ---- Landing + auth pages ---- */
.screen { position: relative; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px 22px; text-align: center; }
.brand-lg { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 40px; line-height: .9; color: var(--accent); }
.brand-squiggle { color: var(--accent); opacity: .85; margin: 6px 0 0; }
.hero { font-family: var(--serif); font-weight: 600; font-size: 25px; line-height: 1.25; color: var(--ink); margin: 24px 0 13px; max-width: 20ch; }
.effort { font-size: 15px; font-weight: 600; color: var(--accent-deep); background: #f7e7d7; border-radius: 12px; padding: 11px 14px; margin: 0 0 13px; }
.lead { color: var(--muted); font-size: 15px; line-height: 1.55; max-width: 30ch; margin: 0 auto 20px; }

/* landing: a look at a saved day */
.peek { width: 100%; max-width: 300px; background: var(--paper); border: 1px solid #ded2ba; border-radius: 20px; padding: 13px 12px 14px; box-shadow: 0 8px 22px rgba(120,90,55,.13); margin: 0 0 22px; }
.peek-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.peek-brand { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 16px; color: var(--accent); }
.peek-when { font-size: 12px; color: var(--muted); }
.peek-day { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; margin: 0 2px 7px; }
.peek-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; text-align: left; }
.peek-meal + .peek-meal { margin-top: 9px; }

.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; }
.loginlink { font-size: 14.5px; color: var(--muted); text-decoration: none; }
.loginlink b { color: var(--accent-deep); }
.trust { display: flex; align-items: flex-start; gap: 8px; text-align: left; font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 22px 0 0; max-width: 300px; }

/* landing: what it grows into */
.becomes { width: 100%; max-width: 300px; margin: 28px 0 0; padding-top: 22px; border-top: 1px solid var(--line); }
.becomes-h { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--ink); margin: 0 0 6px; }
.becomes-p { font-size: 14px; color: var(--muted); margin: 0 0 15px; line-height: 1.5; text-align: left; }
.blist { display: flex; flex-direction: column; gap: 11px; text-align: left; }
.bitem { display: flex; gap: 11px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px; }
.bemoji { font-size: 20px; line-height: 1.2; }
.btitle { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.bsub { font-size: 13.5px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.made { font-size: 13.5px; color: var(--muted); margin: 22px 0 0; max-width: 30ch; line-height: 1.5; }

.authcard { width: 100%; max-width: 340px; text-align: left; }
.authcard h1 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0 0 5px; color: var(--ink); }
.authcard .sub { color: var(--muted); font-size: 14.5px; margin: 0 0 20px; line-height: 1.45; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; color: var(--muted); margin: 0 0 6px; }
.field input { width: 100%; font: inherit; font-size: 16px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fffef9; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,95,54,.15); }
.btn-primary { display: block; width: 100%; text-align: center; text-decoration: none; border: none; border-radius: 13px; padding: 15px; font-family: var(--sans); font-weight: 600; font-size: 16px; color: #fff; background: linear-gradient(158deg, var(--accent-grad-a), var(--accent-grad-b)); box-shadow: 0 8px 20px rgba(207,92,52,.32); cursor: pointer; }
.btn-primary:active { transform: scale(.99); }
.btn-primary[disabled] { opacity: .6; }
.linkline { text-align: center; font-size: 14.5px; color: var(--muted); margin-top: 18px; }
.linkline a { color: var(--accent-deep); font-weight: 600; text-decoration: none; }
.linkbtn { font: inherit; font-size: 14.5px; font-weight: 600; color: var(--accent-deep); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: #e0cdbb; }
.linkbtn:disabled { opacity: .6; cursor: default; }
.formerr { color: var(--red); font-size: 14px; margin: 0 0 12px; }
.backhome { position: absolute; top: 16px; left: 20px; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 19px; color: var(--accent); text-decoration: none; }

/* ---- Weekly summary card ---- */
.summary { margin: 6px 0 4px; }
.sum-card { background: linear-gradient(160deg, #fff6ea, #fceede); border: 1px solid var(--line); border-radius: 18px; padding: 15px 16px; box-shadow: var(--shadow); animation: rise .28s ease both; }
.sum-title { font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--ink); margin-bottom: 12px; }
.sum-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.sum-stat { display: flex; align-items: baseline; gap: 6px; }
.sum-stat-e { font-size: 16px; }
.sum-stat-n { font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1; color: var(--accent-deep); }
.sum-stat-l { font-size: 14px; color: var(--muted); }
.sum-line { font-size: 14px; color: var(--ink); line-height: 1.45; margin: 12px 0 0; }
.sum-kid { margin-top: 11px; font-size: 14px; color: var(--ink); background: #f6e4d3; border-radius: 11px; padding: 9px 11px; line-height: 1.4; }
