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

:root, [data-theme="dark"] {
    --bg: #0a0a0a;
    --text: #e5e5e5;
    --text-secondary: #999;
    --border: #2a2a2a;
    --accent: #fff;
}

[data-theme="light"] {
    --bg: #fafafa;
    --text: #1a1a1a;
    --text-secondary: #666;
    --border: #e0e0e0;
    --accent: #000;
}

[data-theme="sepia"] {
    --bg: #f4f1ea;
    --text: #3a3226;
    --text-secondary: #7a6f5d;
    --border: #d4cbb8;
    --accent: #2a2419;
}

body {
    font-family: 'Karla', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    font-weight: 300;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

header {
    margin-bottom: 4rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid var(--border);
}

h1 {
    font-family: 'Crimson Pro', serif;
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.bio {
    color: var(--text);
    margin-bottom: 1.5rem;
    max-width: 600px;
}

.contact {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.contact a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.contact a:hover {
    color: var(--accent);
}

.theme-switcher {
    position: fixed;
    top: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.75rem;
    z-index: 100;
    background: var(--bg);
    padding: 0.5rem 0.75rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.contents-nav {
    position: fixed;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 99;
    background: var(--bg);
    padding: 0.75rem 0.5rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.contents-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.3;
    position: relative;
}

.contents-dot:hover {
    opacity: 0.7;
    transform: scale(1.3);
}

.contents-dot.active {
    opacity: 1;
    background: var(--accent);
}

.contents-dot::after {
    content: attr(data-label);
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    background: var(--bg);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.contents-dot:hover::after {
    opacity: 1;
}

.theme-button {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.4;
    position: relative;
    /* FIX 1: This prevents the round button from clipping the rectangular label */
    overflow: visible; 
}

.theme-button:hover {
    /* FIX 2: Set opacity to 1 on hover. 
    If opacity is < 1, browsers often clip overflow on rounded elements. */
    opacity: 1; 
    transform: scale(1.1);
}

.theme-button.active {
    opacity: 1;
    border-color: var(--text-secondary);
}

.theme-button::after {
    content: attr(data-label);
    position: absolute;
    top: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    
    /* FIX 3: Ensure the label can expand to fit text width */
    width: max-content; 
    
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    
    /* Optional: Ensure label text is legible above other content */
    background: var(--bg);
    color: var(--text);
    z-index: 1000;
}

.theme-button:hover::after {
    opacity: 1;
}

.theme-button.light::after {
    background: #fafafa;
    color: #1a1a1a;
    border-color: #e0e0e0;
}

.theme-button.dark::after {
    background: #0a0a0a;
    color: #e5e5e5;
    border-color: #2a2a2a;
}

.theme-button.sepia::after {
    background: #f4f1ea;
    color: #3a3226;
    border-color: #d4cbb8;
}

.theme-button.light {
    background: #fafafa;
}

.theme-button.dark {
    background: #0a0a0a;
}

.theme-button.sepia {
    background: #f4f1ea;
}

section {
    margin-bottom: 3.5rem;
}

h2 {
    font-family: 'Crimson Pro', serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: -0.3px;
}

.item {
    margin-bottom: 2.5rem;
}

.item-header {
    margin-bottom: 0.5rem;
}

.item-title {
    font-weight: 500;
    font-size: 1.05rem;
    margin-bottom: 0.2rem;
}

.item-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.item-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.item-description {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.item-list {
    list-style: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.item-list li {
    padding-left: 1rem;
    position: relative;
    margin-bottom: 0.3rem;
}

.item-list li::before {
    content: '–';
    position: absolute;
    left: 0;
}

.publication-title {
    font-weight: 400;
    margin-bottom: 0.3rem;
}

a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--text-secondary);
}


.publication-title a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s;
}

.publication-title a:hover {
    color: var(--text-secondary);
}

.publication-title a[href^="http"]::after,
.item-title a[href^="http"]::after {
    content: "";
    display: inline-block;
    width: 0.65em;
    height: 0.65em;
    margin-left: 0.3rem;
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.6;
    transform: translateY(1px);
    vertical-align: text-top;
    /* Default fallback for dark theme */
    background-image: url("data:image/svg+xml,%3Csvg width='11' viewBox='0 0 11 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.70985 4.5H7.7804M7.7804 4.5V10.5705M7.7804 4.5L0.780396 11.5' stroke='%23e5e5e5' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Arrow */
[data-theme="light"] .publication-title a[href^="http"]::after,
[data-theme="light"] .item-title a[href^="http"]::after {
    background-image: url("data:image/svg+xml,%3Csvg width='11' viewBox='0 0 11 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.70985 4.5H7.7804M7.7804 4.5V10.5705M7.7804 4.5L0.780396 11.5' stroke='%231a1a1a' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-theme="dark"] .publication-title a[href^="http"]::after,
[data-theme="dark"] .item-title a[href^="http"]::after {
    background-image: url("data:image/svg+xml,%3Csvg width='11' viewBox='0 0 11 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.70985 4.5H7.7804M7.7804 4.5V10.5705M7.7804 4.5L0.780396 11.5' stroke='%23e5e5e5' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-theme="sepia"] .publication-title a[href^="http"]::after,
[data-theme="sepia"] .item-title a[href^="http"]::after {
    background-image: url("data:image/svg+xml,%3Csvg width='11' viewBox='0 0 11 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.70985 4.5H7.7804M7.7804 4.5V10.5705M7.7804 4.5L0.780396 11.5' stroke='%233a3226' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.skill-category {
    margin-bottom: 1.5rem;
}

.skill-title {
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.skill-list {
    list-style: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.skill-list li {
    margin-bottom: 0.25rem;
}

footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

    h1 {
        font-size: 2rem;
    }

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

    .contact {
        flex-direction: column;
        gap: 0.5rem;
    }

    .theme-switcher {
        top: 1rem;
        right: 1rem;
    }

    .theme-button::after {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
    
    .theme-button:hover::after,
    .theme-button:active::after,
    .theme-button:focus::after {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }

    .contents-nav {
        display: none;
    }
}