:root {
  --bg: #f4f4f1;
  --ink: #111111;
  --muted: #636363;
  --card: #fbfbf8;
  --border: rgba(17, 17, 17, 0.1);
  --sidebar-width: 18rem;
  --content-offset: 22rem;
}

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

body {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  font-size: 15px;
}

.wrap {
  width: min(1080px, calc(100% - 3rem));
  margin: 0 auto;
}

/* ─── Header ─── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.brand {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
}

nav {
  display: flex;
  gap: 0;
}

nav a {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--muted);
  padding: 0.3rem 0.7rem;
  border-bottom: 2px solid transparent;
  transition: color 150ms, border-color 150ms;
}

nav a:hover,
nav a.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ─── Typography ─── */
h1, h2, h3 {
  font-family: "Manrope", system-ui, sans-serif;
  letter-spacing: -0.02em;
}

p {
  color: var(--muted);
  line-height: 1.72;
}

a {
  color: var(--ink);
}

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

/* ─── Page scaffold ─── */
.page {
  padding: 3.5rem 0 4rem;
}

.page-header {
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 600;
  line-height: 1.1;
}

.page-header p {
  color: var(--muted);
  margin-top: 0.4rem;
  font-size: 0.92rem;
}

.split-layout {
  padding-left: var(--content-offset);
}

.page-sidebar {
  position: fixed;
  top: 6rem;
  left: max(1.5rem, calc((100vw - 1080px) / 2));
  width: var(--sidebar-width);
  align-self: start;
}

.page-sidebar .page-header {
  margin-bottom: 1.5rem;
}

.page-content {
  min-width: 0;
  width: auto;
}

.academic-layout {
  padding-left: var(--content-offset);
}

.academic-sidebar {
  width: var(--sidebar-width);
}

.academic-sidebar .page-header {
  margin-bottom: 1.5rem;
}

.academic-content {
  min-width: 0;
  margin-left: 0;
  width: auto;
}

.academic-content .accordion-body p {
  max-width: none;
}

.jump-nav {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  padding: 0.25rem 0 0;
  border: 0;
}

.jump-nav a {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  width: fit-content;
}

.jump-nav a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.section-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 0;
  border: 0;
  background: none;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  scroll-margin-top: 7rem;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.page-content > .section-label:first-child {
  margin-top: 0;
}

/* ─── Overview intro ─── */
.overview-intro {
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.page-sidebar .overview-intro {
  padding: 0;
  border-bottom: 0;
  margin-bottom: 0;
}

.page-sidebar .overview-intro h1 {
  font-size: clamp(2rem, 3.2vw, 2.85rem);
  max-width: 100%;
  line-height: 1.02;
}

.page-sidebar .overview-intro .tagline {
  max-width: 24ch;
}

.overview-intro .label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.overview-intro h1 {
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 600;
  line-height: 1.05;
  max-width: 15ch;
  margin: 0 0 1.2rem;
}

.overview-intro .tagline {
  font-size: 1rem;
  color: var(--muted);
  max-width: 48ch;
  line-height: 1.75;
}

/* ─── Project grid ─── */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.page-content .proj-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.page-content .overview-grid {
  grid-template-columns: 1fr;
  gap: 1rem;
}

.proj-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  overflow: hidden;
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.overview-grid .proj-card {
  display: grid;
  grid-template-columns: minmax(220px, 18rem) minmax(0, 1fr);
}

.proj-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(17, 17, 17, 0.1);
}

.cover {
  height: 220px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.overview-grid .cover {
  height: 100%;
  min-height: 188px;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0.08) 42%, rgba(0, 0, 0, 0) 100%);
  z-index: 0;
}

.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: grayscale(1);
  transition: transform 400ms ease;
}

.cover img[src*="felixsim.png"] {
  object-position: center 28%;
}

.cover img[src*="tippingcascades.png"] {
  object-position: center 35%;
}

.cover img[src*="cookbook.png"] {
  object-position: center 18%;
}

.proj-card:hover .cover img {
  transform: scale(1.03);
}

.cover-dark {
  background: #1c1c1c;
  background-image: repeating-linear-gradient(
    -55deg, transparent, transparent 5px,
    rgba(255, 255, 255, 0.03) 5px, rgba(255, 255, 255, 0.03) 6px
  );
}

.cover-mid {
  background: #444444;
  background-image: repeating-linear-gradient(
    -55deg, transparent, transparent 5px,
    rgba(255, 255, 255, 0.04) 5px, rgba(255, 255, 255, 0.04) 6px
  );
}

.cover-light {
  background: #d8d6d1;
  background-image: repeating-linear-gradient(
    -55deg, transparent, transparent 5px,
    rgba(0, 0, 0, 0.04) 5px, rgba(0, 0, 0, 0.04) 6px
  );
}

.cover-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.95);
  padding: 0.7rem 0.85rem;
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.cover-light .cover-label {
  color: rgba(255, 255, 255, 0.95);
}

.card-info {
  padding: 0.85rem 0.9rem 0.9rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.overview-grid .card-info {
  padding: 1rem 1rem 0.95rem;
  justify-content: center;
}

.overview-grid .card-info p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-info h3 {
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.24;
  color: var(--ink);
}

.card-info p {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
}

.card-link {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
  margin-top: 0.25rem;
  border-bottom: 1px solid var(--ink);
  align-self: flex-start;
  padding-bottom: 1px;
}

/* ─── Accordion ─── */
.accordion {
  border-bottom: 1px solid var(--border);
}

.accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 0.95rem 0.35rem 0.95rem 0.7rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  user-select: none;
  border-left: 2px solid transparent;
  background: transparent;
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion summary .acc-title {
  font-size: 0.97rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.accordion summary .acc-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.accordion summary .acc-icon {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.1rem;
  color: var(--muted);
  transition: transform 200ms;
  margin-left: auto;
  flex-shrink: 0;
}

.accordion[open] > summary .acc-icon {
  transform: rotate(45deg);
}

.accordion[open] > summary {
  border-left-color: var(--ink);
  background: color-mix(in srgb, var(--card) 84%, white 16%);
}

.accordion-body {
  padding: 0.1rem 0 1.5rem;
}

.accordion-body p {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
  line-height: 1.75;
  max-width: 70ch;
}

.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.link-list li a {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  transition: background 150ms, border-color 150ms, color 150ms;
}

.link-list li a:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.publication-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.publication-item {
  padding: 0.2rem 0 1rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.publication-item + .publication-item {
  padding-top: 0.8rem;
}

.publication-title {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

.publication-title a {
  color: var(--ink);
  text-decoration: none;
}

.publication-title a:hover {
  text-decoration: underline;
}

.publication-meta {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: none;
}

/* ─── About ─── */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 2.2fr;
  gap: 3.5rem;
  align-items: start;
}

.about-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  border-radius: 0.3rem;
  display: block;
}

.about-sidebar .about-photo {
  max-width: none;
}

.about-contact {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.about-contact h2 {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.about-contact p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.75;
  margin: 0;
}

.about-content h2 {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 1.4rem 0 0.45rem;
}

.about-content h2:first-child {
  margin-top: 0;
}

.about-content p {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.75;
  max-width: 58ch;
  margin: 0;
}

.cv-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.cv-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.1rem 0;
}

.cv-title {
  font-size: 0.86rem;
  color: var(--ink);
  line-height: 1.4;
}

.cv-title a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.cv-title a:hover {
  border-bottom-color: var(--ink);
}

.cv-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.about-content a {
  color: var(--ink);
}

.skills-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.skills-list li {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

.skill-name {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
  margin-right: 0.5rem;
}

/* ─── Footer ─── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-footer small {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
}

/* ─── Responsive ─── */
@media (max-width: 720px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  nav a {
    padding: 0.25rem 0.4rem;
  }

  nav a:first-child {
    padding-left: 0;
  }

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

  .page-sidebar .overview-intro {
    margin-bottom: 2.5rem;
  }

  .page-sidebar .overview-intro h1 {
    font-size: 2.2rem;
  }

  .page-sidebar .overview-intro .tagline {
    max-width: 48ch;
  }

  .about-photo {
    max-width: 200px;
  }

  .overview-intro h1 {
    font-size: 2.2rem;
  }

  .split-layout,
  .academic-layout {
    padding-left: 0;
  }

  .page-sidebar,
  .academic-sidebar {
    position: static;
    width: auto;
    left: auto;
  }

  .page-content {
    width: 100%;
  }

  .academic-layout {
    padding-left: 0;
  }

  .academic-sidebar {
    position: static;
    width: auto;
    left: auto;
  }

  .academic-content {
    margin-left: 0;
    width: 100%;
  }

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

  .overview-grid .proj-card {
    grid-template-columns: 1fr;
  }

  .overview-grid .cover {
    min-height: 220px;
  }
}