:root {
    /* PALETA PRO NEURO-ESTUDIO */
    --c-bg: #FDFCF0;
    /* Crema Suave */
    --c-surface: #FFFFFF;
    /* Blanco Puro */
    --c-prime: #1A365D;
    /* Azul Oxford */
    --c-accent: #2B6CB0;
    /* Azul Interacción */
    --c-success: #2F855A;
    /* Verde Académico */
    --c-error: #E53E3E;
    /* Rojo Alerta */
    --c-text: #2D3748;
    /* Gris Oscuro */
    --c-muted: #718096;
    /* Gris Medio */
    --c-border: #E2E8F0;
    /* Borde Suave */

    /* GRADIENTES */
    --grad-prime: linear-gradient(135deg, #1A365D 0%, #2A4365 100%);
    --grad-hover: linear-gradient(135deg, #2A4365 0%, #2B6CB0 100%);

    /* TIPOGRAFIA */
    --font-ui: 'Inter', sans-serif;
    --font-reading: 'Merriweather', serif;

    /* SOMBRAS & RADIUS */
    --rad: 16px;
    --shad-sm: 0 2px 4px rgba(0, 0, 0, 0.03);
    --shad-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
    --shad-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* --- 1. RESET & BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--font-ui);
    font-size: 16px;
    /* Base size, scalabe */
    line-height: 1.5;
    overflow-x: hidden;
}

h1,
h2,
h3 {
    color: var(--c-prime);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

/* UTILITIES */
.hidden {
    display: none !important;
}

.w-100 {
    width: 100%;
}

/* --- 2. LAYOUT & CONTAINERS --- */
.container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
    padding-bottom: 80px;
    /* Space for tutor widget mobile */
}

/* HEADER */
.main-header {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 64px;
    display: flex;
    align-items: center;
    box-shadow: var(--shad-sm);
}

.header-container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.3rem;
    color: var(--c-prime);
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* HAMBURGER (Mobile) */
.hamburger {
    font-size: 1.5rem;
    color: var(--c-prime);
    padding: 0.5rem;
    display: block;
    /* Visible on Mobile */
}

/* NAV MENU (Mobile Off-Canvas style by default) */
.nav-menu {
    position: absolute;
    top: 64px;
    left: 0;
    width: 100%;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 1rem 0;
    flex-direction: column;
    box-shadow: var(--shad-lg);
    display: none;
    /* Hidden by default */
}

.nav-menu.open {
    display: flex;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem 1.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #F0F0F0;
}

.avatar-small {
    width: 32px;
    height: 32px;
    background: #D69E2E;
    color: white;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.nav-links {
    list-style: none;
}

.nav-links li {
    margin-bottom: 0.2rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.5rem;
    color: var(--c-muted);
    font-weight: 500;
    transition: 0.2s;
}

.nav-item.active,
.nav-item:hover {
    background: #F7FAFC;
    color: var(--c-prime);
}

.btn-logout-nav {
    margin: 0.5rem 1.5rem;
    color: var(--c-error);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- 3. COMPONENTS --- */

/* BUTTONS (Touch Friendly > 44px) */
.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    transition: transform 0.2s;
    min-height: 48px;
    /* Accessibility */
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--grad-prime);
    color: white;
    box-shadow: 0 4px 10px rgba(26, 54, 93, 0.3);
}

.btn-lg {
    width: 100%;
    font-size: 1.1rem;
}

/* STATS CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile Stack */
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--c-surface);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--c-border);
    display: flex;
    gap: 1rem;
    align-items: center;
    box-shadow: var(--shad-md);
}

.icon-box {
    width: 50px;
    height: 50px;
    background: #EBF8FF;
    color: var(--c-accent);
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
}

.icon-box.accent {
    background: #FAF5FF;
    color: #805AD5;
}

.stat-data {
    flex: 1;
}

.stat-data h3 {
    font-size: 1rem;
    margin: 0 0 0.3rem 0;
    color: var(--c-muted);
}

.thermometer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.track {
    flex: 1;
    height: 8px;
    background: #EDF2F7;
    border-radius: 4px;
    overflow: hidden;
}

.fill {
    height: 100%;
    background: var(--c-success);
    width: 0;
    transition: 1s;
}

.fill-accent {
    height: 100%;
    background: #805AD5;
    width: 0;
    transition: 1s;
}

/* LIBRARY GRID */
.grid-topics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.lib-card {
    background: var(--c-surface);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid #F0F0F0;
    box-shadow: var(--shad-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: 0.2s;
}

.lib-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shad-md);
}

.lib-card.read-ok {
    border-left: 5px solid var(--c-success);
}

.card-icon {
    font-size: 1.5rem;
    color: var(--c-prime);
}

/* READING PANEL (Mobile: Slide Up) */
.slide-panel {
    position: fixed;
    inset: 0;
    top: 100%;
    background: var(--c-surface);
    z-index: 2000;
    transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.slide-panel.open {
    top: 0;
}

.slide-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
}

.slide-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* TEST UI */
.test-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.progress-bar-top {
    height: 6px;
    background: #E2E8F0;
    border-radius: 3px;
    margin-bottom: 2rem;
}

#p-bar-fill {
    height: 100%;
    background: var(--c-success);
    width: 0;
    transition: 0.3s;
}

.options-list button {
    width: 100%;
    text-align: left;
    padding: 1rem;
    margin-bottom: 0.8rem;
    border: 2px solid var(--c-border);
    border-radius: 12px;
    background: var(--c-surface);
    font-size: 1rem;
}

.options-list button.correct {
    border-color: var(--c-success);
    background: #F0FFF4;
    color: #22543D;
}

.options-list button.incorrect {
    border-color: var(--c-error);
    background: #FFF5F5;
}

/* LOGIN & TUTOR */
.overlay {
    position: fixed;
    inset: 0;
    background: var(--c-bg);
    z-index: 9000;
    display: grid;
    place-items: center;
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shad-lg);
}

.modal input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--c-border);
    border-radius: 12px;
    margin: 1rem 0;
}

.tutor-widget {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    background: var(--c-surface);
    border-radius: 20px;
    box-shadow: var(--shad-lg);
    border: 1px solid var(--c-border);
    z-index: 5000;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
}

.tutor-header {
    background: var(--grad-prime);
    color: white;
    padding: 1rem;
    border-radius: 19px 19px 0 0;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
}

.tutor-content {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

/* --- 4. MEDIA QUERY: DESKTOP (>= 768px) --- */
@media (min-width: 768px) {

    /* Layout */
    .container {
        padding-top: 3rem;
        padding-bottom: 0;
    }

    /* HEADER & NAV */
    .hamburger {
        display: none;
    }

    .nav-menu {
        position: static;
        width: auto;
        height: auto;
        padding: 0;
        border: none;
        background: transparent;
        box-shadow: none;
        display: flex !important;
        /* Force flex on desktop */
        flex-direction: row;
        align-items: center;
        gap: 2rem;
    }

    .nav-user {
        border: none;
        margin: 0;
        padding: 0;
        order: 2;
        /* Move User to right */
        border-left: 1px solid #E2E8F0;
        padding-left: 1.5rem;
    }

    #name-display {
        display: none;
    }

    /* Show only avatar on desktop nav or both? Let's hide name for clean look */

    .nav-links {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        order: 1;
    }

    .nav-links li {
        margin: 0;
    }

    .nav-item {
        padding: 0.5rem 1rem;
        border-radius: 8px;
        font-size: 0.95rem;
    }

    .btn-logout-nav {
        margin: 0;
        padding: 0;
        order: 3;
        margin-left: 1rem;
    }

    .desktop-hidden {
        display: none;
    }

    /* Hide text, verify icon */

    /* DASHBOARD */
    .section-header {
        margin-bottom: 3rem;
        text-align: center;
    }

    .section-header h1 {
        font-size: 2.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .btn-lg {
        width: auto;
        padding: 1rem 4rem;
        font-size: 1.2rem;
    }

    .cta-area {
        text-align: center;
        margin-top: 3rem;
    }

    /* READING PANEL */
    .slide-panel {
        top: 0;
        bottom: 0;
        left: auto;
        right: 0;
        width: 800px;
        max-width: 50vw;
        border-left: 1px solid var(--c-border);
        transform: translateX(100%);
        transition: transform 0.4s ease;
    }

    .slide-panel.open {
        transform: translateX(0);
    }

    /* TUTOR */
    .tutor-widget {
        left: auto;
        width: 350px;
        bottom: 2rem;
        right: 2rem;
        max-height: 600px;
    }
}