/* disCard -- mobile-first. Palette and type follow cyoa-sourdough/www/index.html:
   cream background, amber-900 header, terracotta accents, Georgia headings.
   No CDN dependencies: everything here works offline inside the app. */

:root {
  --bg: #f7f2ea;
  --ink: #4a3b32;
  --muted: #8a6f5a;
  --cream-50: #fdfbf7;
  --cream-100: #f7f2ea;
  --cream-200: #eee5d8;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-300: #fcd34d;
  --amber-700: #b45309;
  --amber-800: #92400e;
  --amber-900: #78350f;
  --amber-950: #451a03;
  --terra: #ea580c;
  --terra-dark: #c2410c;
  --imperial: #2f6fd6;
  --ok: #059669;
  --danger: #b91c1c;
  --radius: 16px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--serif); color: var(--amber-900); margin: 0; line-height: 1.2; }
p { margin: 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

:focus-visible { outline: 3px solid var(--terra); outline-offset: 2px; }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--amber-900); color: var(--amber-50);
  padding-top: var(--safe-t);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.app-header__inner {
  max-width: 760px; margin: 0 auto; padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand__mark { font-size: 1.6rem; }
.brand__name { display: block; font: 700 1.25rem/1.1 var(--serif); letter-spacing: .02em; }
.brand__tag { display: none; font-size: .72rem; color: var(--amber-200); }

.units {
  display: flex; flex: none; overflow: hidden;
  border: 1px solid rgba(180, 83, 9, .7); border-radius: 10px;
  background: rgba(69, 26, 3, .45);
}
.units button {
  border: 0; background: transparent; color: var(--amber-200);
  padding: 7px 10px; min-height: 36px; font-size: .78rem; font-weight: 600;
}
.units button[aria-checked="true"] { background: var(--amber-700); color: #fff; }

/* ---------- layout ---------- */
.app-main {
  flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 24px);
  outline: none;
}
.stack { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: #fff; border: 1px solid var(--amber-200); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(120, 53, 15, .06);
}
.card__pad { padding: 16px; }
.card h2 { font-size: 1.1rem; }
.section-title { font-size: 1.05rem; margin: 6px 2px 0; }

/* ---------- bottom tab bar (top bar on wide screens) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: var(--cream-50); border-top: 1px solid var(--amber-200);
  padding-bottom: var(--safe-b);
  box-shadow: 0 -2px 8px rgba(120, 53, 15, .08);
}
.tabbar a {
  flex: 1; min-height: var(--tab-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .72rem; font-weight: 600; text-decoration: none; color: var(--muted);
}
.tabbar a[aria-current="page"] { color: var(--amber-900); }
.tabbar a[aria-current="page"] svg { stroke: var(--terra-dark); }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon--sm { width: 18px; height: 18px; }

@media (min-width: 800px) {
  .tabbar {
    position: sticky; top: calc(56px + var(--safe-t)); bottom: auto; order: 1;
    justify-content: center; box-shadow: none; padding-bottom: 0;
  }
  .tabbar a { flex: 0 0 140px; min-height: 48px; flex-direction: row; justify-content: center; gap: 8px; font-size: .9rem; }
  .app-main { order: 2; padding-bottom: 48px; }
  .brand__tag { display: block; }
}

/* ---------- starter card ---------- */
.card-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: 0; text-align: left; padding: 16px; min-height: 64px;
}
.card-head h2 { font-size: 1.1rem; }
.chev { transition: transform .2s; color: var(--amber-700); }
.card-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.card-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; }

.field-label { display: block; font-size: .8rem; font-weight: 700; color: var(--amber-900); margin-bottom: 6px; }

.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper button {
  flex: 0 0 56px; min-height: 52px; border-radius: 12px; border: 2px solid var(--amber-300);
  background: var(--amber-100); color: var(--amber-900); font-size: 1.5rem; font-weight: 700; line-height: 1;
}
.stepper button:active { background: var(--amber-200); }
.stepper__input {
  position: relative; flex: 1;
}
.stepper__input input {
  width: 100%; height: 100%; min-height: 52px; padding: 0 34px 0 12px; text-align: center;
  font-size: 1.4rem; font-weight: 700; color: var(--amber-900);
  border: 2px solid var(--amber-300); border-radius: 12px; background: #fff;
  -moz-appearance: textfield;
}
.stepper__input input:focus { outline: none; border-color: var(--terra); }
.stepper__input input::-webkit-outer-spin-button, .stepper__input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--amber-700); }

.seg { display: flex; border: 2px solid var(--amber-300); border-radius: 12px; overflow: hidden; background: #fff; }
.seg button { flex: 1; min-height: 46px; border: 0; background: transparent; font-weight: 600; color: var(--amber-900); }
.seg button + button { border-left: 1px solid var(--amber-200); }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--amber-900); color: #fff; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; background: var(--cream-50); border: 1px solid var(--amber-200);
  border-radius: 12px; padding: 10px 12px; min-height: 52px;
}
.switch-row b { display: block; font-size: .9rem; color: var(--amber-900); }
.switch {
  flex: none; width: 46px; height: 28px; border-radius: 99px; background: #d6c9b8; position: relative; transition: background .15s;
}
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
[aria-checked="true"] > .switch { background: var(--ok); }
[aria-checked="true"] > .switch::after { transform: translateX(18px); }

/* feeding summary tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }
.tile { background: var(--cream-50); border: 1px solid var(--amber-200); border-radius: 12px; padding: 10px 12px; }
.tile__label { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--amber-700); }
.tile__value { font: 700 1.3rem/1.2 var(--serif); color: var(--amber-900); margin-top: 2px; }
.tile__sub { font-size: .8rem; color: var(--muted); }
.tile--hero { grid-column: 1 / -1; background: var(--amber-900); border-color: var(--amber-900); }
.tile--hero .tile__label { color: var(--amber-200); }
.tile--hero .tile__value { color: #fff; font-size: 1.8rem; }
.tile--hero .tile__sub { color: var(--amber-100); }
.tiles__note { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 14px 4px; margin: 0 -14px; scroll-padding: 0 14px; scroll-snap-type: x proximity; }
.chip {
  flex: none; scroll-snap-align: start; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--amber-300); background: var(--amber-100); color: var(--amber-900);
  border-radius: 99px; font-size: .88rem; font-weight: 600; white-space: nowrap;
}
.chip[aria-selected="true"], .chip.is-on { background: var(--amber-900); color: #fff; border-color: var(--amber-900); }

/* ---------- recipe list ---------- */
.recipe-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 600px) { .recipe-grid { grid-template-columns: 1fr 1fr; } }
.recipe-card {
  display: flex; align-items: center; gap: 12px; text-decoration: none; min-height: 68px;
  background: #fff; border: 1px solid var(--amber-200); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(120, 53, 15, .06);
}
.recipe-card:active { background: var(--amber-50); border-color: var(--terra); }
.recipe-card__body { flex: 1; min-width: 0; }
.recipe-card h3 { font-size: 1.02rem; }
.recipe-card .fav { color: var(--terra); }
.recipe-card .go { color: var(--amber-300); }
.fav svg { fill: currentColor; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty b { display: block; color: var(--amber-900); font-family: var(--serif); font-size: 1.1rem; margin-bottom: 4px; }

/* ---------- recipe detail ---------- */
.topbar { display: flex; align-items: center; gap: 8px; }
.topbar h1 { flex: 1; font-size: 1.35rem; min-width: 0; }
.icon-btn {
  flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 1px solid var(--amber-300); background: var(--amber-100); color: var(--amber-900); text-decoration: none;
}
.icon-btn:active { background: var(--amber-200); }
.icon-btn.is-on { color: var(--terra); }
.icon-btn.is-on svg { fill: currentColor; }

.compact-weight { display: flex; align-items: center; gap: 10px; }
.compact-weight .stepper { flex: 1; }
.compact-weight .stepper button { flex-basis: 48px; min-height: 46px; }
.compact-weight .stepper__input input { min-height: 46px; font-size: 1.15rem; }

.ingredients { list-style: none; margin: 0; padding: 4px 16px 8px; }
.ingredients li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--cream-200); }
.ingredients li:last-child { border-bottom: 0; }
.ingredients .name { font-weight: 600; }
.ingredients .qty { text-align: right; flex: none; max-width: 55%; }
.ingredients .qty b { display: block; color: var(--amber-900); }
.ingredients .imperial, .imperial { color: var(--imperial); }
.ingredients .qty .imperial { display: block; font-size: .9rem; }
.ingredients .is-discard .name { color: var(--terra-dark); }
.split-note { padding: 0 16px 14px; font-size: .82rem; color: var(--muted); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: step; }
.step {
  width: 100%; text-align: left; display: flex; gap: 12px; align-items: flex-start;
  background: #fff; border: 1px solid var(--amber-200); border-radius: 14px; padding: 12px 14px; min-height: 56px;
}
.step__num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--amber-100); color: var(--amber-900); font-weight: 700; font-size: .85rem; margin-top: 1px;
}
.step__num svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; }
.step__text strong { color: var(--amber-900); }
.step.is-addin { border-color: #fdba74; background: #fff7ed; }
.step.is-addin .step__text .addin { color: var(--terra-dark); }
.step.is-done { opacity: .55; }
.step.is-done .step__num { background: var(--ok); }
.step.is-done .step__text { text-decoration: line-through; }
.step .muted-span { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 0; font-weight: 700; background: var(--amber-900); color: #fff; text-decoration: none;
}
.btn:active { background: var(--amber-950); }
.btn--ghost { background: var(--amber-100); color: var(--amber-900); border: 1px solid var(--amber-300); }
.btn--ghost:active { background: var(--amber-200); }
.btn--terra { background: var(--terra-dark); }
.btn--block { width: 100%; }
.btn--danger { background: #fff; color: var(--danger); border: 1px solid #fca5a5; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- search ---------- */
.search-box { position: relative; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--amber-700); pointer-events: none; }
.search-box input {
  width: 100%; min-height: 52px; padding: 0 14px 0 44px; border: 2px solid var(--amber-300); border-radius: 14px;
  background: #fff; font-size: 1rem; color: var(--amber-900);
}
.search-box input:focus { outline: none; border-color: var(--terra); }

/* ---------- journal ---------- */
.entry { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.entry__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.entry__top a { font: 700 1.02rem var(--serif); color: var(--amber-900); text-decoration: none; }
.stars { color: var(--amber-700); letter-spacing: 2px; white-space: nowrap; }
.entry__note { white-space: pre-wrap; overflow-wrap: anywhere; }
.entry__foot { display: flex; justify-content: space-between; align-items: center; }
.link-btn { background: none; border: 0; color: var(--danger); font-size: .82rem; font-weight: 600; min-height: 36px; padding: 0 4px; }

/* ---------- sheet (bottom modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(69, 26, 3, .5); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.sheet {
  width: 100%; max-width: 560px; background: var(--cream-50); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px;
  animation: rise .2s ease-out; max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 800px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; } }
.sheet h2 { font-size: 1.2rem; }
.sheet textarea {
  width: 100%; min-height: 110px; padding: 12px; border: 2px solid var(--amber-300); border-radius: 12px; background: #fff; resize: vertical; font-size: 1rem;
}
.sheet textarea:focus, .sheet select:focus, .sheet input[type="time"]:focus { outline: none; border-color: var(--terra); }
.rating { display: flex; gap: 6px; }
.rating button {
  flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--amber-300); background: #fff; font-size: 1.4rem; color: var(--amber-300);
}
.rating button.is-on { color: var(--amber-700); background: var(--amber-100); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- starter tab ---------- */
.form-grid { display: grid; gap: 12px; }
.select, .time-input {
  width: 100%; min-height: 48px; padding: 0 12px; border: 2px solid var(--amber-300); border-radius: 12px; background: #fff; color: var(--amber-900); font-weight: 600;
}
.status { font-size: .88rem; padding: 10px 12px; border-radius: 12px; background: var(--amber-50); border: 1px solid var(--amber-200); }
.status--ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.status--warn { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.pill { display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--amber-100); color: var(--amber-800); vertical-align: middle; }

/* ---------- advertising (website only; see js/ads.js) ---------- */
.ad-slot { margin-top: 32px; min-height: 120px; text-align: center; overflow: hidden; }
.ad-slot .ad-label { display: block; margin-bottom: 4px; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }

.app-footer { margin-top: 24px; text-align: center; font-size: .8rem; color: var(--muted); }
.app-footer a { color: var(--muted); padding: 10px 12px; display: inline-block; }

/* ---------- plain text pages (privacy) ---------- */
.prose { display: flex; flex-direction: column; gap: 12px; }
.prose h2 { font-size: 1.1rem; margin-top: 10px; }
.prose ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 6px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 80; transform: translate(-50%, 20px);
  background: var(--amber-950); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
