/* ---------- Tokens ---------- */
:root {
  --choc: #4A2A1D;        /* chocolate brown: the one accent */
  --choc-soft: #F4EEEA;   /* pale tint for quiet backgrounds */
  --ink: #1D1917;
  --muted: #6F6560;
  --line: #E6E0DC;
  --bg: #FFFFFF;
  --font: "Google Sans Flex", "Google Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--choc); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--choc); outline-offset: 3px; }

/* ---------- Page frame: fits one screen on desktop ---------- */
.frame {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 28px 40px 20px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------- Navigation: joined chocolate-outlined cells ---------- */
nav { display: flex; justify-content: center; }
.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  border: 2px solid var(--choc);
  border-radius: 10px;
  overflow: hidden;
}
.tabs a {
  display: block;
  padding: 11px 22px;
  text-align: center;
  text-decoration: none;
  color: var(--choc);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.01em;
  transition: background-color .18s ease, color .18s ease;
}
.tabs a + a { border-left: 2px solid var(--choc); }
.tabs a:hover, .tabs a[aria-current="page"] { background: var(--choc); color: #fff; }
.tabs a:focus-visible { outline-offset: -5px; outline-color: #fff; }

/* ---------- Views ---------- */
main { min-height: 0; display: flex; justify-content: center; padding: 32px 0 12px; }
.view { width: 100%; display: none; min-height: 0; }
.view.active { display: flex; }

/* About */
#view-about { align-items: center; justify-content: center; }
.about {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 560px);
  align-items: center;
  justify-content: center;
  gap: 64px;
  width: 100%;
}
.photo-wrap { display: flex; }
.photo {
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 200px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--choc-soft);
}
.about h1 {
  margin: 0 0 10px;
  font-size: clamp(38px, 4vw, 56px);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--choc);
}
.affil { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.5; }
.bio { margin: 22px 0 26px; max-width: 54ch; font-size: 17.5px; line-height: 1.7; }
.links { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--choc); font-size: 16px; font-weight: 500;
  text-decoration: none;
  border-bottom: 2px dotted var(--choc);
  padding-bottom: 2px;
}
a.link:hover { border-bottom-style: solid; }
.link svg { width: 18px; height: 18px; flex: none; }
.link.soon { color: var(--muted); border-bottom-color: var(--line); cursor: default; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border: 2px solid var(--choc);
  border-radius: 8px;
  color: var(--choc);
  background: transparent;
  text-decoration: none;
  font: inherit; font-weight: 500; font-size: 15px;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}
.btn:hover { background: var(--choc); color: #fff; }
.btn svg { width: 17px; height: 17px; flex: none; }

/* Research: page fixed, inner panel scrolls */
#view-research, #view-writing, #view-cv { flex-direction: column; align-items: center; }
.panel {
  width: 100%; max-width: 860px;
  min-height: 0; flex: 1;
  overflow-y: auto;
  padding: 4px 20px 24px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.panel section + section { margin-top: 40px; }
h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 600;
  color: var(--choc);
  letter-spacing: -0.01em;
}
.entry {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.entry:last-child { border-bottom: 1px solid var(--line); }
.when { color: var(--muted); font-weight: 500; font-size: 15px; padding-top: 1px; }
.title { margin: 0; font-weight: 500; line-height: 1.4; }
.meta { margin: 4px 0 0; color: var(--muted); font-size: 15.5px; }
.meta b { color: var(--ink); font-weight: 500; }
.kind { display: block; margin-top: 2px; color: var(--choc); font-size: 13px; font-weight: 500; }

/* Writing */
.essay { max-width: 680px; margin: 0 auto; }
.back { display: inline-block; color: var(--choc); font-size: 15px; font-weight: 500; text-decoration: none; border-bottom: 2px dotted var(--choc); padding-bottom: 1px; margin-bottom: 28px; }
.back:hover { border-bottom-style: solid; }
.essay h1 { margin: 0; font-size: 34px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; color: var(--choc); }
.essay .sub { margin: 10px 0 0; font-size: 19px; line-height: 1.4; color: var(--muted); }
.essay-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; padding-bottom: 22px; border-bottom: 2px dotted var(--choc); }
.essay-meta .date { margin: 0 !important; padding: 0 !important; border: 0 !important; }
.copy-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border: 2px solid var(--choc); border-radius: 8px;
  background: transparent; color: var(--choc);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}
.copy-link:hover { background: var(--choc); color: #fff; }
.copy-link svg { width: 16px; height: 16px; }
.essay .date { margin: 14px 0 0; padding-bottom: 22px; border-bottom: 2px dotted var(--choc); color: var(--muted); font-size: 14.5px; font-weight: 500; }
.essay .body { margin-top: 26px; font-size: 18px; line-height: 1.8; }
.essay .body p { margin: 0 0 1.15em; }
.essay .body em { font-style: italic; }
.pager { display: flex; justify-content: space-between; gap: 24px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager a { color: var(--choc); text-decoration: none; font-weight: 500; font-size: 15.5px; max-width: 48%; }
.pager a:hover { text-decoration: underline; }
.pager small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-bottom: 2px; }
.pager .next { text-align: right; margin-left: auto; }
.empty { margin: auto; text-align: center; max-width: 34ch; }
.empty p { color: var(--muted); margin: 0; }
.posts { list-style: none; margin: 0; padding: 0; }
.posts a { display: grid; grid-template-columns: 92px 1fr; gap: 20px; padding: 16px 12px; margin: 0 -12px; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); border-radius: 8px; transition: background-color .18s ease, color .18s ease; }
.posts a:hover { background: var(--choc); color: #fff; }
.posts a:hover .when, .posts a:hover .meta { color: #E9DCD4; }
.posts .meta { display: block; }
.posts .excerpt {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 8px; max-width: 64ch; color: var(--muted); font-size: 15.5px; line-height: 1.6;
}
.posts a:hover .excerpt { color: #E9DCD4; }

/* CV */
.cv-bar { width: 100%; max-width: 980px; display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 14px; }
.cv-frame {
  width: 100%; max-width: 980px; flex: 1; min-height: 0;
  border: 2px solid var(--choc); border-radius: 10px; overflow: hidden; background: var(--choc-soft);
}
.cv-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }

/* Standalone essay pages scroll normally */
.page-essay .frame { height: auto !important; min-height: 100vh; min-height: 100dvh; }
.page-essay main { display: block; padding-top: 40px; }
.page-essay .essay { padding-bottom: 24px; }

footer { text-align: center; color: var(--muted); font-size: 13.5px; padding-top: 8px; }

/* ---------- Desktop: lock to one screen ---------- */
@media (min-width: 900px) and (min-height: 620px) {
  .frame { height: 100vh; height: 100dvh; }
}

/* ---------- Smaller screens: stack and scroll normally ---------- */
@media (max-width: 899px) {
  .frame { padding: 18px 16px 16px; }
  .tabs { grid-template-columns: repeat(4, auto); }
  .tabs a { padding: 9px 14px; font-size: 14.5px; }
  .about { grid-template-columns: 1fr; gap: 28px; max-width: 520px; margin: 0 auto; }
  .photo-wrap { max-width: 300px; margin: 0 auto; width: 100%; }
  .about h1 { font-size: 36px; }
  .panel { overflow: visible; padding-right: 0; }
  .entry, .posts a { grid-template-columns: 1fr; gap: 2px; }
  .essay h1 { font-size: 28px; }
  .essay .body { font-size: 17px; }
  .cv-frame { height: 75vh; flex: none; }
  .cv-bar { justify-content: center; }
}
@media (max-width: 380px) {
  .tabs a { padding: 9px 10px; font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
