        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=JetBrains+Mono:ital,wght@0,400;0,700;1,400&display=swap');

        :root {
            /* [ MATRIX_RGB ] - Verde Musgo y Esmeralda */
            --bg: #0a0c0a;
            --surface: #121612;
            --border: #1a201a;
            --text: #c8dcd0;
            --accent: #4ade80;
            --accent-alt: #22c55e;
            /* Un verde más profundo para títulos */
            --overlay-bg: rgba(5, 8, 5, 0.85);
            --font-main: 'Inter', sans-serif;
            --font-mono: 'JetBrains Mono', monospace;
            --nav-height: 80px;
        }

        [data-theme="bw"] {
            /* [ PAPER_BW ] - Hueso y Tinta Seca */
            --bg: #f5f5f4;
            --surface: #e7e7e4;
            --border: #d6d6d2;
            --text: #1c1917;
            --accent: #44403c;
            --accent-alt: #78716c;
            --overlay-bg: rgba(245, 245, 244, 0.9);
        }

        [data-theme="amber"] {
            /* [ AMBER_CRT ] - Obsidiana y Oro Viejo */
            --bg: #0f0d0a;
            --surface: #1a1612;
            --border: #2d241a;
            --text: #fcd34d;
            --accent: #fbbf24;
            --accent-alt: #d97706;
            --overlay-bg: rgba(10, 8, 5, 0.9);
        }

        [data-theme="steel"] {
            /* [ STEEL_CYBER ] - Ártico y Cobalto */
            --bg: #0f172a;
            --surface: #1e293b;
            --border: #334155;
            --text: #f1f5f9;
            --accent: #38bdf8;
            --accent-alt: #0ea5e9;
            --overlay-bg: rgba(15, 23, 42, 0.9);
        }

        [data-theme="blueprint"] {
            /* Fondo azul muy pálido con textura de puntos */
            --bg: #f0f4f8;
            --surface: #e1e8f0;
            --border: #cbd5e1;
            --text: #334155;
            --accent: #2563eb;
            /* Azul técnico */
            --accent-alt: #0f172a;
            --overlay-bg: rgba(240, 244, 248, 0.9);

            /* Efecto Dot Grid */
            background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
            background-size: 20px 20px;
        }

        [data-theme="ghost"] {
            --bg: #1a1b1e;
            --surface: #25262b;
            --border: #373a40;
            --text: #c1c2c5;
            --accent: #a5d8ff;
            /* Azul hielo */
            --accent-alt: #be4bdb;
            /* Magenta suave para contrastes */
            --overlay-bg: rgba(26, 27, 30, 0.9);
        }

        [data-theme="radar"] {
            --bg: #050b10;
            --surface: #0a141d;
            --border: #142a3d;
            --text: #71b1d9;
            --accent: #00f2ff;
            /* Cian Neón */
            --accent-alt: #0066ff;
            --overlay-bg: rgba(5, 11, 16, 0.9);
        }

        /* Efecto: Círculos concéntricos de Radar (Muy sutiles en las esquinas) */
        [data-theme="radar"] body {
            background-image: radial-gradient(circle at 0% 0%, var(--border) 2px, transparent 1px);
            background-size: 100px 100px;
        }

        [data-theme="olive"] {
            --bg: #e2e4d5;
            /* Verde oficina antiguo */
            --surface: #d8dabf;
            --border: #b5b8a1;
            --text: #2d2f28;
            /* Tinta seca */
            --accent: #5d6342;
            /* Verde militar profundo */
            --accent-alt: #8c7355;
            /* Cuero/Madera */
            --overlay-bg: rgba(226, 228, 213, 0.95);
            --glow: none;
        }

       
        /* Solo aplicar el grid si estamos en blueprint */
        [data-theme="blueprint"] body {
            background-image: radial-gradient(var(--border) 0.5px, transparent 1px);
            background-size: 24px 24px;
        }

        /* Efecto de "Scanline" para temas oscuros técnicos */
        [data-theme="ghost"] body::after,
        [data-theme="matrix"] body::after {
            content: "";
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(rgba(18, 16, 16, 0) 50%,
                    rgba(0, 0, 0, 0.05) 50%);
            background-size: 100% 4px;
            z-index: 9999;
            pointer-events: none;
            opacity: 0.5;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Forzamos que el body y html usen el background dinámico */
        html,
        body {
            background-color: var(--bg);
            color: var(--text);
            transition: background-color 0.3s, color 0.3s;
        }

        body {
            font-family: var(--font-main);
            background-color: var(--bg);
            color: var(--text);
            -webkit-font-smoothing: antialiased;
        }

        /* --- EFECTO CRT (Opcional, se oculta en modo papel) --- */
        body::before {
            content: " ";
            display: block;
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.05) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.01), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.01));
            z-index: 9999;
            background-size: 100% 3px, 3px 100%;
            pointer-events: none;
            opacity: 0.3;
        }

        [data-theme="bw"] body::before {
            display: none;
        }

        /* --- NAVEGACIÓN --- */
        nav {
            display: flex;
            padding: 1rem 2rem;
            border-bottom: 1px solid var(--border);
            background: var(--bg);
            position: sticky;
            top: 0;
            flex-direction: column;
            z-index: 1000;
        }

        .brand {
            font-weight: 900;
            letter-spacing: 2px;
            font-size: 1.1rem;
            text-transform: uppercase;
        }

        .brand span {
            color: var(--accent);
        }

        .nav-controls {
            display: flex;
            gap: 0.5rem;
            margin-top: 0.5rem;
        }

        /* --- BOTONES --- */
        .home-btn,
        a {
            border-radius: 4px;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 700;

            text-decoration: none;
            background: var(--surface);
            border: 1px solid var(--border);
            color: var(--accent);
            padding: 0.5rem 1rem;
            font-family: var(--font-mono);
            font-size: 0.6rem;
            cursor: pointer;
            z-index: 2000;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
        }

        .home-btn:hover,
        .home-btn.active {
            border-color: var(--accent);
            color: var(--bg);
            background: var(--accent);
        }

        /* --- MAIN LAYOUT --- */
        .main-container {
            display: flex;
            flex-direction: column;
            max-width: 900px;
            margin: 0 auto;
            width: 100%;
            flex: 1;
        }

        #document-index {
            position: fixed;
            top: var(--nav-height);
            left: -320px;
            width: 300px;
            height: calc(100vh - var(--nav-height));
            background: var(--surface);
            border-right: 1px solid var(--border);
            padding: 1.5rem;
            z-index: 1100;
            transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            overflow-y: auto;
            gap: 0.5rem;
        }

        #document-index h3,
        #document-index a {
            margin: 0.5rem 0;
        }

        #document-index h3 {
            text-align: center;
        }

        body.toc-active #document-index {
            left: 0;
            box-shadow: 20px 0 50px rgba(0, 0, 0, 0.3);
        }

        #toc-overlay {
            position: fixed;
            top: var(--nav-height);
            left: 0;
            width: 100vw;
            height: calc(100vh - var(--nav-height));
            background: var(--overlay-bg);
            backdrop-filter: blur(8px);
            /* Efecto cristal esmerilado elegante */
            opacity: 0;
            visibility: hidden;
            transition: all 0.4s ease;
            z-index: 1050;
        }

        /* Limpiamos el estilo base de los enlaces del índice para que no hereden el estilo de botón global */
        #toc-container a {
            display: block;
            text-decoration: none;
            font-family: var(--font-mono);
            transition: all 0.2s ease;
            border: none;
            box-shadow: none;
            background: transparent;
            padding: 0.6rem 0;
            line-height: 1.3;
        }

        /* NIVEL 1: Títulos Principales (Capítulos / Unidades) */
        .toc-h1 {
            font-size: 0.75rem;
            font-weight: 700;
            color: var(--accent);
            text-transform: uppercase;
            letter-spacing: 1.5px;
            border-bottom: 1px solid var(--border) !important;
            margin-bottom: 0.5rem;
            margin-top: 1rem;
        }

        .toc-h1:hover {
            color: var(--text);
            padding-left: 5px;
        }

        /* NIVEL 2: Secciones (Artículos / Temas) */
        .toc-h2 {
            font-size: 0.65rem;
            font-weight: 400;
            color: var(--text);
            padding-left: 1.2rem !important;
            opacity: 0.8;
            position: relative;
        }

        /* Guía visual vertical para el nivel 2 */
        .toc-h2::before {
            content: "";
            position: absolute;
            left: 0.4rem;
            top: 0;
            bottom: 0;
            width: 1px;
            background: var(--border);
        }

        .toc-h2:hover {
            opacity: 1;
            color: var(--accent);
            background: var(--bg);
            padding-left: 1.5rem !important;
        }

        /* NIVEL 3: Subsecciones (Incisos / Detalles) */
        .toc-h3 {
            font-size: 0.6rem;
            font-weight: 400;
            color: var(--text);
            padding-left: 2.2rem !important;
            opacity: 0.5;
            font-style: italic;
        }

        .toc-h3:hover {
            opacity: 1;
            color: var(--accent);
            padding-left: 2.5rem !important;
        }

        /* Indicador de "Item Activo" (Opcional, para cuando pasas el mouse) */
        #toc-container a:hover::after {
            content: " _";
            color: var(--accent);
            font-weight: 900;
        }

        body.toc-active #toc-overlay {
            opacity: 1;
            visibility: visible;
        }

        /* --- RENDERER CONTRASTE CORREGIDO --- */
        .viewer-area {
            padding: 3rem 2rem;
            width: 100%;
        }

        #markdown-content {
            line-height: 1.8;
            /* Más aire entre líneas para leyes largas */
            letter-spacing: -0.011em;
            display: flex;
            flex-direction: column;
            
        }

        /* --- JERARQUÍA DE CONTENIDO --- */

        /* H1: Título Maestro del Documento (Solo uno por archivo) */
        #markdown-content h1, h1 {
            font-family: var(--font-mono);
            font-size: 1.8rem;
            color: var(--accent);
            text-align: center;
            margin: 4rem 0 3rem 0;
            padding-bottom: 1rem;
            border-bottom: 2px double var(--border);
            letter-spacing: -1px;
            line-height: 1.1;
        }

        /* H2: Divisiones Mayores (Ej: UNIDAD I, CAPÍTULO II) */
        #markdown-content h2, h2 {
            font-family: var(--font-mono);
            font-size: 1.2rem;
            color: var(--accent);
            margin-top: 2rem;
            /* Mucho aire antes de una sección nueva */
            margin-bottom: 1.5rem;
            padding: 0.5rem 1rem;
            background: var(--surface);
            border-left: 4px solid var(--accent);
            display: inline-block;
            /* No ocupa todo el ancho, se ve más elegante */
            letter-spacing: 1px;
        }


        /* H3: Títulos de Artículos con Enmarcado Angular */
        #markdown-content h3, h3 {
            font-family: var(--font-main);
            font-size: 1.15rem;
            font-weight: 700;
            color: var(--text);

            margin-top: 2rem;
            margin-bottom: 1.5rem;

            padding: 0.8rem 1.5rem;
            /* Espacio interno para que respiren las esquinas */
            position: relative;
            display: inline-block;
            /* Para que el recuadro se ajuste al texto y no ocupe todo el ancho */
            min-width: 200px;

            letter-spacing: -0.01em;
            line-height: 1.2;
        }

        /* ESQUINA SUPERIOR IZQUIERDA */
        #markdown-content h3::before, h3::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 12px;
            height: 12px;
            border-top: 2px solid var(--accent);
            border-left: 2px solid var(--accent);
        }

        /* ESQUINA INFERIOR DERECHA */
        #markdown-content h3::after, h3::after {
            content: "";
            position: absolute;
            bottom: 0;
            right: 0;
            width: 12px;
            height: 12px;
            border-bottom: 2px solid var(--accent-alt);
            border-right: 2px solid var(--accent-alt);
        }

        /* EL SÍMBOLO § (Ahora como un elemento flotante sutil arriba) */
        #markdown-content h3 .section-symbol, h3 .section-symbol {
            position: absolute;
            top: -12px;
            left: 10px;
            font-family: var(--font-mono);
            font-size: 0.6rem;
            background: var(--bg);
            /* Tapa la línea si fuera necesario */
            padding: 0 5px;
            color: var(--accent);
            opacity: 0.8;
        }

        /* H4: Sub-puntos o Comentarios de doctrina */
        #markdown-content h4, h4 {
            font-family: var(--font-main);
            font-size: 0.95rem;
            font-weight: 700;
            color: var(--accent-alt);
            margin-top: 2rem;
            margin-bottom: 0.5rem;
            text-transform: none;
        }

        /* --- DETALLES DE REFINAMIENTO --- */

        /* Ajuste de scroll para que el NAV no tape el título al hacer clic en el índice */
        #markdown-content h1,
        #markdown-content h2,
        #markdown-content h3,
        #markdown-content h4 {
            scroll-margin-top: calc(var(--nav-height) + 20px);
        }

        /* Separador elegante para cuando termines una sección sin usar H2 */
        #markdown-content hr {
            border: none;
            height: 1px;
            background: linear-gradient(to right, transparent, var(--border), transparent);
            margin: 4rem 0;
        }

        #markdown-content blockquote {
            background: var(--surface);
            border-left: 3px solid var(--accent-alt);
            color: var(--text);
            opacity: 0.9;
            font-style: normal;
            /* Menos cansado que la itálica */
            border-radius: 0 4px 4px 0;
        }

        #markdown-content p {
            padding: 0.5rem;
        }

        #markdown-content p:hover {
            border-left: 3px solid var(--accent);
            padding-left: 1rem;
        }

        #markdown-content table {
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
            margin: 0.5rem auto;
        }

        #markdown-content th {
            background: var(--surface);
            border-bottom: 2px solid var(--border);
            color: var(--accent);
            font-family: var(--font-mono);
            text-transform: uppercase;
            font-size: 0.7rem;
            text-align: center;
            padding: 0.4rem;
        }

        #markdown-content td {
            border: 1px solid var(--border);
            padding: 10px;
        }

        #markdown-content th {
            background: var(--surface);
            color: var(--accent);
        }

        /* --- ESTILO BASE PARA LISTAS --- */
        #markdown-content ul,
        #markdown-content ol {
            margin: 1.5rem 0 2rem 2.5rem;
            padding: 0;
            list-style: none;
            /* Quitamos los estilos por defecto */
            position: relative;
        }

        /* Línea vertical de conexión (Efecto de Rama) */
        #markdown-content ol::before {
            content: "";
            position: absolute;
            left: -1.2rem;
            top: 0.5rem;
            bottom: 0.5rem;
            width: 1px;
            background: var(--border);
            opacity: 0.5;
        }

        #markdown-content li {
            margin-bottom: 1rem;
            position: relative;
            line-height: 1.7;
        }

        /* --- LISTAS NO ORDENADAS (UL) --- */
        #markdown-content ul li::before {
            content: ">>";
            /* Marcador tipo consola */
            position: absolute;
            left: -1.8rem;
            font-family: var(--font-mono);
            font-size: 0.65rem;
            color: var(--accent);
            opacity: 0.7;
            top: 0.2rem;
        }

        /* --- LISTAS ORDENADAS (OL) --- */
        #markdown-content ol {
            counter-reset: legal-counter;
            /* Contador personalizado */
        }

        #markdown-content ol li {
            counter-increment: legal-counter;
        }

        #markdown-content ol li::before {
            content: counter(legal-counter, decimal-leading-zero) ".";
            position: absolute;
            left: -2.2rem;
            font-family: var(--font-mono);
            font-size: 0.7rem;
            font-weight: 700;
            color: var(--accent-alt);
            background: var(--surface);
            padding: 0 4px;
            border: 1px solid var(--border);
            border-radius: 2px;
        }

        /* --- LISTAS ANIDADAS (Sub-puntos) --- */
        #markdown-content li ul,
        #markdown-content li ol {
            margin-top: 1rem;
            margin-left: 1.5rem;
            border-left: 1px dashed var(--border);
        }

        /* Efecto Hover: Resalta la "cláusula" activa */
        #markdown-content li:hover {
            color: var(--accent);
            transition: color 0.2s ease;
        }

        #markdown-content li:hover::before {
            opacity: 1;
            transform: scale(1.1);
            transition: all 0.2s ease;
        }

        #theme-toggle {
            position: fixed;
            bottom: 1.5rem;
            right: 1.5rem;
            background: var(--surface);
            border: 1px solid var(--border);
            color: var(--accent);
            padding: 0.5rem 1rem;
            font-family: var(--font-mono);
            font-size: 0.6rem;
            cursor: pointer;
            z-index: 2000;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
        }
    

        /* --- ESTILO PARA ÉNFASIS (EM) --- */

#markdown-content em {
    font-style: normal; /* Evitamos la cursiva estándar para mayor legibilidad */
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent);
    background: rgba(74, 222, 128, 0.1); /* Color de acento con opacidad baja */
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
   
    transition: all 0.2s ease;
}

/* Ajuste de color de fondo según el tema activo para mantener contraste */
[data-theme="bw"] #markdown-content em {
    background: var(--surface);
    
}

[data-theme="amber"] #markdown-content em {
    background: rgba(251, 191, 36, 0.15);
}

/* Efecto al pasar el mouse: "Iluminación" del concepto */
#markdown-content em:hover {
    background: var(--accent);
    color: var(--bg);
    cursor: help; /* Indica que es un término relevante */
}