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

html {
    scroll-padding-top: 90px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: clip;
    max-width: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    font-weight: 400;
    line-height: 1.65;
    letter-spacing: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: clip;
    width: 100%;
    max-width: 100vw;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color var(--dur-slow) var(--ease-out), color var(--dur-slow) var(--ease-out);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
}

[data-theme="dark"] body::before { opacity: 0.35; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-tight);
    color: var(--text-primary);
}

p { line-height: var(--lh-relaxed); }

a { color: inherit; text-decoration: none; }

img, svg, video { max-width: 100%; height: auto; display: block; }

button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

::selection {
    background: var(--accent);
    color: var(--accent-ink);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 0;
}

:focus { outline: none; }
:focus-visible {
    outline: var(--nb-border-w) solid var(--accent-symbol);
    outline-offset: 3px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 5%;
}

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.about,
.stack,
.contact {
    border-top: var(--nb-border-w) solid var(--nb-border);
}

.cursor-dot,
.cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 99999;
    border-radius: 50%;
    opacity: 0;
    will-change: translate, width, height, opacity, transform;
}

.cursor-dot {
    width: 6px;
    height: 6px;
    background-color: var(--cursor-color);
    margin-left: -3px;
    margin-top: -3px;
    box-shadow: var(--cursor-glow);
    transition:
        opacity 0.25s ease,
        width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        height 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        margin 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        background-color 0.3s ease,
        box-shadow 0.3s ease,
        transform 0.2s ease;
}

.cursor-ring {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--cursor-color);
    margin-left: -17px;
    margin-top: -17px;
    transition:
        opacity 0.3s ease,
        width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        margin 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        border-color 0.3s ease,
        border-width 0.25s ease,
        background-color 0.3s ease,
        box-shadow 0.3s ease,
        transform 0.2s ease;
}

.cursor-dot.is-visible,
.cursor-ring.is-visible {
    opacity: 1;
}

.cursor-dot.is-visible {
    transform: scale(1);
}

.cursor-ring.is-visible {
    transform: scale(1);
}

.cursor-dot.is-clicking {
    transform: scale(0.5);
}

.cursor-ring.is-clicking {
    transform: scale(0.7);
}

.cursor-dot.is-link {
    opacity: 1;
    transform: scale(1);
    width: 6px;
    height: 6px;
    margin-left: -3px;
    margin-top: -3px;
    background-color: var(--cursor-color);
    box-shadow: none;
}

.cursor-ring.is-link {
    width: 52px;
    height: 52px;
    margin-left: -26px;
    margin-top: -26px;
    background-color: transparent;
    border-color: var(--cursor-color);
    border-width: 2px;
}

[data-theme="dark"] .cursor-ring.is-link {
    box-shadow: 0 0 14px rgba(245, 239, 227, 0.18);
}

.cursor-dot.is-card {
    width: 4px;
    height: 4px;
    margin-left: -2px;
    margin-top: -2px;
    background-color: var(--accent-symbol);
    box-shadow: none;
}

.cursor-ring.is-card {
    width: 64px;
    height: 64px;
    margin-left: -32px;
    margin-top: -32px;
    border: 1.5px dashed var(--accent-symbol);
    animation: cursorSpin 10s linear infinite;
}

[data-theme="dark"] .cursor-ring.is-card {
    box-shadow: 0 0 20px rgba(251, 146, 60, 0.25);
}

@keyframes cursorSpin {
    from { rotate: 0deg; }
    to { rotate: 360deg; }
}

.cursor-dot.is-text {
    width: 2px;
    height: 22px;
    margin-left: -1px;
    margin-top: -11px;
    border-radius: 1px;
    background-color: var(--cursor-color);
    box-shadow: none;
    animation: cursorBlink 1s step-end infinite;
}

.cursor-ring.is-text {
    opacity: 0;
    transform: scale(0);
}

@keyframes cursorBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.cursor-dot.is-image {
    width: 4px;
    height: 4px;
    margin-left: -2px;
    margin-top: -2px;
    background-color: var(--accent-symbol);
    box-shadow: none;
}

.cursor-ring.is-image {
    width: 72px;
    height: 72px;
    margin-left: -36px;
    margin-top: -36px;
    border-color: var(--accent-symbol);
    border-width: 2px;
}

[data-theme="dark"] .cursor-ring.is-image {
    box-shadow: 0 0 20px rgba(251, 146, 60, 0.3);
}

@media (hover: none), (pointer: coarse) {
    .cursor-dot,
    .cursor-ring {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cursor-dot,
    .cursor-ring {
        display: none !important;
    }
}

body.has-custom-cursor,
body.has-custom-cursor * {
    cursor: none !important;
}