:root {
  color-scheme: light;
  --bg:           var(--pal-primary,   #f6f4f0);
  --bg-accent:    #ede9e3;
  --panel:        var(--pal-surface,   rgba(255, 255, 255, 0.75));
  --panel-border: var(--pal-border,    rgba(0, 108, 80, 0.12));
  --text:         var(--pal-text,      #1e2420);
  --muted:        var(--pal-muted,     #6b7b74);
  --accent:       var(--pal-accent,    #fb7728);
  --accent-strong:#c95d1a;
  --secondary:    var(--pal-secondary, #006c50);
  --shadow:       0 24px 80px rgba(0, 108, 80, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(251, 119, 40, 0.07), transparent 38%),
    radial-gradient(circle at bottom left, rgba(0, 108, 80, 0.05), transparent 42%),
    linear-gradient(180deg, var(--bg), var(--bg-accent));
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

/* ── Navigation ─────────────────────────────────────────────────────────────── */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 clamp(20px, 5vw, 80px);
  height: 56px;
  background: rgba(246, 244, 240, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
}

:root.palette-5 .site-nav {
  background: rgba(0, 52, 38, 0.92);
}

/* ── Dark mode overrides ─────────────────────────────────────────────────────── */

:root.palette-5 .hero-actions a,
:root.palette-5 .paper-card a {
  border-color: rgba(246, 244, 240, 0.22);
  background: rgba(246, 244, 240, 0.06);
}

:root.palette-5 .now-circulating {
  background: #003828;
  color: #f6f4f0;
}

:root.palette-5 .site-footer {
  background: #003828;
}

:root.palette-5 .footer-tagline {
  color: #f6f4f0;
}

/* ── Theme toggle ────────────────────────────────────────────────────────────── */

.theme-toggle {
  background: none;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  transition: border-color 160ms ease, color 160ms ease;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle::before {
  content: "☽";
}

:root.palette-5 .theme-toggle::before {
  content: "☀";
}

.site-nav-name {
  font-family: "IBM Plex Serif", serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: inherit;
  text-decoration: none;
}

.site-nav-links {
  display: flex;
  gap: 28px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: auto;
  margin-right: 14px;
}

.site-nav-links a:hover {
  color: var(--accent);
}

/* ── Hero ────────────────────────────────────────────────────────────────────── */

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px clamp(24px, 8vw, 140px) 48px;
  max-width: 860px;
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--accent-strong);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.under-construction {
  margin-top: 32px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: "IBM Plex Serif", serif;
  font-size: clamp(3.2rem, 8vw, 6rem);
  line-height: 0.93;
  letter-spacing: -0.05em;
  color: var(--text);
}

.headline {
  margin: 22px 0 12px;
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  line-height: 1.28;
  color: var(--text);
}

.summary {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.summary span {
  color: var(--text);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
}

.hero-actions a,
.paper-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(0, 108, 80, 0.28);
  background: rgba(0, 108, 80, 0.06);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.hero-actions a:hover,
.paper-card a:hover {
  transform: translateY(-1px);
  border-color: rgba(251, 119, 40, 0.55);
  color: var(--accent-strong);
}

/* ── Now Circulating banner ──────────────────────────────────────────────────── */

.now-circulating {
  background: var(--secondary);
  color: var(--bg);
  padding: 36px clamp(24px, 5vw, 80px);
  display: flex;
  align-items: center;
}

.now-circulating-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nc-tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.65;
  white-space: nowrap;
}

.nc-sep {
  opacity: 0.35;
}

.nc-title {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
}

.nc-link {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.nc-link:hover {
  color: #ffa05a;
}

/* ── Page shell ──────────────────────────────────────────────────────────────── */

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 56px;
}

/* ── Content grid ────────────────────────────────────────────────────────────── */

.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 24px;
}

.content-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
}

.panel-wide {
  grid-column: span 12;
}

#writing,
#teaching {
  grid-column: span 6;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 18px;
}

.section-title p {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.section-title span,
.fact span,
.detail-list span,
.mini-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

/* ── Research columns ────────────────────────────────────────────────────────── */

.research-section {
  grid-column: span 12;
}

.research-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* When a card is active: 2-col grid, active card spans top row full-width,
   two inactive cards sit side-by-side in the row below */
.research-cols.has-active {
  grid-template-columns: repeat(2, 1fr);
}

.research-cols.has-active .paper-card.active {
  grid-column: 1 / -1;
  grid-row: 1;
}

.research-cols.has-active .paper-card:not(.active) {
  grid-row: 2;
}

.paper-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 160ms ease;
}

.paper-card.active {
  border-color: rgba(251, 119, 40, 0.45);
}

.paper-card h2 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  line-height: 1.35;
}

.paper-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
}

.abstract-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-strong);
  cursor: pointer;
}

.abstract-btn:hover {
  color: var(--accent);
}

.paper-card-abstract {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
}

.paper-card.active .paper-card-abstract {
  display: block;
}

.paper-card-abstract p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.92rem;
}

/* ── Paper metadata (status badges, coauthors, paper button) ─────────────────── */

.about-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.coauthors {
  font-size: 0.82rem;
  margin: 0 0 6px !important;
  color: var(--muted);
}

.paper-status {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-published {
  background: rgba(0, 108, 80, 0.08);
  color: #006c50;
  border: 1px solid rgba(0, 108, 80, 0.22);
}

.status-working {
  background: rgba(251, 119, 40, 0.12);
  color: var(--accent-strong);
  border: 1px solid rgba(251, 119, 40, 0.28);
}

.status-idea {
  background: rgba(0, 108, 80, 0.05);
  color: var(--muted);
  border: 1px solid rgba(0, 108, 80, 0.12);
}

.paper-btn {
  flex-shrink: 0;
  align-self: flex-start;
  min-height: 28px !important;
  padding: 0 10px !important;
  font-size: 0.78rem !important;
}

/* ── About (no box) ─────────────────────────────────────────────────────────── */

.about-section {
  grid-column: span 12;
  padding: 24px 4px;
}

.about-text {
  max-width: 70ch;
  margin-bottom: 18px;
}

.quick-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--panel-border);
}

.fact {
  padding: 0 16px 0 0;
}

.fact + .fact {
  padding-left: 16px;
  border-left: 1px solid var(--panel-border);
}

.fact strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  line-height: 1.45;
}

.link-list,
.detail-list,
.mini-grid {
  display: grid;
  gap: 14px;
}

.mini-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.mini-grid > div {
  padding-top: 14px;
  border-top: 1px solid rgba(0, 108, 80, 0.10);
}

.mini-grid strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.edu-sub {
  margin: 3px 0 0;
  padding: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.funding-section {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--panel-border);
}

.funding-list {
  display: grid;
  gap: 0;
}

.funding-item {
  padding: 14px 0;
  border-top: 1px solid rgba(0, 108, 80, 0.10);
}

.funding-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.funding-item span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.funding-item strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  line-height: 1.45;
}

/* ── Contact footer ──────────────────────────────────────────────────────────── */

.site-footer {
  background: var(--secondary);
  color: var(--bg);
  padding: 48px clamp(24px, 5vw, 80px);
}

.footer-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}

.footer-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-open-to {
  display: block;
  font-size: 0.82rem;
  color: rgba(246, 244, 240, 0.50);
  font-style: italic;
  margin-bottom: 8px;
}

.footer-left a {
  font-size: 0.95rem;
  color: rgba(246, 244, 240, 0.75);
  font-weight: 500;
}

.footer-left a:hover {
  color: var(--bg);
}

.footer-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.footer-tagline {
  font-family: "IBM Plex Serif", serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--bg);
}

.footer-social {
  display: flex;
  gap: 20px;
}

.footer-social a {
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(246, 244, 240, 0.65);
}

.footer-social a:hover {
  color: var(--bg);
}

/* ── Misc lists ──────────────────────────────────────────────────────────────── */

.link-list,
.detail-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.link-list li,
.detail-list li {
  padding: 16px 0;
  border-top: 1px solid rgba(0, 108, 80, 0.10);
}

.link-list li:first-child,
.detail-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.link-list a {
  font-weight: 600;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  #writing,
  #teaching {
    grid-column: span 12;
  }

  .research-cols {
    grid-template-columns: repeat(2, 1fr);
  }

  .research-cols.has-active {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 20px, 1120px);
    padding-bottom: 24px;
  }

  .panel {
    border-radius: 20px;
    padding: 20px;
  }

  .hero {
    padding-left: 24px;
    padding-right: 24px;
  }

  .content-grid {
    margin-top: 16px;
    gap: 16px;
  }

  .section-title {
    flex-direction: column;
  }

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

  .quick-facts {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .fact + .fact {
    padding-left: 0;
    border-left: 0;
  }

  .site-nav-links {
    gap: 18px;
  }

  .now-circulating-inner {
    gap: 10px;
  }

  .nc-sep {
    display: none;
  }

  .research-cols,
  .research-cols.has-active {
    grid-template-columns: 1fr;
  }

  .research-cols.has-active .paper-card.active,
  .research-cols.has-active .paper-card:not(.active) {
    grid-column: auto;
    grid-row: auto;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }

  .footer-right {
    align-items: flex-start;
  }
}
