        /* --- ESTILOS GENERALES --- */
        :root {
            --primary-color: #13a253; /* Verde para el branding */
            --secondary-color: #6B7280; /* Gris para botones */
            --background-color: #f3f4f6;
            --card-background: #ffffff;
            --border-color: #d1d5db;
        }
        html, body {
            height: 100%;
            overflow-x: hidden;
        }
        body {
            font-family: 'Inter', system-ui, sans-serif;
            background-color: var(--background-color);
            color: #333;
            margin: 0;
            display: flex;
            flex-direction: column;
        }

        /* Contenedor Principal de la App */
        #appContainer {
            display: flex;
            flex-direction: column;
            height: 100vh; /* ocupa toda la pantalla */
        }

        /* ENCABEZADO Y FILTROS FIJOS */
        .sticky-header {
            position: sticky;
            top: 0;
            z-index: 50;
            background: #fff; /* para que no se transparente */
        }

        /* Centrado en móviles */
        .header-main-container {
            display: flex;
            flex-direction: column;
            align-items: center;   /* centra horizontal */
            text-align: center;    /* centra el texto */
            gap: 1rem;
        }

        /* En pantallas medianas o más grandes, se vuelve fila */
        @media (min-width: 640px) {
            .header-main-container {
                flex-direction: row;
                justify-content: space-between;
                align-items: center;
                text-align: left;
            }
        }


        /* --- Estilos de UI --- */
        .btn {
            padding: 0.75rem 1.5rem;
            border-radius: 0.5rem;
            font-weight: 600;
            transition: all 0.2s ease-in-out;
            text-align: center;
            cursor: pointer;
            border: 1px solid transparent;
        }
        .btn-secondary {
            background-color: var(--secondary-color);
            color: white;
        }
        .btn-secondary:hover {
            background-color: #4b5563;
        }
        .btn-sm {
            padding: 0.5rem 1rem;
            font-size: 0.875rem;
        }
        .btn-view {
            background-color: var(--primary-color);
            color: white;
        }
        .btn-view:hover {
            background-color: #0d8341;
        }

        .form-input {
            border: 1px solid var(--border-color);
            border-radius: 0.375rem;
            transition: border-color 0.2s, box-shadow 0.2s;
            background-color: var(--card-background);
            color: #333;
            outline: none;
            padding: 0.25rem 0.75rem;
        }
        .form-input:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(19, 162, 83, 0.2);
        }

        .message-base {
            display: none;
            margin-top: 0.75rem;
            padding: 0.75rem;
            border: 1px solid;
            border-radius: 0.375rem;
            font-size: 0.875rem;
        }
        .error-message {
            background-color: #fef2f2;
            color: #991b1b;
            border-color: #fecaca;
        }
        
        /* --- Estilos de la Biblioteca --- */
        .library-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 1.5rem;
        }
        .library-item {
            background-color: var(--card-background);
            border: 1px solid var(--border-color);
            border-radius: 0.75rem;
            padding: 1rem;
            display: flex;
            flex-direction: column;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .library-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .library-item img.library-item-cover {
            width: 100%;
            height: auto;
            max-height: 250px;
            object-fit: contain;
            border-radius: 0.5rem;
            margin-bottom: 0.75rem;
            background-color: #e0e0e0;
            border: 1px solid var(--border-color);
        }
        .library-item h3 {
            font-size: 1.05rem;
            font-weight: 600;
            margin-bottom: 0.25rem;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            min-height: 2.5em;
        }
        .library-item .item-meta {
            font-size: 0.75rem;
            color: #6b7280;
            margin-bottom: 0.75rem;
        }
        .library-item .item-author {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .library-item-actions {
            margin-top: auto;
            display: flex;
            gap: 0.5rem;
            flex-wrap: wrap;
            padding-top: 0.5rem;
        }
        .library-item-actions .btn {
            flex-grow: 1;
            font-size: 0.8rem;
            padding: 0.4rem 0.8rem;
        }

        /* --- FILTROS Y ORDEN --- */
        .filter-sort-controls .btn {
            color: white !important;
        }
        .filter-sort-controls .btn.active {
            background-color: #455A64 !important;
        }
        #collectionFilters .btn[data-collection="Ciencias"].active {
            background-color: #E53935 !important;
        }
        #collectionFilters .btn[data-collection="Sociedad en movimiento"].active {
            background-color: #FDD835 !important;
            color: black !important;
        }
        #collectionFilters .btn[data-collection="Aulas"].active {
            background-color: #1976D2 !important;
        }

        .spinner {
            border: 4px solid rgba(0, 0, 0, 0.1);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            border-left-color: var(--primary-color);
            animation: spin 1s ease infinite;
            display: block;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 2000;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Responsive */
        .header-main-container {
            display: flex;
            flex-direction: column;
            padding: 1rem;
            background-color: #ffffff;
            box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        }
        @media (min-width: 640px) {
            .header-main-container {
                flex-direction: row;
                justify-content: space-between;
                align-items: center;
            }
            .header-actions {
                margin-top: 0;
            }
            .filter-bar-container {
            display: flex !important;
            flex-direction: row !important;
            justify-content: space-between;
            align-items: center;
            }
            .search-input {
                width: auto;
            }
            .app-container {
                width: 100%;
            }
        }
        .flex-grow-1 {
            flex-grow: 1;
        }
        .w-full {
            width: 100%;
        }
        .max-w-lg {
            max-width: 32rem;
        }
        .pb-4 {
            padding-bottom: 1rem;
        }
        .pt-4 {
            padding-top: 1rem;
        }
        .mb-4 {
            margin-bottom: 1rem;
        }
        .mx-auto {
            margin-left: auto;
            margin-right: auto;
        }
        .flex-wrap {
            flex-wrap: wrap;
        }
        .items-center {
            align-items: center;
        }
        .gap-2 {
            gap: 0.5rem;
        }
        .gap-4 {
            gap: 1rem;
        }
        .mt-4 {
            margin-top: 1rem;
        }
        .p-4 {
            padding: 1rem;
        }
        .px-4 {
            padding-left: 1rem;
            padding-right: 1rem;
        }
        .py-4 {
            padding-top: 1rem;
            padding-bottom: 1rem;
        }
        .mr-2 {
            margin-right: 0.5rem;
        }
        .text-sm {
            font-size: 0.875rem;
        }
        .text-xl {
            font-size: 1.25rem;
        }
        .text-2xl {
            font-size: 1.5rem;
        }
        .text-3xl {
            font-size: 1.875rem;
        }
        .font-bold {
            font-weight: 700;
        }
        .font-medium {
            font-weight: 500;
        }
        .text-center {
            text-align: center;
        }
        .text-gray-500 {
            color: #6b7280;
        }
        .rounded-full {
            border-radius: 9999px;
        }
        .flex {
            display: flex;
        }
        .flex-col {
            flex-direction: column;
        }
        .h-full {
            height: 100%;
        }
        .flex-shrink-0 {
            flex-shrink: 0;
        }
        .shadow-sm {
            box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        }
        .z-10 {
            z-index: 10;
        }
        .items-center {
            align-items: center;
        }
        .hidden {
            display: none !important;
        }
        .overflow-y-auto {
            overflow-y: auto;
        }
        .border-t {
            border-top: 1px solid var(--border-color);
        }
        .bg-gray-100 {
            background-color: #f3f4f6;
        }
        .bg-white {
            background-color: #ffffff;
        }
        .bg-gray-50 {
            background-color: #f9fafb;
        }
        .bg-gray-200 {
            background-color: #e5e7eb;
        }
        .p-6 {
            padding: 1.5rem;
        }
        .md\:p-6 {
            padding: 1.5rem;
        }
        @media (min-width: 768px) {
            .md\:p-6 {
                padding: 1.5rem;
            }
        }
        