:root {
    --bg: #f6f4ef;
    --bg-2: #efece4;
    --ink: #262421;
    --ink-soft: #57534c;
    --ink-faint: #8a857a;
    --line: rgba(38,36,33,0.12);
    --line-soft: rgba(38,36,33,0.08);
    --accent: #5b6b52;
    --accent-2: #7a4f3a;
    --card: #fbfaf7;
    --shadow: 0 1px 2px rgba(38,36,33,0.04);
  }
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; }

  body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.65;
    font-size: 16px;
  }

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

  h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 500; letter-spacing: -0.01em; }

  /* ===== Preloader ===== */
  #preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.1rem;
    background: var(--bg);
    transition: opacity 0.5s ease, visibility 0.5s ease;
  }
  #preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .preloader-mark {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    opacity: 0;
    animation: preloader-fade 1.1s ease forwards;
  }
  .preloader-ring {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    animation: preloader-spin 0.8s linear infinite;
  }
  @keyframes preloader-spin { to { transform: rotate(360deg); } }
  @keyframes preloader-fade {
    0% { opacity: 0; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
  }

  body.loading { overflow: hidden; }

  /* Fade the page in once loaded */
  .wrapper, footer {
    opacity: 0;
  }
  body:not(.loading) .wrapper,
  body:not(.loading) footer {
    opacity: 1;
    transition: opacity 0.6s ease 0.1s;
  }

  /* ===== Scroll reveal ===== */
  .reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1), transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .reveal.in-view {
    opacity: 1;
    transform: translateY(0);
  }
  .reveal-stagger.in-view .reveal-child {
    opacity: 1;
    transform: translateY(0);
  }
  .reveal-child {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal, .reveal-child, #preloader, .preloader-mark, .preloader-ring, .wrapper, footer {
      transition: none !important;
      animation: none !important;
      opacity: 1 !important;
      transform: none !important;
    }
  }

  nav {
    position: sticky;
    top: 0; left: 0; right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 3rem;
    background: rgba(246,244,239,0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
  }
  .nav-logo {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    color: var(--ink);
  }
  .nav-links { display: flex; gap: 2.5rem; list-style: none; }
  .nav-links a {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    transition: color 0.2s;
    position: relative;
  }
  .nav-links a:hover { color: var(--accent); }
  .nav-links a::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: -0.45rem;
    left: 0;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.2s ease;
  }
  .nav-links a:hover::after { transform: scaleX(1); transform-origin: left; }
  .nav-cv-link { display: inline-flex; align-items: center; gap: 0.4rem; }
  .nav-cv-link svg { width: 14px; height: 14px; }
  .nav-toggle { display: none; }

  /* ── WRAPPER ── */
  .wrapper { position: relative; z-index: 1; }

  /* ── SECTIONS ── */
  section { padding: 6rem 0; }
  .container { max-width: 1100px; margin: 0 auto; padding: 0 2.5rem; }

  /* ── HERO ── */
  #hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .nav-toggle {
    width: 40px;
    height: 40px;
    margin-left: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.2s;
  }
  .nav-toggle:hover { border-color: var(--accent); }
  .nav-toggle-bars {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 12px;
    position: relative;
  }
  .nav-toggle-bars span {
    display: block;
    position: absolute;
    width: 16px;
    height: 1px;
    background: currentColor;
    transition: transform 0.25s ease, opacity 0.2s, top 0.25s ease;
  }
  .nav-toggle-bars span:nth-child(1) { top: 0; }
  .nav-toggle-bars span:nth-child(2) { top: 5.5px; }
  .nav-toggle-bars span:nth-child(3) { top: 11px; }
  nav.open .nav-toggle-bars span:nth-child(1) { top: 5.5px; transform: rotate(45deg); }
  nav.open .nav-toggle-bars span:nth-child(2) { opacity: 0; }
  nav.open .nav-toggle-bars span:nth-child(3) { top: 5.5px; transform: rotate(-45deg); }

  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(38,36,33,0.25);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  nav.open + .nav-backdrop { display: block; opacity: 1; }
  body.nav-locked { overflow: hidden; }

  section { padding: 5.5rem 0; }
  .container { max-width: 1040px; margin: 0 auto; padding: 0 2.5rem; }

  #hero { padding-top: 4.5rem; padding-bottom: 4.5rem; }
  .hero-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4rem;
    align-items: center;
  }
  .hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    font-weight: 500;
  }
  .hero-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
  .hero-name {
    font-size: clamp(2.6rem, 6vw, 4.2rem);
    font-weight: 500;
    line-height: 1.02;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 0.9rem;
  }
  .hero-tagline {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-faint);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 1.6rem;
  }
  .hero-desc {
    font-size: 1.02rem;
    color: var(--ink-soft);
    max-width: 500px;
    line-height: 1.75;
    margin-bottom: 2.2rem;
  }
  .hero-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 2.2rem;
  }
  .contact-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--ink-soft);
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s, transform 0.2s;
  }
  .contact-pill:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
  .contact-pill svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.75; }

  .hero-btns { display: flex; gap: 0.85rem; flex-wrap: wrap; }
  .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--ink);
    color: var(--bg);
    font-weight: 500;
    font-size: 0.86rem;
    letter-spacing: 0.01em;
    padding: 0.78rem 1.6rem;
    border-radius: 6px;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.2s;
  }
  .btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }
  .btn-primary svg { width: 15px; height: 15px; }
  .btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 0.86rem;
    padding: 0.78rem 1.6rem;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
  }
  .btn-ghost:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
  .btn-ghost svg { width: 15px; height: 15px; }

  .hero-avatar {
    width: 260px;
    height: 320px;
    border-radius: 12px;
    border: 1px solid var(--line);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    background: var(--bg-2);
  }
  .avatar-photo { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(15%); }
  .avatar-info {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(38,36,33,0) 55%, rgba(38,36,33,0.75) 100%);
  }
  .avatar-label { font-size: 0.7rem; color: #f6f4ef; letter-spacing: 0.06em; text-transform: uppercase; }
  .avatar-corner {
    margin-top: 0.4rem;
    color: #e9e6dd;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
  }

  .sec-header { margin-bottom: 2.6rem; }
  .sec-eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-weight: 500;
  }
  .sec-title {
    font-size: clamp(1.6rem, 3.2vw, 2.2rem);
    font-weight: 500;
    letter-spacing: -0.015em;
    line-height: 1.15;
    color: var(--ink);
  }

  .highlights-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
  }
  .highlight-card {
    background: var(--card);
    padding: 1.6rem;
    transition: background 0.2s;
  }
  .highlight-card:hover { background: var(--bg-2); }
  .highlight-title {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: 1rem;
    margin-bottom: 0.4rem;
    color: var(--ink);
  }
  .highlight-desc { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.6; }

  .projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
  }
  .project-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--card);
    padding: 1.9rem;
    text-decoration: none;
    transition: background 0.2s;
  }
  .project-card:hover { background: var(--bg-2); }
  .project-content { flex: 1; }
  .project-title {
    font-family: 'Fraunces', serif;
    font-size: 1.08rem;
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.01em;
  }
  .project-desc {
    font-size: 0.87rem;
    color: var(--ink-soft);
    margin: 0 0 1.1rem 0;
    line-height: 1.6;
  }
  .project-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .project-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.6rem;
    border-radius: 4px;
    background: var(--bg-2);
    color: var(--ink-faint);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.03em;
  }
  .project-arrow {
    font-size: 1.1rem;
    color: var(--ink-faint);
    margin-left: 1rem;
    transition: transform 0.25s, color 0.2s;
    align-self: center;
    flex-shrink: 0;
  }
  .project-card:hover .project-arrow { transform: translateX(4px); color: var(--accent); }

  .education-grid {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 2.2rem;
  }
  .education-meta { display: grid; gap: 1.2rem; align-content: start; }
  .education-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.6rem 1.8rem;
  }
  .education-card-badge {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.7rem;
  }
  .education-card h3 { font-size: 1.02rem; color: var(--ink); line-height: 1.4; margin-bottom: 0.4rem; }
  .education-card p { color: var(--ink-soft); line-height: 1.65; font-size: 0.88rem; }
  .education-highlights { list-style: none; display: grid; gap: 0.6rem; color: var(--ink-soft); font-size: 0.88rem; line-height: 1.6; }
  .education-highlights li { position: relative; padding-left: 1rem; }
  .education-highlights li::before { content: '—'; position: absolute; left: 0; color: var(--ink-faint); }

  .timeline {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.8rem;
  }
  .timeline-item {
    display: grid;
    grid-template-columns: 120px 1px 1fr;
    gap: 0 1.2rem;
    padding-bottom: 1.6rem;
  }
  .timeline-item:last-child { padding-bottom: 0; }
  .timeline-date { text-align: right; padding-top: 0.15rem; }
  .timeline-date-range { font-size: 0.75rem; font-weight: 500; color: var(--ink); letter-spacing: 0.01em; }
  .timeline-date-place { font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.2rem; }
  .timeline-line { display: flex; flex-direction: column; align-items: center; position: relative; }
  .timeline-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 0.3rem; }
  .timeline-track { flex: 1; width: 1px; background: var(--line); margin-top: 4px; }
  .timeline-item:last-child .timeline-track { display: none; }
  .timeline-content { padding-bottom: 0.2rem; }
  .timeline-role { font-family: 'Fraunces', serif; font-weight: 500; font-size: 1rem; margin-bottom: 0.35rem; color: var(--ink); }
  .timeline-org { font-size: 0.8rem; color: var(--ink-faint); margin-bottom: 0.7rem; }
  .timeline-bullets { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; color: var(--ink-soft); line-height: 1.55; font-size: 0.85rem; }
  .timeline-bullets li { position: relative; padding-left: 0.9rem; }
  .timeline-bullets li::before { content: '—'; position: absolute; left: 0; color: var(--ink-faint); }
  .timeline-awards { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
  .award-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.65rem;
    border-radius: 4px;
    background: var(--bg-2);
    color: var(--ink-soft);
    font-size: 0.7rem;
    font-weight: 500;
  }
  .subject-list { font-size: 0.84rem; color: var(--ink-soft); line-height: 1.6; }

  .skills-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }
  .skill-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 1rem; margin-bottom: 2rem; }
  .skill-category { min-width: 0; }
  .skills-group-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 0.9rem;
  }
  .skill-tags { display: flex; flex-wrap: wrap; gap: 0.45rem; }
  .skill-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--card);
    color: var(--ink-soft);
    font-size: 0.78rem;
    transition: border-color 0.2s, color 0.2s, transform 0.2s;
  }
  .skill-tag:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
  .skill-tag i { font-size: 1rem; color: var(--accent); }
  .tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .tag {
    display: inline-flex;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.42rem 0.85rem;
    font-size: 0.82rem;
    color: var(--ink-soft);
    transition: border-color 0.2s, color 0.2s;
  }
  .tag:hover { border-color: var(--accent); color: var(--ink); }

  .lang-bars { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.4rem; }
  .lang-top { display: flex; justify-content: space-between; margin-bottom: 0.35rem; }
  .lang-name { font-size: 0.87rem; font-weight: 500; color: var(--ink); }
  .lang-level { font-size: 0.75rem; color: var(--ink-faint); }
  .lang-bar-bg { height: 3px; background: var(--bg-2); border-radius: 3px; overflow: hidden; }
  .lang-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    width: 0 !important;
    transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .certs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.8rem;
  }
  .cert-card {
    min-height: 92px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  }
  .cert-card:hover { background: var(--bg-2); border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(38,36,33,0.07); }
  .cert-icon {
    width: 2.45rem;
    height: 2.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 7px;
    background: var(--bg-2);
    color: var(--accent);
    font-size: 1.3rem;
  }
  .cert-icon-shield { font-family: 'Fraunces', serif; font-size: 1.55rem; color: var(--accent-2); }
  .cert-name { flex: 1; font-size: 0.85rem; font-weight: 500; line-height: 1.35; color: var(--ink); }
  .cert-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 0.18rem; }
  .cert-provider { color: var(--ink-faint); font-size: 0.68rem; line-height: 1.3; }
  .cert-download { color: var(--ink-faint); font-size: 1.1rem; transition: color 0.2s, transform 0.2s; }
  .cert-card:hover .cert-download { color: var(--accent); transform: translateY(2px); }

  .accomplishment-block {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 1.9rem 2.2rem;
    font-size: 0.98rem;
    color: var(--ink-soft);
    line-height: 1.75;
  }

  .info-pills { display: flex; flex-wrap: wrap; gap: 0.6rem; }
  .info-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem 1.2rem;
    font-size: 0.88rem;
    color: var(--text-muted);
  }
  .info-pill .dot-cyan { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-cyan); flex-shrink: 0; }
  .info-pill .dot-teal { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-teal); flex-shrink: 0; }
  .info-pill .dot-violet { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-violet); flex-shrink: 0; }

  footer {
    border-top: 1px solid var(--line);
    padding: 2.2rem 2.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--ink-faint);
  }
  footer a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line); }
  footer a:hover { color: var(--ink); }

  .sec-divider { width: 100%; height: 1px; background: var(--line-soft); max-width: 1040px; margin: 0 auto; }

  /* Scroll-to-top button */
  #to-top {
    position: fixed;
    right: 1.6rem;
    bottom: 1.6rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--bg);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 80;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 6px 18px rgba(38,36,33,0.18);
  }
  #to-top.visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
  #to-top:hover { opacity: 0.85; }
  #to-top svg { width: 16px; height: 16px; }

  @media (max-width: 900px) {
    nav { padding: 1rem 1.5rem; }
    .hero-inner { grid-template-columns: 1fr; }
    .hero-avatar { display: none; }
    .highlights-grid { grid-template-columns: repeat(2, 1fr); }
    .education-grid { grid-template-columns: 1fr; }
    .timeline-item { grid-template-columns: 1px 1fr; }
    .timeline-date { display: none; }
    .skills-layout { grid-template-columns: 1fr; }
    .skill-groups { grid-template-columns: 1fr; }
  }
  @media (max-width: 600px) {
    .highlights-grid { grid-template-columns: 1fr; }
    nav { padding: 0.85rem 1rem; }
    .nav-toggle { display: block; }
    .nav-links {
      display: flex;
      position: absolute;
      top: calc(100% + 0.5rem);
      right: 1rem;
      left: 1rem;
      flex-direction: column;
      gap: 0;
      padding: 0.5rem;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--card);
      box-shadow: 0 12px 30px rgba(38,36,33,0.12);
      opacity: 0;
      pointer-events: none;
      transform: translateY(-8px);
      transition: opacity 0.2s ease, transform 0.2s ease;
    }
    nav.open .nav-links { opacity: 1; pointer-events: auto; transform: translateY(0); }
    .nav-links li { width: 100%; }
    .nav-links a { display: flex; padding: 0.75rem 0.8rem; }
    .nav-links a::after { display: none; }
  }