/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --black: #000;
    --white: #fff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --gray-900: #171717;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font);
    background: var(--white);
    color: var(--gray-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Navigation ===== */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    transition: box-shadow 0.2s;
}

.nav.scrolled {
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.nav-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--black);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 32px;
}

.nav-links a {
    text-decoration: none;
    color: var(--gray-500);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s;
    letter-spacing: -0.01em;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--black);
}

/* Mobile toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 24px;
    height: 20px;
    position: relative;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--black);
    position: absolute;
    left: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle span:first-child { top: 4px; }
.nav-toggle span:last-child { bottom: 4px; }

.nav-toggle.open span:first-child {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.nav-toggle.open span:last-child {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
}

/* ===== Hero ===== */
.hero {
    padding: 160px 0 100px;
    border-bottom: 1px solid var(--gray-200);
}

.hero h1 {
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--black);
    margin-bottom: 16px;
}

.hero-sub {
    font-size: 1.125rem;
    color: var(--gray-500);
    font-weight: 400;
    margin-bottom: 24px;
}

.hero-desc {
    max-width: 600px;
    color: var(--gray-600);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 32px;
}

.hero-links {
    display: flex;
    gap: 24px;
}

.hero-links a {
    color: var(--black);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--gray-300);
    transition: border-color 0.15s;
}

.hero-links a:hover {
    border-color: var(--black);
}

/* ===== Sections ===== */
.section {
    padding: 80px 0;
    border-bottom: 1px solid var(--gray-200);
}

.section:last-of-type {
    border-bottom: none;
}

.section h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 48px;
    color: var(--black);
}

/* ===== Projects ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--gray-200);
    border: 1px solid var(--gray-200);
}

.project {
    background: var(--white);
    padding: 32px;
    display: flex;
    flex-direction: column;
    transition: background 0.15s;
}

.project:hover {
    background: var(--gray-50);
}

.project-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.project h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--black);
}

.project-top a {
    font-size: 0.8125rem;
    color: var(--gray-400);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s;
}

.project-top a:hover {
    color: var(--black);
}

.project p {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.6;
    margin-bottom: 16px;
    flex: 1;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tags span {
    font-size: 0.75rem;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 3px 10px;
    border-radius: 3px;
    font-weight: 500;
}

.project-award {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--black);
    letter-spacing: -0.01em;
}

/* ===== Horizontal Timeline (Experience) ===== */
.htl {
    position: relative;
}

.htl-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.htl-row {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 36px;
    cursor: pointer;
}

.htl-row:hover .htl-bar {
    background: var(--gray-800);
}

.htl-row.active .htl-bar {
    background: var(--black);
}

.htl-label {
    width: 150px;
    flex-shrink: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-500);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.htl-row:hover .htl-label,
.htl-row.active .htl-label {
    color: var(--black);
}

.htl-track {
    flex: 1;
    position: relative;
    height: 28px;
}

.htl-bar {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--gray-300);
    border-radius: 4px;
    transition: background 0.15s;
    min-width: 8px;
}

/* Axis */
.htl-axis {
    display: flex;
    align-items: flex-start;
    margin-left: 166px; /* label width + gap */
    border-top: 1px solid var(--gray-200);
    padding-top: 8px;
    position: relative;
    height: 24px;
}

.htl-axis-label {
    position: absolute;
    font-size: 0.6875rem;
    color: var(--gray-400);
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Detail panel */
.htl-detail {
    margin-top: 24px;
    min-height: 0;
}

.htl-detail-inner {
    display: none;
    padding: 24px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--gray-50);
}

.htl-detail-inner.active {
    display: block;
}

.htl-detail-head {
    margin-bottom: 16px;
}

.htl-detail-head h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.htl-detail-head span {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.htl-detail ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.htl-detail li {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.6;
    padding-left: 16px;
    position: relative;
}

.htl-detail li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    width: 4px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 50%;
}

/* ===== Education ===== */
.education-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--gray-200);
    border: 1px solid var(--gray-200);
}

.edu-card {
    background: var(--white);
    padding: 32px;
}

.edu-card h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.edu-degree {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.edu-meta {
    font-size: 0.8125rem;
    color: var(--gray-400);
    margin-bottom: 16px;
}

.edu-activities {
    font-size: 0.8125rem;
    color: var(--gray-500);
    line-height: 1.6;
}

/* ===== Awards ===== */
.awards-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 48px;
}

.awards-col h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    margin-bottom: 20px;
}

.awards-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.awards-list li {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.5;
}

.awards-list strong {
    color: var(--black);
    font-weight: 600;
}

/* ===== Skills ===== */
.section-skills {
    border-bottom: none;
    padding-bottom: 40px;
}

.skills-line {
    font-size: 0.9375rem;
    color: var(--gray-500);
    line-height: 2;
    max-width: 800px;
}

/* ===== Footer ===== */
.footer {
    padding: 32px 0;
    border-top: 1px solid var(--gray-200);
}

.footer p {
    font-size: 0.8125rem;
    color: var(--gray-400);
}

/* ===== Chat Widget ===== */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    font-family: var(--font);
}

.chat-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--black);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s, box-shadow 0.15s;
}

.chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.chat-icon-close { display: none; }
.chat-widget.open .chat-icon-open { display: none; }
.chat-widget.open .chat-icon-close { display: block; }

.chat-panel {
    display: none;
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    flex-direction: column;
    overflow: hidden;
}

.chat-widget.open .chat-panel {
    display: flex;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-header-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--black);
    letter-spacing: -0.01em;
}

.chat-header-sub {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 360px;
    min-height: 200px;
}

.chat-msg {
    max-width: 85%;
    line-height: 1.5;
}

.chat-msg p {
    font-size: 0.8125rem;
    padding: 10px 14px;
    border-radius: 10px;
    margin: 0;
}

.chat-msg.assistant p {
    background: var(--gray-100);
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg.user p {
    background: var(--black);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.chat-msg p strong {
    font-weight: 600;
}

.chat-msg p em {
    font-style: italic;
}

.chat-msg p code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    background: var(--gray-200);
    padding: 1px 5px;
    border-radius: 3px;
}

.chat-msg p br + br {
    display: block;
    content: '';
    margin-top: 4px;
}

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--gray-100);
    border-radius: 10px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: chatBounce 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
}

.chat-input-area input {
    flex: 1;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-family: var(--font);
    outline: none;
    color: var(--gray-900);
    transition: border-color 0.15s;
}

.chat-input-area input::placeholder {
    color: var(--gray-400);
}

.chat-input-area input:focus {
    border-color: var(--gray-400);
}

.chat-input-area button {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--black);
    color: var(--white);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.chat-input-area button:hover {
    opacity: 0.8;
}

.chat-input-area button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 16px 24px 24px;
        gap: 16px;
        border-bottom: 1px solid var(--gray-200);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-toggle {
        display: block;
    }

    .hero {
        padding: 120px 0 64px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .section {
        padding: 56px 0;
    }

    .section h2 {
        margin-bottom: 32px;
    }

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

    .project {
        padding: 24px;
    }

    .timeline-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 24px 0;
    }

    .timeline-date {
        font-size: 0.75rem;
    }

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

    .awards-columns {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .htl-label {
        width: 100px;
        font-size: 0.75rem;
    }

    .htl-axis {
        margin-left: 116px;
    }

    .htl-detail-inner {
        padding: 16px;
    }

    .chat-panel {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 60px;
        max-height: 420px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero-links {
        flex-wrap: wrap;
        gap: 16px;
    }
}
