:root {
            --bg: #0b1220;
            --surface: #0f172a;
            --text: #e5eefc;
            --muted: #9db1d7;
            --primary: #4fbbff;
            --primary-2: #00e8a2;
            --accent: #22c55e;
            --border: rgba(255, 255, 255, .08);
            --shadow-sm: 0 8px 24px rgba(2, 6, 23, .25);
            --shadow-md: 0 18px 44px rgba(2, 6, 23, .35);
            --radius: 16px;
            --radius-lg: 24px;
            --header-h: 74px;
            --container: 1180px;
        }

        :root[data-theme="light"] {
            --bg: #f6f7fb;
            --surface: #ffffff;
            --text: #0b1220;
            --muted: #4b5563;
            --primary: #0a84ff;
            --primary-2: #21c7a8;
            --accent: #0ea764;
            --border: rgba(2, 6, 23, .08);
            --shadow-sm: 0 6px 16px rgba(2, 6, 23, .08);
            --shadow-md: 0 20px 60px rgba(2, 6, 23, .12);
        }

        @media (prefers-color-scheme: light) {
            :root {
                --bg: #f6f7fb;
                --surface: #ffffff;
                --text: #0b1220;
                --muted: #4b5563;
                --primary: #0a84ff;
                --primary-2: #21c7a8;
                --accent: #0ea764;
                --border: rgba(2, 6, 23, .08);
                --shadow-sm: 0 6px 16px rgba(2, 6, 23, .08);
                --shadow-md: 0 20px 60px rgba(2, 6, 23, .12);
            }
        }

        * {
            box-sizing: border-box;
        }

        html,
        body {
            height: 100%;
        }

        body {
            margin: 0;
            font-family: Manrope, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
            color: var(--text);
            background-color: var(--bg);
            background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 2px, transparent 2px, transparent 40px), repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 2px, transparent 2px, transparent 40px);
            line-height: 1.65;
            scroll-behavior: smooth;
            padding-top: var(--header-h);
        }

        .container {
            max-width: var(--container);
            margin: 0 auto;
            padding: 0 clamp(16px, 4vw, 28px);
        }

        /* Header pegajoso con glass */
        header {
            position: fixed;
            inset: 0 0 auto 0;
            z-index: 1000;
            height: var(--header-h);
            background: color-mix(in srgb, var(--surface) 78%, transparent);
            backdrop-filter: saturate(150%) blur(12px);
            -webkit-backdrop-filter: saturate(150%) blur(12px);
            border-bottom: 1px solid var(--border);
        }

        .nav {
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
        }

        .brand {
            display: inline-flex;
            align-items: center;
            gap: 12px;
            text-decoration: none;
            color: var(--text);
        }

        .logo {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            flex: 0 0 auto;
            background: conic-gradient(from 180deg, var(--primary), var(--primary-2), var(--primary));
            box-shadow: inset 0 0 0 1px var(--border), 0 10px 24px rgba(0, 0, 0, .25);
        }

        .brand span {
            font-weight: 900;
            letter-spacing: .3px;
            font-size: clamp(18px, 1.8vw, 22px);
        }

        nav ul {
            list-style: none;
            display: flex;
            gap: clamp(14px, 2.2vw, 28px);
            margin: 0;
            padding: 0;
        }

        nav a {
            color: var(--text);
            text-decoration: none;
            font-weight: 700;
            padding: 8px 2px;
            position: relative;
        }

        nav a::after {
            content: "";
            position: absolute;
            left: 0;
            bottom: 0;
            width: 0;
            height: 2px;
            background: var(--primary);
            border-radius: 2px;
            transition: width .25s ease;
        }

        nav a:hover::after,
        nav a:focus-visible::after {
            width: 100%;
        }

        .menu-toggle {
            display: none;
            border: 1px solid var(--border);
            background: color-mix(in srgb, var(--surface) 80%, transparent);
            color: var(--text);
            padding: 10px 12px;
            border-radius: 12px;
            cursor: pointer;
        }

        @media (max-width: 900px) {
            nav ul {
                display: none;
            }

            .menu-toggle {
                display: inline-flex;
                align-items: center;
                gap: 8px;
            }
        }

        .sheet {
            display: none;
            position: fixed;
            top: var(--header-h);
            left: 0;
            right: 0;
            background: color-mix(in srgb, var(--surface) 95%, transparent);
            border-bottom: 1px solid var(--border);
            box-shadow: var(--shadow-sm);
            z-index: 999;
        }

        .sheet nav {
            display: grid;
            gap: 2px;
            padding: 10px;
        }

        .sheet a {
            padding: 12px 16px;
            border-radius: 12px;
            color: var(--text);
            text-decoration: none;
        }

        .sheet a:hover {
            background: color-mix(in srgb, var(--surface) 92%, transparent);
        }

        /* Hero */
        #hero {
            padding: clamp(56px, 9vw, 120px) 0 clamp(36px, 7vw, 80px);
            position: relative;
        }

        .hero-wrap {
            display: grid;
            grid-template-columns: 1.1fr .9fr;
            gap: clamp(18px, 3vw, 28px);
            align-items: center;
        }

        @media (max-width: 980px) {
            .hero-wrap {
                grid-template-columns: 1fr;
            }
        }

        .title {
            font-size: clamp(30px, 5.6vw, 60px);
            line-height: 1.08;
            margin: 0 0 12px;
            font-weight: 900;
        }

        .grad {
            background: linear-gradient(90deg, var(--primary), var(--primary-2));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }

        .lead {
            color: var(--muted);
            font-size: clamp(16px, 2vw, 20px);
            max-width: 64ch;
        }

        .cta {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
            margin-top: 22px;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            font-weight: 800;
            letter-spacing: .2px;
            border: 0;
            cursor: pointer;
            text-decoration: none;
            padding: 14px 18px;
            border-radius: 14px;
            box-shadow: var(--shadow-sm);
        }

        .btn.primary {
            background: linear-gradient(90deg, var(--accent), #1ea55b);
            color: #041016;
        }

        .btn.ghost {
            background: transparent;
            color: var(--text);
            border: 1px solid var(--border);
        }

        .btn:hover {
            box-shadow: var(--shadow-md);
            transform: translateY(-2px);
        }

        .panel {
            background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 94%, transparent), color-mix(in srgb, var(--surface) 90%, transparent));
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: clamp(16px, 2.5vw, 22px);
            box-shadow: var(--shadow-sm);
        }

        .code {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            font-size: 13.5px;
            line-height: 1.45;
            background: #0c162d;
            color: #d6e2ff;
            border-radius: 14px;
            padding: 18px;
            border: 1px solid #233554;
            position: relative;
            overflow: auto;
        }

        .dots {
            position: absolute;
            top: 8px;
            left: 10px;
            display: flex;
            gap: 6px;
        }

        .dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
        }

        .red {
            background: #ff5f56
        }

        .yellow {
            background: #ffbd2e
        }

        .green {
            background: #27c93f
        }

        section {
            padding: clamp(44px, 8vw, 88px) 0;
        }

        .section-title {
            text-align: center;
            margin-bottom: clamp(22px, 4vw, 38px);
        }

        .section-title h2 {
            margin: 0;
            font-size: clamp(24px, 3.2vw, 36px);
            font-weight: 900;
            color: var(--primary);
        }

        .section-title p {
            color: var(--muted);
            max-width: 70ch;
            margin: 8px auto 0;
        }

        .grid {
            display: grid;
            gap: clamp(14px, 2.4vw, 22px);
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }

        @media (max-width: 980px) {
            .grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        @media (max-width: 700px) {
            .grid {
                grid-template-columns: 1fr;
            }
        }

        .card {
            background: color-mix(in srgb, var(--surface) 92%, transparent);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: clamp(18px, 2.2vw, 24px);
            box-shadow: var(--shadow-sm);
            transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
        }

        .card:hover {
            transform: translateY(-6px);
            box-shadow: var(--shadow-md);
            border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
        }

        .icon {
            font-size: clamp(28px, 4vw, 40px);
            color: var(--primary);
        }

        /* Contacto */
        #contacto .content {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: clamp(18px, 3vw, 32px);
        }

        @media (max-width: 980px) {
            #contacto .content {
                grid-template-columns: 1fr;
            }
        }

        label {
            font-weight: 800;
            letter-spacing: .2px;
        }

        input[type="text"],
        input[type="email"],
        textarea {
            width: 100%;
            color: var(--text);
            background: color-mix(in srgb, var(--surface) 94%, transparent);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 12px 14px;
            font: inherit;
            transition: border-color .25s ease, box-shadow .25s ease;
        }

        input:focus,
        textarea:focus {
            outline: none;
            border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
            box-shadow: var(--ring);
        }

        footer {
            padding: 34px 0 60px;
            color: var(--muted);
            text-align: center;
            border-top: 1px solid var(--border);
        }

        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }

        /* Stack */
        #stack .section-title h2 {
            color: var(--primary);
        }

        .stack-grid {
            display: grid;
            gap: clamp(14px, 2.4vw, 22px);
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }

        @media (max-width: 980px) {
            .stack-grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        @media (max-width: 700px) {
            .stack-grid {
                grid-template-columns: 1fr;
            }
        }

        #stack .card {
            padding-top: 20px;
        }

        #stack h3 {
            margin: 0 0 10px;
            font-weight: 900;
            color: var(--text);
        }

        .chips {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: 8px;
        }

        .chip {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            border-radius: 999px;
            background: color-mix(in srgb, var(--surface) 92%, transparent);
            border: 1px solid var(--border);
            color: var(--text);
            font-weight: 700;
            font-size: 0.95rem;
            transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
        }

        .chip i {
            opacity: .9;
        }

        .chip:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-sm);
            border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
        }

        .logo-img {
            height: 40px;
            width: auto;
            display: block;
            filter: brightness(0) invert(1) opacity(0.9);
            /* aclara el logo sobre fondo oscuro */
            transition: filter .3s ease, transform .3s ease;
        }

        header:hover .logo-img {
            filter: brightness(1) invert(0.9);
            transform: scale(1.03);
        }

        @media (prefers-color-scheme: light) {
            .logo-img {
                filter: none;
                /* en modo claro, deja los colores originales */
            }
        }

        .mode-btn {
            background: color-mix(in srgb, var(--surface) 80%, transparent);
            border: 1px solid var(--border);
            color: var(--text);
            border-radius: 12px;
            cursor: pointer;
            font-size: 18px;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all .3s ease;
        }

        .mode-btn:hover {
            background: color-mix(in srgb, var(--surface) 92%, transparent);
            transform: rotate(-10deg);
        }

        /* ---------- Transición suave al cambiar claro/oscuro ---------- */
        /* Aplica a los elementos clave de tu layout */
        :root,
        body,
        header,
        footer,
        .card,
        .panel,
        .section,
        .sheet,
        .mode-btn,
        .btn,
        .chip,
        .code,
        .logo-img,
        nav ul li a,
        input[type="text"],
        input[type="email"],
        textarea {
            transition:
                background-color .35s ease,
                color .35s ease,
                border-color .35s ease,
                box-shadow .35s ease,
                filter .35s ease;
        }

        /* Extra: cuando forzamos la transición con una clase (ver JS) */
        :root.theme-transition *,
        :root.theme-transition {
            transition:
                background-color .35s ease,
                color .35s ease,
                border-color .35s ease,
                box-shadow .35s ease,
                filter .35s ease !important;
        }

        /* Accesibilidad: si el usuario pide menos animación, no animamos */
        @media (prefers-reduced-motion: reduce) {

            :root,
            body,
            header,
            footer,
            .card,
            .panel,
            .section,
            .sheet,
            .mode-btn,
            .btn,
            .chip,
            .code,
            .logo-img,
            nav ul li a,
            input[type="text"],
            input[type="email"],
            textarea,
            :root.theme-transition,
            :root.theme-transition * {
                transition: none !important;
            }
        }

        /* ====== Fade cinematográfico en cambio de tema ====== */
        @keyframes themeFade {
            from {
                opacity: .72;
                filter: saturate(.9) blur(0.2px);
            }

            to {
                opacity: 1;
                filter: none;
            }
        }

        /* Aplica el fade a hero, paneles y cards cuando :root tiene la clase de transición */
        :root.theme-transition #hero,
        :root.theme-transition .panel,
        :root.theme-transition .card {
            will-change: opacity, filter;
            backface-visibility: hidden;
            animation: themeFade .35s ease both;
        }

        /* (Opcional) Pequeño “stagger” en grids para un efecto aún más suave */
        :root.theme-transition .grid .card:nth-child(1) {
            animation-delay: 0ms;
        }

        :root.theme-transition .grid .card:nth-child(2) {
            animation-delay: 50ms;
        }

        :root.theme-transition .grid .card:nth-child(3) {
            animation-delay: 90ms;
        }

        :root.theme-transition .grid .card:nth-child(4) {
            animation-delay: 120ms;
        }

        :root.theme-transition .grid .card:nth-child(5) {
            animation-delay: 150ms;
        }

        :root.theme-transition .grid .card:nth-child(6) {
            animation-delay: 180ms;
        }

        /* Respeta la accesibilidad: sin animaciones si el usuario lo pide */
        @media (prefers-reduced-motion: reduce) {

            :root.theme-transition #hero,
            :root.theme-transition .panel,
            :root.theme-transition .card {
                animation: none !important;
            }
        }