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

:root {
    --font-sans: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Rethink Sans", "Noto Sans", sans-serif;

    --color-bg: #fcfbf8;
    --color-surface: #ffffff;
    --color-text: #171717;
    --color-text-secondary: #4b4b4b;
    --color-heading: #111111;
    --color-border: #d8d3c9;
    --color-border-strong: #b8afa0;
    --color-switcher-border: #d8d3c9;
    --color-switcher-selected: #ffffff;
    --color-switcher-selected-text: #111111;
    --color-focus: #1d4ed8;
    --color-toggle: #525252;
    --shadow-card: 0 12px 30px rgba(17, 17, 17, 0.05);
    --shadow-card-hover: 0 16px 36px rgba(17, 17, 17, 0.08);

    --radius-card: 14px;
    --radius-pill: 999px;

    --font-size-body: 1.125rem;
    --font-size-small: 1rem;
    --font-size-subtitle: 1rem;
    --font-size-heading: 1.5rem;
    --font-size-title: clamp(2.4rem, 5vw, 3.5rem);

    --line-height-body: 1.5;
    --line-height-tight: 1.15;

    --space-2xs: 0.5rem;
    --space-xs: 0.75rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4rem;

    --measure-prose: 64ch;
    --layout-max-width: 68rem;

    color-scheme: light;
}

:root.dark-mode {
    --color-bg: #111111;
    --color-surface: #1b1b1b;
    --color-text: #f4f1eb;
    --color-text-secondary: #ddd7ce;
    --color-heading: #ffffff;
    --color-border: #3b3832;
    --color-border-strong: #5a554d;
    --color-switcher-border: #5a554d;
    --color-switcher-selected: #ffffff;
    --color-switcher-selected-text: #111111;
    --color-focus: #93c5fd;
    --color-toggle: #d9d4cc;
    --shadow-card: 0 12px 30px rgba(0, 0, 0, 0.28);
    --shadow-card-hover: 0 16px 36px rgba(0, 0, 0, 0.36);

    color-scheme: dark;
}

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    color: var(--color-text);
    background-color: var(--color-bg);
    background-image: radial-gradient(circle at top, rgba(186, 176, 152, 0.12), transparent 28rem);
    background-repeat: no-repeat;
}

:root.dark-mode body {
    background-image: none;
}

:root.animations-enabled body {
    transition: background-color 0.3s ease, color 0.3s ease, background-image 0.3s ease;
}

:root.animations-enabled *,
:root.animations-enabled *::before,
:root.animations-enabled *::after {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

a {
    color: inherit;
}

.container {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: 4.5rem 1.5rem 5rem;
}

.page-shell {
    display: flex;
    flex-direction: column;
}

.readable-prose {
    max-width: var(--measure-prose);
}

.preferences-panel {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-xl);
    width: 100%;
    max-width: none;
    align-self: stretch;
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.preference-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.theme-heading {
    color: var(--color-heading);
    font-size: var(--font-size-small);
    line-height: var(--line-height-body);
    font-weight: 600;
}

.theme-toggle-control {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.theme-label,
.animations-label {
    color: var(--color-text-secondary);
    font-size: var(--font-size-small);
    line-height: var(--line-height-body);
    margin: 0;
    min-width: 3.5rem;
    text-align: left;
}

.theme-toggle {
    position: relative;
    display: block;
    width: 56px;
    height: 32px;
}

.theme-toggle input {
    opacity: 0;
    width: 56px;
    height: 32px;
    position: absolute;
    z-index: 2;
    cursor: pointer;
    margin: 0;
}

.slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 56px;
    height: 32px;
    background-color: #d7d2ca;
    border-radius: var(--radius-pill);
    display: block;
    z-index: 1;
    box-shadow: inset 0 0 0 1px var(--color-border-strong);
}

:root.animations-enabled .slider,
:root.animations-enabled .slider::before {
    transition: transform 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.slider::before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: #ffffff;
    border-radius: 50%;
    display: block;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.theme-toggle input:checked + .slider {
    background-color: var(--color-toggle);
    box-shadow: inset 0 0 0 1px var(--color-border-strong);
}

.theme-toggle input:checked + .slider::before {
    transform: translateX(24px);
}

.theme-toggle input:focus-visible + .slider {
    outline: 3px solid var(--color-focus);
    outline-offset: 3px;
}

.intro {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    text-align: center;
    margin-bottom: 2.35rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.intro-copy {
    margin: 0 auto;
    display: grid;
    justify-items: stretch;
    text-align: center;
    width: fit-content;
    max-width: 100%;
}

.intro-copy h1 {
    font-family: var(--font-display);
    font-size: var(--font-size-title);
    font-weight: 500;
    line-height: var(--line-height-tight);
    letter-spacing: -0.03em;
    color: var(--color-heading);
    margin-bottom: 0;
}

.contact-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    width: 100%;
    gap: 0;
    list-style: none;
    margin-top: 0.18rem;
    padding: 0;
}

.contact-links li {
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    line-height: 0;
    color: var(--color-heading);
    text-decoration: none;
}

iconify-icon {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
}

:root.animations-enabled .contact-link {
    transition: transform 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}

:root.animations-enabled .contact-link:hover {
    transform: translateY(-2px);
    opacity: 0.72;
}

.contact-link:hover {
    opacity: 0.72;
}

.contact-link:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 4px;
}

.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;
}

.view-switcher {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    align-self: center;
    margin-top: 0.625rem;
    padding: 0.35rem;
    border: 1px solid var(--color-switcher-border);
    border-radius: var(--radius-pill);
    background-color: transparent;
}

.view-tab {
    appearance: none;
    border: 0;
    background: transparent;
    border-radius: var(--radius-pill);
    padding: 0.65rem 1rem;
    font: inherit;
    font-size: var(--font-size-small);
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-text-secondary);
    cursor: pointer;
}

:root.animations-enabled .view-tab {
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.view-tab[aria-selected="true"] {
    color: var(--color-switcher-selected-text);
    background-color: var(--color-switcher-selected);
    box-shadow: var(--shadow-card);
}

.view-tab:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 3px;
}

.content-panel {
    width: 100%;
}

:root.animations-enabled .content-panel {
    transform-origin: top center;
}

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

:root.animations-enabled .content-panel.is-entering {
    animation: panel-drop 0.28s ease both;
}

.about-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
    margin: 0;
}

.about-panel h2 {
    font-size: var(--font-size-heading);
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-heading);
}

.about-panel p {
    color: var(--color-text);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    max-width: none;
    text-wrap: pretty;
}

.portfolio-panel {
    display: grid;
    gap: 0;
}

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

.projects,
.research,
.writings,
.resume {
    margin-top: 2rem;
}

.portfolio-panel > section:first-child {
    margin-top: 0;
}

.projects h2,
.research h2,
.writings h2,
.resume h2 {
    font-size: var(--font-size-heading);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--space-xs);
    color: var(--color-heading);
}

.tree-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-list--nested {
    grid-column: 2 / 4;
    margin-top: calc(var(--space-2xs) * 0.75);
    padding-left: 0.575rem;
}

.tree-item {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) auto;
    align-items: start;
    column-gap: var(--space-xs);
    margin-top: var(--space-xs);
    font-size: var(--font-size-small);
    line-height: var(--line-height-body);
}

.tree-item--branch {
    margin-bottom: 0;
}

.tree-list--nested .tree-item {
    margin-top: calc(var(--space-xs) * 0.75);
}

.tree-prefix {
    color: var(--color-text-secondary);
    font-family: ui-monospace, "SFMono-Regular", "SF Mono", Consolas, monospace;
    white-space: pre;
}

.tree-label {
    color: var(--color-text);
    font-weight: 500;
}

.tree-meta {
    justify-self: end;
    color: var(--color-text);
    opacity: 0.4;
    white-space: nowrap;
}

.tree-link {
    color: var(--color-text);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.16em;
    overflow-wrap: anywhere;
}

:root.animations-enabled .tree-link {
    transition: color 0.2s ease;
}

.tree-link:visited {
    color: var(--color-text);
}

.tree-link:hover {
    color: var(--color-heading);
}

.tree-link:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 3px;
    border-radius: 2px;
}

@keyframes panel-drop {
    from {
        opacity: 0;
        transform: translateY(-0.75rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 2.75rem 1rem 3rem;
    }

    .intro {
        margin-bottom: 1.4rem;
        padding-bottom: 1rem;
    }

    .intro-copy {
        width: min(100%, 17.5rem);
    }

    .intro-copy h1 {
        margin-bottom: 0.4rem;
    }

    .contact-links {
        margin-top: 0.15rem;
    }

    .contact-link {
        width: 1.6rem;
        height: 1.6rem;
    }

    iconify-icon {
        width: 1.35rem;
        height: 1.35rem;
    }

    .view-switcher {
        width: 100%;
        justify-content: space-between;
    }

    .view-tab {
        flex: 1;
        text-align: center;
    }

    .tree-item {
        grid-template-columns: max-content minmax(0, 1fr);
    }

    .tree-meta {
        grid-column: 2;
        justify-self: start;
        margin-top: 0.1rem;
    }

    .projects,
    .research,
    .writings,
    .resume {
        margin-top: 2rem;
    }

    .portfolio-panel > section:first-child {
        margin-top: 0;
    }

    .preferences-panel {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
        width: 100%;
        margin-top: var(--space-lg);
        padding-top: var(--space-md);
    }

    .preference-item {
        width: 100%;
        justify-content: space-between;
    }

    .theme-toggle {
        width: 64px;
        height: 36px;
    }

    .theme-toggle input,
    .slider {
        width: 64px;
        height: 36px;
    }

    .slider::before {
        width: 28px;
        height: 28px;
        left: 4px;
        bottom: 4px;
    }

    .theme-toggle input:checked + .slider::before {
        transform: translateX(28px);
    }

    .theme-label,
    .animations-label,
    .theme-heading {
        font-size: 1rem;
    }
}

@media (min-width: 901px) {
    .tree-item {
        font-size: 1.05rem;
    }
}
