/* Soft minimal: groups content with space and tint rather than rules */
:root {
  --container: 980px;
  --bar-height: 60px;
  --bg: #fbfaf7;
  --bg-bar: rgba(251, 250, 247, .85);
  --bg-hover: #f3f1ec;
  --text: #1f1f22;
  --text-secondary: #4a4a52;
  --text-muted: #85858d;
  --accent: #2f5aa8;
  --accent-soft: #e8eef9;
  --chip: #efede8;
  --line: #e7e4dd;
  --ph-a: #f1efea;
  --ph-b: #e8e5de;
  --font: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
.dark {
  --bg: #16171a;
  --bg-bar: rgba(22, 23, 26, .85);
  --bg-hover: #1f2024;
  --text: #ececee;
  --text-secondary: #b9b9c0;
  --text-muted: #85858d;
  --accent: #8fb0f0;
  --accent-soft: #232c3d;
  --chip: #26272c;
  --line: #2c2d32;
  --ph-a: #1f2024;
  --ph-b: #27282d;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar-height) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.6;
  transition: background .2s, color .2s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
.page { max-width: var(--container); margin: 0 auto; padding: 48px 24px 32px; }

/* ---------- Pinned top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; height: var(--bar-height);
  background: var(--bg-bar); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.show-avatar { border-bottom-color: var(--line); }
.topbar-inner {
  max-width: var(--container); height: 100%; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-avatar {
  width: 0; height: 30px; border-radius: 50%; object-fit: cover; opacity: 0;
  transition: width .25s, opacity .25s, margin .25s; margin-right: -10px;
}
.show-avatar .brand-avatar { width: 30px; opacity: 1; margin-right: 0; }
.menu { display: flex; align-items: center; gap: 24px; font-size: 15px; }
.menu a { color: var(--text-muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.menu a:hover { color: var(--text); text-decoration: none; }
.menu a.active { color: var(--text); border-bottom-color: var(--accent); }
#theme-toggle {
  width: 34px; height: 34px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--chip); color: var(--text-secondary); font-size: 15px;
}
#theme-toggle:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- Intro: text left, photo right ---------- */
.intro { display: grid; grid-template-columns: 1fr 250px; gap: 48px; align-items: start; }
.intro h1 { margin: 0; font-size: 42px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.role { margin: 6px 0 0; font-size: 17px; color: var(--text-secondary); }
.role strong { color: var(--text); }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; }
.links a.icon {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--chip); color: var(--text-secondary); font-size: 17px;
  transition: background .15s, color .15s, transform .15s;
}
.links a.icon:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.avatar {
  width: 250px; height: 250px; object-fit: cover; border-radius: 24px; margin-top: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 12px 32px rgba(0,0,0,.08);
}
.bio { margin-top: 26px; color: var(--text-secondary); }
.bio p { margin: 0 0 12px; }
.bio ul { margin: 0 0 12px; padding-left: 20px; }
.bio li { margin-bottom: 6px; }
.bio strong { color: var(--text); }

/* ---------- Sections ---------- */
section { margin-top: 80px; }
section.intro { margin-top: 0; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 16px; }
.sec-head h2 { margin: 0; font-size: 26px; font-weight: 700; }
.note { font-size: 12px; color: var(--text-muted); }
#publications > .note { margin-top: 14px; }

/* News */
/* Fixed-height list with its own thin scrollbar; newest items stay on top */
.news {
  list-style: none; margin: 0; padding: 0 12px 0 0;
  max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
/* Fade the bottom edge while there's more to scroll (macOS hides scrollbars until used) */
.news.has-more { -webkit-mask-image: linear-gradient(#000 calc(100% - 40px), transparent); mask-image: linear-gradient(#000 calc(100% - 40px), transparent); }
.news::-webkit-scrollbar { width: 6px; }
.news::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.news::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.news li { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 7px 0; color: var(--text-secondary); }
.news li strong { color: var(--text); }
.news .date { font-size: 14px; font-weight: 700; color: var(--accent); padding-top: 1px; }

/* Selected / All switch */
.view-switch { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--chip); }
.view-switch button {
  border: 0; border-radius: 999px; background: none; cursor: pointer;
  font: inherit; font-size: 13px; padding: 4px 14px; color: var(--text-secondary);
}
.view-switch button.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Tag filter */
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 18px; }
.filter .label { display: none; }
.tag {
  font: inherit; font-size: 13px; line-height: 1; padding: 6px 12px; border: 0; border-radius: 999px;
  background: var(--chip); color: var(--text-secondary); cursor: pointer;
}
.tag:hover { background: var(--accent-soft); color: var(--accent); }
.tag.active { background: var(--accent); color: #fff; }
.tag sup { font-size: 9px; margin-left: 3px; opacity: .7; }

/* Paper rows: figure left; venue label above title */
.row {
  display: grid; grid-template-columns: 220px 1fr; column-gap: 28px;
  padding: 18px; margin: 0 -18px 6px; border-radius: 14px; transition: background .15s;
}
.row:hover { background: var(--bg-hover); }
.row[hidden] { display: none; }
.row > * { min-width: 0; }
.row > .thumb { grid-row: 1 / span 2; align-self: start; }
.row > .venue { grid-column: 2; grid-row: 1; margin-bottom: 4px; }
.row > div:nth-child(2) { grid-column: 2; grid-row: 2; }
/* Figures keep a white background in dark mode: most are transparent charts with dark text */
.thumb {
  aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
}
/* Papers without a figure: a short arXiv tile instead of an empty image box */
.thumb.arxiv {
  aspect-ratio: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 14px; background: var(--chip); box-shadow: none; text-decoration: none;
}
.thumb.arxiv span { font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 700; color: #b31b1b; }
.thumb.arxiv small { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.thumb.arxiv:hover { background: var(--accent-soft); }
.dark .thumb.arxiv span { color: #e06c6c; }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.row h3 { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.4; }
.flag {
  display: inline-block; vertical-align: 2px; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  font-family: var(--mono); font-size: 10px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent);
}
.authors { margin-top: 4px; font-size: 14px; color: var(--text-secondary); }
.authors .me { color: var(--text); font-weight: 700; }
.tldr { margin: 6px 0 0; font-size: 14px; color: var(--text-secondary); }
.row .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.row .tags .tag { font-size: 12px; padding: 3px 10px; }
.mlinks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: 13px; }
.mlinks a { padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-secondary); }
.mlinks a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.venue { font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.venue em { font-style: normal; }
.empty { padding: 24px 0; color: var(--text-muted); font-size: 14px; }

/* Placeholder art until real images are added */
.ph {
  display: grid; place-items: center; color: var(--text-muted); font-family: var(--mono); font-size: 11px;
  background: repeating-linear-gradient(45deg, var(--ph-a), var(--ph-a) 8px, var(--ph-b) 8px, var(--ph-b) 16px);
}

/* Misc */
.misc { color: var(--text-secondary); }
.misc p { margin: 0 0 10px; }

.footer { margin-top: 96px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .page { padding-top: 28px; }
  .menu { gap: 16px; font-size: 14px; }
  .menu a { display: none; }
  .intro { grid-template-columns: 1fr; gap: 24px; }
  .intro > * { min-width: 0; }
  .avatar { grid-row: 1; width: 140px; height: 140px; border-radius: 20px; }
  .intro h1 { font-size: 32px; }
  .row { grid-template-columns: 1fr; row-gap: 12px; }
  .row > .thumb, .row > .venue, .row > div:nth-child(2) { grid-column: 1; grid-row: auto; }
  .news li { grid-template-columns: 1fr; gap: 0; }
}
