:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --line: #e2e5ea;
  --accent: #1f4e79;
  --accent-soft: #e8eff6;
  --todo: #9a6700;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a2028;
    --text: #e4e8ee;
    --muted: #9aa5b3;
    --line: #2b333e;
    --accent: #8db8e3;
    --accent-soft: #1e2b3a;
    --todo: #d9a440;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
}

a { color: var(--accent); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.6rem; margin: 0 0 1rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.1rem; margin: 0 0 .4rem; }

main, .nav, .site-footer p { max-width: 960px; margin: 0 auto; padding: 0 16px; }
main section { padding: 2.5rem 0; }

.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; flex-wrap: wrap; }
.nav ul { display: flex; gap: 1.2rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); font-size: .95rem; }
.nav a:hover { color: var(--accent); }
.nav .brand { font-family: var(--serif); font-weight: 600; color: var(--text); font-size: 1.1rem; }

.hero { display: flex; align-items: center; gap: 2.5rem; padding-top: 3.5rem; }
.hero h1 { font-size: 2.6rem; margin: 0 0 .3rem; }
.role { color: var(--muted); margin: 0 0 1.2rem; }
.lead { font-size: 1.08rem; max-width: 40rem; }
main p, figcaption { text-align: justify; hyphens: auto; }
.links { display: flex; gap: .6rem; flex-wrap: wrap; }
.links a {
  text-decoration: none; padding: .35rem .9rem; border: 1px solid var(--accent);
  border-radius: 999px; font-size: .9rem;
}
.links a:hover { background: var(--accent-soft); }
.card .links { margin-top: 1.1rem; }
.portrait {
  flex: 0 0 160px; width: 160px; height: 160px; border-radius: 50%;
  object-fit: cover; background: var(--accent-soft);
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem; }
.card p { margin: .3rem 0; color: var(--muted); font-size: .95rem; }
.card.code { grid-column: 1 / -1; }
figure { margin: 1rem 0; }
figure img { width: 100%; height: auto; border-radius: 6px; background: #fff; padding: .4rem; border: 1px solid var(--line); }
figcaption { font-size: .85rem; color: var(--muted); margin-top: .4rem; }
.figs { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1rem 0; align-items: start; }
.figs figure { margin: 0; }
.figs img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #f3f4f6; }
.tags { display: flex; gap: .4rem; flex-wrap: wrap; }
.tags span { font-size: .78rem; padding: .1rem .55rem; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }

.muted { color: var(--muted); }
.todo { color: var(--todo) !important; font-style: italic; }

.pub-tools { display: flex; gap: 1rem; justify-content: space-between; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.filters button {
  font: inherit; font-size: .88rem; cursor: pointer;
  padding: .3rem .8rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.filters button.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }
#pub-search {
  font: inherit; font-size: .9rem; padding: .35rem .7rem; min-width: 16rem; flex: 0 1 22rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text);
}

.pub-year { font-family: var(--serif); font-size: 1.15rem; margin: 1.6rem 0 .4rem; color: var(--accent); }
.pub { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.pub-title { font-weight: 600; }
.pub-authors, .pub-venue { font-size: .9rem; color: var(--muted); }
.pub-authors b { color: var(--text); font-weight: 600; }
.pub-venue i { font-style: italic; }
.pub-badge {
  display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 0 .4rem; margin-right: .4rem; border-radius: 3px; vertical-align: .1em;
  border: 1px solid var(--line); color: var(--muted);
}
.pub-links a { font-size: .82rem; margin-right: .7rem; }

.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0; color: var(--muted); font-size: .85rem; }

@media (max-width: 640px) {
  .hero { flex-direction: column-reverse; align-items: flex-start; gap: 1.2rem; padding-top: 2rem; }
  .hero h1 { font-size: 2rem; }
  .portrait { flex-basis: auto; width: 112px; height: 112px; }
  .nav ul { gap: .8rem; }
  #pub-search { min-width: 0; width: 100%; }
  .figs { grid-template-columns: 1fr; }
}
