/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #ffffff;
  --bg-alt:      #f7f7f8;
  --bg-card:     #ffffff;
  --fg:          #1a1a1a;
  --fg-muted:    #5f6368;
  --accent:      #1a56db;
  --accent-hover:#1444b0;
  --accent-bg:   #eef2ff;
  --border:      #e2e5e9;
  --code-bg:     #f3f4f6;
  --shadow:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg:   0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --radius:      6px;
  --radius-lg:   10px;
  --max-width:   820px;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

[data-theme="dark"] {
  --bg:          #111215;
  --bg-alt:      #1a1b1f;
  --bg-card:     #1e1f24;
  --fg:          #e2e4e8;
  --fg-muted:    #9ca0a8;
  --accent:      #6b9eff;
  --accent-hover:#93b8ff;
  --accent-bg:   #1c2536;
  --border:      #2e3038;
  --code-bg:     #22242a;
  --shadow:      0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg:   0 4px 12px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.2);
}

html {
  font-size: 17px;
  line-height: 1.65;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  transition: background 0.25s, color 0.25s;
}

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

/* ── Layout ── */
.site-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Header / Nav ── */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  margin-bottom: 2.5rem;
  border-bottom: 2px solid var(--border);
}

.site-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.site-title:hover { text-decoration: none; color: var(--accent); }

nav { display: flex; align-items: center; gap: 1.5rem; }
nav a {
  color: var(--fg-muted);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
nav a:hover {
  color: var(--accent);
  text-decoration: none;
  border-bottom-color: var(--accent);
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 0.95rem;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
  background: var(--bg);
}

/* ── Footer ── */
.site-footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  border-top: 2px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* ── Content ── */
.content h1 {
  font-size: 1.85rem;
  margin-bottom: 1rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.content h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.75rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.content p  { margin-bottom: 1rem; }
.content ul, .content ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.content li { margin-bottom: 0.3rem; }
.content img { max-width: 100%; height: auto; border-radius: var(--radius); }
.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  color: var(--fg-muted);
  margin: 1rem 0;
  background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.content code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius);
  font-size: 0.88em;
}
.content pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1rem;
}
.content pre code { background: none; padding: 0; }

/* ── Homepage Hero ── */
.homepage-hero {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-bottom: 3rem;
  padding: 2rem;
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.hero-photo {
  flex-shrink: 0;
}
.hero-photo img {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-bio h1 {
  font-size: 1.85rem;
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  color: var(--fg-muted);
  font-size: 1rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.hero-bio p { margin-bottom: 0.6rem; font-size: 0.95rem; }
.hero-bio ul { margin-bottom: 0.5rem; padding-left: 1.25rem; font-size: 0.93rem; }
.hero-bio li { margin-bottom: 0.15rem; }

/* Social icon links */
.social-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.social-links a {
  color: var(--fg-muted);
  transition: color 0.15s;
}
.social-links a:hover { color: var(--accent); }
.social-links svg { vertical-align: middle; }

/* ── Homepage Sections ── */
.homepage-section {
  margin-bottom: 3rem;
}
.homepage-section h2 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

/* ── Section header ── */
.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Paper list ── */
.paper-entry {
  margin-bottom: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.paper-entry:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.paper-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.paper-meta {
  margin-bottom: 0.5rem;
}

.paper-authors {
  color: var(--fg-muted);
  font-size: 0.88rem;
  margin: 0.2rem 0;
}

.paper-abstract {
  color: var(--fg);
  font-size: 0.93rem;
  line-height: 1.65;
  text-align: justify;
}

.paper-venue {
  font-size: 0.88rem;
  color: var(--fg-muted);
  font-style: italic;
}

.paper-note {
  font-size: 0.82rem;
  font-weight: 500;
  color: #92400e;
  margin-top: 0.2rem;
}
[data-theme="dark"] .paper-note {
  color: #fbbf24;
}

.paper-links {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.paper-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.6rem;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: var(--radius);
  font-weight: 500;
  transition: background 0.15s;
}
.paper-links a:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* BibTeX */
.bibtex-wrapper { display: inline-flex; }

.bibtex-toggle {
  background: var(--accent-bg);
  border: none;
  border-radius: var(--radius);
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-sans);
  transition: background 0.15s;
}
.bibtex-toggle:hover {
  background: var(--accent);
  color: #fff;
}

.bibtex-block {
  display: none;
  margin-top: 0.5rem;
  position: relative;
}
.bibtex-block.open { display: block; }

.bibtex-block pre {
  background: var(--code-bg);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  border: 1px solid var(--border);
}

.bibtex-copy {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--fg-muted);
  font-family: var(--font-sans);
  transition: background 0.15s;
}
.bibtex-copy:hover { color: var(--fg); background: var(--bg-alt); }

/* ── Software list ── */
.software-entry {
  margin-bottom: 0.75rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.software-entry:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.software-entry h3 {
  margin-top: 0;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}
.software-description { margin: 0.3rem 0; font-size: 0.93rem; }
.software-description p { margin-bottom: 0.4rem; }
.software-links {
  font-size: 0.85rem;
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.software-links a {
  padding: 0.2rem 0.6rem;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: var(--radius);
  font-weight: 500;
}
.software-links a:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* ── Blog list ── */
.post-entry { margin-bottom: 1.25rem; }
.post-date { color: var(--fg-muted); font-size: 0.85rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .site-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  nav { flex-wrap: wrap; gap: 1rem; }
  .homepage-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
  }
  .hero-photo img { width: 140px; height: 140px; }
  .hero-bio ul { text-align: left; }
  .paper-entry { padding: 0.75rem 1rem; }
}
