:root {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --border: #e4e7ec;
  --text: #1d2939;
  --muted: #5d6b82;
  --accent: #1f5f99;
  --accent-soft: #e8f0f8;
  --radius: 10px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

img { max-width: 100%; height: auto; }

h1, h2, h3, h4 { color: var(--text); line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p, ul { margin: 0 0 1em; }

/* ---------- Layout ---------- */
.wrapper {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 32px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 64px;
}

.sidebar {
  position: sticky;
  top: 56px;
  align-self: start;
}

.avatar {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 20px;
}

.name { font-size: 1.75rem; margin-bottom: 4px; }
.name a { color: var(--text); }
.name a:hover { text-decoration: none; }

.tagline { color: var(--accent); font-weight: 500; font-size: .95rem; margin-bottom: 16px; }
.bio { color: var(--muted); font-size: .92rem; }

.links { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  background: var(--bg);
  transition: border-color .15s, color .15s, background .15s;
}
.btn:hover, .btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.content { min-width: 0; }

/* ---------- Sections ---------- */
.section { margin-bottom: 56px; scroll-margin-top: 24px; }
.section > h2 {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 24px;
}

/* Publication */
.pub { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: start; }
.pub img { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.pub h3 { margin-bottom: 4px; }
.pub .authors { color: var(--muted); font-size: .9rem; margin-bottom: 2px; }
.venue { display: inline-block; font-weight: 600; font-size: .8rem; color: var(--accent); background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; margin-bottom: 10px; }
.pub p.summary { font-size: .93rem; }

/* Timeline (experience / education) */
.entry { margin-bottom: 24px; }
.entry-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.entry-head h3 { margin: 0; }
.entry .when { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.entry .role { color: var(--muted); margin: 0 0 6px; font-size: .92rem; }
.entry ul { padding-left: 18px; font-size: .93rem; }
.entry li { margin-bottom: 4px; }

/* Project cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  list-style: none;
  padding: 0;
}
.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: inherit;
  background: var(--bg);
  height: 100%;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.card:hover, .card:focus-visible {
  text-decoration: none;
  border-color: #cfd6e0;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .08);
  transform: translateY(-2px);
}
.card .thumb {
  aspect-ratio: 16 / 10;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}
.card .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.card .body { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.card h3 { font-size: 1rem; margin-bottom: 6px; }
.card p { color: var(--muted); font-size: .88rem; margin-bottom: 12px; flex: 1; }

/* Tags */
.tags { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.card .tags { margin: 0; }
.tags li {
  font-size: .75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 6px;
}

/* ---------- Project pages ---------- */
.project-page h1 { font-size: 1.8rem; }
.project-page .back { display: inline-block; font-size: .9rem; margin-bottom: 20px; }
.project-page .meta { color: var(--muted); margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.prose { max-width: 720px; }
.prose p { text-align: justify; }
.prose h2 { font-size: 1.1rem; margin-top: 1.8em; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose .lead { font-size: 1.05rem; color: var(--text); }
figure { margin: 28px 0; text-align: center; }
figure img { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
figure.narrow img { max-width: 420px; }
figure.pair { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
figure.pair img { flex: 1 1 260px; max-width: 340px; object-fit: contain; }
figure.pair figcaption { flex-basis: 100%; }
figcaption { color: var(--muted); font-size: .85rem; margin-top: 8px; }

.site-footer { color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .wrapper { grid-template-columns: 1fr; gap: 40px; padding: 32px 16px; }
  .sidebar { position: static; text-align: center; }
  .avatar { margin: 0 auto 16px; max-width: 240px; }
  .bio { text-align: left; }
  .links { justify-content: center; }
}

@media (max-width: 560px) {
  .pub { grid-template-columns: 1fr; }
  .pub img { max-width: 240px; }
  .entry .when { white-space: normal; }
}

@media print {
  .sidebar { position: static; }
  .card { break-inside: avoid; }
}
