:root {
    --bg: #0b0b12;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #ececec;
    --text-muted: #9a9aa6;
    --text-faint: #6b6b78;
    --accent: #8ab4ff;
    --accent-soft: rgba(138, 180, 255, 0.12);
    --gold: #f5c86b;
    --mono: 'JetBrains Mono', 'Courier New', monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 14px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

body {
    font-family: var(--sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg);
    z-index: 50;
    transition: opacity 1.2s ease-out;
    pointer-events: none;
}

.overlay.hidden {
    opacity: 0;
}

.glow {
    position: fixed;
    top: -30vh;
    left: 50%;
    width: min(900px, 100vw);
    height: 600px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(138, 180, 255, 0.12), transparent 65%);
    pointer-events: none;
    z-index: 0;
}

a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 4px;
    transition: color 0.2s, text-decoration-color 0.2s;
}

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

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem max(1.5rem, calc((100vw - 56rem) / 2));
    background: rgba(11, 11, 18, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 0.8rem;
}

.clock {
    display: flex;
    gap: 0.75rem;
    white-space: nowrap;
}

.clock .date {
    color: var(--text-faint);
}

.nav {
    display: flex;
    gap: 1.5rem;
}

.nav a {
    color: var(--text-muted);
    text-decoration: none;
}

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

/* ---------- Layout ---------- */
main {
    position: relative;
    z-index: 1;
    max-width: 56rem;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section {
    padding: 4.5rem 0 1rem;
}

.section-title {
    display: flex;
    align-items: baseline;
    gap: 0.9rem;
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text);
    margin-bottom: 2rem;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
    transform: translateY(-0.3rem);
}

.section-index {
    color: var(--accent);
    font-size: 0.8rem;
}

/* ---------- Hero ---------- */
.hero {
    padding: 7rem 0 3rem;
}

.hero-name {
    font-family: var(--mono);
    font-size: clamp(2.5rem, 7vw, 4rem);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.1;
    min-height: 1.1em;
}

.cursor {
    display: inline-block;
    width: 0.5em;
    height: 0.9em;
    margin-left: 0.1em;
    background-color: var(--accent);
    vertical-align: -0.05em;
    animation: blink 1s steps(1) infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.hero-tagline {
    margin-top: 1.25rem;
    font-size: 1.15rem;
    color: var(--text-muted);
}

.hero-quote {
    margin-top: 1.75rem;
    padding-left: 1.1rem;
    border-left: 2px solid var(--accent);
    color: var(--text-faint);
    font-style: italic;
    max-width: 36rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 3rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat-value {
    font-family: var(--mono);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.social-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2rem;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
}

.social-link svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.social-link:hover {
    color: var(--text);
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-2px);
}

/* ---------- Cards ---------- */
.card {
    position: relative;
    padding: 1.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.25s, background 0.25s;
}

.card:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card p + p {
    margin-top: 0.75rem;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.org {
    color: var(--accent);
    font-size: 0.95rem;
    margin-top: 0.15rem;
}

.card > .org {
    margin-bottom: 1rem;
}

.meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-faint);
    white-space: nowrap;
    text-align: right;
}

.card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    color: #cfcfd6;
    font-size: 0.95rem;
}

.card li {
    position: relative;
    padding-left: 1.2rem;
}

.card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-faint);
}

.card ul.compact {
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.label {
    margin-top: 1.4rem;
    margin-bottom: 0.6rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-faint);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1.25rem;
}

.label + .tags {
    margin-top: 0;
}

.tags span {
    padding: 0.25rem 0.65rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* ---------- Timeline ---------- */
.timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-left: 1.75rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.35rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 1px;
    background: linear-gradient(var(--accent), var(--border) 70%);
}

.timeline .card::before {
    content: '';
    position: absolute;
    left: calc(-1.75rem + 0.35rem - 5px);
    top: 2.1rem;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
}

/* ---------- Research ---------- */
.pub-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.pub {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 1.25rem;
    align-items: baseline;
    padding: 1.1rem 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.pub-venue {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
}

.pub p {
    color: #cfcfd6;
    font-size: 0.95rem;
}

/* ---------- Projects ---------- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.project {
    display: flex;
    flex-direction: column;
}

.project > p:not(.org) {
    font-size: 0.95rem;
    color: #cfcfd6;
}

.project .tags {
    margin-top: auto;
    padding-top: 1.25rem;
}

.project-badge {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    padding: 0.2rem 0.6rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--gold);
    background: rgba(245, 200, 107, 0.1);
    border: 1px solid rgba(245, 200, 107, 0.3);
    border-radius: 999px;
}

.project-link {
    margin-top: 1rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
}

/* ---------- Honors ---------- */
.honors-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.honor {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1.2rem 1.3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.25s, transform 0.25s;
}

.honor:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

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

.honor-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Chat ---------- */
.chat-card {
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.chat-container {
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--accent-soft);
    border: 1px solid rgba(138, 180, 255, 0.25);
}

.chat-message.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

.chat-message .sender {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-faint);
    margin-bottom: 0.2rem;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chat-input {
    flex: 1;
    min-width: 0;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text);
    font-family: var(--sans);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-button {
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.4rem;
    font-family: var(--sans);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-button:hover {
    background: var(--accent);
}

.chat-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.venmo-message {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.venmo-message.visible {
    opacity: 1;
}

/* ---------- Footer ---------- */
footer {
    position: relative;
    z-index: 1;
    margin-top: 5rem;
    padding: 2rem 1.5rem 3rem;
    text-align: center;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-faint);
    border-top: 1px solid var(--border);
}

footer a {
    color: var(--text-muted);
}

/* ---------- Reveal animation ---------- */
.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
    .cursor { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .honors-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    main { padding: 0 1rem; }
    .topbar { padding: 0.85rem 1rem; }
    .nav { display: none; }
    .hero { padding: 4.5rem 0 2rem; }
    .section { padding-top: 3.5rem; }
    .card { padding: 1.35rem; }
    .card-head { flex-direction: column; gap: 0.5rem; }
    .meta { flex-direction: row; gap: 0.75rem; align-items: flex-start; text-align: left; }
    .timeline { padding-left: 1.25rem; }
    .timeline .card::before { left: calc(-1.25rem + 0.35rem - 5px); }
    .pub { grid-template-columns: 1fr; gap: 0.35rem; }
    .honors-grid { grid-template-columns: 1fr; }
    .project-badge { position: static; align-self: flex-start; margin-bottom: 0.75rem; }
}
