/* ---------- Theme tokens ---------- */
:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #656d76;
  --rule: #e4e7eb;
  --surface: #f5f6f8;
  --accent: #0a58ca;
  --accent-ink: #ffffff;
  --desk: #008080;
  --desk-2: #007373;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #3f4144;
  --fg: #f2f2f2;
  --muted: #c3c6ca;
  --rule: #585b60;
  --surface: #4a4d51;
  --accent: #9cc4ff;
  --accent-ink: #10213a;
  --desk: #0d3b3b;
  --desk-2: #0a3131;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.65 var(--sans);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; }
code { font-size: 0.9em; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--bg); padding: 6px 10px; }

/* ---------- Top navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 18px; min-height: 58px;
}
.nav-name { font-weight: 700; font-size: 18px; color: var(--fg); text-decoration: none; white-space: nowrap; }
.nav-links {
  display: flex; gap: 2px; margin: 0 0 0 auto; padding: 0; list-style: none;
  overflow-x: auto; scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  display: block; padding: 6px 10px; color: var(--muted); text-decoration: none; font-size: 15px; white-space: nowrap;
}
.nav-links a:hover { color: var(--fg); }
.nav-links a[aria-current="page"] { color: var(--fg); font-weight: 600; }
.theme-btn {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--rule); background: transparent; color: var(--fg);
  font-size: 16px; cursor: pointer; display: grid; place-items: center;
}
@media (max-width: 700px) {
  .nav-inner { flex-wrap: wrap; gap: 4px 12px; padding: 8px 16px 0; }
  .nav-links { order: 3; flex-basis: 100%; margin: 0 -10px; padding-bottom: 4px; }
  .theme-btn { margin-left: auto; }
}

/* ---------- Two-column shell: profile sidebar on the left ---------- */
.shell {
  max-width: 1200px; margin: 0 auto; padding: 44px 24px 72px;
  display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 56px; align-items: start;
}
.profile { position: sticky; top: 90px; }
.profile-photo {
  width: 200px; height: 200px; border-radius: 50%; object-fit: cover; display: block;
  border: 1px solid var(--rule); padding: 5px; background: var(--bg);
}
.profile-initials {
  display: grid; place-items: center; font-size: 56px; font-weight: 700; color: var(--muted);
  background: var(--surface);
}
.profile-name { font-size: 1.3rem; font-weight: 700; margin: 18px 0 2px; line-height: 1.2; }
.profile-title { color: var(--muted); margin: 0; }
.profile-links { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; font-size: 15px; }
.profile-links a { display: flex; align-items: center; gap: 12px; color: var(--fg); text-decoration: none; word-break: break-word; }
.profile-links a:hover { text-decoration: underline; }
.profile-links svg { flex: none; width: 18px; height: 18px; color: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; gap: 28px; padding-top: 24px; }
  .profile { position: static; display: grid; grid-template-columns: 84px 1fr; gap: 0 16px; align-items: center; }
  .profile-photo { width: 84px; height: 84px; padding: 3px; }
  .profile-initials { font-size: 26px; }
  .profile-name { margin: 0; align-self: center; }
  .profile-title { grid-column: 2; }
  .profile-links { grid-column: 1 / -1; margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
}

/* ---------- Content ---------- */
.prose { max-width: 72ch; }
.prose h1 { font-size: clamp(1.9rem, 3.5vw, 2.4rem); line-height: 1.15; margin: 0 0 16px; }
.prose h2 { font-size: 1.35rem; line-height: 1.25; margin: 40px 0 12px; }
.prose h3 { font-size: 1.05rem; margin: 22px 0 4px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.lede { font-size: 1.1rem; color: var(--muted); }
.meta { font-size: 14px; line-height: 1.4; color: var(--muted); }
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.crumbs a { color: var(--muted); }

.entry { margin: 0 0 20px; }
.entry-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.entry-when { font-size: 14px; color: var(--muted); white-space: nowrap; }
.entry p, .entry ul { margin: 2px 0 6px; }

.pub { margin: 0 0 22px; }
.pub-title { font-weight: 700; }
.pub-authors { margin: 2px 0; }
.pub-authors b { text-decoration: underline; text-underline-offset: 3px; }
.pub-venue { font-size: 14px; color: var(--muted); }
.pub.accepted .pub-venue { color: var(--fg); font-weight: 600; }
.pub-links { font-size: 14px; margin-top: 2px; display: flex; gap: 12px; flex-wrap: wrap; }

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { margin: 0 0 16px; }
.post-list a { font-weight: 600; }

.btn-clean {
  display: inline-block; font: 600 15px var(--sans); text-decoration: none;
  padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.placeholder { background: color-mix(in srgb, #ffd400 30%, transparent); padding: 0 3px; border-radius: 3px; }

.site-foot { color: var(--muted); font-size: 13px; text-align: center; padding: 20px 16px 28px; border-top: 1px solid var(--rule); }
.site-foot p { margin: 4px 0; }
.site-foot a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Library ---------- */
.tiles {
  display: grid; gap: 14px; margin-top: 20px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.tile {
  display: grid; gap: 4px; padding: 18px; text-decoration: none; color: var(--fg);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  transition: border-color 0.15s, transform 0.15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile-icon { font-size: 30px; line-height: 1; }
.tile-name { font-size: 1.25rem; font-weight: 700; }
.tile-count { font: 14px var(--sans); color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; font-family: var(--sans); }
.filter {
  font: 14px var(--sans); padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--bg); color: var(--fg);
}
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.cards {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.card {
  position: relative; display: flex; gap: 12px; padding: 10px; min-height: 130px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  color: var(--fg); text-decoration: none;
}
.card[hidden] { display: none; }
a.card:hover { border-color: var(--accent); }
.spine {
  flex: none; width: 46px; border-radius: 3px 6px 6px 3px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.28), rgba(255,255,255,.08) 18%, rgba(0,0,0,0) 30%, rgba(0,0,0,.18)),
    var(--spine);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: inset 0 6px 0 rgba(255,255,255,.12), inset 0 -6px 0 rgba(0,0,0,.18);
}
.spine-title {
  writing-mode: vertical-rl; transform: rotate(180deg);
  color: #f5efe0; font: 700 12px/1.1 var(--serif); letter-spacing: 0.04em;
  max-height: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-title { font-weight: 700; line-height: 1.25; }
.card-creator { font-size: 15px; }
.card-meta { font: 13px var(--sans); color: var(--muted); }
.card-blurb { font-size: 14px; color: var(--muted); margin-top: 4px; }
.card-note-flag {
  position: absolute; right: 8px; bottom: 8px; font: 600 11px var(--sans);
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em;
}

/* ---------- Teaching/Fieldbuilding ---------- */
.prose .entry-title { font-size: 1.15rem; margin: 30px 0 4px; }
.entry-link { font-size: 15px; margin-left: 6px; white-space: nowrap; }
.pub-note { font-size: 14px; color: var(--muted); margin-top: -6px; }

/* ---------- Research ---------- */
:root {
  --pill-rose-bg: #fde7e9;  --pill-rose-fg: #a1263a;
  --pill-gold-bg: #fbf0d4;  --pill-gold-fg: #7a5a06;
  --pill-violet-bg: #ece8fd; --pill-violet-fg: #4d3aa6;
  --pill-teal-bg: #dcf3ef;  --pill-teal-fg: #0f6156;
  --pill-muted-bg: var(--surface); --pill-muted-fg: var(--muted);
}
:root[data-theme="dark"] {
  --pill-rose-bg: #4a2a30;  --pill-rose-fg: #f2a3ad;
  --pill-gold-bg: #4a3f22;  --pill-gold-fg: #f0cf7a;
  --pill-violet-bg: #3a3556; --pill-violet-fg: #c9bcff;
  --pill-teal-bg: #24433f;  --pill-teal-fg: #8fe0d2;
}
.rs { max-width: 900px; }
.rs-year-h {
  font-size: 1.05rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em;
  margin: 34px 0 0; padding-bottom: 8px; border-bottom: 1px solid var(--rule);
}
.rs-year:first-child .rs-year-h { margin-top: 8px; }
.rs-card {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start;
  padding: 26px 0; border-bottom: 1px solid var(--rule);
}
.rs-card:last-child { border-bottom: 0; }
.rs-card.no-media { grid-template-columns: minmax(0, 1fr); }
.rs-media {
  background: var(--surface); border-radius: 12px; height: 180px;
  display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden;
}
.rs-media img {
  display: block; max-width: 100%; max-height: 156px; width: auto; height: auto;
  border-radius: 6px; background: #fff;
}
.rs-title { font-size: 1.15rem; line-height: 1.35; margin: 0 0 8px; }
.rs-authors { margin: 0 0 10px; color: var(--muted); font-size: 15.5px; line-height: 1.55; }
.rs-authors b { color: var(--fg); font-weight: 700; }
.rs-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.pill { font-size: 13px; font-weight: 600; padding: 4px 11px; border-radius: 999px; line-height: 1.4; }
.pill-rose { background: var(--pill-rose-bg); color: var(--pill-rose-fg); }
.pill-gold { background: var(--pill-gold-bg); color: var(--pill-gold-fg); }
.pill-violet { background: var(--pill-violet-bg); color: var(--pill-violet-fg); }
.pill-teal { background: var(--pill-teal-bg); color: var(--pill-teal-fg); }
.pill-muted { background: var(--pill-muted-bg); color: var(--pill-muted-fg); border: 1px solid var(--rule); }
.rs-links { margin: 0; font-size: 15px; }
@media (max-width: 640px) {
  .rs-card { grid-template-columns: 1fr; gap: 14px; }
  .rs-media { height: 210px; }
  .rs-media img { max-height: 186px; }
}

/* ---------- Library year groups ---------- */
.lib-year { margin-bottom: 8px; }
.lib-year .rs-year-h { margin-bottom: 14px; }
.lib-year[hidden] { display: none; }

/* ---------- Library list layout ---------- */
.lib-list { list-style: none; margin: 0 0 8px; padding: 0; }
.lib-item { padding: 9px 0; border-bottom: 1px solid var(--rule); display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.lib-item:last-child { border-bottom: 0; }
.lib-item[hidden] { display: none; }
.li-title { font-weight: 600; }
a.li-title { color: var(--fg); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a.li-title:hover { text-decoration-color: var(--accent); }
.li-meta { font: 14px var(--sans); color: var(--muted); }
.li-blurb { flex-basis: 100%; font-size: 14px; color: var(--muted); }

/* ---------- Library category tabs ---------- */
.cat-filters { margin: 10px 0 22px; }
.cat-filters .filter { font-size: 15px; padding: 7px 16px; }
.cat-filters .filter[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cat-panel[hidden] { display: none; }
.cat-intro { color: var(--muted); margin: 0 0 14px; }

/* ---------- Library poster cards ---------- */
.cards.posters { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.card.poster { flex-direction: column; gap: 8px; padding: 0; min-height: 0; background: transparent; border: 0; border-radius: 0; }
a.card.poster:hover .poster-art { outline: 2px solid var(--accent); }
.poster-art {
  display: block; aspect-ratio: 2 / 3; width: 100%; overflow: hidden; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.poster-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.poster-blank { display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; background: var(--spine); color: #f5efe0; font: 700 14px/1.2 var(--serif); }
.poster-body { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.card.poster .card-title { font-size: 15px; }
.card.poster .card-creator { font-size: 13.5px; color: var(--muted); }
.card.poster .card-note-flag { position: static; margin-top: 2px; }

/* ---------- Teaching year groups ---------- */
.prose .rs-year-h { margin: 34px 0 0; font-size: 1.05rem; }
.prose .rs-year:first-of-type .rs-year-h { margin-top: 8px; }
.prose .rs-year .entry-title { margin-top: 22px; }

/* ---------- Research: reviewing ---------- */
.rs-venues { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.rs-venues li { padding-left: 14px; position: relative; }
.rs-venues li::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
