:root {
    --text: #1a1614;
    --text-secondary: #6b5f58;
    --heading: #0d0b0a;
    --accent: #cc785c;
    --accent-soft: rgba(204, 120, 92, 0.12);
    --link-hover: #a85a3e;
    --border: rgba(204, 120, 92, 0.16);
    --panel: rgba(255, 253, 251, 0.88);
    --panel-strong: #fffdfb;
    --bg-top: #f5f0ec;
    --bg-bottom: #faf7f5;
    --shadow: 0 18px 50px rgba(30, 20, 15, 0.07);
    --shadow-soft: 0 8px 24px rgba(30, 20, 15, 0.05);
    --terminal-bar: #ede5de;
    --terminal-bg: #f5f0ec;
    --terminal-text: #1a1614;
    --tc-star-color: #cc785c;
    --tc-hash-color: #9a6020;
    --tc-ref-color: #2e7dc4;
    --tc-msg-color: #0d0b0a;
    --tc-date-color: #6b5f58;
    --tc-prompt-color: #27804a;
}

body.dark-theme {
    --text: #e8e0db;
    --text-secondary: #9e9189;
    --heading: #f5ede8;
    --accent: #e8896a;
    --accent-soft: rgba(232, 137, 106, 0.14);
    --link-hover: #ffb08e;
    --border: rgba(232, 137, 106, 0.14);
    --panel: rgba(28, 23, 20, 0.9);
    --panel-strong: #1c1714;
    --bg-top: #171310;
    --bg-bottom: #0f0d0b;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.26);
    --terminal-bar: #1a1614;
    --terminal-bg: #100e0c;
    --terminal-text: #c9d1d9;
    --tc-star-color: #e8896a;
    --tc-hash-color: #e3b341;
    --tc-ref-color: #79c0ff;
    --tc-msg-color: #e6edf3;
    --tc-date-color: #8b949e;
    --tc-prompt-color: #27c93f;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(ellipse at top left, rgba(204, 120, 92, 0.08), transparent 40%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    line-height: 1.75;
    font-size: 16px;
}

.page-shell {
    min-height: 100vh;
    padding: 32px 20px 48px;
}

.container {
    max-width: 920px;
    margin: 0 auto;
}

.theme-toggle-wrap {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    color: var(--accent);
    border-color: rgba(165, 106, 58, 0.24);
    transform: translateY(-1px);
}

.theme-toggle-icon {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.9rem;
    line-height: 1;
}

.hero,
.panel,
.section-nav,
footer {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.hero,
.panel,
footer {
    border-radius: 16px;
}

.hero {
    padding: 30px 32px;
    margin-bottom: 18px;
}

.hero:hover,
.panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.header-content {
    display: flex;
    gap: 24px;
    align-items: center;
}

.photo-wrap {
    position: relative;
    width: 136px;
    height: 136px;
    flex-shrink: 0;
}

.profile-photo {
    display: block;
    width: 136px;
    height: 136px;
    border-radius: 20px;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 14px 30px rgba(165, 106, 58, 0.14);
    transition: transform 0.28s ease, box-shadow 0.28s ease, filter 0.28s ease, opacity 0.28s ease;
}

.profile-photo-pixel {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 1;
    z-index: 1;
    image-rendering: pixelated;
}

.hero:hover .profile-photo {
    transform: rotate(-1.5deg) scale(1.02);
    box-shadow: 0 18px 36px rgba(165, 106, 58, 0.18);
    filter: saturate(1.04);
}

.hero:hover .profile-photo:not(.profile-photo-pixel) {
    opacity: 1;
}

.hero:hover .profile-photo-pixel {
    opacity: 0;
}

.hero-copy {
    flex: 1;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.1;
    font-weight: 700;
    color: var(--heading);
    margin-bottom: 6px;
}

h1 .degree {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    vertical-align: middle;
}

.name-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.affiliation {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.hero-summary {
    max-width: 60ch;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.contact-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.contact-links a,
.section-nav a {
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.contact-links a {
    padding: 8px;
    border-radius: 999px;
    color: var(--accent);
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(165, 106, 58, 0.16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.contact-icon {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
}

.contact-icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.contact-links a:hover,
.contact-links a:focus-visible {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 10px 22px rgba(165, 106, 58, 0.18);
    transform: translateY(-1px);
}

.contact-links a:hover .contact-icon,
.contact-links a:focus-visible .contact-icon {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.section-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px;
    margin-bottom: 18px;
    border-radius: 12px;
    position: sticky;
    top: 16px;
    z-index: 100;
}

.section-nav a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 999px;
}

.section-nav a:hover,
.section-nav a:focus-visible,
.section-nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
}

main {
    display: grid;
    gap: 18px;
}

.panel {
    padding: 28px 30px;
}

.panel:target {
    border-color: rgba(165, 106, 58, 0.3);
    box-shadow: 0 18px 38px rgba(165, 106, 58, 0.1);
}

section {
    scroll-margin-top: 18px;
}

h2 {
    font-size: 1.2rem;
    color: var(--heading);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.panel p + p {
    margin-top: 12px;
}

.entry {
    margin-bottom: 22px;
    transition: transform 0.18s ease;
}

.entry:hover {
    transform: translateX(4px);
}

.entry:last-child,
.pub-list li:last-child {
    margin-bottom: 0;
}

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

.entry-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--heading);
}

.location,
.date,
.role,
.hero-summary,
footer {
    color: var(--text-secondary);
}

.location {
    font-weight: 600;
    font-size: 0.95rem;
}

.date {
    white-space: nowrap;
    font-weight: 700;
    font-size: 0.92rem;
}

.role {
    font-style: italic;
    margin-bottom: 4px;
}

.meta {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.83rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.tag {
    display: inline-block;
    margin-right: 8px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.83rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.tag-blog {
    background: var(--accent-soft);
    color: var(--accent);
}

.tag-paper {
    background: rgba(58, 110, 95, 0.12);
    color: #2e7a65;
}

body.dark-theme .tag-paper {
    background: rgba(100, 190, 160, 0.14);
    color: #7dd4b8;
}

.latest-list {
    list-style: none;
    margin-left: 0;
}

.latest-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.latest-list li:first-child {
    padding-top: 0;
}

.latest-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

ul,
ol {
    margin-left: 22px;
    margin-top: 8px;
}

li {
    margin-bottom: 8px;
}

.pub-list {
    margin-left: 22px;
}

.pub-list li {
    padding-left: 4px;
    line-height: 1.7;
}

strong {
    color: var(--heading);
}

a {
    color: var(--accent);
}

.panel p a,
.panel li a {
    color: var(--heading);
    text-decoration: none;
    background-image: linear-gradient(rgba(204, 120, 92, 0.2), rgba(204, 120, 92, 0.2));
    background-repeat: no-repeat;
    background-size: 100% 0.42em;
    background-position: 0 88%;
    transition: color 0.18s ease, background-size 0.18s ease, background-position 0.18s ease;
}

.panel p a:hover,
.panel p a:focus-visible,
.panel li a:hover,
.panel li a:focus-visible {
    color: var(--accent);
    background-size: 100% 100%;
    background-position: 0 100%;
}

footer {
    margin-top: 22px;
    padding: 18px 22px;
    text-align: center;
    font-size: 0.9rem;
}

body.dark-theme .contact-links a {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(240, 218, 198, 0.12);
}

body.dark-theme .hero:hover,
body.dark-theme .panel:hover {
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.26);
}

body.dark-theme .profile-photo {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
}

@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        --text: #e8e0db;
        --text-secondary: #9e9189;
        --heading: #f5ede8;
        --accent: #e8896a;
        --accent-soft: rgba(232, 137, 106, 0.14);
        --link-hover: #ffb08e;
        --border: rgba(232, 137, 106, 0.14);
        --panel: rgba(28, 23, 20, 0.9);
        --panel-strong: #1c1714;
        --bg-top: #171310;
        --bg-bottom: #0f0d0b;
        --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
        --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.26);
        --terminal-bar: #1a1614;
        --terminal-bg: #100e0c;
        --terminal-text: #c9d1d9;
        --tc-star-color: #e8896a;
        --tc-hash-color: #e3b341;
        --tc-ref-color: #79c0ff;
        --tc-msg-color: #e6edf3;
        --tc-date-color: #8b949e;
        --tc-prompt-color: #27c93f;
    }

    body:not(.light-theme) .contact-links a {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(240, 218, 198, 0.12);
    }

    body:not(.light-theme) .hero:hover,
    body:not(.light-theme) .panel:hover {
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.26);
    }

    body:not(.light-theme) .profile-photo {
        border-color: rgba(255, 255, 255, 0.1);
        box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
    }

    body:not(.light-theme) .tag-paper {
        background: rgba(100, 190, 160, 0.14);
        color: #7dd4b8;
    }
}

@media (max-width: 720px) {
    .page-shell {
        padding: 18px 14px 28px;
    }

    .hero,
    .panel {
        padding: 24px 20px;
    }

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

    .photo-wrap {
        width: 112px;
        height: 112px;
    }

    .profile-photo {
        width: 112px;
        height: 112px;
        border-radius: 18px;
    }

    h1 {
        font-size: 2rem;
    }

    .entry-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .section-nav {
        gap: 6px;
    }

    .tc-date {
        display: none;
    }

    .hero:hover,
    .panel:hover,
    .entry:hover,
    .hero:hover .profile-photo {
        transform: none;
    }

}

@media (hover: none) {
    .profile-photo-pixel {
        opacity: 0;
    }
}

.terminal-panel {
    padding: 0;
    overflow: hidden;
}

.panel.terminal-panel {
    background: var(--terminal-bar);
    backdrop-filter: none;
}

.terminal-bar {
    background: var(--terminal-bar);
    border-radius: 15px 15px 0 0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-red    { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green  { background: #27c93f; }

.terminal-title {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    color: #7a7572;
    font-family: ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Consolas, monospace;
}

.terminal-body {
    background: var(--terminal-bg);
    padding: 18px 22px 20px;
    font-family: ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.75;
    color: var(--terminal-text);
    border-radius: 0 0 15px 15px;
    overflow-x: auto;
}

.terminal-prompt-line {
    margin: 0 0 6px;
    color: #8b949e;
}

.tc-prompt {
    color: var(--tc-prompt-color);
    font-weight: 700;
}

.tc-line {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    min-width: max-content;
}

.tc-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.tc-star  { color: var(--tc-star-color); }
.tc-hash  { color: var(--tc-hash-color); }
.tc-ref   { color: var(--tc-ref-color); }
.tc-msg   { color: var(--tc-msg-color); }
.tc-date  { color: var(--tc-date-color); flex-shrink: 0; }

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

.terminal-cursor {
    display: none;
    color: #8b949e;
    animation: blink 1s step-end infinite;
}

.terminal-cursor.visible {
    display: inline;
}

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

    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}
