/* ============================================================
   DinnerDash - Meal Swiping for Families
   ============================================================ */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; touch-action:manipulation; }

:root {
    --orange: #ea580c;
    --orange-mid: #dc2626;
    --red-end: #be123c;
    --orange-light: #fed7aa;
    --orange-bg: #fff7ed;
    --green: #10b981;
    --green-light: #d1fae5;
    --red: #ef4444;
    --red-light: #fee2e2;
    --grad: linear-gradient(145deg, #ea580c 0%, #dc2626 50%, #be123c 100%);
    --bg: #fff7ed;
    --text: #1a1523;
    --text2: #64748b;
    --text3: #94a3b8;
    --border: #e2e8f0;
    --radius: 20px;
    --radius-sm: 12px;
}

html, body {
    height:100%; overflow:hidden;
    font-family:'DM Sans',-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
    background:var(--grad); color:var(--text);
    -webkit-font-smoothing:antialiased;
}

.hidden { display:none !important; }

.screen { display:none; position:fixed; inset:0; flex-direction:column; overflow:hidden; }
.screen.active { display:flex; max-width:480px; margin:0 auto; box-shadow:0 0 60px rgba(0,0,0,0.3); }
@media (max-width:480px) { .screen.active { max-width:100%; box-shadow:none; } }

@keyframes fadeUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:none; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes shake { 0%,100% { transform:translateX(0); } 25% { transform:translateX(-8px); } 75% { transform:translateX(8px); } }
@keyframes cardFadeIn { from { opacity:0; } to { opacity:1; } }

/* ===== Landing ===== */
.landing-bg {
    flex:1; display:flex; align-items:safe center; justify-content:center;
    padding:24px; overflow-y:auto; -webkit-overflow-scrolling:touch;
}
.landing-inner { width:100%; max-width:400px; }
.brand { text-align:center; margin-bottom:28px; animation:fadeUp 0.6s ease-out; }
.brand-logo { width:64px; height:64px; margin-bottom:4px; }
.brand h1 { font-family:'Nunito',sans-serif; font-size:2.8rem; font-weight:900; color:white; letter-spacing:-2px; }
.brand p { color:rgba(255,255,255,0.7); font-size:1rem; font-weight:500; }

.auth-buttons { display:flex; flex-direction:column; gap:10px; animation:fadeUp 0.5s ease-out 0.15s both; }
.btn-primary { padding:11px; border:none; border-radius:var(--radius-sm); background:white; color:var(--orange); font-size:0.95rem; font-weight:700; cursor:pointer; width:100%; }
.btn-primary:active { transform:scale(0.97); }
.btn-outline { padding:11px; border:2px solid rgba(255,255,255,0.4); border-radius:var(--radius-sm); background:transparent; color:white; font-size:0.95rem; font-weight:600; cursor:pointer; width:100%; }
.btn-ghost { padding:10px; border:none; background:none; color:rgba(255,255,255,0.7); font-size:0.9rem; font-weight:500; cursor:pointer; width:100%; text-align:center; }
.divider { text-align:center; color:rgba(255,255,255,0.3); margin:4px 0; font-size:0.8rem; }
.join-inline { display:flex; flex-direction:column; gap:8px; }
.join-inline input { width:100%; padding:12px; border:none; border-radius:var(--radius-sm); background:rgba(255,255,255,0.15); color:white; outline:none; }
.join-inline input::placeholder { color:rgba(255,255,255,0.4); }
.join-inline button { width:100%; }

.auth-form { animation:fadeUp 0.3s ease-out; }
.auth-form h2 { color:white; text-align:center; margin-bottom:8px; font-size:1.1rem; }
.auth-form input { width:100%; padding:10px 12px; border:none; border-radius:8px; background:rgba(255,255,255,0.15); color:white; font-size:0.9rem; margin-bottom:6px; outline:none; }
.auth-form input::placeholder { color:rgba(255,255,255,0.5); }
.auth-form input:focus { background:rgba(255,255,255,0.25); }
.auth-error { margin-top:12px; padding:10px; border-radius:var(--radius-sm); background:rgba(255,255,255,0.15); color:white; font-size:0.85rem; text-align:center; }
.pin-setup { background:rgba(255,255,255,0.08); border-radius:8px; padding:8px 10px; margin-bottom:6px; display:flex; align-items:center; gap:8px; }
.pin-setup label { color:white; font-weight:600; font-size:0.8rem; white-space:nowrap; }
.pin-setup input { margin:0; flex:1; text-align:center; font-size:1.2rem !important; letter-spacing:6px; padding:8px !important; }

/* Mode buttons */
.mode-buttons { display:flex; flex-direction:column; gap:14px; animation:fadeUp 0.6s ease-out 0.15s both; }
.mode-btn { display:flex; align-items:center; gap:16px; background:rgba(255,255,255,0.12); backdrop-filter:blur(12px); border:1px solid rgba(255,255,255,0.2); border-radius:var(--radius); padding:20px; cursor:pointer; text-align:left; color:white; }
.mode-btn:active { transform:scale(0.97); background:rgba(255,255,255,0.2); }
.mode-emoji { font-size:2.4rem; }
.mode-label { font-family:'Nunito',sans-serif; font-size:1.15rem; font-weight:800; display:block; }
.mode-desc { font-size:0.8rem; opacity:0.7; display:block; margin-top:2px; }

/* PIN */
.pin-content { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:24px; color:white; }
.pin-content h2 { font-size:1.3rem; margin-bottom:28px; font-weight:700; }
.pin-dots { display:flex; gap:16px; margin-bottom:36px; }
.dot { width:18px; height:18px; border-radius:50%; border:2px solid rgba(255,255,255,0.5); transition:all 0.15s; }
.dot.filled { background:white; border-color:white; transform:scale(1.15); }
.dot.wrong { border-color:var(--red); animation:shake 0.3s; }
.pin-pad { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; max-width:280px; width:100%; }
.pin-pad button { height:64px; border-radius:50%; border:none; background:rgba(255,255,255,0.12); color:white; font-size:1.5rem; font-weight:600; cursor:pointer; }
.pin-pad button:active { background:rgba(255,255,255,0.25); transform:scale(0.92); }
.pin-empty { visibility:hidden; }
.pin-hint { margin-top:24px; font-size:0.8rem; opacity:0.5; color:white; }
.back-btn { position:absolute; top:16px; left:16px; background:rgba(255,255,255,0.15); border:none; color:white; width:40px; height:40px; border-radius:50%; font-size:1.2rem; cursor:pointer; z-index:10; }

/* Kid select */
.pick-content { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:safe center; background:transparent; padding:24px; color:white; position:relative; overflow-y:auto; }
.pick-content h2 { font-size:1.4rem; font-weight:700; margin-bottom:28px; }
.kid-list { display:grid; grid-template-columns:repeat(2,1fr); gap:12px; width:100%; max-width:360px; }
.kid-option { background:rgba(255,255,255,0.12); border:2px solid transparent; border-radius:var(--radius); padding:20px 12px; text-align:center; cursor:pointer; color:white; }
.kid-option:active { transform:scale(0.95); }
.kid-option .avatar { font-size:2.4rem; display:block; margin-bottom:6px; }
.kid-option .name { font-size:0.9rem; font-weight:700; }

/* Swipe */
.swipe-header { display:flex; align-items:center; padding:10px 14px; background:rgba(255,255,255,0.1); backdrop-filter:blur(12px); border-bottom:1px solid rgba(255,255,255,0.1); color:white; gap:10px; flex-shrink:0; }
.hdr-btn { background:rgba(255,255,255,0.2); border:none; width:36px; height:36px; border-radius:50%; font-size:1.1rem; cursor:pointer; color:white; display:flex; align-items:center; justify-content:center; }
.hdr-center { flex:1; text-align:center; font-weight:700; font-size:0.95rem; color:white; }

.picks-btn { background:rgba(255,255,255,0.2); color:white; border:none; padding:6px 14px; border-radius:20px; font-size:0.8rem; font-weight:700; cursor:pointer; display:flex; align-items:center; gap:4px; }
.picks-btn span { background:white; color:var(--orange); font-size:0.7rem; width:20px; height:20px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-weight:800; }

.cat-tabs { display:flex; overflow-x:auto; background:rgba(255,255,255,0.08); scrollbar-width:thin; scrollbar-color:rgba(255,255,255,0.3) transparent; flex-shrink:0; padding:4px 8px; }
.cat-tabs::-webkit-scrollbar { height:4px; }
.cat-tabs::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.3); border-radius:4px; }
.cat-tab { flex:0 0 auto; padding:8px 14px; margin:2px; border:none; background:transparent; border-radius:20px; font-size:0.8rem; font-weight:600; color:rgba(255,255,255,0.6); cursor:pointer; white-space:nowrap; }
.cat-tab.active { background:rgba(255,255,255,0.2); color:white; }

.swipe-tutorial { position:absolute; inset:0; z-index:60; display:flex; align-items:center; justify-content:space-between; background:rgba(0,0,0,0.35); border-radius:20px; padding:20px; cursor:pointer; }
.tut-side { display:flex; flex-direction:column; align-items:center; gap:6px; }
.tut-left { color:var(--red); }
.tut-right { color:var(--green); }
.tut-arrow { font-size:2.5rem; font-weight:900; }
.tut-label { font-size:1.1rem; font-weight:800; }
.tut-center { color:white; font-size:0.9rem; font-weight:600; text-align:center; opacity:0.8; }

.swipe-area { flex:1; display:flex; align-items:center; justify-content:center; padding:12px; overflow:hidden; position:relative; }
.card-stack { position:relative; width:100%; max-width:360px; aspect-ratio:3/4; max-height:500px; }

/* Card */
.card { position:absolute; top:0; left:0; width:100%; height:100%; background:white; border-radius:var(--radius); box-shadow:0 8px 32px rgba(234,88,12,0.15); overflow:hidden; cursor:grab; user-select:none; touch-action:none; will-change:transform; display:flex; flex-direction:column; }
.card:active { cursor:grabbing; }
.card.behind { z-index:-1; pointer-events:none; opacity:0; }
.card.entering { animation:cardFadeIn 0.12s ease-out; }

.card-img { flex:1; display:flex; align-items:center; justify-content:center; background:white; position:relative; overflow:hidden; min-height:0; }
.card-img img { width:100%; height:100%; object-fit:cover; }
.card-img .ph { font-size:5.5rem; opacity:0.2; }

.card-stamp { position:absolute; top:50%; padding:12px 28px; border-radius:12px; font-size:2rem; font-weight:900; opacity:0; pointer-events:none; z-index:10; background:rgba(255,255,255,0.9); }
.card-stamp.yes { right:50%; transform:translate(50%,-50%) rotate(12deg); color:var(--green); border:4px solid var(--green); }
.card-stamp.no { left:50%; transform:translate(-50%,-50%) rotate(-12deg); color:var(--red); border:4px solid var(--red); }

.card-detail { padding:14px 18px; border-top:1px solid #f0f0f0; flex-shrink:0; background:white; }
.card-title { font-family:'Nunito',sans-serif; font-size:1.05rem; font-weight:800; line-height:1.3; color:var(--text); }
.card-meta { font-size:0.8rem; color:var(--text2); margin-top:4px; display:flex; gap:10px; }
.card-meta span { display:flex; align-items:center; gap:3px; }

.undo-btn { position:absolute; bottom:50px; left:50%; transform:translateX(-50%) translateY(20px); background:rgba(0,0,0,0.7); color:white; padding:8px 24px; border-radius:25px; font-size:0.85rem; font-weight:700; cursor:pointer; opacity:0; transition:all 0.3s ease; z-index:50; }
.undo-btn.show { opacity:1; transform:translateX(-50%) translateY(0); }

.swipe-buttons { display:flex; gap:12px; padding:8px 20px; flex-shrink:0; justify-content:center; }
.swipe-btn { flex:1; max-width:160px; padding:12px; border:none; border-radius:25px; font-size:0.95rem; font-weight:700; cursor:pointer; }
.swipe-btn:active { transform:scale(0.93); }
.swipe-btn.nope { background:var(--red); color:white; }
.swipe-btn.want { background:var(--green); color:white; }

.done-msg { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; color:rgba(255,255,255,0.8); }
.done-icon { font-size:4rem; color:var(--green); margin-bottom:12px; }
.done-msg p { font-size:1.1rem; margin-bottom:20px; }
.done-msg button { padding:10px 28px; border-radius:25px; border:none; background:rgba(255,255,255,0.2); color:white; font-size:1rem; font-weight:600; cursor:pointer; }

/* Parent */
.parent-header { display:flex; align-items:center; padding:12px 14px; background:rgba(255,255,255,0.1); backdrop-filter:blur(12px); border-bottom:1px solid rgba(255,255,255,0.1); color:white; gap:10px; flex-shrink:0; }
.parent-header h1 { flex:1; text-align:center; font-family:'Nunito',sans-serif; font-size:1.1rem; font-weight:800; color:white; }
.parent-body { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:16px; padding-bottom:40px; }
.picks-body { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:12px; padding-bottom:40px; }

.dash-section { margin-bottom:20px; }
.dash-title { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.dash-title h3 { font-family:'Nunito',sans-serif; font-size:0.95rem; font-weight:800; color:white; }

.meal-card { background:rgba(255,255,255,0.12); backdrop-filter:blur(8px); border:1px solid rgba(255,255,255,0.15); border-radius:var(--radius-sm); margin-bottom:8px; overflow:hidden; cursor:pointer; }
.meal-card:active { transform:scale(0.98); }
.meal-card-inner { display:flex; gap:12px; padding:10px; }
.meal-card-img { width:70px; height:70px; border-radius:10px; overflow:hidden; flex-shrink:0; background:rgba(255,255,255,0.1); }
.meal-card-img img { width:100%; height:100%; object-fit:cover; }
.meal-card-info { flex:1; min-width:0; }
.meal-card-title { font-weight:700; font-size:0.9rem; color:white; }
.meal-card-meta { font-size:0.75rem; color:rgba(255,255,255,0.6); margin-top:2px; }
.meal-card-kid { font-size:0.7rem; color:rgba(255,255,255,0.5); margin-top:4px; }
.pick-remove-row {
    padding:6px 12px; border-top:1px solid rgba(255,255,255,0.08); text-align:right;
}
.pick-remove-btn {
    background:rgba(255,255,255,0.15); border:none; color:white;
    font-size:0.8rem; font-weight:600; cursor:pointer;
    padding:4px 12px; border-radius:12px;
}

.meal-servings-row {
    display:flex; align-items:center; gap:8px;
    padding:6px 12px; border-top:1px solid rgba(255,255,255,0.08);
    font-size:0.8rem; color:rgba(255,255,255,0.6);
}
.meal-servings-row button {
    width:26px; height:26px; border-radius:50%; border:none;
    background:rgba(255,255,255,0.2); color:white;
    font-size:0.9rem; font-weight:700; cursor:pointer;
}
.meal-servings-row button:active { background:rgba(255,255,255,0.35); }
.meal-serv-count { font-weight:700; color:white; font-size:0.95rem; min-width:20px; text-align:center; }

/* Servings control */
.servings-control { display:flex; align-items:center; gap:6px; }
.servings-control button { width:28px; height:28px; border-radius:50%; border:none; background:rgba(255,255,255,0.2); color:white; font-size:1rem; font-weight:700; cursor:pointer; }
.servings-control span { color:white; font-weight:700; font-size:1rem; }
.servings-label { font-size:0.75rem; color:rgba(255,255,255,0.5); }

/* Ingredient list */
.aisle-group { margin-bottom:12px; }
.aisle-name { font-size:0.75rem; font-weight:700; color:rgba(255,255,255,0.5); text-transform:uppercase; letter-spacing:1px; margin-bottom:6px; }
.ing-item { display:flex; justify-content:space-between; padding:8px 12px; background:rgba(255,255,255,0.1); border-radius:8px; margin-bottom:4px; color:white; font-size:0.88rem; }
.ing-amount { color:rgba(255,255,255,0.7); font-weight:600; }

.share-btn { display:block; width:100%; padding:12px; border:none; border-radius:var(--radius-sm); background:rgba(255,255,255,0.2); color:white; font-weight:700; font-size:0.9rem; cursor:pointer; margin-top:12px; text-align:center; }
.clear-btn { display:block; width:100%; text-align:center; padding:8px; background:none; border:none; color:var(--red); font-size:0.8rem; font-weight:600; cursor:pointer; text-decoration:underline; }

/* Meal detail */
.detail-body { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; padding-bottom:40px; }
.detail-hero { width:100%; height:250px; object-fit:cover; }
.detail-content { padding:16px; }
.detail-title { font-family:'Nunito',sans-serif; font-size:1.3rem; font-weight:900; color:white; margin-bottom:8px; }
.detail-meta { display:flex; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.detail-badge { background:rgba(255,255,255,0.15); color:white; padding:4px 10px; border-radius:20px; font-size:0.75rem; font-weight:600; }
.detail-section { margin-bottom:16px; }
.detail-section h3 { font-family:'Nunito',sans-serif; font-size:0.95rem; font-weight:800; color:white; margin-bottom:8px; }
.detail-ing { padding:6px 0; border-bottom:1px solid rgba(255,255,255,0.08); color:rgba(255,255,255,0.9); font-size:0.88rem; }
.detail-steps { color:rgba(255,255,255,0.85); font-size:0.88rem; line-height:1.6; }
.detail-steps p { margin-bottom:8px; }

/* Add kid form */
.add-kid-form { width:100%; max-width:360px; }
.ak-input { width:100%; padding:12px; border:none; border-radius:var(--radius-sm); background:rgba(255,255,255,0.15); color:white; font-size:1rem; outline:none; margin-bottom:12px; text-align:center; }
.ak-input::placeholder { color:rgba(255,255,255,0.4); }
.ak-input:focus { background:rgba(255,255,255,0.25); }
.ak-avatars { display:flex; gap:6px; flex-wrap:wrap; justify-content:center; margin-bottom:16px; }
.av-pick { width:44px; height:44px; border-radius:50%; border:2px solid transparent; background:rgba(255,255,255,0.1); font-size:1.4rem; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.av-pick.sel { border-color:white; background:rgba(255,255,255,0.3); transform:scale(1.1); }
.ak-buttons { display:flex; flex-direction:column; gap:8px; }

.list-empty { text-align:center; color:rgba(255,255,255,0.5); padding:20px; font-size:0.9rem; }
.loading { text-align:center; color:rgba(255,255,255,0.6); padding:30px; font-size:0.9rem; }
.spin { display:inline-block; width:20px; height:20px; border:3px solid rgba(255,255,255,0.2); border-top-color:white; border-radius:50%; animation:spin 0.5s linear infinite; margin-right:8px; vertical-align:middle; }
@keyframes spin { to { transform:rotate(360deg); } }

.toast { position:fixed; bottom:80px; left:50%; transform:translateX(-50%) translateY(80px); background:rgba(0,0,0,0.8); color:white; padding:10px 20px; border-radius:16px; font-size:0.85rem; font-weight:600; opacity:0; transition:all 0.3s ease; z-index:999; max-width:85vw; text-align:center; line-height:1.3; pointer-events:none; }
.toast.show { transform:translateX(-50%) translateY(0); opacity:1; }
.toast.error { background:var(--red); }
