:root {
  --bg: #f7f4ef;
  --bg-tint: #efe9e0;
  --bg-raised: #fffdf9;
  --ink: #1b1917;
  --muted: #5d574f;
  --line: #e3dbd0;
  --line-strong: #d2c8ba;
  --accent: #0f4c5c;
  --accent-hover: #0a3540;
  --accent-soft: rgba(15, 76, 92, 0.08);
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 10px 28px rgba(28, 25, 23, 0.06);
  --shadow-lift: 0 2px 4px rgba(28, 25, 23, 0.05), 0 16px 38px rgba(28, 25, 23, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --max: 50rem;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f;
    --bg-tint: #1c1915;
    --bg-raised: #201d18;
    --ink: #f4efe7;
    --muted: #b5aa9d;
    --line: #35302a;
    --line-strong: #4a4339;
    --accent: #83bec9;
    --accent-hover: #b8dbe1;
    --accent-soft: rgba(131, 190, 201, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.26);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.34), 0 16px 38px rgba(0, 0, 0, 0.34);
  }
}

:root[data-theme="dark"] {
  --bg: #15130f;
  --bg-tint: #1c1915;
  --bg-raised: #201d18;
  --ink: #f4efe7;
  --muted: #b5aa9d;
  --line: #35302a;
  --line-strong: #4a4339;
  --accent: #83bec9;
  --accent-hover: #b8dbe1;
  --accent-soft: rgba(131, 190, 201, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.26);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.34), 0 16px 38px rgba(0, 0, 0, 0.34);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(
    120% 42rem at 50% -14rem,
    var(--accent-soft),
    transparent 70%
  );
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.15s ease;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.4rem 0.7rem;
  z-index: 10;
}

.skip:focus {
  top: 0.75rem;
}

.wrap {
  width: min(var(--max), calc(100% - 2.4rem));
  margin-inline: auto;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

@supports not (background: color-mix(in srgb, red, blue)) {
  .site-header {
    background: var(--bg);
  }
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.6rem;
}

.wordmark {
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.wordmark:hover {
  color: var(--accent);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.1rem;
  margin-left: auto;
  font-size: 0.95rem;
}

.nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
}

.nav a:hover::after,
.nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

.theme-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Hero -------------------------------------------------------------------- */

main {
  padding: 2.8rem 0 4rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 11.5rem;
  gap: 2.2rem;
  align-items: start;
  margin-bottom: 3rem;
}

.kicker {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

h1 {
  margin: 0 0 0.9rem;
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5vw, 3rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.lead > p:first-child {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--ink);
}

.lead p {
  margin: 0 0 1rem;
}

.lead p:last-child {
  margin-bottom: 0;
}

.portrait {
  width: 11.5rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--line);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.7rem;
  margin-top: 1.4rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-raised);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg-raised);
}

/* Sections ---------------------------------------------------------------- */

section {
  margin-top: 3rem;
}

h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h2::before {
  content: "";
  flex: none;
  width: 3px;
  height: 1.05em;
  border-radius: 2px;
  background: var(--accent);
}

.sub-heading {
  margin: 2rem 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-intro {
  margin: -0.3rem 0 1.4rem;
  color: var(--muted);
}

/* Cards ------------------------------------------------------------------- */

.cards {
  display: grid;
  gap: 1rem;
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 1.2rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift);
}

.card:has(.thumb-wrap) {
  grid-template-columns: 8.5rem minmax(0, 1fr);
}

.thumb-wrap {
  grid-row: 1 / span 4;
  align-self: start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-tint);
}

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.card h3 {
  margin: 0 0 0.15rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-meta {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.card p {
  margin: 0 0 0.6rem;
}

.card .links {
  margin: 0;
}

/* Lists ------------------------------------------------------------------- */

.news {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news li {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}

.news li:last-child {
  border-bottom: 1px solid var(--line);
}

.news time {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  padding-top: 0.12rem;
}

.paper {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.paper + .sub-heading {
  border-top: 1px solid var(--line);
  padding-top: 1.6rem;
}

.paper:last-of-type {
  border-bottom: 1px solid var(--line);
}

.paper h3,
.paper h4 {
  margin: 0 0 0.25rem;
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.4;
}

.paper .meta,
.item .meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.paper .venue {
  margin: 0.2rem 0 0.45rem;
  color: var(--muted);
  font-style: italic;
}

.paper p {
  margin: 0 0 0.4rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  font-size: 0.94rem;
}

.timeline {
  display: grid;
  gap: 1.3rem;
}

.item h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 600;
}

.item ul {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
}

.item li,
.plain-list li {
  margin: 0.2rem 0;
}

.plain-list {
  margin: 0;
  padding-left: 1.1rem;
}

.honors {
  list-style: none;
  margin: 0;
  padding: 0;
}

.honors li {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}

.honors li:last-child {
  border-bottom: 1px solid var(--line);
}

.honors span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
}

/* Footer ------------------------------------------------------------------ */

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

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1.2rem;
}

/* Pages ------------------------------------------------------------------- */

.page-title {
  margin-bottom: 0.35rem;
}

.cv-download {
  margin: 0 0 1rem;
  color: var(--muted);
}

.cv-actions {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.not-found {
  min-height: 50vh;
  display: grid;
  place-content: center;
  text-align: center;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li {
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
}

.post-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.post-list h2 {
  display: block;
  margin: 0 0 0.2rem;
  font-size: 1.25rem;
}

.post-list h2::before {
  content: none;
}

.post-list h2 a {
  color: inherit;
  text-decoration: none;
}

.post-list h2 a:hover {
  color: var(--accent);
}

.post-date {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.94rem;
}

/* Markdown ---------------------------------------------------------------- */

.markdown {
  margin-top: 1.5rem;
}

.markdown h2,
.markdown h3 {
  display: block;
  margin: 1.9rem 0 0.6rem;
  font-family: var(--serif);
  letter-spacing: -0.02em;
}

.markdown h2::before {
  content: none;
}

.markdown h2 {
  font-size: 1.4rem;
}

.markdown h3 {
  font-size: 1.12rem;
}

.markdown p,
.markdown ul,
.markdown ol {
  margin: 0 0 1rem;
}

.markdown ul,
.markdown ol {
  padding-left: 1.2rem;
}

.markdown li {
  margin: 0.25rem 0;
}

.markdown hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.markdown pre {
  overflow-x: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  font-size: 0.92rem;
}

.markdown code {
  font-size: 0.92em;
}

.markdown :not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--bg-tint);
}

.markdown blockquote {
  margin: 0 0 1rem;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-family: var(--serif);
}

.markdown img {
  border-radius: var(--radius-sm);
}

.markdown table {
  width: 100%;
  margin: 0 0 1.2rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.markdown th,
.markdown td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown th {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.markdown .ref a {
  text-decoration: none;
  padding: 0 0.1em;
}

.markdown .footnotes {
  margin-top: 2.6rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

.markdown .footnotes h2 {
  margin-top: 0;
}

.markdown .footnotes ol {
  padding-left: 1.3rem;
}

.markdown .footnotes li {
  margin: 0.4rem 0;
}

.back-link {
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 760px) {
  main {
    padding-top: 1.6rem;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 1.4rem;
    margin-bottom: 2.2rem;
  }

  .portrait {
    width: 8.5rem;
    order: -1;
  }

  .news li,
  .honors li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .columns {
    grid-template-columns: 1fr;
  }

  .card,
  .card:has(.thumb-wrap) {
    grid-template-columns: minmax(0, 1fr);
  }

  .thumb-wrap {
    grid-row: auto;
    margin-bottom: 0.9rem;
  }

  .thumb {
    aspect-ratio: 16 / 7;
  }

  .header-inner {
    flex-wrap: wrap;
    padding-block: 0.5rem;
  }

  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-header,
  .actions,
  .theme-toggle,
  .site-footer,
  .thumb-wrap {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 10.5pt;
  }

  .card {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: none;
  }

  a {
    color: inherit;
  }

  h2::before {
    display: none;
  }

  section {
    break-inside: avoid;
  }
}
