/* =============================================
   Design tokens
   ============================================= */
:root {
    --bg: #ffffff;
    --bg-subtle: #fafafa;
    --surface: #ffffff;
    --text: #18181b;
    --text-muted: #5f5f6b;
    --text-soft: #9a9aa5;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0fe;
    --border: #ededf0;
    --border-strong: #d8d8de;
    --radius: 16px;
    --radius-sm: 9px;
    --sidebar-w: 340px;
    --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.04);
    --shadow-md: 0 6px 24px -8px rgba(24, 24, 27, 0.12);
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Dark theme */
html[data-theme="dark"] {
    --bg: #0e0e12;
    --bg-subtle: #17171d;
    --surface: #141419;
    --text: #ececf1;
    --text-muted: #a3a3ae;
    --text-soft: #6c6c78;
    --accent: #8b93ff;
    --accent-hover: #a7adff;
    --accent-soft: rgba(139, 147, 255, 0.14);
    --border: #26262e;
    --border-strong: #36363f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 28px -10px rgba(0, 0, 0, 0.6);
}

html[data-theme="dark"] .hero-avatar {
    background: linear-gradient(150deg, #3a3a4a 0%, #23232c 100%);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-padding-top: 24px;
}

body {
    font-family: 'Outfit', -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

/* =============================================
   Top-right controls : language switch + theme
   ============================================= */
.top-controls {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Language segmented switch */
.lang-switch {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.lang-switch button {
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.lang-switch button:hover {
    color: var(--text);
}

.lang-switch button.active {
    color: #fff;
    background: var(--accent);
}

.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
        background 0.2s var(--ease), transform 0.2s var(--ease);
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

::selection {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

/* =============================================
   Layout : sticky sidebar + scrollable content
   ============================================= */
.layout {
    max-width: 1240px;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 0;
}

/* ----- Sidebar (自己紹介 — 常に表示) ----- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
    padding: 56px 40px 36px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    margin: auto 0;
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.hero-avatar {
    width: 64px;
    height: 64px;
    background: linear-gradient(150deg, #2b2b3a 0%, #18181b 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.hero-greeting {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    margin-bottom: 4px;
}

.hero-name {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.6px;
    line-height: 1.15;
}

.hero-subtitle {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.highlight {
    color: var(--text);
    font-weight: 600;
}

.hero-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 20px;
}

.hero-interests {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 24px;
}

.interest-tag {
    font-size: 0.74rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    padding: 4px 11px;
    border-radius: 999px;
    transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.interest-tag:hover {
    color: var(--accent);
    border-color: var(--accent-soft);
}

/* Profile photo (when set) */
.hero-avatar.has-photo {
    background: none;
    overflow: hidden;
}

.hero-avatar.has-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Profile links (ORCID / Scholar / GitHub / Email / CV ...) */
.profile-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
}

.profile-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    cursor: pointer;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
        background 0.2s var(--ease), transform 0.2s var(--ease);
}

.profile-link svg {
    flex-shrink: 0;
}

.profile-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.profile-link.copied {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

/* Sidebar section nav */
.side-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.side-nav a:hover,
.side-nav a.active {
    color: var(--text);
    background: var(--bg-subtle);
}

.side-nav-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-soft);
}

.side-nav a.active .side-nav-num {
    color: var(--accent);
}

/* ----- Content ----- */
.content {
    flex: 1;
    min-width: 0;
    padding: 64px 48px 40px;
}

.section {
    margin-bottom: 64px;
}

.section-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.section-header.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
}

.section-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.4px;
}

/* =============================================
   Education & Publications — simple list
   ============================================= */
.edu-list,
.pub-list {
    display: flex;
    flex-direction: column;
}

.edu-item,
.pub-item {
    padding: 18px 0;
    border-top: 1px solid var(--border);
    opacity: 0;
    transform: translateY(10px);
}

.edu-list .edu-item:first-child,
.pub-list .pub-item:first-child {
    border-top: none;
    padding-top: 2px;
}

.edu-item.visible,
.pub-item.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

/* Education list */
.edu-school {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.2px;
    margin-bottom: 3px;
}

.edu-dept {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.edu-line {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-soft);
}

/* Publications summary line (replaces stat boxes) */
.pub-stats {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.pub-stats b {
    color: var(--text);
    font-weight: 600;
}

/* Filters */
.pub-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.filter-chip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border-strong);
    padding: 5px 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.filter-chip:hover {
    color: var(--text);
    border-color: var(--text-soft);
}

.filter-chip.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

/* Publication item */
.pub-item {
    display: flex;
    gap: 18px;
}

.pub-item.hidden {
    display: none;
}

.pub-year-col {
    flex-shrink: 0;
    width: 88px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 2px;
}

.pub-year {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.pub-type {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.3;
    white-space: nowrap;
}

.pub-type::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-soft);
    flex-shrink: 0;
}

.pub-type-full::before     { background: #10b981; }
.pub-type-short::before    { background: #f59e0b; }
.pub-type-workshop::before { background: #6366f1; }
.pub-type-journal::before  { background: #ec4899; }
.pub-type-poster::before   { background: #38bdf8; }
.pub-type-preprint::before { background: #94a3b8; }

.pub-body {
    flex: 1;
    min-width: 0;
}

.pub-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.pub-star {
    color: #f59e0b;
    margin-right: 4px;
    vertical-align: -1px;
}

.pub-title a {
    color: var(--text);
    text-decoration: none;
    background-image: linear-gradient(var(--accent), var(--accent));
    background-size: 0% 1.5px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.25s var(--ease), color 0.2s var(--ease);
}

.pub-title a:hover {
    color: var(--accent);
    background-size: 100% 1.5px;
}

.pub-authors {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin-bottom: 3px;
    line-height: 1.5;
}

.pub-authors .author-self {
    color: var(--text);
    font-weight: 600;
}

.pub-venue-line {
    font-size: 0.82rem;
    color: var(--text-soft);
    margin-bottom: 8px;
    line-height: 1.5;
}

.pub-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.pub-link {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s var(--ease);
}

.pub-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* =============================================
   Footer
   ============================================= */
.footer {
    text-align: center;
    padding-top: 28px;
    border-top: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 0.82rem;
}

/* =============================================
   Responsive : stack sidebar on top
   ============================================= */
@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        height: auto;
        overflow: visible;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 40px 28px 28px;
    }

    .sidebar-inner {
        margin: 0;
    }

    .side-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .content {
        padding: 40px 28px;
    }
}

@media (max-width: 560px) {
    .sidebar {
        padding: 32px 20px 24px;
    }

    .content {
        padding: 32px 20px;
    }

    .profile-head {
        gap: 14px;
    }

    .hero-avatar {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }

    .pub-item {
        flex-direction: column;
        gap: 8px;
    }

    .pub-year-col {
        flex-direction: row;
        width: auto;
        align-items: center;
        gap: 10px;
        padding-top: 0;
    }
}
