:root {
  --bg: #0a0e13;
  --fg: #f3f1ec;
  --muted: #9aa3ad;
  --card: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.09);
  --wm-blue: #a5c5e2;
  --wm-pink: #e3b7c3;
  --wm-white: #e6e6ec;
  --accent-blue: #a5c5e2;
  --accent-pink: #e3b7c3;
  --c: #7f95e8;
  --grad: linear-gradient(120deg, #a5c5e2, #e3b7c3);
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 20px 60px -24px rgba(165, 197, 226, 0.45);
  --btn-depth: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  --card-fill: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  --serif: "Merriweather", Georgia, "Times New Roman", serif; /* titles and h1 */
  --sans: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif; /* everything else */
  /* Theme-dependent helpers (dark values; the light set is below). */
  --wm-period: #e6e6ec;
  --frame-mid: rgba(255, 255, 255, 0.04);
  --spot: rgba(255, 255, 255, 0.07);
  --aurora-k: 1;
  --text-soft: #d6d2e4;
  --hover-line: rgba(255, 255, 255, 0.3);
  --dot: rgba(255, 255, 255, 0.22);
  --code-bg: rgba(255, 255, 255, 0.07);
  color-scheme: dark;
}

/* Light theme: chosen with the header toggle, or the system setting when no choice is stored. */
:root[data-theme="light"] {
  --bg: #f6f3ec;
  --fg: #15181d;
  --muted: #5d6670;
  --card: rgba(255, 255, 255, 0.65);
  --border: rgba(21, 24, 29, 0.10);
  --accent-blue: #365f86;
  --accent-pink: #94475f;
  --c: #4a5fc9;
  --wm-period: #0a0e13;
  --card-fill: linear-gradient(160deg, rgba(21, 24, 29, 0.07), rgba(21, 24, 29, 0.02));
  --frame-mid: rgba(21, 24, 29, 0.04);
  --spot: rgba(10, 14, 19, 0.05);
  --aurora-k: 0.5;
  --text-soft: #15181d;
  --hover-line: rgba(21, 24, 29, 0.3);
  --dot: rgba(21, 24, 29, 0.22);
  --code-bg: rgba(21, 24, 29, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f3ec;
    --fg: #15181d;
    --muted: #5d6670;
    --card: rgba(255, 255, 255, 0.65);
    --border: rgba(21, 24, 29, 0.10);
    --accent-blue: #365f86;
    --accent-pink: #94475f;
    --c: #4a5fc9;
    --wm-period: #0a0e13;
    --card-fill: linear-gradient(160deg, rgba(21, 24, 29, 0.07), rgba(21, 24, 29, 0.02));
    --frame-mid: rgba(21, 24, 29, 0.04);
    --spot: rgba(10, 14, 19, 0.05);
    --aurora-k: 0.5;
    --text-soft: #15181d;
    --hover-line: rgba(21, 24, 29, 0.3);
    --dot: rgba(21, 24, 29, 0.22);
    --code-bg: rgba(21, 24, 29, 0.06);
    color-scheme: light;
}
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.7 var(--sans);
  overflow-x: clip;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; border-radius: 6px; }

/* ---------- background ---------- */
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.blob {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: calc(0.38 * var(--aurora-k));
  animation: drift 24s ease-in-out infinite alternate;
}
.b1 { background: #4a6f94; top: -20vmax; left: -15vmax; }
.b2 { background: #9a5d73; bottom: -25vmax; right: -15vmax; animation-duration: 30s; animation-delay: -8s; opacity: calc(0.32 * var(--aurora-k)); }
.b3 { background: #3b4a9e; top: 30vh; left: 40vw; width: 35vmax; height: 35vmax; animation-duration: 36s; animation-delay: -15s; opacity: calc(0.2 * var(--aurora-k)); }

@keyframes drift {
  to { transform: translate(12vmax, 8vmax) scale(1.2) rotate(30deg); }
}

.spotlight {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 30%), var(--spot), transparent 60%);
}

/* ---------- layout ---------- */
main, footer {
  width: min(100% - 2rem, 62rem);
  margin-inline: auto;
}

.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1.1rem max(1rem, calc((100% - 62rem) / 2));
}
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(var(--bg) 40%, transparent);
  backdrop-filter: blur(8px);
  mask-image: linear-gradient(#000 60%, transparent);
}
.wm-period { fill: var(--wm-period); }
/* Wordmark clear space: at least the period's diameter (about 0.2 of the mark's height) on every side. */
.brand {
  display: block; padding: 0.28rem;
  transform-origin: left top;
}
.brand .wordmark { display: block; height: 1.35rem; width: auto; }
.has-hero-logo .brand { opacity: 0; pointer-events: none; }
.has-hero-logo .brand.is-active { opacity: 1; }
.has-hero-logo .brand.is-docked { opacity: 1; pointer-events: auto; }
/* Keep the focus ring visible when the link is reached with the keyboard before the mark has docked. */
.has-hero-logo .brand:focus-visible { opacity: 1; }
nav { display: flex; gap: 1.5rem; white-space: nowrap; }
nav a { color: var(--muted); font-size: 0.95rem; transition: color 0.2s; }
nav a:hover { color: var(--fg); }
nav { align-items: center; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer;
  font: inherit; font-size: 0.85rem; font-weight: 400; line-height: 1.2; color: var(--muted);
  padding: 0.35rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  transition: color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--hover-line); }
.theme-toggle .ico { margin: 0; }
.theme-toggle[hidden] { display: none; }

section { padding: 5rem 0; }

/* ---------- hero ---------- */
.hero {
  min-height: 82vh;
  position: relative;
  padding-bottom: 6rem;
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 3rem; align-items: center;
}
.eyebrow { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.85rem; margin: 0 0 1rem; }
h1 { font-family: var(--serif); font-weight: 400; }
h2, h3, h4, h5, h6 { font-family: var(--sans); font-weight: 700; }
h1 {
  font-size: clamp(2.6rem, 8vw, 5.5rem);
  line-height: 1.1; letter-spacing: -0.02em;
  margin: 0 0 1.5rem; font-weight: 400;
}
.hero-logo {
  --wm-h: clamp(3.5rem, 12vw, 7.5rem);
  width: fit-content; line-height: 1;
  padding-block: calc(var(--wm-h) * 0.2); margin: 0 0 0.5rem;
}
.hero-logo .wordmark { display: block; height: var(--wm-h); width: auto; }
.hero-logo.is-floating { pointer-events: none; }

.lead { font-size: clamp(1.15rem, 2.8vw, 1.6rem); color: var(--muted); max-width: 36rem; margin: 0 0 2rem; line-height: 1.45; }
.rotator { color: var(--fg); font-weight: 700; white-space: nowrap; border-bottom: 2px solid var(--accent-blue); }
.rotator-word { display: inline-block; transition: opacity 0.35s, transform 0.35s; }
.rotator-word.out { opacity: 0; transform: translateY(0.4em); }

.cta { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.btn {
  padding: 0.8rem 1.5rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); font-weight: 700; font-size: 0.98rem;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--hover-line); }
.btn.primary,
.plink.primary {
  background: var(--grad); border-color: transparent; color: #0a0e13;
  box-shadow: var(--btn-depth);
}
.btn.primary:hover,
.plink.primary:hover { border-color: transparent; box-shadow: var(--btn-depth), var(--shadow-2); }

.scroll-hint {
  position: absolute; bottom: 1.5rem; left: 0;
  color: var(--muted); font-size: 1.5rem; animation: bob 2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(8px); } }

/* ---------- sections ---------- */
h2 { font-size: clamp(1.9rem, 5vw, 2.7rem); font-weight: 400; letter-spacing: -0.02em; margin: 0 0 2rem; }
h2 .num { font-size: 0.9rem; color: var(--accent-blue); font-weight: 700; letter-spacing: 0.1em; vertical-align: super; margin-right: 0.6rem; }

.about-grid { display: grid; gap: 2.5rem; grid-template-columns: 1.4fr 1fr; align-items: start; }
.about-grid p { margin: 0 0 1.2rem; color: var(--text-soft); }
.about-grid strong { color: var(--fg); }

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.chips li {
  padding: 0.4rem 0.95rem; border-radius: 999px; font-size: 0.9rem;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.chips li:hover { color: var(--fg); border-color: var(--accent-blue); transform: translateY(-2px); }

/* ---------- cards ---------- */
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }

.card {
  position: relative; display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1.6rem; border-radius: 1.2rem;
  background: var(--card-fill); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  backdrop-filter: blur(10px);
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.15s ease-out, border-color 0.3s, box-shadow 0.3s;
}
a.card:hover, .card.tilt:hover { border-color: transparent; box-shadow: 0 0 0 1px var(--accent-blue), var(--shadow-2); }
.card h3 { margin: 0.2rem 0 0; font-size: 1.3rem; letter-spacing: -0.02em; }
.card p { margin: 0; color: var(--muted); font-size: 0.98rem; flex: 1; }
.tag { font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-pink); font-weight: 700; }
.more { margin-top: 0.8rem; font-weight: 700; font-size: 0.95rem; }
.more i { display: inline-block; font-style: normal; transition: transform 0.2s; }
.ico { width: 1em; height: 1em; vertical-align: -0.12em; margin-left: 0.15em; }
a.card:hover .more i { transform: translateX(6px); }
.card.soon { border-style: dashed; background: transparent; box-shadow: none; }
.card.soon .tag { color: var(--accent-blue); }

/* ---------- links ---------- */
.links { display: grid; gap: 0.8rem; }
.links a {
  display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.4rem;
  border: 1px solid var(--border); border-radius: 1rem; background: var(--card-fill); box-shadow: var(--shadow-1);
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.links a:hover { border-color: var(--accent-blue); transform: translateX(6px); background: rgba(165, 197, 226, 0.07); }
.links b { min-width: 5rem; }
.links span { color: var(--muted); flex: 1; overflow-wrap: anywhere; }
.links i { font-style: normal; color: var(--accent-blue); display: grid; }

footer { padding: 3rem 0 4rem; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--border); }
footer p { margin: 0; }

/* ---------- reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.8s ease, transform 0.8s ease; }
.js .reveal.in { opacity: 1; transform: none; }
.js .card.reveal.in { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }

@media (max-width: 40rem) {
  .about-grid { grid-template-columns: 1fr; }
  .links a { flex-wrap: wrap; gap: 0.2rem 1rem; }
  .links span { flex-basis: 100%; order: 3; }
  .links i { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- portrait ---------- */
.portrait { margin: 0; justify-self: center; width: min(100%, 23rem); }
.frame {
  position: relative; aspect-ratio: 4 / 5;
  border-radius: 999px 999px 1.4rem 1.4rem;
  padding: 0.5rem; background: linear-gradient(160deg, rgba(165, 197, 226, 0.7), var(--frame-mid) 45%, rgba(227, 183, 195, 0.5));
  box-shadow: 0 30px 80px -30px rgba(165, 197, 226, 0.45);
  transform: translate3d(var(--px, 0), var(--py, 0), 0);
  transition: transform 0.2s ease-out;
}
.frame::after {
  content: ""; position: absolute; inset: 0.5rem; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 -60px 60px -40px rgba(10, 14, 19, 0.5);
}
.frame picture, .frame img { display: block; width: 100%; height: 100%; }
.frame img {
  object-fit: cover; object-position: 50% 28%;
  border-radius: 999px 999px 1rem 1rem;
  filter: saturate(1.03) contrast(1.02);
}
.portrait figcaption { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; margin-top: 1.1rem; text-align: center; }
.portrait figcaption b { font-family: var(--serif); font-weight: 400; font-size: 1.15rem; }
.portrait figcaption span { color: var(--muted); font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0 0 3.5rem; padding: 0 0 0 1.6rem; border-left: 1px solid var(--border); }
.timeline li { position: relative; padding-bottom: 2rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: calc(-1.6rem - 5px); top: 0.55rem;
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent-blue);
  box-shadow: 0 0 0 4px var(--bg), 0 0 14px var(--accent-blue);
}
.when { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-pink); font-weight: 700; }
.timeline h3 { margin: 0.2rem 0 0; font-size: 1.2rem; letter-spacing: -0.02em; }
.timeline .org { margin: 0 0 0.4rem; color: var(--accent-blue); font-size: 0.95rem; }
.timeline p:last-child { margin: 0; color: var(--muted); font-size: 0.98rem; max-width: 40rem; }

.edu h3 { font-size: 1.3rem; margin: 0 0 1rem; letter-spacing: -0.02em; }
.edu-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.edu-grid > div {
  display: flex; flex-direction: column; gap: 0.3rem; padding: 1.2rem 1.3rem;
  border: 1px solid var(--border); border-radius: 1rem; background: var(--card-fill); box-shadow: var(--shadow-1);
}
.edu-grid span { color: var(--muted); font-size: 0.92rem; }
.edu-grid small { color: var(--muted); font-size: 0.82rem; line-height: 1.5; margin-top: 0.3rem; }

@media (max-width: 48rem) {
  .hero { grid-template-columns: 1fr; gap: 2rem; min-height: 0; padding-top: 1.5rem; }
  .portrait { order: -1; width: min(72%, 17rem); justify-self: start; }
  .portrait figcaption { align-items: flex-start; text-align: left; }
  .scroll-hint { display: none; }
}

/* ---------- expertise tiles, presentations ---------- */
h3.sub { font-size: 1.3rem; margin: 3rem 0 1rem; letter-spacing: -0.02em; }
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 40rem) { .tiles { grid-template-columns: 1fr; } }
.tiles > div {
  display: flex; flex-direction: column; gap: 0.4rem; padding: 1.2rem 1.3rem;
  border: 1px solid var(--border); border-radius: 1rem; background: var(--card-fill); box-shadow: var(--shadow-1);
}
.tiles b { font-family: var(--sans); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.tiles span { color: var(--muted); font-size: 0.92rem; line-height: 1.55; }

.edu { margin-top: 2.5rem; }
.edu:first-of-type { margin-top: 0; }
.pubs { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.9rem; }
.pubs li { color: var(--muted); font-size: 0.95rem; line-height: 1.6; padding-left: 1rem; border-left: 2px solid var(--border); max-width: 46rem; }
.pubs em { color: var(--fg); font-style: normal; }

/* ---------- small screens ---------- */
@media (max-width: 40rem) {
  body { font-size: 1rem; }
  section { padding: 3.5rem 0; }
  .site-header { padding-block: 0.8rem; }
  nav { gap: 0.9rem; flex-wrap: wrap; justify-content: flex-end; row-gap: 0.45rem; }
  nav a { font-size: 0.88rem; }
  .theme-toggle { font-size: 0.8rem; padding: 0.25rem 0.7rem; }
  section[id] { scroll-margin-top: 5.75rem; }
  h1 { font-size: clamp(2.4rem, 13vw, 3.4rem); }
  .rotator { white-space: normal; }
  .card, .tiles > div, .edu-grid > div { padding: 1.2rem; }
  .btn { padding: 0.75rem 1.3rem; }
}
@media (max-width: 22rem) {
  nav { gap: 0.6rem; }
  nav a { font-size: 0.8rem; }
}

/* ---------- project cards ---------- */
.card-top { display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; min-height: 3.1rem; }
.badge {
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700;
  color: var(--accent-blue); border: 1px solid rgba(165, 197, 226, 0.4); border-radius: 999px; padding: 0.1rem 0.6rem;
}
.card-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }
.plink {
  display: inline-flex; align-items: center; gap: 0.2rem;
  padding: 0.45rem 1rem; border-radius: 999px; font-size: 0.88rem; font-weight: 700;
  border: 1px solid var(--border); background: var(--card);
  transition: transform 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.plink:hover { transform: translateY(-2px); border-color: var(--accent-blue); }
.note { margin: 1.5rem 0 0; color: var(--muted); font-size: 0.88rem; }
.grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }

/* ==========================================================
   Papers & Projects collection
   ========================================================== */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.anchor { position: relative; top: -5rem; display: block; }
section[id] { scroll-margin-top: 4.5rem; }

/* ---------- cards with media ---------- */
.card-media {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 16 / 10; margin: -0.6rem -0.6rem 0.5rem; border-radius: 0.85rem;
  background: #10151c; border: 1px solid var(--border);
}
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s ease; }
.card:hover .card-media img { transform: scale(1.04); }
.ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 15% 10%, rgba(165, 197, 226, 0.4), transparent 60%),
    radial-gradient(90% 90% at 90% 100%, rgba(227, 183, 195, 0.4), transparent 60%),
    #0f141b;
}
.ph span { font-family: var(--serif); font-size: 4.2rem; line-height: 1; color: rgba(243, 241, 236, 0.85); }
.media-chip {
  position: absolute; top: 0.7rem; left: 0.7rem;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.2rem 0.65rem; border-radius: 999px;
  background: rgba(10, 14, 19, 0.72); color: #f3f1ec; border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
}
.card-title { color: inherit; }
.card-title:hover { color: var(--accent-blue); }
.card[hidden] { display: none; }

/* ---------- filters, search, empty state ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.5rem; }
.filter {
  font: inherit; font-size: 0.9rem; font-weight: 400; cursor: pointer;
  padding: 0.45rem 1rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.filter span { margin-left: 0.3rem; font-size: 0.78rem; }
.filter:hover { color: var(--fg); border-color: var(--hover-line); }
.filter[aria-pressed="true"] { color: #0a0e13; background: var(--wm-blue); border-color: transparent; }
.empty { color: var(--muted); padding: 2rem 0; }
.more-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; margin-top: 2rem; }
.more-row .note { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.toolbar .filters { margin: 0; }
.search input {
  font: inherit; font-size: 0.95rem; color: var(--fg);
  width: min(22rem, 100%); padding: 0.6rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); outline: none;
}
.search input:focus { border-color: var(--accent-blue); }
.search input:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.search { flex: 0 1 22rem; }
.search input { width: 100%; }

/* ---------- collection and item headers ---------- */
.collection-head { padding: 3rem 0 1rem; }
.collection-list { padding-top: 1.5rem; }
.crumbs { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; color: var(--muted); margin-bottom: 1.6rem; }
.crumbs a { color: var(--muted); transition: color 0.2s; }
.crumbs a:hover { color: var(--fg); }
.item-title { font-size: clamp(2.1rem, 6vw, 3.8rem); line-height: 1.12; margin: 0.6rem 0 1.2rem; font-weight: 400; }
.item-page { padding: 3rem 0 2rem; }
.item-head .lead { max-width: 44rem; }
.item-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 0.5rem; }
.item-actions .btn { display: inline-flex; align-items: center; gap: 0.2rem; }

/* ---------- media: single figure, carousel, pdf ---------- */
.item-figure { margin: 3rem 0 0; border-radius: 1.2rem; overflow: hidden; border: 1px solid var(--border); background: #10151c; }
.item-figure img { display: block; width: 100%; height: auto; }

.carousel { position: relative; margin: 3rem 0 0; }
.carousel-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  border-radius: 1.2rem; border: 1px solid var(--border); background: #10151c;
  scrollbar-width: none; outline: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track:focus-visible { box-shadow: 0 0 0 2px var(--c); }
.slide { flex: 0 0 100%; margin: 0; scroll-snap-align: center; position: relative; aspect-ratio: 16 / 9; }
.slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.slide figcaption {
  position: absolute; left: 1rem; bottom: 1rem; max-width: calc(100% - 2rem);
  font-size: 0.85rem; color: #f3f1ec; padding: 0.4rem 0.8rem; border-radius: 0.6rem;
  background: rgba(10, 14, 19, 0.75); backdrop-filter: blur(6px);
}
.cbtn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  color: #f3f1ec; background: rgba(10, 14, 19, 0.65); border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px); transition: background 0.2s, border-color 0.2s;
}
.cbtn:hover { border-color: var(--accent-blue); background: rgba(10, 14, 19, 0.85); }
.cbtn .ico { margin: 0; width: 1.1rem; height: 1.1rem; }
.cbtn.prev { left: 0.8rem; }
.cbtn.next { right: 0.8rem; }
.dots { display: flex; justify-content: center; gap: 0.45rem; margin-top: 0.9rem; }
.dots button { width: 0.5rem; height: 0.5rem; padding: 0; border-radius: 999px; border: 0; cursor: pointer; background: var(--dot); transition: width 0.25s, background 0.25s; }
.dots button[aria-current="true"] { width: 1.4rem; background: var(--accent-blue); }

.pdf-embed { margin: 3rem 0 0; border-radius: 1.2rem; overflow: hidden; border: 1px solid var(--border); background: #10151c; }
.pdf-embed object { display: block; width: 100%; height: min(80vh, 60rem); }
.pdf-embed p { padding: 1.5rem; color: var(--muted); }

/* ---------- body and sidebar ---------- */
.item-body { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 3rem; margin-top: 3.5rem; align-items: start; }
.prose { color: var(--text-soft); max-width: 44rem; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.7rem; margin: 2.2rem 0 0.8rem; }
.prose h3 { font-size: 1.25rem; margin: 1.8rem 0 0.6rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1rem; }
.prose li { margin-bottom: 0.35rem; }
.prose a { color: var(--accent-blue); text-decoration: underline; text-decoration-color: rgba(165, 197, 226, 0.4); text-underline-offset: 0.2em; }
.prose a:hover { text-decoration-color: var(--accent-blue); }
.prose strong { color: var(--fg); }
.prose blockquote { margin: 1.5rem 0; padding: 0.2rem 0 0.2rem 1.2rem; border-left: 2px solid var(--accent-blue); color: var(--muted); font-style: italic; }
.prose code { font-size: 0.88em; padding: 0.1em 0.4em; border-radius: 0.35rem; background: var(--code-bg); }
.prose pre { overflow-x: auto; padding: 1rem 1.2rem; border-radius: 0.8rem; background: var(--code-bg); border: 1px solid var(--border); }
.prose pre code { padding: 0; background: none; }
.prose img { max-width: 100%; height: auto; border-radius: 0.8rem; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.2rem; font-size: 0.95rem; }
.prose th, .prose td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.item-side { display: grid; gap: 1.2rem; position: sticky; top: 5rem; }
.side-block { padding: 1.2rem 1.3rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--card-fill); box-shadow: var(--shadow-1); }
.side-h { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-pink); margin: 0 0 0.8rem; }
.side-p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.side-p a { color: var(--accent-blue); }
.side-block .chips li { font-size: 0.82rem; padding: 0.3rem 0.75rem; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.files a { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.55rem 0.7rem; border-radius: 0.7rem; border: 1px solid var(--border); transition: border-color 0.2s; }
.files a:hover { border-color: var(--accent-blue); }
.files .ico { color: var(--accent-blue); margin: 0.2rem 0 0; flex: none; }
.files b { display: block; font-weight: 400; font-size: 0.92rem; overflow-wrap: anywhere; }
.files small { display: block; color: var(--muted); font-size: 0.8rem; }

/* ---------- Dublin Core table and citation ---------- */
.dc { margin-top: 4rem; padding: 0; }
.dc h2 .num { vertical-align: super; }
.dc-table { margin: 0; border-top: 1px solid var(--border); }
.dc-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--border); }
.dc-row dt { color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding-top: 0.2rem; }
.dc-row dd { margin: 0; display: flex; flex-direction: column; gap: 0.25rem; overflow-wrap: anywhere; }
.dc-row dd a { color: var(--accent-blue); }
.cite { margin-top: 2.5rem; padding: 1.4rem 1.5rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--card-fill); box-shadow: var(--shadow-1); }
.cite-text { margin: 0 0 0.8rem; font-family: var(--sans); font-size: 1.05rem; line-height: 1.6; overflow-wrap: anywhere; }

@media (max-width: 48rem) {
  .item-body { grid-template-columns: 1fr; gap: 2rem; }
  .item-side { position: static; }
  .dc-row { grid-template-columns: 1fr; gap: 0.3rem; }
  .slide { aspect-ratio: 4 / 3; }
  .cbtn { width: 2.2rem; height: 2.2rem; }
}
@media (max-width: 40rem) {
  .card-media { margin: -0.4rem -0.4rem 0.4rem; }
  .item-page { padding-top: 2rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { flex-basis: auto; }
}

/* ---------- legal pages (/tos/, /privacy-policy/) ---------- */
.legal { padding: 3rem 0 2rem; max-width: 46rem; }
.legal .item-title { margin-bottom: 2rem; }
.legal .prose { max-width: none; }
.legal .prose h2 { font-size: 1.55rem; margin-top: 2.6rem; padding-top: 1.4rem; border-top: 1px solid var(--border); }
.legal .prose h3 { font-size: 1.15rem; margin-top: 1.8rem; }
.legal .prose table { margin: 0.5rem 0 1.4rem; }
.legal .prose th { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.legal .prose td:first-child { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; color: var(--fg); }
.legal-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 3rem; }
.legal-links a { padding: 0.45rem 1rem; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 0.9rem; transition: border-color 0.2s; }
.legal-links a:hover { border-color: var(--a); }
.legal-links a[aria-current="page"] { color: #0a0e13; background: var(--a); border-color: transparent; }
footer a { color: var(--muted); text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.2); text-underline-offset: 0.2em; }
footer a:hover { color: var(--fg); }

/* ---------- sitemap (/sitemap/) and 404 ---------- */
.sitemap-page { padding: 3rem 0 2rem; }
.sitemap-page .lead { max-width: 44rem; }
.sitemap-page .lead a { color: var(--accent-blue); text-decoration: underline; text-decoration-color: var(--hover-line); text-underline-offset: 0.2em; }
.sitemap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-top: 2.5rem; }
.sitemap-section { min-width: 0; padding: 1.5rem; border: 1px solid var(--border); border-radius: 1.2rem; background: var(--card-fill), var(--card); box-shadow: var(--shadow-1); }
.sitemap-wide { grid-column: 1 / -1; }
.sitemap-section h2 { font-size: 1.5rem; margin: 0 0 1rem; }
.sitemap-section h3 { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-pink); margin: 0 0 0.4rem; }
.sitemap-section ul { margin: 0; padding: 0; list-style: none; }
.sitemap-section li { padding: 0.7rem 0; border-top: 1px solid var(--border); }
.sitemap-section li > a { color: var(--fg); font-weight: 700; transition: color 0.2s; }
.sitemap-section li > a:hover { color: var(--accent-blue); }
.sitemap-section li > a .ico { color: var(--accent-blue); }
.sitemap-note { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.sitemap-parts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.sitemap-parts a { padding: 0.2rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 0.8rem; transition: color 0.2s, border-color 0.2s; }
.sitemap-parts a:hover { color: var(--fg); border-color: var(--accent-blue); }
.sitemap-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.notfound { padding-bottom: 4rem; }
@media (max-width: 44rem) {
  .sitemap-grid, .sitemap-cols { grid-template-columns: 1fr; }
}
