
  :root {
    --bg: #FAF7F2;
    --bg-alt: #F2EDE4;
    --text: #1C1917;
    --text-muted: #78716C;
    --accent: hsl(32, 90%, 37%);
    --accent-light: hsl(32, 100%, 93%);
    --accent-hover: hsl(32, 90%, 27%);
    --border: #D6CEC3;
    --card-bg: #FFFFFF;
    --tag-bg: #EDE8DF;
    --serif: 'Instrument Serif', Georgia, serif;
    --sans: 'DM Sans', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --max-w: min(90vw, 1200px);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

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

  html { scroll-behavior: smooth; }

  body {
    font-family: var(--sans);
    background-color: var(--bg);
    background-image: radial-gradient(circle, rgba(0,0,0,0.045) 1.5px, transparent 1.5px);
    background-size: 26px 26px;
    color: var(--text);
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
  }

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

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

  /* ─── NAV ─── */
  nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(250, 247, 242, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    transition: box-shadow var(--transition);
  }
  nav.scrolled {
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
  }
  .nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
  }
  .nav-logo {
    font-family: var(--serif);
    font-size: 1.35rem;
    color: var(--text);
    letter-spacing: -0.02em;
    cursor: pointer;
  }
  .nav-logo:hover { color: var(--accent); }
  .nav-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
  }
  .nav-links a {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 450;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    transition: all var(--transition);
    letter-spacing: 0.01em;
  }
  .nav-links a:hover {
    color: var(--text);
    background: var(--bg-alt);
  }
  .nav-links a.active {
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 550;
  }

  /* mobile nav */
  .nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
  }
  .nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    margin: 5px 0;
    transition: all 0.3s;
  }

  @media (max-width: 640px) {
    .nav-toggle { display: block; }
    .nav-links {
      display: none;
      position: absolute;
      top: 64px;
      left: 0;
      right: 0;
      background: var(--bg);
      flex-direction: column;
      padding: 1rem 2rem;
      border-bottom: 1px solid var(--border);
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 0.75rem 0; }
  }

  /* ─── MAIN ─── */
  main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 2rem;
    min-height: 100vh;
  }
  @media (max-width: 480px) {
    main { padding: 0 1.1rem; }
    .nav-inner { padding: 0 1.1rem; }
  }

  .page {
    display: none;
    padding-top: 100px;
    padding-bottom: 80px;
    animation: fadeUp 0.45s ease both;
  }
  .page.active { display: block; }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ─── HOME ─── */
  .hero {
    padding: 4rem 0 3rem;
  }
  .hero-inner {
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
  }
  .hero-text {
    flex: 1;
    min-width: 0;
  }
  .hero-photo {
    flex-shrink: 0;
  }
  .profile-img-wrap {
    width: 185px;
    height: 185px;
    border-radius: 10px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
  }
  .profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  /* Initials placeholder shown when no image loads */
  .profile-img-wrap::after {
    content: 'AG';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif);
    font-size: 2.2rem;
    color: var(--text-muted);
    z-index: -1;
  }
  @media (max-width: 640px) {
    .hero-inner {
      flex-direction: column;
      gap: 1.5rem;
    }
    .profile-img-wrap { width: 110px; height: 110px; }
    .profile-img-wrap::after { font-size: 1.5rem; }
  }
  .hero-greeting {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.4rem;
    font-weight: 500;
  }
  .hero-school {
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
    line-height: 1.4;
  }
  .hero-name {
    font-family: var(--serif);
    font-size: clamp(2.2rem, 5.5vw, 3.25rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
  }
  .hero h1 {
    font-family: var(--serif);
    font-size: clamp(1.4rem, 3.5vw, 1.85rem);
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    font-weight: 400;
  }
  .hero h1 em {
    color: var(--accent);
    font-style: italic;
  }
  .hero-desc {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.75;
    margin-bottom: 2.5rem;
  }
  .hero-interests {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
  }
  .hero-interests-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
    margin-bottom: 0.6rem;
  }
  .hero-interests ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }
  .hero-interests li {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    padding-left: 0.85rem;
    position: relative;
  }
  .hero-interests li::before {
    content: '·';
    position: absolute;
    left: 0;
    color: var(--accent);
  }
  .hero-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
  }
  .hero-links a {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
    transition: all var(--transition);
  }
  .hero-links a:hover {
    color: var(--accent);
    border-color: var(--accent);
  }

  .home-section {
    margin-top: 4rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
  }
  .home-section h2 {
    font-family: var(--serif);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
  }

  .research-areas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
  }
  .research-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    transition: all var(--transition);
  }
  .research-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
  }
  .research-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
  }
  .research-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
  }

  /* ─── PAGE HEADERS ─── */
  .page-header {
    padding: 3rem 0 2.5rem;
    border-bottom: none;
    margin-bottom: 2.5rem;
    position: relative;
  }
  .page-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border) 18%, var(--border) 82%, transparent);
  }
  .page-header h1 {
    font-family: var(--serif);
    font-size: clamp(2rem, 5vw, 2.75rem);
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
  }
  .page-header p {
    color: var(--text-muted);
    font-size: 1rem;
  }
  #page-projects .page-header::after,
  #page-blog .page-header::after,
  #page-cv .page-header::after,
  #page-photos .page-header::after {
    display: none;
  }

  /* ─── PUBLICATIONS ─── */
  .pub-year {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
    letter-spacing: 0.06em;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 500;
  }
  .pub-year:first-of-type { margin-top: 0; }

  .pub-item {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--tag-bg);
    transition: all var(--transition);
  }
  .pub-item:last-child { border-bottom: none; }
  .pub-item:hover { transform: translateX(0.75rem); }
  .pub-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.35rem;
    line-height: 1.45;
  }
  .pub-title a,
  .project-card h3 a,
  .blog-item h3 a {
    color: var(--text);
    transition: color var(--transition);
  }
  .pub-title a:hover,
  .project-card h3 a:hover,
  .blog-item h3 a:hover {
    color: var(--accent);
  }
  .pub-authors {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
  }
  .pub-authors strong {
    color: var(--text);
    font-weight: 600;
  }
  .pub-venue {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
  }

  /* ─── BLOG ─── */
  .blog-list {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .blog-item {
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--tag-bg);
    cursor: pointer;
    transition: all var(--transition);
  }
  .blog-item:hover { padding-left: 0.75rem; }
  .blog-date {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
  }
  .blog-item h3 {
    font-family: var(--serif);
    font-size: 1.3rem;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    transition: color var(--transition);
  }
  .blog-item:hover h3 a { color: var(--accent); }
  .blog-item p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.65;
  }
  .blog-tags {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
  }
  .blog-tag {
    font-size: 0.72rem;
    font-family: var(--mono);
    background: var(--tag-bg);
    color: var(--text-muted);
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
  }

  /* ─── PROJECTS ─── */
  .projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
  }
  @media (max-width: 740px) {
    .projects-grid { grid-template-columns: 1fr; }
  }
  .project-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
  }
  .project-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
  }
  .project-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    margin-bottom: 1rem;
  }
  .project-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
  }
  .project-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    flex-grow: 1;
    margin-bottom: 1rem;
  }
  .project-tech {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
  }
  .project-tech span {
    font-family: var(--mono);
    font-size: 0.7rem;
    background: var(--tag-bg);
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
  }

  /* ─── CV ─── */
  .cv-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent);
    color: white;
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 3rem;
    transition: all var(--transition);
  }
  .cv-download:hover {
    background: var(--accent-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45,90,61,0.25);
  }

  .cv-section {
    margin-bottom: 3rem;
  }
  .cv-section h2 {
    font-family: var(--serif);
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
  }
  .cv-entry {
    padding: 1rem 0;
    display: grid;
    grid-template-columns: 175px 1fr;
    gap: 1.5rem;
  }
  @media (max-width: 640px) {
    .cv-entry {
      grid-template-columns: 1fr;
      gap: 0.25rem;
    }
  }
  .cv-date {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    padding-top: 0.15rem;
    white-space: nowrap;
  }
  .cv-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
  }
  .cv-content .cv-org {
    color: var(--accent);
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
  }
  .cv-content p {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.65;
  }

  /* ─── FOOTER ─── */
  footer {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 2.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
  footer span {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  .footer-links {
    display: flex;
    gap: 1.25rem;
  }
  .footer-links a {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  .footer-links a:hover { color: var(--accent); }

  /* ─── DARK MODE TOGGLE ─── */
  .theme-toggle {
    background: none;
    border: 1px solid var(--border);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all var(--transition);
    color: var(--text-muted);
  }
  .theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  /* ─── DARK THEME ─── */
  body.dark {
    --bg: #1C1917;
    --bg-alt: #292524;
    --text: #E7E5E4;
    --text-muted: #A8A29E;
    --accent: hsl(32, 92%, 58%);
    --accent-light: hsl(32, 80%, 12%);
    --accent-hover: hsl(32, 92%, 68%);
    --border: #44403C;
    --card-bg: #231F1E;
    --tag-bg: #292524;
  }
  body.dark {
    background-image: radial-gradient(circle, rgba(255,255,255,0.035) 1.5px, transparent 1.5px);
  }
  body.dark nav {
    background: rgba(28, 25, 23, 0.88);
  }

  /* ─── PHOTOS GALLERY ─── */
  .photos-grid {
    columns: 2;
    column-gap: 1rem;
  }
  @media (max-width: 640px) {
    .photos-grid { columns: 1; }
  }
  .photo-item {
    break-inside: avoid;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    background: var(--bg-alt);
    cursor: pointer;
  }
  .photo-wrap {
    overflow: hidden;
    border-radius: 10px;
    aspect-ratio: unset;
    background: transparent;
    border: none;
  }
  .photo-wrap img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .photo-item:hover .photo-wrap img {
    transform: scale(1.04);
  }
  .photo-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 100%);
    border-radius: 0 0 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: none;
  }
  .photo-item:hover .photo-caption {
    opacity: 1;
    transform: translateY(0);
  }
  .photo-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
  }
  .photo-meta {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.03em;
  }

  /* ─── LONG TEXT: PREVENT OVERFLOW ─── */
  .hero-school,
  .cv-org {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* ─── MOBILE: SPACING & LAYOUT (≤640px) ─── */
  @media (max-width: 640px) {
    /* Reduce page top padding (nav is 64px; give 16px breathing room) */
    .page {
      padding-top: 84px;
      padding-bottom: 50px;
    }

    /* Hero */
    .hero {
      padding: 1.75rem 0 1.25rem;
    }
    .hero-name {
      font-size: clamp(1.85rem, 9vw, 2.2rem);
    }
    .hero-desc {
      font-size: 0.975rem;
      margin-bottom: 1.75rem;
    }

    /* Page headers */
    .page-header {
      padding: 1.75rem 0 1.25rem;
      margin-bottom: 1.5rem;
    }

    /* Home sections */
    .home-section {
      margin-top: 2.5rem;
      padding-top: 1.75rem;
    }

    /* CV */
    .cv-section {
      margin-bottom: 2rem;
    }
    .cv-download {
      margin-bottom: 2rem;
      font-size: 0.8rem;
    }

    /* Research interests — flow horizontally under photo on mobile */
    .hero-interests ul {
      flex-direction: row;
      flex-wrap: wrap;
      gap: 0.3rem 0.75rem;
    }
    .hero-interests li {
      white-space: nowrap;
    }

  }

  /* ─── MOBILE: SMALL SCREENS (≤480px) ─── */
  @media (max-width: 480px) {
    /* Footer: stack vertically */
    footer {
      flex-direction: column;
      padding: 1.5rem 1.1rem;
      text-align: center;
      gap: 0.5rem;
    }

    /* Research areas: single column */
    .research-areas {
      grid-template-columns: 1fr;
    }

    /* Publication links: wrap if needed */
    .pub-links {
      flex-wrap: wrap;
    }

    /* Disable hover indent on touch devices (avoids layout shift) */
    .blog-item:hover {
      padding-left: 0;
    }
    .pub-item:hover {
      transform: none;
    }

    /* Page header H1 */
    .page-header h1 {
      font-size: clamp(1.6rem, 8vw, 2rem);
    }

    /* Reduce hero h1 subtitle */
    .hero h1 {
      font-size: clamp(1.15rem, 5.5vw, 1.4rem);
    }
  }
