:root {
    /* iOS System Colors & Modern Gradients (LIGHT MODE) */
    --bg-app: #F2F2F7; 
    --bg-card: #FFFFFF; 
    --text-main: #1C1C1E; 
    --text-muted: #8E8E93;
    --separator: #C6C6C8; 
    
    --accent: #FF9500; 
    --accent-gradient: linear-gradient(135deg, #FF9500 0%, #FF5E3A 100%);
    --accent-glow: rgba(255, 94, 58, 0.35);
    --danger: #FF3B30;
    --danger-tint: rgba(255, 59, 48, 0.1);
    
    --radius-card: 20px; 
    --radius-input: 16px;
    --radius-btn: 16px;
    
    --shadow-ios: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    --font-main: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    --container-width: 800px;

    /* NUEVO: Variables dinámicas para elementos de cristal */
    --bg-header: rgba(242, 242, 247, 0.85);
    --border-header: rgba(0, 0, 0, 0.05);
    --bg-fab: rgba(255, 255, 255, 0.9);
}

/* 🌙 DARK MODE VARIABLES */
[data-theme="dark"] {
    --bg-app: #000000; 
    --bg-card: #1C1C1E; 
    --text-main: #FFFFFF; 
    --text-muted: #98989D;
    --separator: #38383A; 
    --shadow-ios: 0 4px 12px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
    --danger-tint: rgba(255, 59, 48, 0.2);

    /* NUEVO: Cristal negro para el modo noche */
    --bg-header: rgba(0, 0, 0, 0.85);
    --border-header: rgba(255, 255, 255, 0.1);
    --bg-fab: rgba(28, 28, 30, 0.9);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* FIX ANDROID PULL-TO-REFRESH */
html, body { height: 100%; overflow-x: hidden; overscroll-behavior-y: none; overscroll-behavior-x: none; }

/* FIX: Quitamos el padding-top para que la cabecera cubra el Notch (barra de estado) */
body { background-color: var(--bg-app); color: var(--text-main); font-family: var(--font-main); padding-bottom: calc(100px + env(safe-area-inset-bottom)); -webkit-font-smoothing: antialiased; letter-spacing: -0.2px; transition: background-color 0.3s ease, color 0.3s ease; }

/* LOADING & SPLASH */
.loading-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: var(--bg-header); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: background 0.3s; }
.loading-overlay p { margin-top: 15px; font-weight: 600; color: var(--text-main); }
.spinner { width: 44px; height: 44px; border: 4px solid var(--bg-app); border-top: 4px solid var(--accent); border-radius: 50%; animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.splash-screen { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: var(--bg-app); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.splash-content { text-align: center; animation: pulse 2s infinite; }
.big-logo { width: 60px; height: 60px; margin: 0 auto 20px; position: relative; }
.big-logo .flavor-base { width: 30px; height: 30px; top: 10px; }
.big-logo .flavor-accent { width: 30px; height: 30px; top: 0; box-shadow: 0 0 20px var(--accent); }
.splash-content h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 0.5rem; letter-spacing: -1px; }
.splash-content p { color: var(--text-muted); font-weight: 500; }
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.95; transform: scale(0.98); } 100% { opacity: 1; transform: scale(1); } }

/* HEADER (FIXED) */
.app-header { 
    display: flex; justify-content: space-between; align-items: center; 
    /* El padding-top ahora absorbe el Safe Area (Notch del iPhone/Android) */
    padding: calc(1rem + env(safe-area-inset-top)) 1.5rem 1rem 1.5rem; 
    background: var(--bg-header); 
    backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); 
    position: sticky; top: 0; z-index: 100; 
    border-bottom: 0.5px solid var(--border-header); 
    transition: background-color 0.3s ease, border-color 0.3s ease; 
}
.logo-wrapper { display: flex; align-items: center; gap: 8px; }
.logo-mark { position: relative; width: 20px; height: 20px; }
.flavor-base { width: 12px; height: 12px; background: var(--text-main); border-radius: 50%; position: absolute; left: 0; top: 4px; transition: background 0.3s ease; }
.flavor-accent { width: 12px; height: 12px; background: var(--accent-gradient); border-radius: 50%; position: absolute; right: 0; top: 0; box-shadow: 0 2px 8px var(--accent-glow); }
.logo-text { font-weight: 800; font-size: 1.4rem; letter-spacing: -0.5px; }
#nav-actions { display: flex; align-items: center; gap: 10px; }

/* MAIN & COMMON */
main { max-width: var(--container-width); margin: 0 auto; padding: 0 1.5rem; }
.page-title { font-size: 34px; font-weight: 800; letter-spacing: -1px; margin: 1.5rem 0 1rem; color: var(--text-main); }
.hidden { display: none !important; }
.loader { text-align: center; color: var(--text-muted); margin-top: 2rem; width: 100%; grid-column: 1/-1; font-weight: 500; }
.app-footer { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 3rem; padding-bottom: 2rem; font-weight: 600; }

/* 🔥 BOTONES MAGISTRALES 🔥 */
.btn-primary { background: var(--accent-gradient); color: white; font-size: 17px; font-weight: 700; letter-spacing: 0.2px; padding: 16px 24px; border-radius: var(--radius-btn); border: none; cursor: pointer; width: 100%; display: flex; justify-content: center; align-items: center; gap: 10px; box-shadow: 0 8px 20px var(--accent-glow), inset 0 1px 1px rgba(255, 255, 255, 0.3); transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease; }
.btn-primary:active { transform: scale(0.95); box-shadow: 0 4px 10px var(--accent-glow), inset 0 1px 1px rgba(255, 255, 255, 0.3); }

.btn-ghost { background: rgba(255, 149, 0, 0.1); color: var(--accent); font-size: 17px; border: none; font-weight: 700; border-radius: var(--radius-btn); padding: 16px 24px; cursor: pointer; transition: all 0.2s ease; display: flex; justify-content: center; align-items: center; }
.btn-ghost:active { transform: scale(0.96); background: rgba(255, 149, 0, 0.15); }
.btn-ghost.text-danger { background: var(--danger-tint); color: var(--danger) !important; }
.btn-ghost.text-danger:active { background: rgba(255, 59, 48, 0.18); }

.btn-icon-header { padding: 10px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text-main); background: rgba(142, 142, 147, 0.15); border-radius: 14px; transition: all 0.2s ease; border: none; cursor: pointer; font-size: 18px;}
.btn-icon-header:active { background: rgba(142, 142, 147, 0.25); transform: scale(0.92); }

.btn-back { background: rgba(142, 142, 147, 0.15); padding: 8px 16px; border-radius: 12px; border: none; font-weight: 700; font-size: 15px; margin-bottom: 1rem; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px; transition: transform 0.2s ease; }
.btn-back:active { transform: scale(0.95); }

/* Margen superior para los botones independientes */
#view-editor .btn-back, #view-profile .btn-back { margin-top: 24px; }

/* FAB: El nuevo botón redondo para el pulgar */
.fab-add { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); right: 20px; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-gradient); color: white; font-size: 32px; font-weight: 400; border: none; box-shadow: 0 10px 25px var(--accent-glow), inset 0 1px 1px rgba(255,255,255,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; cursor: pointer; transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease; padding-bottom: 4px; }
.fab-add:active { transform: scale(0.9); box-shadow: 0 5px 15px var(--accent-glow); }

/* FAB: Vidrio esmerilado puro, para el WakeLock */
.btn-icon { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); right: 20px; width: 64px; height: 64px; border-radius: 22px; background: var(--bg-fab); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); box-shadow: 0 10px 30px rgba(0,0,0,0.1), inset 0 1px 1px rgba(255,255,255,0.1); color: var(--text-main); font-size: 26px; border: 1px solid var(--border-header); display:flex; align-items:center; justify-content:center; transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); cursor: pointer; z-index: 50; }
.btn-icon.active { background: var(--accent-gradient); color: white; border: none; box-shadow: 0 10px 25px var(--accent-glow), inset 0 1px 1px rgba(255,255,255,0.3); transform: scale(1.05); }

.fab-actions { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); right: 20px; z-index: 50; }

.sm { font-size: 14px; padding: 8px 14px; border-radius: 10px; }

/* GRID & CARDS */
.search-container { position: relative; margin-bottom: 1.5rem; }
.search-container input { background-color: var(--bg-card); border: 1px solid var(--separator); border-radius: var(--radius-input); padding: 14px 18px; font-size: 17px; color: var(--text-main); width: 100%; transition: all 0.2s ease; box-shadow: var(--shadow-ios); }
.search-container input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.3); outline: none; }

.recipe-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding-bottom: 10px;}
@media (min-width: 768px) { .recipe-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; } }

.recipe-card { background: var(--bg-card); border-radius: var(--radius-card); box-shadow: var(--shadow-ios); overflow: hidden; border: 1px solid rgba(142, 142, 147, 0.1); transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease; cursor: pointer; display: flex; flex-direction: column; }
.recipe-card:active { transform: scale(0.94); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.card-img { width: 100%; height: 140px; background-color: var(--bg-app); background-size: cover; background-position: center; }
.card-info { padding: 12px; flex: 1; display: flex; flex-direction: column; justify-content: flex-start; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; line-height: 1.2; }
.tags { display: flex; gap: 4px; font-size: 12px; color: var(--text-muted); font-weight: 600; flex-wrap: wrap;}

/* FORMS & LOGIN */
.login-container, #view-editor form { background: var(--bg-card); border-radius: var(--radius-card); padding: 24px; box-shadow: var(--shadow-ios); margin-top: 20px; border: 1px solid rgba(142, 142, 147, 0.1); }
.input-group { margin-bottom: 20px; }
.input-group label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
input:not([type="file"]), select, textarea { width: 100%; padding: 16px; border: 1px solid var(--separator); border-radius: var(--radius-input); font-size: 17px; font-family: var(--font-main); background: var(--bg-card); color: var(--text-main); -webkit-appearance: none; transition: all 0.2s ease; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.2); }
.full-width { width: 100%; margin-top: 1rem; }
.row-group { display: flex; gap: 1rem; } .row-group .input-group { flex: 1; }
.mt-2 { margin-top: 1rem; } .mt-1 { margin-top: 0.5rem; }
.time-inputs { display: flex; gap: 10px; }
.time-inputs input[type="number"] { flex: 2; -moz-appearance: textfield; }
.time-inputs select { flex: 1; background-color: var(--bg-app); text-align: center; font-weight: 700; border: none; color: var(--text-main); }

/* IMAGEN & CONTROLES */
.img-source-toggle { display: flex; background: var(--bg-app); border-radius: 12px; padding: 4px; }
.toggle-btn { flex: 1; border: none; background: transparent; padding: 10px; font-size: 14px; font-weight: 700; border-radius: 10px; cursor: pointer; color: var(--text-muted); transition: all 0.2s ease; }
.toggle-btn.active { background: var(--bg-card); color: var(--text-main); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.file-upload-wrapper { background: var(--bg-app); border: 2px dashed var(--separator); border-radius: var(--radius-input); height: 160px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; transition: border-color 0.2s; }
.file-upload-wrapper:hover { border-color: var(--accent); }
.file-upload-wrapper input[type="file"] { position: absolute; width: 100%; height: 100%; opacity: 0; z-index: 2; cursor: pointer; }
#preview-box img { width: 100%; height: 220px; object-fit: cover; border-radius: var(--radius-input); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
#upload-text { color: var(--text-muted); font-weight: 700; }
.img-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; background: var(--bg-card); padding: 12px; border-radius: 16px; border: 1px solid var(--separator); }
.img-label { font-size: 13px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.pos-buttons { display: flex; gap: 6px; }
.btn-pos { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--separator); background: var(--bg-app); color: var(--text-main); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-pos.active { background: var(--text-main); color: var(--bg-card); border-color: var(--text-main); }

/* DETALLE */
.recipe-detail { padding-bottom: 90px; } 
.recipe-detail img { border-radius: var(--radius-card); box-shadow: var(--shadow-ios); margin-bottom: 24px; width: 100%; height: 320px; object-fit: cover; border: 1px solid rgba(142, 142, 147, 0.1); }
.ingredient-item { display: flex; align-items: flex-start; padding: 14px 0; border-bottom: 0.5px solid var(--separator); }
.ingredient-item input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 26px; height: 26px; border: 2px solid var(--separator); background: var(--bg-card); border-radius: 8px; margin-right: 14px; flex-shrink: 0; transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.ingredient-item input[type="checkbox"]:checked { background: var(--accent-gradient); border-color: transparent; transform: scale(1.1); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E"); }
.step-card { background: transparent; padding: 0 0 24px 0; margin-bottom: 0; line-height: 1.6; color: var(--text-main); }
.step-card strong { color: var(--accent); font-size: 16px; margin-bottom: 6px; display: block; letter-spacing: 0.5px; }

/* Barra de navegación del Detalle Nivelada Milimétricamente */
.detail-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; margin-bottom: 20px; }
.detail-nav .btn-back { margin-bottom: 0; }
.detail-actions { display: flex; align-items: center; gap: 8px; }
.detail-actions .btn-ghost.sm { margin: 0; }

/* MODALES */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--bg-card); width: 100%; max-width: 400px; border-radius: 28px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,0.4); border: 1px solid rgba(142, 142, 147, 0.1); }
.modal-box h3 { margin-bottom: 20px; font-size: 22px; text-align: center; font-weight: 800; color: var(--text-main); }
.modal-box .btn-ghost { width: 100%; margin-top: 12px; }
#qr-video { width: 100%; border-radius: 20px; background: #000; margin-bottom: 20px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); }

/* PERFIL Y BUZÓN */
.profile-card { background: var(--bg-card); padding: 2.5rem 2rem; border-radius: var(--radius-card); text-align: center; box-shadow: var(--shadow-ios); margin-top: 1rem; border: 1px solid rgba(142, 142, 147, 0.1); }
.profile-card h2 { margin-bottom: 8px; font-weight: 800; }
.hint { color: var(--text-muted); font-size: 14px; margin-top: 10px; line-height: 1.4; }
#qrcode-container img { width: 200px; height: 200px; margin: 2rem 0; border: 12px solid white; border-radius: 20px; box-shadow: 0 8px 25px rgba(0,0,0,0.08); }
.chef-id-box { background: var(--bg-app); padding: 14px 20px; border-radius: 16px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--separator); }
.chef-id-box .label { font-size: 13px; color: var(--text-muted); font-weight: 800; }
.chef-id-box strong { font-size: 22px; letter-spacing: 1.5px; color: var(--text-main); }

.inbox-section { margin-top: 2.5rem; }
.inbox-section h3 { margin-bottom: 1.5rem; font-size: 22px; font-weight: 800; }
.inbox-item { background: var(--bg-card); padding: 20px; border-radius: 20px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-ios); border: 1px solid rgba(142, 142, 147, 0.1); }
.inbox-content { flex: 1; padding-right: 15px; }
.inbox-title { font-weight: 800; font-size: 17px; margin-bottom: 6px; color: var(--text-main); }
.inbox-sender { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.inbox-btns { display: flex; gap: 10px; }
.inbox-btns .btn-pos { border-radius: 12px; }

/* BARRA DE NOTIFICACIÓN EN DASHBOARD */
.inbox-banner { background: var(--accent-gradient); color: white; padding: 16px 20px; border-radius: 18px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; box-shadow: 0 8px 20px var(--accent-glow), inset 0 1px 1px rgba(255,255,255,0.3); font-size: 15px; transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.inbox-banner:active { transform: scale(0.96); }