@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #2a3554 var(--inst-ink);
}

body {
    margin: 0;
    padding-top: var(--nav-h);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-base);
    color: var(--text-primary);
    background: var(--bg);
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, li {
    overflow-wrap: break-word;
}

img {
    max-width: 100%;
    height: auto;
}

::selection {
    background: rgba(91, 124, 255, 0.35);
    color: #fff;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--inst-ink);
}

::-webkit-scrollbar-thumb {
    background: #232c4a;
    border: 2px solid var(--inst-ink);
    border-radius: var(--radius-pill);
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--inst-blue-600);
    }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

a:focus-visible, button:focus-visible {
    border-radius: 4px;
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1003;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 16px var(--section-pad-x);
    background: var(--bg);
    border-bottom: 1px solid #222;
    transition: background 0.25s ease, border-color 0.25s ease;
}

    .navbar.scrolled {
        background: rgba(11, 15, 26, 0.85);
        backdrop-filter: blur(10px);
        border-bottom-color: #333;
    }

.logo {
    font-weight: 700;
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
}

.logo a {
    text-decoration: none;
    color: var(--text-primary);
}

.logo-mark {
    display: block;
    height: 36px;
    width: auto;
}

html:not([data-theme="light"]) .logo-mark--light,
html[data-theme="light"] .logo-mark--dark {
    display: none;
}

.navbar nav {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

    .navbar nav .nav-link {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin: 0;
        padding: 8px 12px;
        border: 0;
        background: transparent;
        white-space: nowrap;
        text-decoration: none;
        font-family: inherit;
        font-size: var(--text-sm);
        font-weight: 500;
        line-height: 1.3;
        color: var(--text-muted);
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: color 0.2s ease, background 0.2s ease;
    }

        .navbar nav .nav-link:hover,
        .nav-item.is-open > .nav-trigger {
            color: var(--text-primary);
            background: rgba(255, 255, 255, 0.04);
        }

        .navbar nav .nav-link.is-current {
            color: var(--text-primary);
            background: rgba(91, 124, 255, 0.1);
            box-shadow: inset 0 -2px 0 var(--brand);
        }

.nav-item {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-item--wide {
    position: static;
}

.nav-caret {
    width: 13px;
    height: 13px;
    flex: none;
    color: var(--text-faint);
    transition: transform 0.2s var(--ease-out), color 0.2s ease;
}

.nav-item.is-open > .nav-trigger .nav-caret {
    transform: rotate(180deg);
    color: var(--brand);
}

.nav-panel {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    z-index: 1004;
    background: var(--bg-panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}

    .nav-panel::before {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: -14px;
        height: 14px;
    }

    .nav-panel[hidden] {
        display: none;
    }

.nav-item.is-open > .nav-panel {
    opacity: 1;
    transform: none;
}

.nav-panel--compact {
    width: 320px;
}

.nav-panel--grid {
    left: auto;
    right: 0;
    width: min(620px, calc(100vw - 48px));
}

.nav-panel-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.nav-panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    padding: 0;
    counter-reset: nav-grid;
}

.nav-entry {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 15px 18px;
    border-radius: 0;
    text-decoration: none;
    transition: background var(--dur-1) ease, box-shadow var(--dur-1) ease;
}

.nav-panel-list .nav-entry + .nav-entry {
    border-top: 1px solid var(--line);
}

.nav-panel-list .nav-entry:first-child {
    border-top-left-radius: calc(var(--radius-md) - 1px);
    border-top-right-radius: calc(var(--radius-md) - 1px);
}

.nav-panel-list:last-child .nav-entry:last-child {
    border-bottom-left-radius: calc(var(--radius-md) - 1px);
    border-bottom-right-radius: calc(var(--radius-md) - 1px);
}

.nav-panel-grid .nav-entry {
    counter-increment: nav-grid;
    padding: 20px 36px 20px 22px;
}

    .nav-panel-grid .nav-entry:nth-child(odd) {
        border-right: 1px solid var(--line);
    }

    .nav-panel-grid .nav-entry:nth-child(n + 3) {
        border-top: 1px solid var(--line);
    }

    .nav-panel-grid .nav-entry:first-child {
        border-top-left-radius: calc(var(--radius-md) - 1px);
    }

    .nav-panel-grid .nav-entry:nth-child(2) {
        border-top-right-radius: calc(var(--radius-md) - 1px);
    }

.nav-panel-grid:last-child .nav-entry:nth-last-child(2):nth-child(odd) {
    border-bottom-left-radius: calc(var(--radius-md) - 1px);
}

.nav-panel-grid:last-child .nav-entry:last-child {
    border-bottom-right-radius: calc(var(--radius-md) - 1px);
}

.nav-panel-grid .nav-entry::after {
    content: '\2192';
    position: absolute;
    top: 18px;
    right: 18px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1;
    color: var(--text-faint);
    opacity: 0.35;
    transform: translateX(-2px);
    transition: opacity var(--dur-1) ease, color var(--dur-1) ease, transform var(--dur-1) var(--ease-out);
}

.nav-entry:hover {
    background: rgba(255, 255, 255, 0.03);
}

.nav-entry:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
    z-index: 1;
}

.nav-entry.is-active {
    background: var(--brand-soft);
    box-shadow: inset 2px 0 0 var(--brand);
}

.nav-panel-grid .nav-entry:hover::after,
.nav-panel-grid .nav-entry:focus-visible::after,
.nav-panel-grid .nav-entry.is-active::after {
    opacity: 1;
    color: var(--brand-bright);
    transform: translateX(0);
}

.nav-entry-head {
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 5px;
}

.nav-entry-title {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    transition: color var(--dur-1) ease;
}

.nav-entry:hover .nav-entry-title,
.nav-entry.is-active .nav-entry-title {
    color: var(--brand-bright);
}

.nav-entry-tag {
    flex: none;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    transition: color var(--dur-1) ease;
}

.nav-panel-grid .nav-entry-tag::before {
    content: counter(nav-grid, decimal-leading-zero) ' \00b7  ';
    color: var(--brand);
}

.nav-entry:hover .nav-entry-tag,
.nav-entry.is-active .nav-entry-tag {
    color: var(--text-muted);
}

.nav-entry-desc {
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.nav-panel-foot {
    padding: 0;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px);
}

.nav-foot-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 22px;
    border-radius: 0 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--dur-1) ease, background var(--dur-1) ease;
}

    .nav-foot-link:hover {
        color: var(--brand-bright);
        background: rgba(255, 255, 255, 0.03);
    }

    .nav-foot-link:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: -2px;
    }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: none;
    margin-left: 6px;
    padding: 6px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

    .theme-toggle:hover {
        color: var(--text-primary);
    }

        .theme-toggle:hover .theme-toggle__track {
            background: var(--overlay);
        }

.theme-toggle__track {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    flex: none;
    width: 58px;
    height: 30px;
    padding: 0 7px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    transition: background 0.2s ease;
}

.theme-toggle__icon {
    position: relative;
    z-index: 1;
    width: 15px;
    height: 15px;
    color: var(--text-faint);
    transition: color 0.25s ease;
}

.theme-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--grad-brand);
    box-shadow: 0 2px 8px rgba(91, 124, 255, 0.35);
    transform: translateX(28px);
    transition: transform 0.3s var(--ease-out);
}

.theme-toggle__icon--moon {
    color: #fff;
}

.theme-toggle__state {
    display: none;
    color: var(--text-primary);
}

.burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    z-index: 1001;
    padding: 8px;
}

    .burger span {
        width: 25px;
        height: 3px;
        background: var(--text-primary);
        border-radius: 2px;
        transition: 0.3s;
    }

    .burger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 6px);
    }

    .burger.active span:nth-child(2) {
        opacity: 0;
    }

    .burger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -7px);
    }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    z-index: 1000;
}

    .overlay.active {
        opacity: 1;
        pointer-events: all;
    }

.primary, .secondary {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.primary {
    border: none;
    background: linear-gradient(135deg, #5b7cff 0%, #7a94ff 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(91, 124, 255, 0.25);
}

    .primary::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.5s ease;
    }

    .primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 26px rgba(91, 124, 255, 0.38);
    }

        .primary:hover::before {
            left: 100%;
        }

    .primary:active {
        transform: translateY(-1px);
    }

.secondary {
    background: transparent;
    border: 1px solid rgba(91, 124, 255, 0.6);
    color: #fff;
}

    .secondary:hover {
        transform: translateY(-2px);
        border-color: var(--brand);
        background: rgba(91, 124, 255, 0.1);
    }

    .primary span, .secondary span {
        position: relative;
        z-index: 1;
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .primary svg, .secondary svg {
        width: 18px;
        height: 18px;
        transition: transform 0.3s ease;
    }

    .primary:hover svg, .secondary:hover svg {
        transform: translateX(4px);
    }

html[data-theme="light"] {
    scrollbar-color: #cbd5e1 #f4f6fa;
}

[data-theme="light"] ::selection {
    background: rgba(91, 124, 255, 0.2);
    color: #0f172a;
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: var(--bg);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-color: var(--bg);
}

    [data-theme="light"] ::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

[data-theme="light"] .navbar {
    border-bottom-color: var(--line);
}

    [data-theme="light"] .navbar.scrolled {
        background: rgba(255, 255, 255, 0.85);
        border-bottom-color: var(--line);
    }

    [data-theme="light"] .navbar nav .nav-link:hover,
    [data-theme="light"] .nav-item.is-open > .nav-trigger {
        background: rgba(15, 23, 42, 0.04);
    }

[data-theme="light"] .nav-panel-grid .nav-entry-tag::before {
    color: var(--brand-bright);
}

[data-theme="light"] .nav-entry:hover {
    background: rgba(15, 23, 42, 0.03);
}

[data-theme="light"] .nav-panel-foot {
    background: var(--surface);
}

[data-theme="light"] .nav-foot-link:hover {
    background: rgba(15, 23, 42, 0.045);
}

[data-theme="light"] .navbar nav .nav-link {
    border-bottom-color: var(--line);
}

[data-theme="light"] .theme-toggle__thumb {
    transform: translateX(0);
}

[data-theme="light"] .theme-toggle__icon--sun {
    color: #fff;
}

[data-theme="light"] .theme-toggle__icon--moon {
    color: var(--text-faint);
}

[data-theme="light"] .overlay {
    background: rgba(15, 23, 42, 0.3);
}

[data-theme="light"] .primary {
    box-shadow: 0 4px 14px rgba(91, 124, 255, 0.18);
}

[data-theme="light"] .secondary {
    border-color: rgba(91, 124, 255, 0.4);
    color: var(--text-primary);
}

    [data-theme="light"] .secondary:hover {
        background: rgba(91, 124, 255, 0.08);
    }

@media (max-width: 900px) {
    .navbar {
        padding: 12px 20px;
    }

    .burger {
        display: flex;
    }

    .logo-mark {
        height: 30px;
    }

    .navbar nav {
        position: fixed;
        top: 0;
        right: -100%;
        height: 100vh;
        height: 100dvh;
        width: min(320px, 86vw);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding-top: 96px;
        background: var(--bg);
        border-left: 1px solid var(--line);
        transition: right 0.3s ease;
        z-index: 1002;
        overflow-y: auto;
    }

        .navbar nav.active {
            right: 0;
        }

    .nav-item,
    .nav-item--wide {
        position: static;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .navbar nav .nav-link {
        justify-content: space-between;
        width: 100%;
        padding: 16px 24px;
        font-size: var(--text-base);
        border-bottom: 1px solid #1c2338;
        border-radius: 0;
    }

        .navbar nav .nav-link.is-current {
            box-shadow: inset 2px 0 0 var(--brand);
        }

    .nav-panel,
    .nav-panel--compact,
    .nav-panel--grid {
        position: static;
        width: 100%;
        border: 0;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        background: var(--bg-panel);
        box-shadow: none;
        opacity: 1;
        transform: none;
    }

        .nav-panel::before {
            display: none;
        }

    .nav-panel-list,
    .nav-panel-grid {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
    }

        .nav-panel-list .nav-entry,
        .nav-panel-grid .nav-entry {
            padding: 14px 24px 14px 30px;
            border-right: 0;
            border-top: 0;
            border-radius: 0;
        }

            .nav-panel-list .nav-entry + .nav-entry,
            .nav-panel-grid .nav-entry + .nav-entry {
                border-top: 1px solid var(--line);
            }

            .nav-panel-grid .nav-entry::after {
                display: none;
            }

    .nav-entry-desc {
        font-size: 0.76rem;
    }

    .nav-panel-foot {
        border-radius: 0;
    }

    .nav-foot-link {
        padding: 13px 24px 13px 30px;
        border-radius: 0;
    }

    .theme-toggle {
        width: 100%;
        flex-direction: row-reverse;
        justify-content: space-between;
        margin: 16px 0 0;
        padding: 16px 24px;
        border-radius: 0;
    }

    .theme-toggle__state {
        display: block;
    }
}

@media (max-width: 768px) {
    .primary, .secondary {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .primary, .secondary, .navbar, .burger span, .overlay, .navbar nav,
    .nav-link, .nav-caret, .nav-panel, .nav-entry, .nav-entry-title, .nav-entry-tag,
    .nav-panel-grid .nav-entry::after, .nav-foot-link {
        transition: none !important;
    }

    .nav-panel-grid .nav-entry::after {
        transform: none !important;
    }

    .theme-toggle, .theme-toggle__track, .theme-toggle__thumb, .theme-toggle__icon {
        transition: none !important;
    }

    .primary::before {
        display: none;
    }

    .primary:hover, .secondary:hover {
        transform: none;
    }
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: var(--dur-3);
    animation-timing-function: var(--ease-in-out);
}

html.theme-fade,
html.theme-fade *,
html.theme-fade *::before,
html.theme-fade *::after {
    transition: background-color var(--dur-3) var(--ease-in-out), color var(--dur-3) var(--ease-in-out), border-color var(--dur-3) var(--ease-in-out), fill var(--dur-3) var(--ease-in-out), stroke var(--dur-3) var(--ease-in-out), box-shadow var(--dur-3) var(--ease-in-out) !important;
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none !important;
    }

    html.theme-fade,
    html.theme-fade *,
    html.theme-fade *::before,
    html.theme-fade *::after {
        transition: none !important;
    }
}
