@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Inter:wght@300;400;500;600&display=swap');

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

:root {
  --bg: #ffffff; --bg-secondary: #f7fafc; --text: #1a202c; --text-secondary: #4a5568;
  --card-bg: #ffffff; --border: #e2e8f0; --primary: #2c5282; --primary-hover: #2a4365;
  --link: #2c5282; --link-hover: #1a365d; --nav-bg: #ffffff; --nav-text: #2d3748;
  --footer-bg: #f7fafc; --footer-text: #718096; --code-bg: #edf2f7; --code-text: #2d3748;
  --shadow: 0 1px 3px rgba(0,0,0,0.08); --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --navbar-height: 64px;
}

[data-theme="dark"] {
  --bg: #0d1117; --bg-secondary: #161b22; --text: #c9d1d9; --text-secondary: #8b949e;
  --card-bg: #161b22; --border: #30363d; --primary: #63b3ed; --primary-hover: #90cdf4;
  --link: #63b3ed; --link-hover: #90cdf4; --nav-bg: #0d1117; --nav-text: #c9d1d9;
  --footer-bg: #161b22; --footer-text: #8b949e; --code-bg: #21262d; --code-text: #c9d1d9;
  --shadow: 0 1px 3px rgba(0,0,0,0.3); --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-family: 'Lora', Georgia, serif; font-weight: 600; line-height: 1.3; color: var(--text); }

a { color: var(--link); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--link-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* Navbar */
.navbar { position: sticky; top: 0; z-index: 100; background: var(--nav-bg); border-bottom: 1px solid var(--border); height: var(--navbar-height); display: flex; align-items: center; }
.navbar .container { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 1100px; padding: 0 1.5rem; }
.navbrand { font-family: 'Lora', Georgia, serif; font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.navbrand:hover { text-decoration: none; color: var(--primary); }
.navlinks { display: flex; align-items: center; gap: 0.25rem; list-style: none; }
.navlinks a { padding: 0.5rem 0.85rem; border-radius: 0.375rem; font-size: 0.9rem; font-weight: 500; color: var(--nav-text); transition: background-color 0.2s, color 0.2s; }
.navlinks a:hover { background: var(--bg-secondary); color: var(--primary); text-decoration: none; }
.navlinks a.active { color: var(--primary); background: var(--bg-secondary); }

.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 0.375rem; padding: 0.4rem 0.6rem; cursor: pointer; color: var(--text); transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; }
.theme-toggle:hover { background: var(--bg-secondary); border-color: var(--primary); }

.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 0.375rem; padding: 0.4rem 0.5rem; cursor: pointer; flex-direction: column; gap: 4px; margin-left: 0.5rem; }
.menu-toggle-bar { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; transition: all 0.3s ease; }
.menu-toggle[aria-expanded="true"] .menu-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle-bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .menu-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.page { padding-top: 3rem; padding-bottom: 4rem; min-height: calc(100vh - var(--navbar-height)); }
.pageheader { margin-bottom: 2.5rem; }
.pageheader h1 { font-size: 2rem; margin-bottom: 0.5rem; }

.profile { display: flex; gap: 2.5rem; align-items: flex-start; margin-bottom: 2rem; }
.profilephoto { flex-shrink: 0; width: 160px; height: 160px; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); }
.profileinfo h1 { font-size: 2.25rem; margin-bottom: 0.75rem; }
.profileinfo .lead { font-size: 1.1rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 0.75rem; }
.profileinfo p { margin-bottom: 0.75rem; }

.newssection { margin-top: 2.5rem; }
.newssection h2 { font-size: 1.4rem; margin-bottom: 1.25rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.newslist { list-style: none; }
.newsitem { display: flex; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.newsitem:last-child { border-bottom: none; }
.newsdate { flex-shrink: 0; width: 110px; font-size: 0.875rem; color: var(--text-secondary); padding-top: 0.15rem; }
.newscontent { font-size: 0.95rem; }
.newscontent a { font-weight: 500; }

.publist { list-style: none; }
.pubitem { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.pubitem:last-child { border-bottom: none; }
.pubyear { font-size: 0.875rem; font-weight: 600; color: var(--primary); margin-bottom: 0.5rem; }
.pubtitle { font-family: 'Lora', Georgia, serif; font-size: 1.1rem; font-weight: 600; margin-bottom: 0.35rem; }
.pubauthors { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.pubvenue { font-size: 0.875rem; color: var(--text-secondary); font-style: italic; }
.publinks { display: flex; gap: 1rem; margin-top: 0.5rem; flex-wrap: wrap; }
.publinks a { font-size: 0.875rem; font-weight: 500; }

.projectgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.projectcard { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden; background: var(--card-bg); box-shadow: var(--shadow); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.projectcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.projectcard img { width: 100%; height: 180px; object-fit: cover; border-bottom: 1px solid var(--border); }
.projectcardbody { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; }
.projectcardbody h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.projectcardbody p { font-size: 0.9rem; color: var(--text-secondary); flex: 1; margin-bottom: 0.75rem; }
.projectcard a { font-size: 0.875rem; font-weight: 500; color: var(--primary); }
.projectcard a:hover { text-decoration: underline; }

.projectdetail { max-width: 850px; margin: 0 auto; }
.projectdetail h1 { font-size: 1.9rem; margin-bottom: 1rem; }
.projectmeta { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.projectmeta a { font-weight: 500; }
.projectlinks { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.projectlinks a { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 0.375rem; background: var(--card-bg); font-size: 0.875rem; font-weight: 500; transition: all 0.2s; }
.projectlinks a:hover { border-color: var(--primary); background: var(--bg-secondary); text-decoration: none; }
.projectabstract { margin: 1.5rem 0; padding: 1.5rem; background: var(--bg-secondary); border-radius: 0.5rem; border: 1px solid var(--border); font-size: 0.95rem; line-height: 1.8; }
.projectabstract h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.projectsection { margin: 2rem 0; }
.projectsection h2 { font-size: 1.25rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

.bibtex { background: var(--code-bg); color: var(--code-text); padding: 1.25rem; border-radius: 0.5rem; border: 1px solid var(--border); font-family: 'Courier New', monospace; font-size: 0.8rem; line-height: 1.6; overflow-x: auto; white-space: pre; }

.herotriptych { display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 0; border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border); margin-bottom: 1.5rem; }
.herotriptych img { width: 100%; height: 280px; object-fit: cover; display: block; border: none; }
.herotriptych video { width: 100%; height: 280px; object-fit: cover; display: block; }
.herovid { width: 100%; height: 280px; overflow: hidden; }
.herovid video { width: 100%; height: 100%; object-fit: cover; display: block; }

.statsgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.statcard { padding: 1.25rem; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 0.5rem; text-align: center; }
.statnum { font-family: 'Lora', serif; font-size: 1.75rem; font-weight: 700; color: var(--primary); margin-bottom: 0.25rem; }
.statlbl { font-size: 0.85rem; color: var(--text-secondary); }

.cvsection { margin-bottom: 2.5rem; }
.cvsection h2 { font-size: 1.3rem; margin-bottom: 1.25rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.cventry { margin-bottom: 1.5rem; padding-left: 1rem; border-left: 3px solid var(--primary); }
.cventryheader { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.25rem; }
.cventrytitle { font-weight: 600; font-size: 1rem; }
.cventrydate { font-size: 0.85rem; color: var(--text-secondary); }
.cventrysubtitle { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.cventrysubtitle a { color: var(--primary); }
.cventrybody { font-size: 0.9rem; color: var(--text-secondary); }

.reposection { margin-bottom: 3rem; }
.reposection h2 { font-size: 1.2rem; margin-bottom: 1.25rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.githubUser { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.ghLink img, .ghstat img { display: block; height: auto; }
.repoStats { display: flex; flex-direction: column; gap: 1.5rem; }
.repogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.repocard { border: 1px solid var(--border); border-radius: 0.5rem; padding: 1.25rem; background: var(--card-bg); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.75rem; }
.repoHeader { display: flex; justify-content: space-between; align-items: center; text-decoration: none; }
.repoName { font-family: 'Lora', serif; font-size: 1rem; font-weight: 600; color: var(--link); }
.repoStar { height: 18px; }
.repoDesc { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5; flex: 1; }
.repoTopics { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.topic { display: inline-block; padding: 0.15rem 0.6rem; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 9999px; font-size: 0.75rem; color: var(--text-secondary); }
.repoBtn { display: inline-block; text-align: center; padding: 0.5rem 1rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: 0.375rem; font-size: 0.875rem; font-weight: 500; color: var(--primary); text-decoration: none; transition: all 0.2s; }
.repoBtn:hover { border-color: var(--primary); background: var(--bg-secondary); text-decoration: none; }

.sociallinks { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.sociallinks a { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: 0.375rem; background: var(--card-bg); font-size: 0.875rem; color: var(--text-secondary); transition: all 0.2s; }
.sociallinks a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

.footer { background: var(--footer-bg); border-top: 1px solid var(--border); padding: 2rem 0; text-align: center; font-size: 0.85rem; color: var(--footer-text); }
.footer a { color: var(--footer-text); }
.footer a:hover { color: var(--primary); }

.sectiondivider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.archimage { width: 100%; border-radius: 0.5rem; border: 1px solid var(--border); margin-bottom: 1rem; }

@media (max-width: 768px) {
  .profile { flex-direction: column; align-items: center; text-align: center; }
  .profilephoto { width: 140px; height: 140px; }
  .navlinks { gap: 0; }
  .navlinks a { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
  .pageheader h1 { font-size: 1.6rem; }
  .newsitem { flex-direction: column; gap: 0.35rem; }
  .newsdate { width: auto; }
  .herotriptych { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .herotriptych img, .herovid { height: 200px; }
  .herovid video { height: 200px; }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .menu-toggle { display: flex; }
  .navlinks {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    box-shadow: var(--shadow-md);
  }
  .navlinks.open { display: flex; }
  .navlinks li { width: 100%; }
  .navlinks a { display: block; padding: 0.75rem 1.5rem; font-size: 0.95rem; border-radius: 0; }
  .navbar { position: sticky; }
  .navbar .container { position: relative; }
}
