:root {
  --bg: #0b1209;
  --panel: #111c10;
  --panel2: #20341c;
  --text: #f8fafc;
  --muted: #b7c4b1;
  --accent: #a3e635;
  --accentInk: #101b0d;
  --warning: #facc15;
  --danger: #fca5a5;
  --border: rgba(255,255,255,.14);
  --radius: 22px;
  --gap: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 5% 0%, rgba(163,230,53,.22), transparent 35%),
    radial-gradient(circle at 92% 8%, rgba(250,204,21,.10), transparent 38%),
    var(--bg);
  line-height: 1.5;
  overflow-wrap: break-word;
}
.app { width: min(960px, 100%); margin: 0 auto; padding: 22px 18px 32px; }

/* Header */
.hero { margin-bottom: 18px; }
.eyebrow a { display: inline-flex; align-items: center; min-height: 24px; }
.eyebrow, .label {
  color: var(--accent); font-size: .72rem; letter-spacing: .09em;
  text-transform: uppercase; font-weight: 900; margin: 0 0 8px;
}
h1 { font-size: clamp(2rem, 8vw, 3.4rem); line-height: 1.02; margin: 0 0 10px; }
h2 { margin: 0 0 6px; font-size: 1.25rem; }
h3 { margin: 0; }
.subtext { color: var(--muted); max-width: 640px; margin: 0; font-size: 1.02rem; }

/* Status banner */
.banner {
  display: flex; align-items: center; gap: 10px;
  border-radius: 16px; padding: 13px 15px; margin: 16px 0 4px;
  border: 1px solid var(--border); font-weight: 600; font-size: .95rem;
}
.banner .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); flex: none; }
.banner.ok { background: rgba(163,230,53,.10); border-color: rgba(163,230,53,.30); color: #d7f7a0; }
.banner.ok .dot { background: var(--accent); }
.banner.demo { background: rgba(250,204,21,.10); border-color: rgba(250,204,21,.28); color: #fde68a; }
.banner.demo .dot { background: var(--warning); }

/* Panels */
.panel {
  background: rgba(17, 28, 16, .97); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: var(--gap);
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
}

/* Mode selector */
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-btn {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  text-align: left; background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; padding: 14px;
  cursor: pointer; min-height: 76px; transition: border-color .15s, background .15s;
}
.mode-btn .t { font-weight: 800; font-size: 1rem; }
.mode-btn .d { font-size: .8rem; color: var(--muted); font-weight: 500; }
.mode-btn.active { border-color: var(--accent); background: rgba(163,230,53,.12); }
.mode-btn.active .d { color: #c8e89a; }
/* Non-colour cue for the selected mode (screen readers get aria-pressed). */
.mode-btn.active .t::before { content: "✓ "; content: "✓ " / ""; }
.mode-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Buttons */
button {
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accentInk);
  padding: 0 22px; min-height: 50px; font-weight: 800; cursor: pointer; font-size: 1rem;
  transition: transform .08s, opacity .15s; width: 100%;
}
button:active { transform: scale(.985); }
button:disabled, button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
/* Busy buttons use aria-disabled (not disabled) so keyboard focus stays on them. */
button[aria-disabled="true"]:active { transform: none; }
button.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
button.small { min-height: 42px; padding: 0 16px; font-size: .9rem; width: auto; }

/* Photo */
.file-wrap { background: #071006; border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin: 14px 0; }
input[type="file"] { width: 100%; color: var(--text); font-size: 16px; }
/* 44px pointer target for the native "Choose files" button. */
input[type="file"]::file-selector-button { min-height: 44px; padding: 0 16px; margin-right: 12px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accentInk); font: inherit; font-weight: 800; cursor: pointer; }
.preview-box {
  width: 100%; min-height: 200px; border: 2px dashed rgba(163,230,53,.35);
  border-radius: 18px; background: rgba(0,0,0,.22); display: grid; place-items: center;
  overflow: hidden; margin: 14px 0; text-align: center; color: var(--muted);
  padding: 16px; position: relative;
}
#previewImage { width: 100%; max-height: 340px; object-fit: cover; border-radius: 14px; }
.spinner { position: absolute; inset: 0; display: none; place-items: center; background: rgba(0,0,0,.55); border-radius: 18px; }
.spinner.active { display: grid; }
.ring { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(163,230,53,.25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Ingredients */
textarea {
  width: 100%; min-height: 120px; background: #071006; color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; padding: 14px;
  font: inherit; font-size: 16px; resize: vertical;
}
.quick-adds { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  width: auto; min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: rgba(163,230,53,.13); color: var(--text);
  border: 1px solid rgba(163,230,53,.28); font-weight: 700; font-size: .92rem;
}

/* Status line */
.status { color: var(--muted); margin: 12px 0 0; font-size: .94rem; min-height: 1.3em; }
.status.warn { color: #fde68a; }
.spacer { height: 14px; }

/* Results */
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.recipe-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.recipe-card { background: #071006; border: 1px solid var(--border); border-radius: 18px; padding: 17px; overflow-wrap: anywhere; } /* long unbroken AI words must wrap, not widen the page */
.recipe-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.recipe-top h3 { font-size: 1.18rem; min-width: 0; }
.badge { display: inline-flex; white-space: nowrap; border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: .82rem; }
.badge.best { background: rgba(163,230,53,.16); color: #d7f7a0; border: 1px solid rgba(163,230,53,.3); }
.badge.miss { background: rgba(250,204,21,.14); color: #fde68a; border: 1px solid rgba(250,204,21,.25); }
.recipe-meta { color: var(--muted); margin: 0 0 12px; font-size: .9rem; }
.ing-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.ing-grid div { border-radius: 12px; background: rgba(255,255,255,.045); padding: 11px; font-size: .9rem; }
.ing-grid h4 { display: block; margin: 0 0 5px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.miss-col h4 { color: var(--warning); }
.ing-grid .ing-text { margin: 0; }
.steps-title { margin: 0; font-size: 1rem; }
ol { padding-left: 20px; margin: 8px 0 0; }
ol li { margin-bottom: 5px; }

/* Pricing */
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pricing-grid div { background: #071006; border: 1px solid var(--border); border-radius: 14px; padding: 15px; }
/* PayPal's SDK injects helper divs (e.g. #smart-menu, layered over the button iframe) that must stay transparent. */
.pricing-grid #paypal-button-container div { background: transparent; border: 0; border-radius: 0; padding: 0; }
.pricing-grid .plan-name { font-size: 1.05rem; margin: 0; }
/* Sub-section headings keep the look of the eyebrow text they replaced. */
.pricing-grid h3.label, .pricing-grid h4.label { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }
.paypal-sandbox h3.label { margin: 0; }
.pricing-grid p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }

/* Multi-photo previews */
.preview-strip { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.preview-thumb { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }

/* Preferences (cuisine + alcohol) */
.prefs { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 14px 0 4px; }
.prefs-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 200px; }
.prefs-label { color: var(--accent); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; font-weight: 900; }
.prefs select {
  width: 100%; background: #071006; color: var(--text); border: 1px solid var(--border);
  border-radius: 14px; padding: 13px 14px; font: inherit; font-size: 16px; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23b7c4b1' stroke-width='2'><path d='M3 5l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
}
.prefs-check { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; font-size: .95rem; font-weight: 700; cursor: pointer; }
.prefs-check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Meat warning */
#meatWarning:empty { display: none; }
.banner.warn-meat { background: rgba(250,204,21,.10); border-color: rgba(250,204,21,.32); color: #fde68a; margin: 4px 0 14px; }
.banner.warn-meat .dot { background: var(--warning); }

/* Upgrade / premium */
.upgrade-btn { display: inline-block; margin-top: 12px; text-decoration: none; text-align: center; background: var(--accent); color: var(--accentInk); border-radius: 999px; padding: 12px 22px; font-weight: 800; }
.activate-premium { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.field-label { display: block; margin: 10px 0 4px; font-size: .88rem; color: var(--muted); font-weight: 700; }
.activate-premium input { width: 100%; background: #071006; color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; font: inherit; font-size: 16px; }
.activate-premium button { margin-top: 12px; }
.premium-active { color: var(--accent); font-weight: 800; }
/* SAFE PREVIEW ONLY: dashed "test" box so it never reads as a live checkout. */
.paypal-sandbox { margin-top: 16px; padding: 14px; border: 2px dashed var(--warning); border-radius: 14px; background: rgba(250,204,21,.06); }
.sandbox-note { margin: 4px 0 12px; color: #fde68a; font-weight: 700; }

/* Feedback */
.stars { display: flex; gap: 6px; margin: 6px 0 12px; }
.star { width: auto; min-width: 44px; min-height: 44px; background: none; border: 0; border-radius: 10px; padding: 0; line-height: 1; font-size: 1.9rem; color: var(--muted); cursor: pointer; }
.star.on { color: var(--warning); }
.fb-email { width: 100%; background: #071006; color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; font: inherit; font-size: 16px; margin-top: 0; }
#feedbackForm textarea { margin-top: 4px; }
#feedbackForm button[type="submit"] { margin-top: 12px; }

.hidden { display: none !important; }

/* Form field boundaries at >= 3:1 against the panel; readable placeholders. */
textarea, .prefs select, .activate-premium input, .fb-email { border-color: rgba(255,255,255,.4); }
::placeholder { color: #93a18d; opacity: 1; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Skip link: off-screen until focused, then shown at the top left. */
.skip-link {
  position: absolute; left: 12px; top: 12px; z-index: 100; transform: translateY(-200%);
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--accent); color: var(--accentInk); font-weight: 800; text-decoration: none;
}
.skip-link:focus { transform: none; }
.skip-link:hover { color: var(--accentInk); }

/* Links + keyboard focus */
a { color: var(--accent); }
a:hover { color: #d7f7a0; }
:focus-visible { outline: 3px solid var(--warning); outline-offset: 2px; }
.plan-note { color: var(--muted); font-size: .84rem; margin: 8px 0 0; }

/* Footer */
.site-footer { width: min(960px, 100%); margin: 0 auto; padding: 0 18px 40px; color: var(--muted); font-size: .88rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 18px; margin-bottom: 8px; }
.site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; }
.site-footer p { margin: 0; }

@media (max-width: 640px) {
  .app { padding: 18px 14px 28px; }
  .site-footer { padding: 0 14px 32px; }
  .modes { grid-template-columns: 1fr; }
  .ing-grid { grid-template-columns: minmax(0, 1fr); }
  .pricing-grid { grid-template-columns: 1fr; }
  .recipe-top { flex-direction: column; }
}

/* Legal pages */
.legal h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); }
.legal h2 { margin-top: 22px; }
.legal p, .legal li { color: #dfe7da; }
.legal ul { padding-left: 20px; }

/* Reduced motion: drop nonessential transitions; slow the loading spinner. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
  button:active { transform: none; }
  .ring { animation-duration: 2.4s; }
}

/* Windows high contrast / forced colours: keep boundaries and states visible. */
@media (forced-colors: active) {
  button, .chip, .mode-btn, .upgrade-btn, .banner, .panel { border: 1px solid ButtonText; }
  .mode-btn.active, .star[aria-pressed="true"] { outline: 2px solid Highlight; }
  .star.on { color: Highlight; }
  .banner .dot { forced-color-adjust: none; }
  :focus-visible { outline: 3px solid Highlight; }
}

/* Age / guardian confirmation (first use). Native <dialog>: modal focus handling built in. */
.age-dialog {
  width: min(520px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; box-sizing: border-box;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 18px; padding: 22px;
}
.age-dialog::backdrop { background: rgba(4, 8, 3, .82); }
.age-dialog h2 { margin: 0 0 8px; }
.age-dialog p { margin: 0 0 14px; }
.age-dialog .plan-note { margin: 14px 0 0; }
.age-choices { display: grid; gap: 10px; }
.age-choices button { min-height: 50px; height: auto; padding: 12px 22px; line-height: 1.3; }
.age-choices #ageGuardian { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.prefs-check:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.link-btn {
  display: inline-flex; align-items: center; width: auto; min-height: 44px; padding: 0; border: 0; border-radius: 0;
  background: none; color: var(--accent); font: inherit; font-weight: 400; text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: #d7f7a0; }
.link-btn:active { transform: none; }

/* Premium subscription: disclosure list and cancellation. */
.price { margin: 6px 0 0; font-size: 1.15rem; color: var(--text); }
.sub-terms { margin: 10px 0 12px; padding-left: 18px; color: var(--muted); font-size: .9rem; }
.sub-terms li { margin: 4px 0; }
.manage-sub { margin-top: 12px; }
.cancel-confirm { margin-top: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel2); }
.cancel-confirm h4 { margin: 0 0 6px; }
.cancel-confirm p { margin: 0 0 12px; color: var(--text); }
.cancel-confirm button + button { margin-top: 10px; }

/* Help & FAQ (help.html only): wrapped questions stay clear of the arrow; larger tap target. */
.faq summary { cursor: pointer; padding: 0.6rem 0 0.6rem 1.25em; text-indent: -1.25em; }
.faq details[open] summary { font-weight: 600; }
.faq details > p { margin: 0.25rem 0 0.9rem 1.25em; }
