:root {
  --bg: #f6f5f2;
  --ink: #16171a;
  --ink-soft: #5a5a52;
  --ink-faint: #9a978a;
  --accent: #7c5cff;
  --border: #e6e4dd;
  --card: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Karla', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .8; }

.sg { font-family: 'Space Grotesk', sans-serif; }
.fr { font-family: 'Fraunces', serif; }

.wrap {
  max-width: 1264px;
  margin: 0 auto;
  padding: 0 88px;
}

@media (max-width: 900px) {
  .wrap { padding: 0 20px; }
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 0;
  position: relative;
}

.nav .brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  white-space: nowrap;
}

.nav nav {
  display: flex;
  gap: 30px;
  align-items: center;
}

.nav nav a { font-size: 14px; color: var(--ink-soft); }
.nav nav a.current { color: var(--ink); }
.nav nav a.cta {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
}

/* Hamburger toggle: hidden on desktop, shown only under the mobile breakpoint
   below. Three plain bars, no icon font/SVG dependency. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: var(--ink);
  border-radius: 1px;
}

@media (max-width: 900px) {
  .nav-toggle { display: flex; }

  /* Collapsed by default: an absolutely positioned dropdown panel, not part of
     normal flow, so it never contributes to the page's own width or height
     (and can't be the thing pushing content off-screen while it's closed). */
  .nav nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 12px 32px rgba(22, 23, 26, 0.12);
    z-index: 20;
  }
  .nav nav.open { display: flex; }
  .nav nav a {
    padding: 14px 12px;
    border-radius: 8px;
    font-size: 16px;
  }
  .nav nav a.cta { text-align: center; margin-top: 4px; }
}

.preview-banner {
  background: #16171a;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-family: 'Space Grotesk', sans-serif;
}

.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.tag {
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  display: inline-block;
}

.btn {
  display: inline-block;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { border: 1.5px solid var(--ink); color: var(--ink); }

.ph {
  border: 1.5px dashed #d2cfc4;
  background: #f0efe8;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Bento home grid */
.bento {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(140px, auto);
  gap: 20px;
  padding-bottom: 40px;
}
@media (max-width: 900px) {
  .bento { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .bento > * { grid-column: auto !important; grid-row: auto !important; }
}

/* Editorial inner pages */
.kicker {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.editorial-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  line-height: 1.15;
  margin: 14px 0 0 0;
}

.list-row {
  display: flex;
  gap: 32px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  align-items: baseline;
}

/* Work index thumbnail + trailing CTA, and Research's date + PDF/arXiv links:
   fixed-width flex children that don't shrink, so .list-row (flex, no wrap)
   pushed them off-screen below the breakpoint instead of reflowing. */
.work-row-thumb { width: 260px; height: 170px; flex-shrink: 0; }
.work-row-cta { font-size: 14px; color: var(--accent); font-weight: 600; flex-shrink: 0; }
.research-row-date { width: 90px; flex-shrink: 0; font-size: 13px; color: var(--ink-faint); }
.research-row-links { display: flex; gap: 16px; font-size: 14px; flex-shrink: 0; }

@media (max-width: 900px) {
  .list-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .work-row-thumb { width: 100%; height: 200px; }
  .research-row-date { width: auto; }
  .research-row-links { gap: 20px; }
}

/* Key/value row: a fixed-width label or date column beside flexible content --
   Resume's Experience/Education/Certifications entries and skill groups ("--kv-w"
   overrides the label width for the latter, 200px vs the default 160px).
   Collapses to a single column on mobile instead of squeezing the content
   column down to a sliver next to an unshrinking fixed column. */
.kv-row {
  display: grid;
  grid-template-columns: var(--kv-w, 160px) 1fr;
  column-gap: 32px;
}
@media (max-width: 900px) {
  .kv-row { grid-template-columns: 1fr; row-gap: 6px; }
}

/* Two-up grid: Resume's Languages and References. Fluid columns (minmax(0,1fr))
   never overflow, but two columns of real content is too cramped on a phone. */
.two-col-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 900px) {
  .two-col-grid { grid-template-columns: 1fr; }
}

/* Writing index cards: same fluid-but-cramped situation as .two-col-grid, one
   column wider. */
.writing-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px; }
@media (max-width: 900px) {
  .writing-grid { grid-template-columns: 1fr; gap: 40px; }
}

/* Work detail: body copy beside a Stack/Links sidebar. Sidebar moves below the
   body on mobile instead of both columns being squeezed by the 64px gap. */
.detail-grid { display: grid; grid-template-columns: 3fr 1fr; column-gap: 64px; }
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; row-gap: 40px; }
}

/* Home's "Latest work"/"Latest writing" cards: thumbnail beside text in a fixed-
   width flex row. Stacks on mobile instead of squeezing the text into a sliver
   next to an unshrinking thumbnail. */
.feature-card { display: flex; overflow: hidden; text-decoration: none; color: inherit; }
.feature-card-thumb { width: 180px; flex-shrink: 0; border-radius: 0; border-top: none; border-bottom: none; border-left: none; }
@media (max-width: 900px) {
  .feature-card { flex-direction: column; }
  .feature-card-thumb { width: 100%; height: 160px; border: none; border-bottom: 1.5px dashed #d2cfc4; }
}

/* Now page rows: a short fixed-width label beside a paragraph. Stacks on mobile
   -- the label reads naturally as a heading above its own paragraph. */
.now-row { display: flex; gap: 24px; }
.now-row-label { flex-shrink: 0; width: 110px; padding-top: 2px; }
@media (max-width: 900px) {
  .now-row { flex-direction: column; gap: 6px; }
  .now-row-label { width: auto; padding-top: 0; }
}

.footer {
  padding: 56px 0 80px 0;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--ink-faint);
}

code, pre {
  font-family: 'IBM Plex Mono', monospace;
}
pre {
  background: #16171a;
  color: #dbe2e6;
  font-size: 14px;
  line-height: 1.7;
  border-radius: 10px;
  padding: 22px 26px;
  overflow-x: auto;
}

/* Resume header links (two email_reveal items + GitHub/LinkedIn/Scholar): plain
   flex with no wrap pushed the trailing links off-screen on mobile instead of
   wrapping to a second line. */
.resume-links { display: flex; gap: 18px; row-gap: 10px; margin-top: 10px; font-size: 14px; flex-wrap: wrap; }

/* Click-to-reveal email (address is never in the page source) */
.email-item { display: inline-flex; align-items: center; gap: 10px; flex-wrap: nowrap; white-space: nowrap; }
.email-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.email-reveal {
  font: inherit; font-size: 14px; color: var(--accent); background: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px;
}
.email-reveal:hover { border-color: var(--accent); }

/* RSS link hidden for now (no published posts yet); /feed.xml is still generated.
   Delete this rule to show it again. */
.rss-link { display: none; }

/* One-off confirmation after visiting a page with #no-track (owner analytics opt-out). */
.no-track-note {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--card); color: var(--ink); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; font-size: 14px; max-width: calc(100% - 32px);
}
