:root {
  --bg: #fbf9f5;
  --text: #2b2926;
  --muted: #6d6962;
  --rule: #e7e3db;
  --accent: #c1200d;
  --accent-hover: #8f1709;
  --panel: #f2eee7;
  --thumb-bg: #ffffff;
  --thumb-border: #e3ded5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #23211e;
    --text: #e8e4dd;
    --muted: #a39e95;
    --rule: #38352f;
    --accent: #ff7a66;
    --accent-hover: #ffa496;
    --panel: #2d2a26;
    --thumb-bg: #e9e5de;
    --thumb-border: #38352f;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 56px 32px 80px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 56px;
}

/* Sidebar */
.sidebar { position: sticky; top: 56px; align-self: start; }
.photo { display: block; width: 160px; height: 160px; border-radius: 8px; object-fit: cover; }
.name { font-size: 22px; font-weight: 600; line-height: 1.25; margin: 20px 0 6px; }
.contact { margin: 0 0 14px; font-size: 14px; word-break: break-all; }
.links { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.links li { margin: 2px 0; }

/* Sections */
main { max-width: 720px; }
section + section { margin-top: 48px; }
h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
#about h2 { margin-top: 4px; }
p { margin: 0 0 14px; text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }
.section-note { font-size: 14px; color: var(--muted); margin-top: -6px; }

/* News */
.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; margin-bottom: 8px; }
.news-date { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Publications */
.pubs { list-style: none; padding: 0; margin: 0; }
.pub {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 20px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 16px;
}
.pub:first-child { border-top: 0; padding-top: 4px; }
.pub:target .pub-title a { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.pub-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 110px;
  padding: 6px;
  background: var(--thumb-bg);
  border: 1px solid var(--thumb-border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.pub-thumb:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--thumb-border));
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.08);
  transform: translateY(-1px);
}
/* Multiply blends each figure's white background into the box color, so
   box and figure read as one surface in both themes. */
.pub-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.pub-title { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 0 0 4px; text-wrap: balance; }
.pub-authors, .pub-note, .pub-venue { font-size: 14px; margin: 0; }
.pub-authors { color: var(--muted); }
.pub-authors strong { color: var(--text); font-weight: 600; }
.pub-note { color: var(--muted); font-style: italic; }
.pub-venue { font-style: italic; margin-top: 2px; }
.pub-blurb { font-size: 14px; margin: 6px 0 0; }
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 18px;
  vertical-align: 1px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 9px;
}
.pub-links { font-size: 14px; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.pub-links a::before, .toggle::before { content: "["; }
.pub-links a::after, .toggle::after { content: "]"; }
.caret {
  display: inline-block;
  width: 0.75em;
  margin-right: 2px;
  font-size: 1.05em;
  line-height: 1;
  text-align: center;
  transition: transform 0.15s ease;
}
.caret::before { content: "\25B8"; }
.toggle[aria-expanded="true"] .caret { transform: rotate(90deg); }

button { font: inherit; color: inherit; }
.toggle {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
}
.toggle:hover { color: var(--accent-hover); text-decoration: underline; }
.toggle[aria-expanded="true"] { font-weight: 600; }

.pub-panel {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.55;
}
.pub-panel p { margin: 0; }
.pub-bib { position: relative; }
.pub-bib pre {
  margin: 0;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 12px;
  padding: 2px 10px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
}
.copy:hover { border-color: var(--muted); }

/* Projects */
.projects { padding-left: 18px; margin: 0; }
.projects li { margin-bottom: 8px; }
.year { color: var(--muted); }

/* Footer */
.site-footer {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}
.site-footer p { margin: 0; }

/* 404 page */
.not-found { max-width: 560px; margin: 0 auto; padding: 18vh 24px 80px; }
.not-found h1 { font-size: 28px; font-weight: 600; margin: 0 0 8px; }

/* Narrow screens: sidebar becomes a header */
@media (max-width: 760px) {
  .page { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 24px 16px 56px; }
  .sidebar { position: static; display: flex; gap: 16px; align-items: center; }
  .photo { width: 96px; height: 96px; flex-shrink: 0; }
  .name { margin-top: 0; font-size: 20px; }
  .contact { margin-bottom: 4px; }
  .links { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 14px; }
  .pub { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
  .pub-thumb { width: 96px; height: 72px; padding: 4px; }
  .pub-panel { margin-left: -110px; }
}

/* Print: a clean one-page bio */
@media print {
  :root {
    --bg: #fff; --text: #000; --muted: #444; --rule: #ccc; --accent: #000; --panel: #fff;
  }
  body { font-size: 11pt; }
  .page { display: block; max-width: none; padding: 0; }
  .sidebar { position: static; display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
  .photo { width: 80px; height: 80px; }
  .name { margin-top: 0; }
  .links { display: flex; flex-wrap: wrap; gap: 0 12px; }
  .links a::after { content: " (" attr(href) ")"; font-size: 9pt; color: var(--muted); }
  .pub { display: block; padding: 8px 0; break-inside: avoid; }
  .pub-thumb, .pub-links button, .pub-panel { display: none !important; }
  .pub-title a::after { content: " \2014  " attr(href); font-weight: 400; font-size: 9pt; color: var(--muted); word-break: break-all; }
  a { text-decoration: none; }
  section + section { margin-top: 20px; }
  .site-footer { margin-top: 24px; }
}
