:root {
  --bg: #f4ead2;
  --bg-elev: #ede0bf;
  --fg: #2a2620;
  --fg-mid: #6b5d49;
  --fg-mute: #9c8c70;
  --line: rgba(42,38,32,.14);
  --line-strong: rgba(42,38,32,.32);
  --accent: #b85c3a;
  --accent-soft: rgba(184,92,58,.12);
  --selection: rgba(184,92,58,.22);
  --card: #f9f1da;
  --pill: rgba(42,38,32,.06);
}
[data-theme="dark"] {
  --bg: #161310;
  --bg-elev: #1f1b16;
  --fg: #ede1c7;
  --fg-mid: #a59478;
  --fg-mute: #6f6149;
  --line: rgba(237,225,199,.12);
  --line-strong: rgba(237,225,199,.28);
  --accent: #e2885e;
  --accent-soft: rgba(226,136,94,.14);
  --selection: rgba(226,136,94,.24);
  --card: #1c1813;
  --pill: rgba(237,225,199,.06);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .35s ease, color .35s ease;
}
::selection { background: var(--selection); }

.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-feature-settings: 'liga' 0; }
.serif { font-family: 'Newsreader', Georgia, serif; }

a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line-strong); transition: color .15s, border-color .15s; }
a:hover { color: var(--accent); border-color: var(--accent); }

/* ── Top nav ───────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 40px;
}
.brand { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--accent); font-size: 14px; letter-spacing: -.01em; }
.nav-links { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.nav-links a { border: 0; font-size: 13.5px; color: var(--fg-mid); padding: 6px 2px; position: relative; }
.nav-links a:hover { color: var(--fg); }
.nav-links a.active { color: var(--fg); }
.nav-links a.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 1.5px; background: var(--accent);
}
.nav-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.theme-btn {
  border: 1px solid var(--line-strong); background: transparent; color: var(--fg-mid);
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; padding: 0;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.nav-menu-btn {
  display: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--fg-mid);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color .2s, border-color .2s;
}
.nav-menu-btn:hover { color: var(--accent); border-color: var(--accent); }
.nav-menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-menu-icon {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

/* ── Mobile nav panel ──────────────────────────────────────────── */
.nav-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
}
.nav-panel.open {
  pointer-events: auto;
  visibility: visible;
}
.nav-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 19, 16, .45);
  opacity: 0;
  transition: opacity .25s ease;
}
[data-theme="dark"] .nav-panel-backdrop { background: rgba(0, 0, 0, .55); }
.nav-panel.open .nav-panel-backdrop { opacity: 1; }
.nav-panel-drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: min(280px, 85vw);
  height: 100%;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .28s ease;
  box-shadow: 8px 0 32px rgba(0, 0, 0, .12);
}
.nav-panel.open .nav-panel-drawer { transform: translateX(0); }
.nav-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.nav-panel-title {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.nav-panel-close {
  border: 0;
  background: transparent;
  color: var(--fg-mid);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  transition: color .15s, background .15s;
}
.nav-panel-close:hover { color: var(--accent); background: var(--pill); }
.nav-panel-links {
  display: flex;
  flex-direction: column;
  padding: 12px 20px 24px;
  gap: 4px;
}
.nav-panel-links a {
  border: 0;
  font-size: 15px;
  color: var(--fg-mid);
  padding: 10px 0;
  transition: color .15s;
}
.nav-panel-links a:hover,
.nav-panel-links a.active { color: var(--fg); }
.nav-panel-links a.active { font-weight: 500; }
body.nav-panel-open { overflow: hidden; }

/* ── Layout ────────────────────────────────────────────────────── */
.layout {
  max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: 320px 1fr; gap: 72px;
  padding: 56px 40px 96px;
}
.sidebar { max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 8px; }
.sidebar::-webkit-scrollbar { width: 0; }

/* ── Profile ───────────────────────────────────────────────────── */
.avatar {
  width: 160px; height: 160px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  overflow: hidden;
  margin-bottom: 18px;
  flex-shrink: 0;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.name { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 6px; }
.role { color: var(--fg-mid); font-size: 14.5px; line-height: 1.5; margin-bottom: 4px; }
.role .mono { font-size: 12.5px; color: var(--fg-mute); }
.affil { color: var(--fg-mid); font-size: 13.5px; margin-bottom: 22px; }
.tagline {
  border-left: 2px solid var(--accent); padding: 4px 0 4px 14px;
  color: var(--fg); font-size: 15px; line-height: 1.5; margin: 22px 0 20px;
  font-style: italic;
}
.bio { color: var(--fg-mid); font-size: 14px; line-height: 1.7; }
.bio strong { color: var(--fg); font-weight: 600; }

.actions { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.actions a, .actions button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  border: 1px solid var(--line-strong);
  background: transparent; color: var(--fg) !important;
  cursor: pointer;
  transition: transform .15s, filter .15s, border-color .15s, color .15s, background .15s;
  white-space: nowrap;
}
.actions a:hover, .actions button:hover { border-color: var(--accent); color: var(--accent) !important; transform: translateY(-1px); }
.actions svg { width: 13px; height: 13px; }
.actions .primary {
  background: var(--fg); color: var(--bg) !important;
  border-color: var(--fg);
  font-weight: 500;
}
.actions .primary:hover { background: var(--accent); border-color: var(--accent); color: #fff !important; filter: none; }
[data-theme="dark"] .actions .primary { background: var(--accent); border-color: var(--accent); color: #1a1612 !important; }
[data-theme="dark"] .actions .primary:hover { filter: brightness(1.08); color: #1a1612 !important; }

/* ── Main column / sections ─────────────────────────────────────── */
main { min-width: 0; }
section { margin-bottom: 72px; scroll-margin-top: 80px; }
section:last-of-type { margin-bottom: 0; }

.sec-header {
  display: flex; align-items: baseline; gap: 14px; margin-bottom: 28px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.sec-num { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--accent); font-weight: 500; }
.sec-title { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.sec-aside { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--fg-mute); }

/* ── Item / entry pattern ───────────────────────────────────────── */
.entry { display: grid; grid-template-columns: 1fr auto; gap: 12px 24px; margin-bottom: 28px; }
.entry:last-child { margin-bottom: 0; }
.entry-title { font-size: 16px; font-weight: 600; line-height: 1.35; margin: 0; }
.entry-org { color: var(--fg-mid); font-size: 14px; margin-top: 2px; }
.entry-meta { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--fg-mute); white-space: nowrap; padding-top: 4px; }
.entry-body { grid-column: 1 / -1; color: var(--fg-mid); font-size: 14.5px; line-height: 1.7; margin-top: 8px; }
.entry-body ul { margin: 8px 0 0; padding-left: 0; list-style: none; }
.entry-body ul li { position: relative; padding-left: 20px; margin-bottom: 8px; }
.entry-body ul li::before {
  content: '›'; position: absolute; left: 4px; top: 0; color: var(--accent); font-family: 'JetBrains Mono', monospace;
}
.entry-body em { color: var(--fg); font-style: italic; }

/* ── Education (serif, editorial) ──────────────────────────── */
.edu { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; padding: 18px 0; border-bottom: 1px dashed var(--line); }
.edu:last-child { border-bottom: 0; }
.edu-title { font-family: 'Newsreader', Georgia, serif; font-size: 22px; font-weight: 500; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.005em; }
.edu-org { color: var(--fg-mid); font-size: 14.5px; }
.edu-meta { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--fg-mute); white-space: nowrap; padding-top: 8px; }
.edu-note { grid-column: 1 / -1; margin: 8px 0 0; color: var(--fg-mid); font-size: 14.5px; line-height: 1.65; max-width: 62ch; }
.edu-note em { color: var(--accent); font-style: italic; font-weight: 500; }

/* ── Awards (serif, editorial) ─────────────────────────────── */
.award { display: grid; grid-template-columns: 80px 1fr; gap: 20px; padding: 16px 0; border-bottom: 1px dashed var(--line); }
.award:last-child { border-bottom: 0; }
.award-year { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent); padding-top: 6px; }
.award-title { font-family: 'Newsreader', Georgia, serif; font-size: 20px; font-weight: 500; margin: 0 0 4px; line-height: 1.3; letter-spacing: -.005em; }
.award p { margin: 0; color: var(--fg-mid); font-size: 14.5px; line-height: 1.6; max-width: 68ch; }

/* ── Skills / chips ─────────────────────────────────────────────── */
.skills-grid { display: grid; grid-template-columns: 140px 1fr; gap: 14px 24px; }
.skill-label { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--fg-mute); padding-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  padding: 4px 9px; border-radius: 5px;
  background: var(--pill); color: var(--fg);
  border: 1px solid transparent;
  transition: all .12s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.chip.primary { color: var(--accent); background: var(--accent-soft); }

/* ── Publications ──────────────────────────────────────────────── */
.pub-filters { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.pub-filter {
  font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
  padding: 5px 10px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--fg-mid); cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.pub-filter:hover { color: var(--fg); }
.pub-filter.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
[data-theme="dark"] .pub-filter.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.pub {
  padding: 18px 0; border-bottom: 1px solid var(--line);
}
.pub:last-child { border-bottom: 0; }
.pub-title { font-size: 15.5px; font-weight: 600; line-height: 1.4; margin: 0 0 6px; }
.pub-venue { color: var(--fg-mid); font-size: 13.5px; line-height: 1.55; margin-bottom: 6px; }
.pub-authors { font-size: 13px; color: var(--fg-mid); }
.pub-authors .me { color: var(--fg); font-weight: 600; }
.pub-actions { display: flex; gap: 14px; margin-top: 10px; align-items: center; }
.pub-action {
  font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
  padding: 4px 9px; border-radius: 5px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--fg-mid); display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.pub-action:hover { color: var(--accent); border-color: var(--accent); }
.pub-action svg { width: 11px; height: 11px; }
.pub-year { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--fg-mute); margin-left: auto; }

/* ── Languages ─────────────────────────────────────────────────── */
.langs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 28px; }
.lang-row { display: flex; flex-direction: column; gap: 6px; }
.lang-head { display: flex; justify-content: space-between; align-items: baseline; }
.lang-name { font-size: 14.5px; font-weight: 500; }
.lang-level { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--fg-mute); }
.lang-bar { height: 4px; background: var(--pill); border-radius: 2px; overflow: hidden; }
.lang-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* ── Gallery ───────────────────────────────────────────────────── */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gphoto {
  aspect-ratio: 4/3; border-radius: 6px;
  background:
    repeating-linear-gradient(135deg, var(--pill) 0 8px, transparent 8px 16px),
    var(--bg-elev);
  border: 1px solid var(--line);
  display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--fg-mute);
  cursor: pointer; transition: transform .15s, border-color .15s;
}
.gphoto:hover { transform: translateY(-2px); border-color: var(--line-strong); }

/* ── Toast / copy feedback ─────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  padding: 10px 18px; border-radius: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Caret blink for cute touch ────────────────────────────────── */
.caret { display: inline-block; width: 8px; height: 1em; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── Desktop: fixed sidebar (avoids sticky release shift at scroll end) ── */
@media (min-width: 921px) {
  :root {
    --layout-max: 1240px;
    --layout-pad-x: 40px;
    --layout-pad-top: 56px;
    --sidebar-w: 320px;
    --col-gap: 72px;
    --nav-h: 59px;
    --sidebar-top: calc(var(--nav-h) + var(--layout-pad-top));
  }
  .nav {
    height: var(--nav-h);
    box-sizing: border-box;
  }
  .nav-inner {
    height: 100%;
    align-items: center;
  }
  .layout {
    display: block;
    max-width: var(--layout-max);
    padding: var(--layout-pad-top) var(--layout-pad-x) 96px;
    padding-left: calc(var(--layout-pad-x) + var(--sidebar-w) + var(--col-gap));
  }
  .sidebar {
    position: fixed;
    top: var(--sidebar-top);
    left: max(var(--layout-pad-x), calc((100vw - var(--layout-max)) / 2 + var(--layout-pad-x)));
    width: var(--sidebar-w);
    max-height: calc(100vh - var(--sidebar-top) - 16px);
  }
}

/* ── Responsive (preview-safe) ──────────────────────────────────── */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; gap: 40px; padding: 32px 24px 60px; }
  .sidebar { position: static; max-height: none; }
  .nav-inner { padding: 12px 24px; }
  .nav-links { display: none; }
  .nav-end { margin-left: auto; }
  .nav-menu-btn { display: flex; }
  .award {
    grid-template-columns: 52px 1fr;
    gap: 12px;
  }
  .skills-grid {
    grid-template-columns: 96px 1fr;
    gap: 10px 14px;
  }
}
