:root {
    color-scheme: light;
    --bg: #f4f4f5;
    --surface: #ffffff;
    --ink: #111113;
    --muted: #6b6b72;
    --line: #e5e5e9;
    --grid: rgba(0, 0, 0, 0.05);
    --accent: #000000;
    --accent-soft: #3a3a40;
    --glow: rgba(0, 0, 0, 0.14);
    --panel: #0c0c0e;
    --panel-text: #ececef;
    --panel-muted: #8b8b92;
    --panel-accent: #e6e6ea;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', 'SF Mono', monospace;
    --font-head: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d0d10;
    --surface: #16161a;
    --ink: #f0f0f2;
    --muted: #a1a1a9;
    --line: #2b2b31;
    --grid: rgba(255, 255, 255, 0.045);
    --accent: #ffffff;
    --accent-soft: #c9c9cf;
    --glow: rgba(0, 0, 0, 0.55);
    --panel: #050507;
    --panel-text: #e9e9ec;
    --panel-muted: #7e7e87;
    --panel-accent: #e6e6ea;
}

* {
    box-sizing: border-box;
    scroll-padding-top: 70px;
}

#vanta-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--ink);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---------- status bar ---------- */
.statusbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--panel);
    color: var(--panel-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 0.55rem 2rem;
    border-bottom: 1px solid var(--line);
}
.status-tag {
    color: var(--panel-accent);
}
.status-msg {
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@keyframes blink {
    50% { opacity: 0.25; }
}

/* ---------- nav ---------- */
.nav-container {
    z-index: 9999;
    height: 70px;
    position: sticky;
    top: 0;
    display: flex;
    justify-content: center;
    background-color: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.navbar {
    flex: 1 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    color: var(--ink);
}
.nav-logo {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    padding-inline: 2rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.nav-logo p {
    display: inline-flex;
    align-items: center;
}
.nav-logo .bracket {
    color: var(--muted);
}
.nav-logo .cursor {
    display: inline-block;
    width: 9px;
    height: 1em;
    margin-left: 3px;
    background: var(--accent);
    animation: blink 1.1s infinite;
}
nav ul {
    display: flex;
    list-style-type: none;
    justify-content: flex-end;
    gap: 1rem 1.5rem;
    padding-inline: 2rem;
    align-items: center;
    margin: 0;
}
nav ul li a {
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 500;
    position: relative;
    padding: 4px 0;
}
nav ul li a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 0;
    background: var(--accent);
    transition: width 0.25s ease;
}
nav ul li a:hover {
    color: var(--accent);
}
nav ul li a:hover::after {
    width: 100%;
}
nav ul li a.active {
    color: var(--accent);
}
nav ul li a.active::after {
    width: 100%;
}
#searchBtn,
#themeToggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    background: transparent;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    transition: all 0.25s ease;
}
#searchBtn:hover,
#themeToggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 14px var(--glow);
}
#searchBtn svg,
#themeToggle svg {
    fill: currentColor;
}
#themeToggle svg.icon-sun {
    fill: none;
    stroke: currentColor;
}
#themeToggle .icon-moon {
    display: block;
}
#themeToggle .icon-sun {
    display: none;
}
html[data-theme="dark"] #themeToggle .icon-moon {
    display: none;
}
html[data-theme="dark"] #themeToggle .icon-sun {
    display: block;
}

/* ---------- layout ---------- */
h1, h2, h3, h4, h5, h6 {
    color: var(--ink);
    font-family: var(--font-head);
    font-weight: 700;
}

main {
    display: flex;
    justify-content: center;
    padding: 2.5rem 1rem 1rem;
}

.container {
    max-width: 880px;
    width: 100%;
}

/* ---------- hero ---------- */
.hero-panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    display: flex;
    gap: 2rem;
    align-items: center;
}
.hero-panel::before,
.hero-panel::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.hero-panel::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
}
.hero-panel::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
}
.hero-avatar {
    position: relative;
    width: 150px;
    height: 150px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hero-avatar .ring {
    position: absolute;
    inset: -10px;
    border: 1px dashed var(--muted);
    border-radius: 50%;
    animation: spin 14s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.hero-avatar img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    box-shadow: 0 0 0 4px var(--surface), 0 0 26px var(--glow);
}
.hero-avatar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    flex: none;
}
.hero-avatar-col .hero-actions {
    margin-top: 0;
}
.hero-info {
    min-width: 0;
    flex: 1;
}
.hero-name {
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 4vw, 1.9rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0 0 0.35rem;
    line-height: 1.15;
    word-break: break-word;
}
.hero-role {
    font-family: var(--font-head);
    font-weight: 600;
    color: var(--accent-soft);
    margin: 0 0 0.75rem;
    font-size: 1.3rem;
}
.hero-role.role-open {
    color: #22d3ee;
}

/* glitch effect (monochrome, theme-aware) */
.glitch-item {
    position: relative;
    display: inline-block;
}
.glitch-item::before,
.glitch-item::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}
.glitch-item.glitching::before {
    opacity: 1;
    left: 2px;
    text-shadow: 2px 0 var(--accent), -2px 0 var(--muted);
    clip-path: inset(10% 0 55% 0);
    animation: glitch-slice 0.4s infinite linear alternate;
}
.glitch-item.glitching::after {
    opacity: 1;
    left: -2px;
    text-shadow: -2px 0 var(--accent);
    clip-path: inset(60% 0 5% 0);
    animation: glitch-slice2 0.55s infinite linear alternate;
}
@keyframes glitch-slice {
    0% { clip-path: inset(10% 0 55% 0); transform: translateX(0); }
    50% { clip-path: inset(40% 0 20% 0); transform: translateX(-3px); }
    100% { clip-path: inset(70% 0 5% 0); transform: translateX(3px); }
}
@keyframes glitch-slice2 {
    0% { clip-path: inset(60% 0 5% 0); transform: translateX(0); }
    50% { clip-path: inset(15% 0 60% 0); transform: translateX(3px); }
    100% { clip-path: inset(40% 0 35% 0); transform: translateX(-3px); }
}
.hero-bio {
    color: var(--muted);
    line-height: 1.7;
    font-size: 0.95rem;
    margin: 0;
}
.hero-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-top: 1rem;
}
.hero-contact .k {
    color: var(--accent);
    margin-right: 0.4rem;
    font-size: 1.15rem;
    line-height: 1;
}
.hero-email {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s ease;
}
.hero-email:hover {
    color: var(--accent);
}
.hero-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.4rem;
    flex-wrap: wrap;
}
.btn-socials {
    display: flex;
    gap: 0.6rem;
}
.btn-socials a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    transition: all 0.25s ease;
}
.btn-socials a:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 14px var(--glow);
    transform: translateY(-3px);
}

/* ---------- sections ---------- */
.section {
    margin-top: 2.5rem;
}
.section-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.section-head h2 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
}
.section-head .mono-tag {
    color: var(--accent);
}
.section-head .line {
    flex: 1;
    height: 1px;
    background: var(--line);
}

.panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: clamp(1.25rem, 3vw, 1.75rem);
}

/* ---------- skills ---------- */
.skill-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem 2rem;
}
.skill-item {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0;
    border-bottom: 1px dashed var(--line);
}
.skill-item::before {
    content: '>';
    color: var(--accent);
    font-weight: 700;
}

/* ---------- certs ---------- */
.cert-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.cert-item {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
    padding: 0.65rem 0;
    border-bottom: 1px dashed var(--line);
}
.cert-item:last-child {
    border-bottom: none;
}
.cert-year {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-soft);
    flex: none;
    min-width: 92px;
}
.cert-name a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.cert-name a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.cert-name .issuer {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 400;
}

/* ---------- experience ---------- */
.timeline {
    border-left: 2px solid var(--line);
    margin-left: 0.5rem;
    padding-left: 1.6rem;
}
.exp-item {
    position: relative;
    margin-bottom: 1.75rem;
}
.exp-item:last-child {
    margin-bottom: 0;
}
.exp-item::before {
    content: '';
    position: absolute;
    left: -1.78rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border: 2px solid var(--accent);
    background: var(--surface);
    border-radius: 50%;
}
.exp-period {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-soft);
}
.exp-role {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.12rem;
    margin: 0.25rem 0 0.1rem;
}
.exp-org {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
}
.exp-desc {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.65;
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
}
.exp-desc li {
    margin: 0.3rem 0;
}

/* ---------- education ---------- */
.edu-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.8rem 0;
    border-bottom: 1px dashed var(--line);
}
.edu-item:last-child {
    border-bottom: none;
}
.edu-degree {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1rem;
}
.edu-school {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}
.edu-year {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-soft);
    flex: none;
}

/* ---------- projects ---------- */
.project-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.project-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    text-decoration: none;
    color: var(--ink);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.project-card::before,
.project-card::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    pointer-events: none;
}
.project-card::before {
    top: 0;
    left: 0;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
}
.project-card::after {
    bottom: 0;
    right: 0;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
}
.project-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 14px 32px -18px var(--glow);
}
.project-icon {
    flex: none;
    color: var(--accent);
    width: 30px;
    height: 30px;
    margin-top: 0.1rem;
}
.project-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}
.project-card h3 {
    margin: 0 0 0.35rem;
    font-size: 1.02rem;
}
.project-card p {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.6;
    margin: 0;
}

/* ---------- contact ---------- */
.contact-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.1rem;
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--surface);
    border-radius: 4px;
    transition: all 0.25s ease;
}
.contact-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}
.contact-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 14px var(--glow);
}
/* ---------- footer ---------- */
footer {
    height: auto;
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 1.4rem 1em;
    background-color: var(--surface);
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
}
footer .ftag {
    color: var(--accent);
}

/* ---------- modal ---------- */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
}
.modal-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(6px);
    background-color: color-mix(in srgb, var(--bg) 65%, transparent);
    padding: 1rem;
}
.modal-content {
    position: relative;
    background-color: var(--surface);
    width: 600px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    border: 1px solid var(--accent);
    box-shadow: 0 24px 64px -24px var(--glow);
}
.modal-content::before,
.modal-content::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.modal-content::before {
    top: -1px;
    left: -1px;
    border-top: 3px solid var(--accent);
    border-left: 3px solid var(--accent);
}
.modal-content::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
}
.modal-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
}
#searchForm {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
}
#searchForm input[type="text"] {
    width: 80%;
    padding: 12px 14px;
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--font-mono);
    border: 1px solid var(--line);
    border-radius: 4px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
#searchForm input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--glow);
}
#searchForm button {
    padding: 12px 20px;
    background-color: var(--accent);
    color: var(--surface);
    border: 1px solid var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.25s;
}
#searchForm button:hover {
    background-color: var(--accent-soft);
    border-color: var(--accent-soft);
    box-shadow: 0 0 16px var(--glow);
}
#searchResults {
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
}
#searchResults.visible {
    padding: 1.25rem 0.25rem;
}
#searchResults a {
    text-decoration: none;
}
.search-item {
    padding: 0.9rem 0;
    border-top: 1px dashed var(--line);
    text-align: left;
}
.search-item h3 {
    margin: 0 0 0.3rem;
    font-size: 1rem;
    font-family: var(--font-head);
}
#searchResults a:hover h3 {
    color: var(--accent);
}
.search-item .s-date {
    color: var(--accent-soft);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.search-item p {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0.3rem 0 0;
    line-height: 1.5;
}

/* ---------- responsive ---------- */
@media (max-width: 768px) {
    * {
        scroll-padding-top: 0px;
    }
    .statusbar {
        padding: 0.5rem 1rem;
    }
    .status-msg {
        display: none;
    }
    .nav-container {
        height: auto;
        position: relative;
        padding: 0.6rem 0;
    }
    .navbar {
        flex-direction: column;
        gap: 0.4rem;
    }
    .nav-logo {
        padding-inline: 1rem;
    }
    nav ul {
        padding-inline: 1rem;
        gap: 0.75rem 1rem;
    }
    main {
        padding: 1.5rem 0.75rem 0.5rem;
    }
    .hero-panel {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .hero-avatar {
        margin-bottom: 0.25rem;
    }
    .hero-contact {
        justify-content: center;
    }
    .hero-actions {
        justify-content: center;
    }
    .skill-grid {
        grid-template-columns: 1fr;
    }
    .project-grid {
        grid-template-columns: 1fr;
    }
    .cert-item {
        flex-direction: column;
        gap: 0.25rem;
    }
    .modal-content {
        width: 90%;
    }
    #searchForm {
        flex-direction: column;
    }
    #searchForm input[type="text"] {
        width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    * {
        scroll-padding-top: 0px;
    }
}