/* ============================================================
COMPAÑERO ATMAN - Sistema de Diseño "Twilight Zen"
Diseño Premium, Minimalista y Orgánico
============================================================ */

:root {
    /* 🎨 Paleta Twilight Zen (Modo Claro) */
    --primary: #3A5A78;
    --primary-light: #5B82A0;
    --primary-dark: #243B53;
    --primary-gradient: linear-gradient(135deg, #3A5A78 0%, #5B82A0 100%);
    
    --secondary: #7BA38D;
    --secondary-light: #95BDA5;
    --secondary-dark: #5C826D;
    
    --destructive: #E07A5F;
    --success: #7BA38D;
    
    --background: #F4F7F9;
    --foreground: #1A2A3A;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(255, 255, 255, 0.6);
    
    --muted: #64748B;
    --muted-light: #94A3B8;
    
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-xl: 0 24px 60px rgba(15, 23, 42, 0.12);
    
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-xl: 36px;
    
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.5);
}

body.dark {
    --primary: #6B9AC4;
    --primary-light: #8BB4D6;
    --primary-dark: #4A7A9E;
    --primary-gradient: linear-gradient(135deg, #4A7A9E 0%, #6B9AC4 100%);
    
    --secondary: #81B29A;
    --secondary-light: #A3C9B4;
    --secondary-dark: #5F927B;
    
    --destructive: #F4A261;
    --success: #81B29A;
    
    --background: #0B131A;
    --foreground: #E2E8F0;
    --card-bg: rgba(22, 34, 50, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    
    --muted: #64748B;
    --muted-light: #475569;
    
    --glass-bg: rgba(15, 23, 35, 0.75);
    --glass-border: rgba(255, 255, 255, 0.06);
}

/* ---------- Reset y base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    height: 100%;
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--foreground);
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background 0.4s ease, color 0.4s ease;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    width: 100%;
    max-width: 480px;
    height: 100dvh;
    max-height: 100dvh;
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 0;
    padding: 24px 20px 16px;
    box-shadow: var(--shadow-xl);
    transition: background 0.4s ease, border-color 0.4s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ---------- Páginas y Transiciones ---------- */
.page {
    display: none;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    padding: 8px 4px 16px;
    animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.page.active { display: flex; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Tipografía Premium ---------- */
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; background: var(--primary-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.15; }
h2 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; color: var(--foreground); margin: 0; }
h3 { font-size: 1.125rem; font-weight: 600; color: var(--primary); }
p { line-height: 1.65; color: var(--muted); font-size: 0.95rem; }
.subtitle { color: var(--muted); font-size: 1rem; margin-top: 4px; font-weight: 400; }

a { color: var(--secondary); text-decoration: none; transition: color 0.2s; cursor: pointer; }
a:hover { color: var(--secondary-dark); text-decoration: underline; }

/* ---------- Formularios ---------- */
.auth-container { display: flex; flex-direction: column; gap: 20px; flex: 1; justify-content: center; }
.auth-header { text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-weight: 500; font-size: 0.9rem; color: var(--foreground); }
.form-group input, .form-group textarea {
    padding: 14px 18px; border-radius: var(--radius-md); border: 1.5px solid var(--card-border);
    background: rgba(255, 255, 255, 0.4); color: var(--foreground); font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; width: 100%; font-family: inherit;
}
body.dark .form-group input, body.dark .form-group textarea { background: rgba(255, 255, 255, 0.05); }
.form-group input:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(58, 90, 120, 0.15); background: rgba(255, 255, 255, 0.8);
}
body.dark .form-group input:focus, body.dark .form-group textarea:focus { box-shadow: 0 0 0 4px rgba(107, 154, 196, 0.2); background: rgba(255, 255, 255, 0.08); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--muted); opacity: 0.7; }
.auth-switch { text-align: center; font-size: 0.95rem; margin-top: 4px; }

.message { text-align: center; font-size: 0.9rem; padding: 10px 14px; border-radius: var(--radius-sm); min-height: 2.5rem; transition: all 0.3s; display: flex; align-items: center; justify-content: center; }
.message.error { color: var(--destructive); background: rgba(224, 122, 95, 0.12); }
.message.success { color: var(--secondary-dark); background: rgba(123, 163, 141, 0.15); }
body.dark .message.success { color: var(--secondary-light); }

/* ---------- Botones ---------- */
button {
    font-family: inherit; padding: 14px 24px; border: none; border-radius: var(--radius-md);
    font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 52px; min-width: 52px; -webkit-tap-highlight-color: transparent; user-select: none; letter-spacing: 0.01em;
}
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--primary-gradient); color: #fff; box-shadow: 0 4px 14px rgba(58, 90, 120, 0.25), 0 2px 6px rgba(58, 90, 120, 0.15); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(58, 90, 120, 0.35), 0 4px 8px rgba(58, 90, 120, 0.2); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.98); box-shadow: 0 2px 8px rgba(58, 90, 120, 0.2); }

.btn-secondary { background: transparent; color: var(--foreground); border: 1.5px solid var(--card-border); backdrop-filter: blur(4px); }
.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); border-color: var(--primary-light); }
body.dark .btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); }

.btn-danger { background: linear-gradient(135deg, var(--destructive), #C2634A); color: #fff; box-shadow: 0 4px 14px rgba(224, 122, 95, 0.3); }
body.dark .btn-danger { background: linear-gradient(135deg, #F4A261, #E08A4B); box-shadow: 0 4px 14px rgba(244, 162, 97, 0.3); }
.btn-danger:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(224, 122, 95, 0.4); }
.btn-danger:active:not(:disabled) { transform: translateY(0) scale(0.98); }

.btn-block { width: 100%; justify-content: center; }
.btn-icon { background: transparent; box-shadow: none; min-height: 44px; min-width: 44px; padding: 8px; border-radius: 50%; font-size: 1.4rem; color: var(--muted); }
.btn-icon:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); color: var(--foreground); }

.btn-logout { background: transparent; color: var(--muted); font-size: 0.85rem; padding: 10px 20px; min-height: 44px; border: 1.5px solid var(--card-border); border-radius: var(--radius-md); transition: all 0.3s ease; margin-top: auto; }
.btn-logout:hover:not(:disabled) { color: var(--destructive); border-color: var(--destructive); background: rgba(224, 122, 95, 0.06); }

/* ============================================================
NAVEGACIÓN INFERIOR (Estilo Nativo Premium)
============================================================ */
#bottom-nav, .bottom-nav-placeholder {
    display: flex; justify-content: space-around; align-items: center; margin-top: auto;
    padding: 8px 12px 12px; background: var(--glass-bg); backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%); border-top: 1px solid var(--glass-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
    gap: 4px; width: 100%; z-index: 100;
}
.btn-nav {
    background: transparent; box-shadow: none; color: var(--muted); font-size: 0.7rem;
    padding: 8px 6px; min-height: 52px; border-radius: var(--radius-md); font-weight: 500;
    flex: 1; max-width: 80px; flex-direction: column; gap: 4px;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); border: none;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    font-family: inherit; letter-spacing: 0.02em; position: relative;
}
.btn-nav .nav-icon { font-size: 1.3rem; line-height: 1; display: block; transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.btn-nav .nav-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; display: block; line-height: 1.2; opacity: 0.8; }
.btn-nav:hover:not(:disabled) { color: var(--foreground); background: rgba(255, 255, 255, 0.08); }
.btn-nav:active:not(:disabled) { transform: scale(0.92); }
.btn-nav.active { color: var(--primary); background: rgba(58, 90, 120, 0.12); font-weight: 600; }
.btn-nav.active .nav-icon { transform: translateY(-3px) scale(1.1); }
.btn-nav.active .nav-label { opacity: 1; }
body.dark .btn-nav.active { color: var(--secondary-light); background: rgba(129, 178, 154, 0.15); }

/* ---------- Dashboard ---------- */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; padding: 0 4px; }
.greeting h2 { font-size: 1.5rem; margin: 0; font-weight: 700; letter-spacing: -0.02em; color: var(--foreground); }
.streak-badge { display: inline-flex; align-items: center; gap: 4px; background: var(--card-bg); border: 1px solid var(--card-border); padding: 6px 14px; border-radius: 50px; font-size: 0.8rem; font-weight: 500; color: var(--muted); box-shadow: var(--shadow-sm); transition: all 0.3s ease; }
.streak-badge:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.streak-badge span { font-weight: 700; color: var(--primary); font-size: 0.9rem; }
body.dark .streak-badge span { color: var(--secondary-light); }

.dashboard-cards { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-md); transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1); position: relative; overflow: hidden; }
.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--primary-gradient); opacity: 0; transition: opacity 0.3s ease; }
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.card:hover::before { opacity: 1; }

.practice-card .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.day-badge { background: var(--primary-gradient); color: #fff; padding: 6px 14px; border-radius: 50px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; box-shadow: 0 4px 12px rgba(58, 90, 120, 0.2); }
.status-badge { font-size: 0.75rem; font-weight: 600; padding: 6px 12px; border-radius: 50px; background: rgba(224, 122, 95, 0.12); color: var(--destructive); transition: all 0.3s ease; }
.status-badge.completed { background: rgba(123, 163, 141, 0.15); color: var(--secondary-dark); }
body.dark .status-badge.completed { color: var(--secondary-light); }
.card-description { margin: 8px 0 16px; font-size: 0.95rem; line-height: 1.6; color: var(--muted); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-grid button { min-height: 56px; font-size: 0.9rem; padding: 12px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.quick-grid button:active:not(:disabled) { transform: scale(0.96); }

/* ============================================================
PRÁCTICA Y PÁNICO (Círculos Hipnóticos)
============================================================ */
.practice-container, .panic-container { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 4px 0; text-align: center; flex: 1; justify-content: flex-start; }
.practice-container h2, .panic-container h2 { font-size: 1.3rem; margin-bottom: 4px; }
.panic-container h2 { color: var(--destructive); }
#practice-back, #panic-back { align-self: flex-start; margin-bottom: 0; font-size: 1.4rem; }

#breath-wrapper, #panic-wrapper { width: 280px; height: 280px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; margin: 12px auto; position: relative; }

#breath-circle, #panic-circle {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(1);
    width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border: 4px solid var(--primary); box-shadow: 0 0 40px rgba(58, 90, 120, 0.25);
    transition: border-color 0.8s ease, box-shadow 0.8s ease, width 0.1s linear, height 0.1s linear;
    z-index: 0; transform-origin: center; will-change: transform, width, height;
    display: flex; align-items: center; justify-content: center;
}

/* 🪄 MAGIA CSS: Sobrescribe colores hardcodeados si el JS falla */
#breath-circle, #panic-circle { border-color: var(--primary) !important; box-shadow: 0 0 40px rgba(58, 90, 120, 0.25) !important; }
#breath-circle.phase-inhala, #panic-circle.phase-inhala { border-color: var(--primary) !important; box-shadow: 0 0 40px rgba(58, 90, 120, 0.4) !important; }
#breath-circle.phase-exhala, #panic-circle.phase-exhala { border-color: var(--secondary) !important; box-shadow: 0 0 40px rgba(123, 163, 141, 0.4) !important; }
#breath-circle.wave-mode, #panic-circle.wave-mode { border-color: transparent !important; box-shadow: 0 0 50px rgba(91, 130, 160, 0.3) !important; }
#breath-circle.phase-reten, #panic-circle.phase-reten { border-color: var(--primary-light) !important; }

#breath-circle::before, #panic-circle::before {
    content: ''; position: absolute; top: -8px; left: -8px; right: -8px; bottom: -8px; border-radius: 50%;
    background: conic-gradient(from 0deg, var(--primary) 0%, var(--primary-light) 10%, var(--primary) 20%, var(--primary-light) 30%, var(--primary) 40%, var(--primary-light) 50%, var(--primary) 60%, var(--primary-light) 70%, var(--primary) 80%, var(--primary-light) 90%, var(--primary) 100%);
    mask: radial-gradient(circle, transparent 55%, black 57%, black 85%, transparent 87%);
    -webkit-mask: radial-gradient(circle, transparent 55%, black 57%, black 85%, transparent 87%);
    opacity: 0; transition: opacity 0.8s ease; z-index: -1; pointer-events: none;
}
#breath-circle.wave-mode::before, #panic-circle.wave-mode::before { opacity: 1; animation: rotateWave 4s linear infinite; }
@keyframes rotateWave { 100% { transform: rotate(360deg); } }

#panic-circle.pulse-effect { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.05); opacity: 0.85; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.breath-phase { font-size: 1.5rem; font-weight: 600; color: var(--foreground); min-height: 2.2rem; transition: color 0.5s; margin-top: 4px; }
.breath-timer { font-size: 2.5rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
body.dark .breath-timer { color: var(--secondary-light); }
.practice-controls { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
#panic-status { font-size: 1rem; font-weight: 500; color: var(--muted); min-height: 1.8rem; }

/* ---------- Contador (Días 2-7) ---------- */
#counter-wrapper { width: 100%; max-width: 300px; margin: 12px auto; display: none; flex-direction: column; align-items: center; gap: 16px; }
.practice-counter { font-size: 2.5rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; letter-spacing: 0.05em; }
body.dark .practice-counter { color: var(--secondary-light); }
.progress-bar { width: 100%; height: 10px; background: rgba(255, 255, 255, 0.2); border-radius: 50px; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1); }
.progress-fill { height: 100%; background: var(--primary-gradient); border-radius: 50px; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); width: 0%; box-shadow: 0 2px 8px rgba(58, 90, 120, 0.3); }
body.dark .progress-fill { background: linear-gradient(135deg, var(--primary), var(--secondary)); }

/* ---------- Instrucciones y Logs ---------- */
.practice-instructions, .previous-logs { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 16px 20px; margin: 8px 0; text-align: left; width: 100%; max-width: 320px; box-shadow: var(--shadow-sm); }
.practice-instructions .instructions-title { font-weight: 600; font-size: 1.1rem; color: var(--foreground); margin-bottom: 6px; }
.practice-instructions .instructions-desc { color: var(--muted); font-size: 0.95rem; line-height: 1.6; }
.previous-logs { max-height: 200px; overflow-y: auto; font-size: 0.9rem; }
.previous-logs .log-entry { padding: 8px 0; border-bottom: 1px solid var(--card-border); }
.previous-logs .log-entry:last-child { border-bottom: none; }
.log-empty { color: var(--muted); text-align: center; padding: 16px 0; font-style: italic; }

/* ============================================================
PÁGINA DE PROGRESO
============================================================ */
.progress-container { padding: 4px 0; display: flex; flex-direction: column; gap: 16px; }
.progress-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 16px 8px; text-align: center; box-shadow: var(--shadow-sm); transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-number { font-size: 1.8rem; font-weight: 700; color: var(--primary); display: block; }
body.dark .stat-number { color: var(--secondary-light); }
.stat-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }

.progress-bar-container { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 16px 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm); }
.progress-bar-label { font-weight: 500; font-size: 0.9rem; color: var(--foreground); min-width: 60px; }
.progress-percentage { font-weight: 600; font-size: 0.9rem; color: var(--primary); min-width: 40px; text-align: right; }
body.dark .progress-percentage { color: var(--secondary-light); }

.progress-days-list { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 4px 0; }
.day-progress-item { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: var(--radius-sm); padding: 10px 4px; text-align: center; font-size: 0.75rem; font-weight: 600; transition: all 0.2s; }
.day-progress-item.completed { border-color: var(--success); background: rgba(123, 163, 141, 0.15); color: var(--secondary-dark); }
body.dark .day-progress-item.completed { color: var(--secondary-light); }
.day-progress-item.current { border-color: var(--primary); background: rgba(58, 90, 120, 0.12); color: var(--primary); box-shadow: 0 0 12px rgba(58, 90, 120, 0.1); }
body.dark .day-progress-item.current { border-color: var(--secondary-light); background: rgba(129, 178, 154, 0.15); color: var(--secondary-light); }
.day-progress-item.pending { color: var(--muted); opacity: 0.5; }

.progress-logs-container, #daily-logs-container { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 16px 20px; max-height: 300px; overflow-y: auto; box-shadow: var(--shadow-sm); }
.progress-logs-container .log-group { margin-bottom: 16px; }
.progress-logs-container .log-group-title { font-weight: 600; font-size: 0.95rem; color: var(--foreground); margin-bottom: 8px; }
.progress-logs-container .log-entry { font-size: 0.85rem; padding: 6px 0; border-bottom: 1px solid var(--card-border); color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.progress-logs-container .log-entry:last-child { border-bottom: none; }
.progress-logs-container .log-entry .log-text { color: var(--foreground); flex: 1; }
.progress-logs-container .log-entry .log-time { font-size: 0.7rem; color: var(--muted-light); white-space: nowrap; }

.daily-logs-header { font-weight: 600; font-size: 1rem; margin-bottom: 12px; color: var(--foreground); }
.daily-log-entry { padding: 12px 0; border-bottom: 1px solid var(--card-border); }
.daily-log-entry:last-child { border-bottom: none; }
.daily-log-date { font-weight: 600; color: var(--primary); margin-bottom: 4px; }
body.dark .daily-log-date { color: var(--secondary-light); }
.daily-log-item { font-size: 0.9rem; color: var(--muted); margin-top: 2px; }

/* ============================================================
PÁGINA DE AJUSTES
============================================================ */
.settings-container { display: flex; flex-direction: column; gap: 20px; padding: 4px 0; }
.settings-section { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-sm); }
.settings-section h3 { font-size: 1.1rem; font-weight: 600; color: var(--foreground); margin-bottom: 16px; }
.setting-group { margin-bottom: 16px; }
.setting-group:last-child { margin-bottom: 0; }
.setting-group label { display: block; font-weight: 500; font-size: 0.9rem; color: var(--foreground); margin-bottom: 8px; }

.setting-group input[type="range"] { width: 100%; height: 6px; background: var(--card-border); border-radius: 3px; outline: none; -webkit-appearance: none; appearance: none; }
.setting-group input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); cursor: pointer; border: 3px solid #fff; box-shadow: var(--shadow-sm); }
body.dark .setting-group input[type="range"]::-webkit-slider-thumb { border-color: var(--background); }

.setting-group input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; margin-right: 10px; }
.setting-group input[type="time"] { padding: 10px 14px; border: 1.5px solid var(--card-border); border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.4); color: var(--foreground); font-family: inherit; font-size: 1rem; width: 100%; max-width: 150px; }
body.dark .setting-group input[type="time"] { background: rgba(255, 255, 255, 0.05); }
.setting-group .range-value { font-weight: 600; color: var(--primary); margin-left: 8px; }
body.dark .setting-group .range-value { color: var(--secondary-light); }

.voice-gender-filter { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.voice-gender-filter button { min-height: 36px; padding: 6px 16px; font-size: 0.8rem; border-radius: 50px; border: 1.5px solid var(--card-border); background: transparent; color: var(--muted); cursor: pointer; transition: all 0.2s; }
.voice-gender-filter button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
body.dark .voice-gender-filter button.active { background: var(--secondary-light); color: var(--background); border-color: var(--secondary-light); }

.voice-list { max-height: 200px; overflow-y: auto; margin-top: 8px; }
.voice-option { padding: 10px 14px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.2s; display: flex; align-items: center; gap: 12px; }
.voice-option:hover { background: rgba(255, 255, 255, 0.08); }
.voice-option.selected { background: rgba(58, 90, 120, 0.12); border-left: 4px solid var(--primary); }
body.dark .voice-option.selected { background: rgba(129, 178, 154, 0.12); border-left-color: var(--secondary-light); }
.voice-option .voice-name { font-weight: 500; color: var(--foreground); flex: 1; }
.voice-option .voice-lang { font-size: 0.8rem; color: var(--muted); }
.voice-option .voice-gender-badge { font-size: 0.7rem; background: var(--card-border); padding: 2px 10px; border-radius: 50px; color: var(--muted); }

/* ============================================================
MODALES
============================================================ */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 28px; max-width: 400px; width: 100%; box-shadow: var(--shadow-xl); animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-content h3 { margin-bottom: 6px; color: var(--foreground); }
.modal-content .modal-subtitle { color: var(--muted); font-size: 0.95rem; margin-bottom: 20px; }
.modal-content textarea { width: 100%; min-height: 120px; padding: 14px 18px; border-radius: var(--radius-md); border: 1.5px solid var(--card-border); background: rgba(255, 255, 255, 0.4); color: var(--foreground); font-family: inherit; font-size: 1rem; resize: vertical; transition: border-color 0.2s, box-shadow 0.2s; }
body.dark .modal-content textarea { background: rgba(255, 255, 255, 0.05); }
.modal-content textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(58, 90, 120, 0.15); }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; justify-content: flex-end; }
.modal-actions button { min-height: 44px; padding: 10px 24px; min-width: 100px; }

/* ============================================================
PÁGINA DE PROTOCOLOS (Rediseño Editorial Premium)
============================================================ */
.protocols-container { display: flex; flex-direction: column; gap: 28px; padding: 8px 0 16px; }

/* --- HERO SECTION (Con Background Blobs) --- */
.protocols-hero {
    position: relative; padding: 48px 24px 40px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    border-radius: var(--radius-xl); color: #fff; overflow: hidden;
    box-shadow: var(--shadow-xl); text-align: center;
}
.protocols-hero::before, .protocols-hero::after {
    content: ''; position: absolute; border-radius: 50%; filter: blur(50px); opacity: 0.35; z-index: 0; pointer-events: none;
}
.protocols-hero::before { width: 200px; height: 200px; background: var(--secondary); top: -60px; right: -40px; }
.protocols-hero::after { width: 150px; height: 150px; background: var(--destructive); bottom: -40px; left: -30px; opacity: 0.2; }
.protocols-hero > * { position: relative; z-index: 1; }

.protocols-badge {
    display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); padding: 8px 18px;
    border-radius: 50px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.12em; margin-bottom: 20px; border: 1px solid rgba(255, 255, 255, 0.2);
}
.protocols-hero h1 {
    font-size: 2.4rem; font-weight: 800; margin: 0 0 8px 0; color: #fff;
    background: none; -webkit-background-clip: unset; background-clip: unset;
    letter-spacing: -0.03em; line-height: 1.1; text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.protocols-subtitle { font-size: 1rem; opacity: 0.85; margin: 0 0 20px 0; font-weight: 400; letter-spacing: 0.02em; }
.protocols-tagline {
    font-size: 1.15rem; font-weight: 500; margin: 0 auto 24px; font-style: italic;
    background: rgba(255, 255, 255, 0.1); padding: 12px 24px; border-radius: 16px;
    display: inline-block; max-width: 90%; border: 1px solid rgba(255, 255, 255, 0.15); line-height: 1.4;
}
.protocols-cta { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.protocols-cta .btn-primary {
    background: #fff; color: var(--primary-dark); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0,0,0,0.1);
    min-height: 54px; font-weight: 700; font-size: 1.05rem; padding: 16px 32px; border-radius: 50px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.protocols-cta .btn-primary:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); }
.protocols-cta .btn-primary:active { transform: translateY(0) scale(0.98); }

/* --- SECCIONES DE CONTENIDO --- */
.protocols-section {
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
    padding: 28px 24px; box-shadow: var(--shadow-md); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.protocols-section h2 { font-size: 1.4rem; font-weight: 700; color: var(--foreground); margin: 0 0 16px 0; letter-spacing: -0.02em; }
.protocols-section p { margin: 0 0 16px 0; line-height: 1.75; color: var(--muted); font-size: 0.98rem; }
.protocols-section p:last-child { margin-bottom: 0; }
.protocols-section strong { color: var(--foreground); font-weight: 600; }

/* --- GRID DE PROTOCOLOS (Cards Premium) --- */
.protocols-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.protocol-card {
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md);
    padding: 24px 16px; text-align: center; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative; overflow: hidden;
}
.protocol-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--primary-gradient); transform: scaleX(0); transform-origin: left; transition: transform 0.4s ease;
}
.protocol-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.protocol-card:hover::before { transform: scaleX(1); }
.protocol-card-icon { font-size: 2.5rem; margin-bottom: 12px; display: block; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05)); transition: transform 0.4s ease; }
.protocol-card:hover .protocol-card-icon { transform: scale(1.15) rotate(-5deg); }
.protocol-card h3 { font-size: 1rem; font-weight: 700; color: var(--foreground); margin: 0 0 8px 0; letter-spacing: -0.01em; }
.protocol-card p { font-size: 0.85rem; color: var(--muted); margin: 0; line-height: 1.5; }

/* --- TESTIMONIAL (Cita Editorial) --- */
.protocols-testimonial {
    position: relative; background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: var(--radius-lg); padding: 36px 28px; text-align: center;
    box-shadow: var(--shadow-md); overflow: hidden;
}
.protocols-testimonial::before {
    content: '“'; position: absolute; top: -15px; left: 15px; font-size: 8rem;
    font-family: Georgia, 'Times New Roman', serif; color: var(--primary-light);
    opacity: 0.15; line-height: 1; pointer-events: none;
}
.protocols-testimonial blockquote { font-size: 1.3rem; font-style: italic; color: var(--foreground); margin: 0 0 16px 0; line-height: 1.5; font-weight: 500; position: relative; z-index: 1; }
.protocols-testimonial cite { font-size: 0.9rem; color: var(--muted); font-style: normal; font-weight: 500; letter-spacing: 0.02em; }

/* --- FINAL CTA --- */
.protocols-final-cta {
    text-align: center; background: var(--card-bg); border: 2px solid transparent;
    background-image: linear-gradient(var(--card-bg), var(--card-bg)), var(--primary-gradient);
    background-origin: border-box; background-clip: padding-box, border-box;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    padding: 32px 24px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.protocols-final-cta h2 { margin: 0; font-size: 1.5rem; background: var(--primary-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.protocols-final-cta p { margin: 0; color: var(--muted); line-height: 1.6; }
.protocols-final-cta .btn-primary { margin: 8px 0 0; min-height: 54px; padding: 16px 40px; font-size: 1.05rem; }
.protocols-small { font-size: 0.8rem; color: var(--muted-light); margin: 0; letter-spacing: 0.02em; }

/* ---------- Utilidades ---------- */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; } .flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .justify-center { justify-content: center; }
.gap-2 { gap: 8px; } .gap-4 { gap: 16px; } .hidden { display: none !important; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
body.dark ::-webkit-scrollbar-thumb { background: var(--muted); }

/* ---------- Responsive (¡SIN TOCAR EL FONT-SIZE DEL BODY!) ---------- */
@media (max-width: 480px) {
    #app { padding: 16px 14px 12px; border-radius: 0; }
    h1 { font-size: 1.7rem; } h2 { font-size: 1.2rem; }
    .breath-phase { font-size: 1.3rem; min-height: 2rem; }
    .breath-timer { font-size: 2rem; }
    .quick-grid { grid-template-columns: 1fr; }
    .practice-controls button { min-height: 48px; padding: 12px 20px; font-size: 0.95rem; }
    #breath-wrapper, #panic-wrapper { width: 240px; height: 240px; }
    .btn-nav .nav-label { font-size: 0.6rem; }
    .protocols-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .protocols-hero h1 { font-size: 1.9rem; }
    .protocols-tagline { font-size: 1rem; padding: 10px 18px; }
    .protocols-cta { flex-direction: column; gap: 12px; }
    .protocols-cta .btn-primary { width: 100%; }
    .protocols-testimonial blockquote { font-size: 1.15rem; }
}

@media (max-width: 374px) {
    #app { padding: 12px 10px 10px; }
    /* ⚠️ ELIMINADO: body { font-size: 14px; } para proteger los REM de la navegación */
    .breath-phase { font-size: 1.1rem; min-height: 1.8rem; }
    .breath-timer { font-size: 1.7rem; }
    #breath-wrapper, #panic-wrapper { width: 200px; height: 200px; }
    .btn-nav .nav-label { font-size: 0.55rem; }
    .progress-stats { grid-template-columns: 1fr 1fr; }
    .stat-card:last-child { grid-column: span 2; }
    .protocols-grid { grid-template-columns: 1fr; }
    .protocol-card { padding: 20px 16px; }
}

/* ---------- Safe areas (PWA) ---------- */
@supports (padding: max(0px)) {
    #app {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-top: max(24px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ---------- Colores de texto para fases de respiración ---------- */
.phase-text-inhala { color: var(--primary) !important; }
.phase-text-exhala { color: var(--secondary) !important; }
.phase-text-reten { color: var(--primary-light) !important; }
body.dark .phase-text-inhala { color: var(--primary-light) !important; }
body.dark .phase-text-exhala { color: var(--secondary-light) !important; }
body.dark .phase-text-reten { color: var(--primary-light) !important; }