/* Meal Buddy — Bread Buddy visual language */
:root {
    --primary-dark: #3f2e21;
    --primary-light: #6b4a32;
    --accent: #b8875c;
    --accent-dark: #a0704c;
    --border-color: #efe2d6;
    --bg-warm: #fcf6ef;
    --card-bg: #ffffff;
    --text-muted: #8b6f58;
    --border-radius: 26px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: var(--bg-warm);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    padding: 16px 14px 0;
    color: #2c241e;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.app-container { max-width: 540px; width: 100%; flex: 1; }
.header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.header h1 {
    font-size: 1.8rem; font-weight: 700; letter-spacing: -0.3px;
    background: linear-gradient(135deg, #7a5238, #b8875c);
    background-clip: text; -webkit-background-clip: text; color: transparent;
}
.header-emoji { font-size: 2rem; line-height: 1; }
.subhead {
    font-size: 0.82rem; color: var(--text-muted);
    border-left: 3px solid #dcc4ae; padding-left: 12px;
    margin-bottom: 18px; margin-top: 2px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
}
.hydration-badge {
    background: #e3d5c8; padding: 0 14px; border-radius: 30px;
    font-size: 0.7rem; font-weight: 600; color: #3f2e21;
    line-height: 1.9; letter-spacing: 0.3px;
    border: 1px solid #d0bcaa; margin-left: auto; white-space: nowrap;
}
.hero {
    background: linear-gradient(135deg, #fdf6ee 0%, #f7ece0 100%);
    border-radius: 22px; padding: 16px 18px; margin-bottom: 16px;
    border: 1px solid #ecdfd0;
}
.hero-title {
    font-size: 0.95rem; font-weight: 700; color: var(--primary-light);
    margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
}
.hero-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
    font-size: 0.78rem; color: #4f3d2e;
}
.hero-grid .hero-item { display: flex; align-items: flex-start; gap: 6px; }
.hero-grid .hero-item span:first-child { flex-shrink: 0; }
.card {
    background: var(--card-bg); border-radius: var(--border-radius);
    padding: 1rem 1rem 1.1rem; margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02), 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid var(--border-color);
}
.card-header {
    font-weight: 620; font-size: 1rem; color: var(--primary-light);
    display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
    letter-spacing: -0.15px;
}
.card-header.static { cursor: default; }
.card-header .badge {
    background: #eee3d9; padding: 0 12px; border-radius: 30px;
    font-size: 0.65rem; font-weight: 500; color: #7a5a40; line-height: 1.8;
}
.form-row {
    display: flex; flex-wrap: wrap; gap: 10px 12px;
    align-items: center; margin-bottom: 10px;
}
.form-row label {
    font-size: 0.85rem; font-weight: 500; color: #4f3a2b; min-width: 110px;
}
.form-row .flex-1 { flex: 1; min-width: 140px; }
select {
    width: 100%; padding: 10px 14px;
    background: #fefaf5; border: 1.5px solid #e5d5c8;
    border-radius: 44px; font-size: 0.9rem; font-family: inherit;
    color: #3a2c22; cursor: pointer; appearance: auto;
    transition: border-color 0.2s;
}
select:focus { outline: none; border-color: var(--accent); }
.ingredient-list { display: flex; flex-direction: column; gap: 4px; }
.ingredient-row {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 6px 0; border-bottom: 1px dashed #f0e2d6;
    font-size: 0.9rem; flex-wrap: wrap;
}
.ingredient-row .name { font-weight: 450; color: #3f2e21; }
.ingredient-row .amount { font-weight: 500; color: #5f402b; text-align: right; }
.ingredient-total {
    margin-top: 10px; padding-top: 10px;
    border-top: 2px solid #e8d7c8;
    font-weight: 600; font-size: 0.9rem;
    display: flex; justify-content: space-between; color: #4f3a2b;
}
.step-list { display: flex; flex-direction: column; gap: 10px; }
.step-item {
    background: #fefaf7; border-radius: 18px; padding: 12px 14px;
    border-left: 4px solid #d6bb9c; font-size: 0.88rem; line-height: 1.5;
}
.step-item .step-num {
    display: inline-block; font-weight: 700; color: var(--accent);
    margin-right: 6px; font-size: 0.85rem;
}
.step-item .step-title { font-weight: 600; color: #3f2e21; }
.step-item .step-desc { color: #4f3d2e; margin-top: 3px; }
.step-item.phase { border-left-color: var(--accent); background: #fdf6ee; }
.step-item.tip { border-left-color: #b0c9dd; background: #f4f9fc; }
.share-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.btn-primary {
    background: var(--accent-dark); border: none; padding: 12px 28px;
    border-radius: 60px; font-weight: 600; color: #fff; cursor: pointer;
    font-family: inherit; font-size: 0.95rem;
    display: inline-flex; align-items: center; gap: 8px;
    flex: 1; justify-content: center;
}
.btn-primary:active { transform: scale(0.97); background: #8a5d3e; }
.btn-secondary {
    background: #e8d7c8; border: none; padding: 12px 20px;
    border-radius: 60px; font-weight: 600; color: #4f3a2b; cursor: pointer;
    font-family: inherit; font-size: 0.95rem;
    display: inline-flex; align-items: center; gap: 8px;
    flex: 1; justify-content: center;
}
.btn-secondary:active { transform: scale(0.97); background: #dcc4ae; }
.toast-container {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    z-index: 1000; pointer-events: none;
}
.toast {
    background: #2c241e; color: #fef8f2; padding: 12px 24px;
    border-radius: 40px; font-size: 0.85rem; font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    opacity: 0; transform: translateY(20px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.info-box {
    background: #f7efe8; border-radius: 18px; padding: 14px 16px;
    border-left: 5px solid var(--accent);
    font-size: 0.85rem; line-height: 1.5; color: #3f2e21;
}
.info-box p { margin-bottom: 8px; }
.info-box p:last-child { margin-bottom: 0; }
.info-tag {
    display: inline-block; background: #dcc4ae; border-radius: 20px;
    padding: 0 10px; font-size: 0.7rem; font-weight: 600;
    color: #4f3a2b; line-height: 1.8; margin-right: 4px;
}
.text-muted { color: #9b7a60; font-size: 0.78rem; }
.mt-1 { margin-top: 6px; }
.header .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 4px 10px;
    border: 1px solid #efe2d6;
    border-radius: 8px;
    background: #fcf6ef;
    color: #4f3d2e;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.header .back-link:hover,
.header .back-link:focus-visible {
    border-color: #3f2e21;
    color: #3f2e21;
    background: #f3e7da;
    text-decoration: none;
}
/* Help button + popup */
.help-btn {
    background: #f0e4d8; border: 1.5px solid #d0bcaa; color: #3f2e21;
    font-family: inherit; font-weight: 700; font-size: 0.78rem;
    padding: 6px 14px; border-radius: 30px; cursor: pointer; white-space: nowrap;
}
.help-popup-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(40,26,15,0.85); z-index: 1200;
    justify-content: center; align-items: center;
    padding: 20px 12px; backdrop-filter: blur(2px);
}
.help-popup-overlay.active { display: flex; }
.help-popup {
    background: #fff; border: 1px solid var(--border-color);
    border-radius: var(--border-radius); padding: 1.4rem 1.6rem;
    max-width: min(620px, calc(100vw - 24px)); width: 100%;
    max-height: calc(100vh - 40px); overflow-y: auto;
    box-shadow: 0 24px 60px -12px rgba(0,0,0,0.4);
}
.help-popup .help-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.4rem; gap: 0.5rem;
}
.help-popup h2 { color: var(--primary-dark); font-size: 1.4rem; }
.help-popup .close-btn {
    background: none; border: none; font-size: 1.8rem;
    cursor: pointer; color: var(--text-muted); line-height: 1;
    padding: 0 0.2rem;
}
.help-popup h3 {
    color: var(--primary-dark); font-size: 1rem; margin-top: 1rem; margin-bottom: 0.2rem;
}
.help-popup h3 .badge {
    background: var(--accent); color: #fff; font-size: 0.65rem;
    font-weight: 700; padding: 0.05rem 0.5rem; border-radius: 12px;
}
.help-popup ul { margin: 0.2rem 0 0.6rem 1.2rem; line-height: 1.6; font-size: 0.85rem; }
.help-popup .help-close {
    margin-top: 12px; padding: 12px 16px; background: #fff3cd;
    border-radius: 14px; border-left: 4px solid #f9a825;
    font-size: 0.82rem; line-height: 1.5; color: #4e3b1f;
}

/* Footer */
.app-footer {
    margin-top: 28px; padding: 20px 14px;
    border-top: 1px solid var(--border-color); width: 100%; max-width: 540px;
    background: var(--bg-warm);
}
.footer-inner { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.info-text { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.coffee-btn {
    background: #ffdd99; border: 2px solid #f5b56b;
    padding: 12px 28px; border-radius: 60px;
    font-weight: 700; font-size: 1rem; color: #3f2e21;
    cursor: pointer; font-family: inherit;
    display: inline-flex; align-items: center; gap: 8px;
    box-shadow: 0 2px 8px rgba(245,181,107,0.3);
}
.legal-line { font-size: 0.75rem; color: var(--text-muted); text-align: center; line-height: 1.5; }
.support-line { font-size: 0.72rem; color: var(--text-muted); text-align: center; line-height: 1.5; max-width: 420px; }
.footer-version {
    background: #eee3d9; padding: 0 10px; border-radius: 30px;
    font-size: 0.6rem; font-weight: 600; color: #7a5a40;
    line-height: 1.8; letter-spacing: 0.3px;
}
.footer-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.footer-disclaimer { font-size: 0.65rem; color: var(--text-muted); text-align: center; }
.footer-toast-container { margin-top: 4px; min-height: 28px; }
.footer-toast {
    background: #2c241e; color: #fef8f2; padding: 6px 18px;
    border-radius: 30px; font-size: 0.7rem; font-weight: 500;
    opacity: 0; transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    display: inline-block;
}
.footer-toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 420px) {
    .header h1 { font-size: 1.5rem; }
    .hero-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; align-items: stretch; gap: 6px; }
    .form-row label { min-width: auto; }
    .ingredient-row, .step-item { font-size: 0.82rem; }
    .subhead { flex-direction: column; align-items: flex-start; gap: 4px; }
    .hydration-badge { margin-left: 0; align-self: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; }
}
/* ── Protein optgroups ── */
optgroup {
    font-weight: 700;
    color: #3f2e21;
    background: #f7efe8;
    font-size: 0.82rem;
    letter-spacing: 0.4px;
    padding: 8px 0 4px;
    border-top: 1px solid #e5d5c8;
}
optgroup:first-of-type { border-top: none; }

optgroup option {
    font-weight: 400;
    color: #3f2e21;
    background: #ffffff;
    padding: 10px 14px 10px 30px;
    font-size: 0.9rem;
    letter-spacing: 0;
}
optgroup option:checked {
    background: #e8d7c8;
    color: #3f2e21;
    font-weight: 600;
}