/* ============================================================
   Beikost-Tracker — "Nursery Cookbook"
   Warm, tactile cookbook feel: cream paper, sage green,
   apricot, cocoa ink. Display serif Fraunces + body Nunito.
   Fully self-contained (local fonts, no CDN calls).
   ============================================================ */

/* ---------- Fonts (bundled locally) ---------- */
@font-face { font-family: "Fraunces"; font-weight: 500; font-display: swap;
  src: url("/static/fonts/fraunces-500.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 600; font-display: swap;
  src: url("/static/fonts/fraunces-600.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/fraunces-700.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 900; font-display: swap;
  src: url("/static/fonts/fraunces-900.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap;
  src: url("/static/fonts/nunito-400.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap;
  src: url("/static/fonts/nunito-600.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/nunito-700.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap;
  src: url("/static/fonts/nunito-800.woff2") format("woff2"); }

:root {
  --paper: #faf5ec;
  --paper-2: #f1e8d7;
  --card: #fffdf8;
  --ink: #3b3228;
  --ink-soft: #756857;
  --ink-faint: #9b8f7d;

  --sage: #7d9a6d;
  --sage-deep: #5c7a4e;
  --sage-soft: #e6eedd;

  --apricot: #e29a63;
  --apricot-deep: #c87b42;
  --apricot-soft: #f8e6d1;

  --berry: #c25b7e;
  --berry-soft: #f6e1e8;

  --line: #e8dcc6;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;

  --r-lg: 22px;
  --r-md: 14px;
  --shadow-sm: 0 1px 2px rgba(91, 70, 38, .06);
  --shadow: 0 6px 18px -8px rgba(91, 70, 38, .22), 0 2px 5px rgba(91, 70, 38, .06);
  --shadow-lg: 0 18px 38px -14px rgba(91, 70, 38, .34);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  line-height: 1.55;
  background-color: var(--paper);
  /* soft color clouds (gradient mesh) for atmosphere */
  background-image:
    radial-gradient(60rem 40rem at 110% -8%, rgba(226,154,99,.16), transparent 60%),
    radial-gradient(48rem 38rem at -12% 4%, rgba(125,154,109,.16), transparent 58%),
    radial-gradient(70rem 60rem at 50% 120%, rgba(125,154,109,.10), transparent 60%);
  background-attachment: fixed;
}

/* fine paper grain as an overlay */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: -.01em; }
a { color: var(--sage-deep); text-underline-offset: 2px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, rgba(255,253,248,.92), rgba(250,245,236,.86));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + .85rem) 1.1rem .75rem;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 1120px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.brand-emoji {
  font-size: 1.55rem; line-height: 1; flex: none;
  width: 2.6rem; height: 2.6rem; display: grid; place-items: center;
  background: var(--sage-soft); border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(125,154,109,.35);
}
.topbar h1 {
  font-size: 1.08rem; font-weight: 700; color: var(--ink); line-height: 1.1;
}
.brand-link { text-decoration: none; color: inherit; cursor: pointer; border-radius: 999px; }
.topbar-back {
  display: flex; align-items: center; gap: .75rem; min-width: 0;
  text-decoration: none; color: inherit;
}
.topbar-back-icon {
  width: 1.2rem; height: 1.2rem; stroke: var(--sage-deep); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none;
}
.back-link {
  font-family: var(--body); font-weight: 700; text-decoration: none;
  color: var(--sage-deep); white-space: nowrap;
  background: var(--sage-soft); padding: .45rem .8rem; border-radius: 999px;
}

.progress { display: flex; align-items: center; }
.progress-ring {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  background: var(--card); border: 1.5px solid var(--sage); border-radius: 999px;
  padding: .2rem .85rem .25rem; box-shadow: var(--shadow-sm);
}
.progress-count-row {
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
  color: var(--sage-deep); line-height: 1;
}
.progress-total { color: var(--ink-faint); font-size: .8em; }
.progress-label {
  font-family: var(--body); font-size: .6rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-faint); line-height: 1;
}
.progress-bar {
  height: 6px; background: var(--apricot-soft); border-radius: 999px;
  max-width: 1120px; margin: .7rem auto 0; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--sage), var(--apricot));
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* ---------- Brand group (title + child bubble) ---------- */
.brand-group {
  display: flex; align-items: center; gap: .45rem; position: relative;
}
.child-name-label {
  font-family: var(--body); font-size: .8rem; font-weight: 700;
  color: var(--ink-soft); background: var(--sage-soft);
  padding: .22rem .65rem; border-radius: 999px;
}

/* Child picker dropdown (details/summary, CSS-only) */
.child-picker { position: relative; }
.child-picker[open] { z-index: 100; }
.child-picker-toggle {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: .3rem;
  font-family: var(--body); font-size: .8rem; font-weight: 700;
  color: var(--ink); background: var(--sage-soft);
  border: 1px solid transparent;
  padding: .22rem .55rem .22rem .65rem; border-radius: 999px;
  user-select: none;
  transition: background .15s, color .15s, border-color .15s;
}
.child-picker-toggle::-webkit-details-marker { display: none; }
.child-picker-toggle:hover {
  background: var(--sage); color: #fff; border-color: var(--sage);
}
.child-picker[open] .child-picker-toggle {
  background: var(--sage); color: #fff; border-color: var(--sage);
}
.child-picker-chevron {
  font-size: .75em; display: inline-block;
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.child-picker[open] .child-picker-chevron { transform: rotate(180deg); }

.child-picker-drop {
  position: absolute; top: calc(100% + .5rem); left: 50%;
  transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border);
  border-radius: .85rem; box-shadow: var(--shadow);
  padding: .35rem; min-width: 11rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.child-picker-drop form { display: contents; }
.child-pick-btn {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font-family: var(--body); font-size: .85rem; font-weight: 600; color: var(--ink);
  padding: .45rem .75rem; border-radius: .55rem;
  display: flex; align-items: center; gap: .5rem;
  transition: background .12s;
}
.child-pick-btn:hover:not(.is-active) { background: var(--sage-soft); }
.child-pick-btn.is-active { background: var(--sage); color: #fff; cursor: default; }
.child-pick-check {
  width: .9em; flex: none; font-size: .85em;
}

/* ---------- Main ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 1.4rem 1.1rem 4rem; }

/* ---------- Settings page ---------- */
.settings-main { max-width: 560px; margin: 0 auto; padding: 1.4rem 1.1rem 4rem; }
.settings-page { max-width: 560px; margin: 0 auto; padding: 1.4rem 1.1rem 4rem; }
.child-add-form { margin-top: .75rem; }
.settings-section { margin-bottom: 2rem; }
.settings-section h2 {
  font-family: var(--display); font-size: 1.1rem; font-weight: 700;
  color: var(--ink); margin: 0 0 .8rem;
}
.settings-welcome {
  background: var(--sage-soft); border: 1.5px solid var(--sage);
  border-radius: .75rem; padding: .8rem 1rem; margin-bottom: 1.5rem;
}
.settings-welcome-text {
  margin: 0; font-size: .9rem; color: var(--sage-deep); font-weight: 600;
}
.child-card {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: .9rem; padding: .9rem 1rem; margin-bottom: .7rem;
  transition: border-color .15s;
}
.child-card.is-active { border-color: var(--sage); }
.child-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .4rem;
}
.child-card-name { font-weight: 700; font-size: 1rem; color: var(--ink); }
.child-active-badge {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; background: var(--sage); color: #fff;
  padding: .15rem .5rem; border-radius: 999px;
}
.child-edit-details summary {
  cursor: pointer; font-size: .82rem; color: var(--ink-faint);
  font-weight: 600; list-style: none; user-select: none;
}
.child-edit-details summary::-webkit-details-marker { display: none; }
.child-edit-details[open] > summary { display: none; }
.child-form {
  display: flex; flex-direction: column; gap: .7rem; margin-top: .5rem;
}
.child-form label {
  display: flex; flex-direction: column; gap: .25rem;
  font-size: .82rem; font-weight: 600; color: var(--ink-soft);
}
.child-form input[type="text"],
.child-form input[type="date"] {
  font-family: var(--body); font-size: .9rem; color: var(--ink);
  background: #fff; border: 1.5px solid var(--sage);
  border-radius: .5rem; padding: .45rem .7rem;
  transition: border-color .15s, box-shadow .15s;
}
.child-form input:focus {
  outline: none; border-color: var(--sage-deep);
  box-shadow: 0 0 0 3px rgba(122,168,116,.18);
}
.child-form-actions {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  margin-top: .8rem;
}
.child-form-actions form { display: contents; }
.btn {
  font-family: var(--body); font-size: .85rem; font-weight: 700;
  border: none; border-radius: .5rem; padding: .45rem .9rem; cursor: pointer;
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn-primary   { background: var(--sage); color: #fff; }
.btn-secondary { background: var(--paper-2); color: var(--ink-soft); }
.btn-danger    { background: #d94f4f; color: #fff; }
.btn-link {
  background: none; border: none; cursor: pointer;
  font-size: .82rem; font-weight: 600; color: var(--sage-deep);
  padding: 0; text-decoration: underline;
}

/* ---------- Safety (subtle) ---------- */
.safety { margin: .1rem 0 1.2rem; }
.safety-bottom { margin: 2.4rem 0 .5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.safety-toggle {
  display: inline-flex; align-items: center; gap: .5rem;
  background: transparent; border: 0; color: var(--ink-soft);
  font-family: var(--body); font-weight: 700; font-size: .82rem; cursor: pointer;
  padding: .3rem 0;
}
.safety-toggle::before {
  content: ""; width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--apricot); box-shadow: 0 0 0 3px var(--apricot-soft);
}
.safety-toggle:hover { color: var(--ink); }
.safety-toggle .chev { font-size: .65rem; transition: transform .2s; }
.safety-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.safety-body {
  gap: .7rem; margin-top: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.safety-body:not([hidden]) { display: grid; }
[hidden] { display: none !important; }
.safety-card {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--apricot);
  border-radius: var(--r-md); padding: .85rem .95rem; box-shadow: var(--shadow-sm);
}
.safety-card h3 { font-size: .98rem; color: var(--apricot-deep); margin-bottom: .25rem; }
.safety-card p { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.src-link { font-family: var(--body); font-size: .8rem; font-weight: 700; }

/* ---------- Controls ---------- */
.controls { display: grid; gap: .85rem; margin-bottom: 1.4rem; }
.seg {
  display: inline-flex; align-self: start; gap: 3px;
  background: var(--paper-2); border-radius: 999px; padding: 4px;
  box-shadow: inset 0 1px 2px rgba(91,70,38,.06);
}
.seg-btn {
  border: 0; background: transparent; color: var(--ink-soft);
  font-family: var(--body); font-weight: 800; font-size: .88rem;
  padding: .5rem 1.1rem; border-radius: 999px; cursor: pointer; transition: .18s;
}
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

.filters { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
#search {
  flex: 1 1 200px; min-width: 150px; padding: .62rem 1rem;
  border: 1.5px solid var(--line); border-radius: 999px; font-size: 1rem;
  background: var(--card); color: var(--ink); font-family: var(--body);
  transition: border-color .15s, box-shadow .15s;
}
#search::placeholder { color: var(--ink-faint); }
#search:focus { outline: 0; border-color: var(--sage); box-shadow: 0 0 0 4px var(--sage-soft); }
.chk {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  font-size: .86rem; font-weight: 700; color: var(--ink-soft);
  background: var(--card); border: 1.5px solid var(--line);
  padding: .48rem .8rem; border-radius: 999px; transition: .15s;
}
.chk:hover { border-color: var(--sage); color: var(--ink); }
.chk input { accent-color: var(--sage); width: 1rem; height: 1rem; }

.month-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .55rem;
  font-size: .9rem; font-weight: 700; color: var(--ink-soft);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: .7rem .9rem; box-shadow: var(--shadow-sm);
}
.month-row select {
  padding: .42rem .7rem; border-radius: 10px; border: 1.5px solid var(--line);
  font-size: 1rem; background: var(--paper); color: var(--ink); font-family: var(--body); font-weight: 700;
}
.hint { color: var(--ink-faint); font-size: .8rem; font-weight: 600; }

/* ---------- Sections & grid ---------- */
.cat-title {
  font-family: var(--display); font-size: 1.25rem; font-weight: 700;
  color: var(--ink); margin: 1.5rem 0 .75rem;
}
.cat-section { margin-bottom: 2rem; }
.cat-head {
  display: flex; align-items: center; gap: .3rem; margin: 1rem 0 .6rem;
  border-bottom: 2px solid var(--line); padding-bottom: .3rem;
}
.cat-fold {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .55rem;
  background: transparent; border: 0; cursor: pointer; padding: .2rem 0; text-align: left;
  font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.cat-fold .chev { font-size: .75rem; color: var(--ink-faint); transition: transform .2s; flex: none; }
.cat-section.collapsed .cat-fold .chev { transform: rotate(-90deg); }
.cat-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count {
  font-family: var(--body); font-size: .72rem; font-weight: 800; color: var(--ink-faint);
  background: var(--paper-2); border-radius: 999px; padding: .15rem .55rem; flex: none;
}
.cat-section.collapsed .cat-body { display: none; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }

/* ---------- Card ---------- */
.card {
  position: relative; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1rem .95rem .9rem; display: flex; flex-direction: column; gap: .55rem;
  box-shadow: var(--shadow);
  transition: transform .18s cubic-bezier(.4,0,.2,1), box-shadow .18s, opacity .25s;
  animation: cardIn .5s both;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* soft, staggered fade-in per category grid */
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.grid .card:nth-child(1) { animation-delay: .02s; }
.grid .card:nth-child(2) { animation-delay: .06s; }
.grid .card:nth-child(3) { animation-delay: .10s; }
.grid .card:nth-child(4) { animation-delay: .14s; }
.grid .card:nth-child(5) { animation-delay: .18s; }
.grid .card:nth-child(6) { animation-delay: .22s; }
.grid .card:nth-child(7) { animation-delay: .26s; }
.grid .card:nth-child(8) { animation-delay: .30s; }

.card.is-allergen { border-color: #eccdd7; }
.card.is-allergen::after {
  content: ""; position: absolute; top: 0; left: 1.2rem; right: 1.2rem; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--berry);
}
.card.is-eaten { background: var(--sage-soft); border-color: #cfe0c2; }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; }
.card-icon {
  width: 58px; height: 58px; object-fit: contain; flex: none;
  background: radial-gradient(circle at 50% 38%, rgba(255,255,255,.9), var(--paper-2));
  border-radius: 50%; padding: 7px; box-shadow: inset 0 0 0 1px rgba(91,70,38,.06);
}
.card.is-eaten .card-icon { background: radial-gradient(circle at 50% 38%, #fff, #d9e6cd); }
.card-badges { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.badge {
  font-family: var(--body); font-size: .64rem; font-weight: 800; letter-spacing: .02em;
  padding: .18rem .5rem; border-radius: 999px; white-space: nowrap;
}
.badge-allergen { background: var(--berry-soft); color: var(--berry); }
.badge-age { background: var(--sage-soft); color: var(--sage-deep); }
.badge-season, .season-now { background: var(--apricot-soft); color: var(--apricot-deep); }

.card-name { font-family: var(--display); font-weight: 600; font-size: 1.08rem; line-height: 1.15; color: var(--ink); }
.card-desc { margin: 0; font-size: .82rem; color: var(--ink-soft); flex: 1; }
.card-note summary {
  font-family: var(--body); font-size: .78rem; font-weight: 800; color: var(--berry);
  cursor: pointer; list-style: none;
}
.card-note summary::before { content: "✿ "; }
.card-note p { font-size: .8rem; color: var(--ink-soft); margin: .35rem 0 0; }
.allergen-note summary::before { content: "⚠ "; }
.allergen-note summary { color: var(--berry); }
.card-safety {
  margin: 0; font-size: .76rem; color: var(--apricot-deep);
  background: var(--apricot-soft); padding: .42rem .58rem; border-radius: 10px;
}

.eat-btn {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1.5px solid var(--sage); background: var(--card); color: var(--sage-deep);
  font-family: var(--body); font-weight: 800; font-size: .86rem;
  padding: .58rem; border-radius: 12px; cursor: pointer; transition: .15s;
}
.eat-btn .eat-check {
  display: grid; place-items: center; width: 1.05rem; height: 1.05rem; border-radius: 50%;
  border: 1.5px solid var(--sage); color: transparent; font-size: .7rem; line-height: 1; transition: .15s;
}
.eat-label { font-size: .86rem; }
.eat-btn:hover { background: var(--sage-soft); }
.eat-btn:active { transform: scale(.97); }
.card.is-eaten .eat-btn { background: var(--sage); border-color: var(--sage); color: #fff; }
.card.is-eaten .eat-btn .eat-check { background: #fff; border-color: #fff; color: var(--sage-deep); }

.card.filtered-out { display: none; }
.card.out-of-season { opacity: .45; filter: saturate(.7); }

/* ---------- Footer & misc ---------- */
.empty { text-align: center; color: var(--ink-soft); padding: 2.5rem; font-size: 1.05rem; font-family: var(--display); }
.foot { margin-top: 2.5rem; text-align: center; }
.foot a {
  font-family: var(--body); font-weight: 800; text-decoration: none; color: var(--sage-deep);
  background: var(--sage-soft); padding: .55rem 1rem; border-radius: 999px; display: inline-block;
}
.disclaimer { font-size: .76rem; color: var(--ink-faint); margin-top: 1rem; line-height: 1.5; max-width: 60ch; margin-inline: auto; }

/* ---------- Sources page (/quellen) ---------- */
.prose { max-width: 68ch; font-size: .95rem; color: var(--ink-soft); }
.source-list { padding-left: 1.1rem; display: grid; gap: .55rem; }
.source-list a { font-weight: 700; }
.src-table { display: grid; gap: .55rem; }
.src-row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: .7rem .9rem; display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  align-items: center; justify-content: space-between; box-shadow: var(--shadow-sm);
}
.src-food { display: flex; align-items: center; gap: .7rem; }
.src-icon { width: 34px; height: 34px; object-fit: contain; }
.src-food strong { font-family: var(--display); font-weight: 600; }
.src-cat { display: block; font-size: .76rem; color: var(--ink-faint); font-weight: 600; }
.src-refs { display: flex; flex-wrap: wrap; gap: .35rem .8rem; }
.src-refs a { font-size: .8rem; font-weight: 700; }

/* ---------- Rezepte ---------- */
.recipe-cta {
  display: flex; align-items: center; gap: .85rem; text-decoration: none;
  background: linear-gradient(110deg, var(--apricot-soft), var(--sage-soft));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: .85rem 1.1rem; margin-bottom: 1.2rem; color: var(--ink);
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s;
}
.recipe-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.recipe-cta-emoji {
  font-size: 1.5rem; width: 2.6rem; height: 2.6rem; flex: none;
  display: grid; place-items: center; background: var(--card); border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.recipe-cta-text { flex: 1; font-size: .92rem; }
.recipe-cta-text strong { font-family: var(--display); font-weight: 700; }
.recipe-cta-arrow { font-size: 1.3rem; color: var(--apricot-deep); font-weight: 800; }

.age-pill {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: .55rem 1rem; font-size: .88rem; color: var(--ink-soft);
  box-shadow: var(--shadow-sm); margin: 0 0 1.3rem;
}
.age-pill strong { color: var(--sage-deep); }

.randomizer { text-align: center; margin-bottom: 2rem; }
.dice-btn {
  font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: #fff;
  background: linear-gradient(135deg, var(--sage), var(--apricot));
  border: 0; border-radius: 999px; padding: .8rem 1.8rem; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; letter-spacing: -.01em;
}
.dice-btn:hover { transform: translateY(-2px) rotate(-1deg); box-shadow: var(--shadow-lg); }
.dice-btn:active { transform: scale(.97); }
.randomizer-hint { font-size: .8rem; color: var(--ink-faint); margin: .6rem 0 0; }
/* Meal tabs (time of day) – reuse .seg/.seg-btn, may wrap on mobile */
.meal-seg { display: flex; flex-wrap: wrap; max-width: 100%; margin-bottom: 1.1rem; }

/* Stable result slot: no jump – fade in instead of scrolling */
.recipe-result {
  margin-top: 1.4rem; opacity: 0; transition: opacity .3s ease;
}
.recipe-result.is-shown { opacity: 1; }
.recipe-result:empty { margin-top: 0; }
.result-label {
  font-family: var(--display); font-weight: 600; font-size: 1.15rem; color: var(--apricot-deep);
  margin: 0 0 .7rem; text-align: center;
}
.recipe-result .recipe-card { animation: cardIn .45s both; box-shadow: var(--shadow-lg); border-color: var(--apricot); }

/* Time-of-day filter for the recipe list */
.recipe-card.filtered-out { display: none; }
.badge-meal { background: var(--apricot-soft); color: var(--apricot-deep); }

.recipe-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.recipe-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .75rem;
}
.recipe-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; justify-content: space-between; }
.recipe-title { font-family: var(--display); font-weight: 600; font-size: 1.18rem; color: var(--ink); line-height: 1.15; }
.recipe-badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge-kind { background: var(--paper-2); color: var(--ink-soft); }

.recipe-ings { display: flex; flex-wrap: wrap; gap: .4rem; }
.ing-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px;
  padding: .2rem .55rem .2rem .25rem; font-size: .78rem; font-weight: 700; color: var(--ink-soft);
}
.ing-chip img { border-radius: 50%; background: var(--card); }
.ing-chip.in-season { background: var(--apricot-soft); border-color: #eccfb0; color: var(--apricot-deep); }
.ing-chip.is-allergen { box-shadow: inset 0 0 0 1.5px var(--berry-soft); }

.recipe-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; font-size: .86rem; color: var(--ink-soft); }
.recipe-steps li::marker { color: var(--sage); font-weight: 800; }
.recipe-tip {
  margin: 0; font-size: .82rem; color: var(--sage-deep);
  background: var(--sage-soft); padding: .5rem .65rem; border-radius: 10px;
}
.more-recipes { margin-top: 2.2rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
  z-index: 300; max-width: min(92vw, 26rem);
  background: var(--ink); color: var(--paper);
  font-weight: 700; font-size: .92rem; line-height: 1.4; text-align: center;
  padding: .65rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease both;
}
.toast.error { background: var(--berry); color: #fff; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Language toggle ---------- */
.lang-bar {
  display: flex;
  justify-content: center;
  padding: .6rem 0 .4rem;
}
.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: .2rem .4rem;
  opacity: .75;
  border-radius: 999px;
}
.lang-btn:hover, .lang-btn:focus-visible { opacity: 1; outline: none; }

@media (min-width: 640px) {
  .topbar h1 { font-size: 1.45rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); }
  main { padding-top: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .recipe-result, .recipe-result .recipe-card { animation: none; transition: none; }
  .progress-bar-fill { transition: none; }
  .toast { animation: none; }
  * { scroll-behavior: auto; }
}

/* =============================================================
   Auth + Settings + Modal  (ported from foundation template)
   Color map: --sea→--sage, --coral→--berry, --r-pill→999px,
              --r-sm→.5rem, --ink-label→--ink-faint
   ============================================================= */

/* ---------- Shared button variants (auth / settings) ---------- */
.primary-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 700; font-size: .88rem; color: #fff;
  background: var(--sage); border: 1.5px solid var(--sage); border-radius: .5rem;
  padding: .5rem .95rem; cursor: pointer; transition: .15s;
  -webkit-tap-highlight-color: transparent;
}
.primary-btn:hover { background: var(--sage-deep); border-color: var(--sage-deep); }
.primary-btn:active { transform: scale(.97); }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; }
.primary-btn.danger { background: var(--berry); border-color: var(--berry); }
.primary-btn.danger:hover { background: #a0446a; border-color: #a0446a; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 700; font-size: .8rem; color: var(--ink-soft);
  background: transparent; border: 1.5px solid var(--line); border-radius: 999px;
  padding: .4rem .8rem; cursor: pointer; transition: .15s;
}
.ghost-btn:hover { background: var(--card); border-color: var(--sage); color: var(--ink); }
.ghost-btn:active { transform: scale(.97); }
.ghost-btn.danger { color: var(--berry); background: var(--berry-soft); border-color: rgba(194,91,126,.35); }
.ghost-btn.danger:hover { background: var(--berry); border-color: var(--berry); color: #fff; }

.text-input {
  padding: .55rem .75rem; border: 1.5px solid var(--line); border-radius: .5rem;
  font: 400 .9rem/1.4 var(--body); background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.text-input:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 4px var(--sage-soft); }

/* ---------- Login / Auth pages ---------- */
.login-page {
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem 4rem;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card); border-radius: var(--r-lg);
  border: 1px solid var(--line); padding: 2rem;
  box-shadow: var(--shadow);
}
.login-heading {
  font: 700 1.4rem/1.2 var(--display); color: var(--ink);
  margin: 0 0 1.25rem; text-align: center;
}
.login-tabs {
  display: flex; gap: 0; margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--line);
}
.login-tab {
  flex: 1; padding: .6rem .5rem; background: none; border: none; cursor: pointer;
  font: 600 .9rem/1 var(--body); color: var(--ink-soft);
  position: relative; transition: color .15s;
}
.login-tab.active { color: var(--sage-deep); }
.login-tab.active::after {
  content: ""; position: absolute; bottom: -2px; left: 0; right: 0;
  height: 2px; background: var(--sage);
}
.login-tab:hover:not(.active) { color: var(--ink); }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-label {
  font: 700 .72rem/1 var(--body); color: var(--ink-soft);
  letter-spacing: .04em; text-transform: uppercase;
}
.form-input {
  padding: .6rem .75rem; border: 1.5px solid var(--line); border-radius: .5rem;
  font: 400 1rem/1.4 var(--body); background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 4px var(--sage-soft); }
.form-input::placeholder { color: var(--ink-faint); }
.form-hint { font-size: .78rem; color: var(--ink-soft); }
.login-submit { width: 100%; margin-top: .25rem; }
.forgot-link {
  font-size: .8rem; color: var(--sage-deep); text-decoration: none; align-self: flex-end;
}
.forgot-link:hover { text-decoration: underline; }
.login-error {
  font-size: .85rem; color: var(--berry); background: rgba(194,91,126,.06);
  border: 1px solid rgba(194,91,126,.25); border-radius: .5rem;
  padding: .5rem .75rem; margin: 0;
}
.login-success {
  font-size: .85rem; color: var(--sage-deep); background: rgba(125,154,109,.08);
  border: 1px solid rgba(125,154,109,.3); border-radius: .5rem;
  padding: .5rem .75rem; margin: 0;
}
.login-divider {
  display: flex; align-items: center; gap: .75rem;
  margin: 1.25rem 0 1rem; color: var(--ink-soft); font-size: .8rem;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; padding: .65rem 1rem; border-radius: .5rem;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font: 600 .9rem/1 var(--body); text-decoration: none; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.google-btn:hover { border-color: var(--sage); background: var(--paper); }
.auth-desc { font-size: .9rem; color: var(--ink-soft); margin: -.5rem 0 1.25rem; line-height: 1.5; }
.auth-back-link {
  display: inline-block; margin-top: 1.25rem;
  font-size: .85rem; color: var(--sage-deep); text-decoration: none;
}
.auth-back-link:hover { text-decoration: underline; }

/* ---------- Settings cards + forms ---------- */
.settings-heading {
  font-family: var(--display); font-size: 1.5rem; font-weight: 900;
  color: var(--ink); margin: 0 0 1.4rem;
}
.settings-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.settings-card-danger { border-color: var(--berry); background: var(--berry-soft); }
.settings-section-title {
  font-family: var(--body); font-size: .75rem; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 .75rem;
}
.settings-user-row { display: flex; align-items: center; gap: 1rem; }
.settings-user-info { min-width: 0; }
.settings-avatar {
  width: 2.8rem; height: 2.8rem; border-radius: 50%; background: var(--sage);
  color: #fff; display: grid; place-items: center;
  font-size: 1.2rem; font-weight: 700; flex: none;
}
.settings-user-name { font-weight: 700; color: var(--ink); margin: 0 0 .15rem; font-size: 1rem; }
.settings-user-email { color: var(--ink-soft); font-size: .85rem; margin: 0; }
.settings-card-desc { color: var(--ink-soft); font-size: .88rem; margin: 0 0 .75rem; line-height: 1.5; }
.settings-danger-msg { color: var(--ink-soft); font-size: .88rem; margin: 0 0 .9rem; line-height: 1.5; }
.settings-nav-link {
  display: block; color: var(--sage-deep); text-decoration: none;
  padding: .45rem 0; font-size: .95rem; border-top: 1px solid var(--line);
}
.settings-nav-link:first-of-type { border-top: none; }
.settings-nav-link:hover { text-decoration: underline; }
.settings-loading { opacity: .6; }
.settings-row { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; }
.settings-section-label {
  font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-faint); margin: .9rem 0 .35rem;
}
.settings-form { display: flex; flex-direction: column; gap: .65rem; }
.settings-field-group { display: flex; flex-direction: column; gap: .3rem; }
.settings-field-label {
  font: 700 .72rem/1 var(--body); color: var(--ink-soft);
  letter-spacing: .04em; text-transform: uppercase;
}
.settings-field-input {
  width: 100%; box-sizing: border-box;
  padding: .55rem .75rem; border: 1.5px solid var(--line); border-radius: .5rem;
  font: 400 .9rem/1.4 var(--body); background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.settings-field-input:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 4px var(--sage-soft); }
.settings-form-error { font-size: .82rem; color: var(--berry); margin: 0; }
.settings-card > .primary-btn,
.settings-card > .ghost-btn { display: flex; width: 100%; justify-content: center; box-sizing: border-box; }
.licenses-list { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: .3rem .75rem; font-size: .88rem; }
.licenses-list dt { color: var(--ink); font-weight: 600; }
.licenses-list dd { margin: 0; color: var(--ink-soft); text-align: right; }

/* ---------- Family management (settings) ---------- */
.family-members-list { display: flex; flex-direction: column; gap: .4rem; margin: .6rem 0; }
.family-member-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem 0; border-bottom: 1px solid var(--line);
}
.family-member-row:last-child { border-bottom: none; }
.family-member-avatar {
  width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
  background: var(--sage); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font: 700 .9rem/1 var(--body);
}
.family-member-name { flex: 1; font-weight: 600; font-size: .9rem; color: var(--ink); }
.family-role-badge {
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  padding: .15rem .5rem; border-radius: 999px;
  background: var(--sage-soft); color: var(--sage-deep);
}
.family-role-badge.role-owner { background: var(--apricot-soft); color: var(--apricot-deep); }
.family-promote-btn, .family-remove-btn { font-size: .78rem; padding: .25rem .55rem; }
.family-invite-section { margin-top: .8rem; }
.invite-link-row {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  background: var(--paper-2); border-radius: .5rem; padding: .5rem .6rem;
  margin-bottom: .4rem;
}
.invite-link-url {
  flex: 1; min-width: 0;
  font: .75rem/1.4 ui-monospace, monospace; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.family-leave-row { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); }

/* ---------- Join / invite landing page ---------- */
.join-page { max-width: 480px; margin: 3rem auto; padding: 0 1.1rem; }
.join-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 2rem 1.6rem; text-align: center; box-shadow: var(--shadow-sm);
}
.join-card-error { border-color: var(--berry); }
.join-icon { font-size: 3rem; display: block; margin-bottom: .75rem; }
.join-heading {
  font-family: var(--display); font-size: 1.4rem; font-weight: 900;
  color: var(--ink); margin: 0 0 .75rem;
}
.join-msg { color: var(--ink-soft); line-height: 1.6; margin: 0 0 1.4rem; }
.join-action-btn {
  display: inline-block; text-decoration: none;
  background: var(--sage); color: #fff; border: none; border-radius: .5rem;
  padding: .7rem 1.4rem; font: 700 .95rem/1.2 var(--body); cursor: pointer;
}
.join-action-btn:hover { background: var(--sage-deep); }
.join-note { font-size: .8rem; color: var(--ink-faint); margin: 1rem 0 0; }

/* ---------- Modal (delete/confirm dialogs) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(59,50,40,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.5rem; max-width: 380px; width: 100%;
  box-shadow: var(--shadow-lg); animation: slideUp .18s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-title { font-family: var(--display); font-weight: 700; font-size: 1.3rem; color: var(--ink); margin: 0; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.modal-close {
  background: none; border: none; cursor: pointer; padding: .25rem;
  color: var(--ink-faint); font-size: 1.1rem; border-radius: .35rem; line-height: 1;
}
.modal-close:hover { color: var(--ink); background: var(--paper-2); }
.modal-msg { margin: 0 0 1.3rem; color: var(--ink-soft); font-size: .95rem; line-height: 1.5; }
.modal-actions { display: flex; gap: .75rem; }
.modal-btn {
  flex: 1; padding: .6rem .8rem; border-radius: .5rem; font: 700 .88rem/1 var(--body);
  border: 1.5px solid var(--line); cursor: pointer; transition: .15s;
}
.modal-btn.cancel { background: var(--card); color: var(--ink-soft); }
.modal-btn.cancel:hover { background: var(--paper-2); color: var(--ink); }
.modal-btn.confirm { background: var(--sage); border-color: var(--sage); color: #fff; }
.modal-btn.confirm:hover { background: var(--sage-deep); }
.modal-btn.confirm.danger { background: var(--berry); border-color: var(--berry); }
.modal-btn.confirm.danger:hover { background: #a0446a; }
.modal-btn:active { transform: scale(.97); }
body.modal-open { overflow: hidden; }

/* ---------- User initial / avatar (footer nav) ---------- */
.user-initial {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--sage); color: #fff;
  font: 700 .75rem/1 var(--body); text-transform: uppercase;
}
.avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.settings-avatar.has-photo,
.user-initial.has-photo { overflow: hidden; padding: 0; background: none; color: transparent; }
