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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: #fafafa;
    color: #444452;
    line-height: 1.6;
    font: 300 1rem/1.6 'IBM Plex Mono', monospace;
    overflow-x: hidden;
}

body.night {
    background: #131417;
    color: #afafbf;
}

a {
    text-decoration: none;
    color: #36363c;
    transition: color 0.2s ease;
}

a:hover {
    color: #007bff;
}

body.night a {
    color: #e7e7e7;
}

body.night a:hover {
    color: #6eb5ff;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 200;
    padding: 10px 16px;
    background: #007bff;
    color: #fff;
    font-size: 0.85rem;
    border-radius: 4px;
}

.skip-link:focus {
    top: 12px;
}

.text-muted {
    color: #aaa;
}

body.night .text-muted {
    color: #666;
}

.site-top {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    background: rgba(250, 250, 250, 0.92);
    border-bottom: 1px solid #e8e8ec;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.night .site-top {
    background: rgba(19, 20, 23, 0.92);
    border-bottom-color: #2a2a32;
}

.site-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px 20px;
    font-size: 0.8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    min-width: 0;
    flex: 1;
}

.site-nav::-webkit-scrollbar {
    display: none;
}

.site-nav a {
    color: #666;
    white-space: nowrap;
    padding: 8px 2px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.site-nav a:hover,
.site-nav a.is-active {
    color: #007bff;
}

body.night .site-nav a {
    color: #9a9aaa;
}

body.night .site-nav a:hover,
body.night .site-nav a.is-active {
    color: #6eb5ff;
}

.site {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Theme toggle */
.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    color: #666;
    position: relative;
}

body.night .switch-wrapper {
    color: #c8c8d4;
}

.theme-icon {
    flex-shrink: 0;
}

#switch {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-wrapper label {
    cursor: pointer;
    text-indent: -9999px;
    width: 44px;
    height: 26px;
    background: #888;
    display: block;
    border-radius: 100px;
    position: relative;
    flex-shrink: 0;
}

.switch-wrapper label::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 40px;
    transition: 0.3s;
}

#switch:checked + label {
    background: #007bff;
}

#switch:checked + label::after {
    left: calc(100% - 2px);
    transform: translateX(-100%);
}

/* Intro */
.intro {
    padding: 48px 0 56px;
}

.intro_status {
    margin: 0 0 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #007bff;
    letter-spacing: 0.04em;
}

body.night .intro_status {
    color: #6eb5ff;
}

.intro h1 {
    font-size: clamp(1.35rem, 4vw, 1.85rem);
    font-weight: 500;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    line-height: 1.25;
    word-wrap: break-word;
}

.intro_subtitle {
    margin: 0 0 20px;
    font-size: 0.9rem;
    color: #666;
}

body.night .intro_subtitle {
    color: #9a9aaa;
}

.intro_tagline {
    max-width: 620px;
    margin: 0 0 24px;
    color: #666;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}

body.night .intro_tagline {
    color: #9a9aaa;
}

.intro_contact {
    font-size: 0.9rem;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 0;
}

.highlight-link {
    box-shadow: inset 0 -2px 0 #007bff;
    word-break: break-word;
}

.highlight-link:hover {
    color: #007bff;
}

.contact-sep {
    margin: 0 8px;
    color: #aaa;
}

/* Sections */
.section {
    display: flex;
    padding: 40px 0;
    border-top: 1px solid #e8e8ec;
    scroll-margin-top: 72px;
}

body.night .section {
    border-top-color: #2a2a32;
}

.section_title {
    flex-shrink: 0;
    width: 140px;
    margin: 0 40px 0 0;
    color: #007bff;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    padding-top: 4px;
}

.section_content {
    flex: 1;
    min-width: 0;
    max-width: 620px;
    font-size: 0.95rem;
}

.section_content p {
    margin: 0 0 16px;
}

.section_content p:last-child {
    margin-bottom: 0;
}

.section_content li {
    position: relative;
    padding-left: 16px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.55;
}

.section_content li::before {
    content: '–';
    position: absolute;
    left: 0;
    color: #007bff;
}

/* Experience & projects */
.job {
    margin-bottom: 32px;
}

.job:last-of-type {
    margin-bottom: 24px;
}

.job_header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-bottom: 4px;
}

.job_time {
    font-size: 0.8rem;
    color: #888;
}

body.night .job_time {
    color: #888899;
}

.job_role {
    margin: 0 0 10px;
    color: #666;
}

body.night .job_role {
    color: #9a9aaa;
}

.arrow-link {
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-block;
    transition: transform 0.15s ease;
}

.arrow-link:hover {
    transform: translateX(4px);
}

/* Skills grid */
.skills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 32px;
}

.skill_group h3 {
    margin: 0 0 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #36363c;
}

body.night .skill_group h3 {
    color: #e7e7e7;
}

.skill_group li {
    margin: 4px 0;
    font-size: 0.85rem;
}

/* Footer */
.footer {
    padding: 40px 0 max(64px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    border-top: 1px solid #e8e8ec;
    font-size: 0.85rem;
}

body.night .footer {
    border-top-color: #2a2a32;
}

.footer_links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.footer_links a {
    color: #007bff;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

body.night .footer_links a {
    color: #6eb5ff;
}

/* Back to top */
#top-button {
    background: #fff;
    border: 1px solid #e8e8ec;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
    cursor: pointer;
    font-size: 1.1rem;
    color: #444452;
    line-height: 1;
    z-index: 50;
}

body.night #top-button {
    background: #1e1e24;
    border-color: #2a2a32;
    color: #afafbf;
}

#top-button:hover {
    border-color: #007bff;
    color: #007bff;
}

/* Tablet */
@media (max-width: 768px) {
    .section {
        flex-direction: column;
        padding: 32px 0;
    }

    .section_title {
        width: auto;
        margin: 0 0 16px;
    }

    .skills {
        grid-template-columns: 1fr 1fr;
        gap: 20px 24px;
    }

    .footer {
        flex-direction: column;
        text-align: center;
        justify-content: center;
    }

    .footer_links {
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .site-top {
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .site-nav {
        font-size: 0.75rem;
        gap: 4px 14px;
    }

    .intro {
        padding: 32px 0 40px;
    }

    .intro_contact {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .contact-sep {
        display: none;
    }

    .skills {
        grid-template-columns: 1fr;
    }

    .job_header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section_content li {
        font-size: 0.875rem;
    }
}

/* Desktop wide */
@media (min-width: 769px) {
    .site-top {
        padding: 14px 24px;
    }

    .site {
        padding: 0 24px;
    }

    .site-nav {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .intro {
        padding: 56px 0 64px;
    }

    .skills {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }
}

@media (min-width: 1024px) {
    .skills {
        display: flex;
        flex-wrap: wrap;
        gap: 24px 40px;
    }

    .skill_group {
        min-width: 140px;
    }
}
