/* =============================================================================
   styles.css — "Popular Science 1980" design system
   Rust terracotta + warm paper, Roboto Slab body, condensed uppercase headings.
   You normally never need to touch this file — edit content.js instead.
============================================================================= */

/* ---- Theme tokens ---------------------------------------------------------- */
:root {
  color-scheme: light;
  --rust: #c04a2b;
  --warm-orange: #d4652a;
  --golden: #d4a834;
  --cream: #e8d5b0;
  --dark-brown: #3a2218;
  --paper: #faf6ee;

  --bg: var(--paper);
  --text: #1a1a1a;
  --text-light: #6b6b6b;
  --theme: var(--rust);
  --hover: var(--warm-orange);
  --card-bg: #ffffff;
  --divider: rgba(0, 0, 0, 0.10);
  --footer-bg: var(--dark-brown);
  --footer-text: var(--cream);
  --code-bg: rgba(192, 74, 43, 0.05);
  --shadow: 0 2px 8px rgba(58, 34, 24, 0.10), 0 1px 2px rgba(58, 34, 24, 0.08);
  --max-width: 930px;

  /* Article figure "wells" — figures/charts sit on true white, framed,
     so they read cleanly even though the page itself stays warm paper. */
  --fig-mat: #ffffff;
  --fig-border: rgba(58, 34, 24, 0.12);
  --fig-cap-bg: #f4ecdc;
  --fig-cap-text: #6b6b6b;
  --fig-shadow: 0 2px 16px rgba(58, 34, 24, 0.12), 0 1px 3px rgba(58, 34, 24, 0.07);

  --font-body: "Roboto Slab", Georgia, "Times New Roman", serif;
  --font-head: "Barlow Condensed", "Roboto", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--dark-brown);
  --text: var(--cream);
  --text-light: #b89b78;
  --theme: var(--golden);
  --hover: var(--cream);
  --card-bg: #4a2f22;
  --divider: #5a4233;
  --footer-bg: #2c1a12;
  --footer-text: var(--cream);
  --code-bg: rgba(232, 213, 176, 0.08);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  /* figure wells stay light in dark mode (charts read best on white) */
  --fig-border: rgba(0, 0, 0, 0.18);
  --fig-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

/* Japanese typography — swap to Noto when the page is in Japanese */
html[lang="ja"] {
  --font-body: "Noto Serif JP", "Roboto Slab", serif;
  --font-head: "Noto Sans JP", "Barlow Condensed", sans-serif;
}
html[lang="ja"] h1, html[lang="ja"] h2, html[lang="ja"] h3,
html[lang="ja"] .lead-tagline, html[lang="ja"] .nav-link,
html[lang="ja"] .brand-name {
  text-transform: none;     /* uppercasing does not apply to Japanese */
  letter-spacing: 0;
  font-weight: 700;
}
html[lang="ja"] .drop-cap > p:first-of-type::first-letter { float: none; font-size: inherit; padding: 0; color: inherit; }
/* Noto JP has a larger glyph body than Roboto Slab, and the headings swap from
   the CONDENSED Barlow to full-width Noto Sans JP — so Japanese reads visibly
   bigger at the same px. Scale the key elements down so the layout keeps the
   same visual weight across all three languages. */
html[lang="ja"] body { font-size: 16px; }
html[lang="ja"] h1 { font-size: 2.05rem; }
html[lang="ja"] h2 { font-size: 1.48rem; }
html[lang="ja"] h3 { font-size: 1.18rem; }
html[lang="ja"] .lead-tagline { font-size: 1.42rem; }
html[lang="ja"] .post-desc { font-size: 0.94rem; }
html[lang="ja"] .nav-link { font-size: 0.86rem; }
html[lang="ja"] .year-head { font-size: 1.28rem; }
html[lang="ja"] .pub-title { font-size: 1rem; }
html[lang="ja"] .conf-title { font-size: 0.96rem; }
html[lang="ja"] .masthead .post-title { font-size: 2.5rem; }
html[lang="ja"] .article-title { font-size: 1.95rem; }
html[lang="ja"] .article-body { font-size: 1.04rem; }
html[lang="ja"] .article-body > h2 { font-size: 1.35rem; }
html[lang="ja"] .article-body > h3 { font-size: 1.15rem; }
html[lang="ja"] .post-row-title { font-size: 1.3rem; }

/* ---- Reset / base ---------------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}
img { max-width: 100%; height: auto; }
a { color: var(--theme); text-decoration: none; transition: color 0.15s; }
a:hover { text-decoration: underline; }
p { margin: 0 0 1.1rem; }
::selection { background: var(--golden); color: #1a1a1a; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin: 0 0 0.8rem;
}
h1 { font-size: 2.6rem; }
h2 { font-size: 1.9rem; }
h3 { font-size: 1.4rem; }

/* magazine section rule under h2 */
.section-rule {
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--theme);
  margin-bottom: 1.2rem;
}

/* ---- Layout ---------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}
main {
  flex: 1 0 auto;
  width: 100%;
  padding-top: 88px;     /* clear fixed navbar */
  padding-bottom: 48px;
}
.page { animation: fade 0.4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Navbar ---------------------------------------------------------------- */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--divider);
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.brand-social { display: flex; align-items: center; gap: 15px; font-size: 1.18rem; }
.brand-social a { color: var(--text); display: inline-flex; }
.brand-social a:hover { color: var(--theme); }
.nav-spacer { flex: 1 1 auto; min-width: 8px; }
.nav-links { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-link {
  font-family: var(--font-head);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 0.98rem;
  color: var(--text);
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  background: none; border: none;
  position: relative;
  white-space: nowrap;
}
.nav-link::after {
  content: ""; position: absolute; left: 9px; right: 9px; bottom: 0;
  height: 2px; background: var(--theme); transform: scaleX(0);
  transform-origin: left; transition: transform 0.2s;
}
.nav-link:hover { text-decoration: none; color: var(--theme); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }
.nav-link.active { color: var(--theme); }

.nav-tool {
  background: none; border: none; cursor: pointer; color: var(--text);
  font-size: 0.92rem; padding: 5px 7px; border-radius: 5px;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.02em;
  white-space: nowrap;
}
.nav-tool:hover { color: var(--theme); background: var(--code-bg); }
.kbd { font-family: var(--font-head); font-size: 0.85rem; opacity: 0.7; }
.nav-burger { display: none; background: none; border: none; cursor: pointer; color: var(--text);
  font-size: 1.15rem; padding: 5px 9px; border-radius: 5px; align-items: center; }
.nav-burger:hover { color: var(--theme); background: var(--code-bg); }
/* wrapper is transparent on desktop (children flow into the bar); becomes the
   dropdown panel on phones. order: keeps links left, lang on the right. */
.nav-collapse { display: contents; }
.nav-burger { order: 1; }
.nav-links { order: 2; }
.nav-spacer { order: 3; }
#search-toggle { order: 4; }
.lang-switch { order: 5; }
#theme-toggle { order: 6; }

/* ---- Language switcher (variants) ----------------------------------------- */
.lang-switch { display: flex; align-items: center; }

/* segmented (default) */
.lang-switch[data-style="segmented"] { background: var(--code-bg); border-radius: 6px; padding: 2px; gap: 0; }
.lang-switch[data-style="segmented"] .lang-opt {
  font-family: var(--font-head); font-weight: 600; font-size: 0.88rem;
  letter-spacing: 0.03em; border: none; background: none; cursor: pointer;
  color: var(--text-light); padding: 3px 9px; border-radius: 4px; line-height: 1.3;
}
.lang-switch[data-style="segmented"] .lang-opt.active { background: var(--theme); color: #fff; }

/* text links */
.lang-switch[data-style="text"] { gap: 2px; }
.lang-switch[data-style="text"] .lang-opt {
  font-family: var(--font-head); font-weight: 600; font-size: 0.92rem;
  border: none; background: none; cursor: pointer; color: var(--text-light);
  padding: 2px 5px;
}
.lang-switch[data-style="text"] .lang-opt::after { content: "/"; margin-left: 7px; color: var(--divider); }
.lang-switch[data-style="text"] .lang-opt:last-child::after { content: ""; }
.lang-switch[data-style="text"] .lang-opt.active { color: var(--theme); }

/* globe dropdown */
.lang-switch[data-style="globe"] { position: relative; }
.lang-switch[data-style="globe"] .lang-current {
  background: none; border: none; cursor: pointer; color: var(--text);
  font-size: 1rem; padding: 5px 7px; border-radius: 5px;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-head); font-weight: 600; letter-spacing: 0.03em;
}
.lang-switch[data-style="globe"] .lang-current:hover { color: var(--theme); background: var(--code-bg); }
.lang-switch[data-style="globe"] .lang-menu {
  position: absolute; top: 110%; right: 0; min-width: 130px;
  background: var(--card-bg); border: 1px solid var(--divider); border-radius: 8px;
  box-shadow: var(--shadow); padding: 5px; display: none; flex-direction: column; z-index: 20;
}
.lang-switch[data-style="globe"].open .lang-menu { display: flex; }
.lang-switch[data-style="globe"] .lang-opt {
  font-family: var(--font-head); font-weight: 500; font-size: 0.95rem; text-align: left;
  border: none; background: none; cursor: pointer; color: var(--text);
  padding: 6px 10px; border-radius: 5px;
}
.lang-switch[data-style="globe"] .lang-opt:hover { background: var(--code-bg); color: var(--theme); }
.lang-switch[data-style="globe"] .lang-opt.active { color: var(--theme); font-weight: 700; }

/* ---- Home / about ---------------------------------------------------------- */
.post-title { margin-bottom: 0.2rem; }
.post-desc { color: var(--text-light); font-size: 1.05rem; margin-bottom: 1.6rem; font-family: var(--font-body); }
.profile {
  float: right; width: 270px; max-width: 42%; margin: 0 0 1rem 2rem;
}
.profile img { border-radius: 6px; box-shadow: var(--shadow); display: block; width: 100%; }
.lead-tagline {
  font-family: var(--font-head); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.01em; font-size: 2rem; line-height: 1.15; color: var(--theme);
  margin: 0 0 1.25rem;
}
.drop-cap > p:first-of-type::first-letter {
  font-family: var(--font-head); font-weight: 700; color: var(--theme);
  float: left; font-size: 3.6rem; line-height: 0.78; padding: 0.35rem 0.6rem 0 0;
}
.clearfix::after { content: ""; display: block; clear: both; }

/* hero variant: masthead */
.masthead {
  border-top: 3px solid var(--theme); border-bottom: 3px solid var(--theme);
  padding: 14px 0; margin-bottom: 1.6rem; text-align: center;
}
.masthead .post-title { font-size: 3.2rem; margin: 0; }
.masthead .post-desc { text-align: center; margin: 0.4rem 0 0; }

/* ---- Publications ---------------------------------------------------------- */
.year-head {
  font-family: var(--font-head); font-weight: 700; color: var(--theme);
  font-size: 1.6rem; margin: 2rem 0 0.8rem; padding-bottom: 0.2rem;
  border-bottom: 2px solid var(--theme);
}
.year-head:first-child { margin-top: 0.5rem; }

.pub-list { list-style: none; margin: 0; padding: 0; }
.pub {
  display: grid; grid-template-columns: 90px 1fr; gap: 18px;
  padding: 16px 0; align-items: start;
}
.pub-thumb { width: 90px; }
.pub-thumb img { width: 100%; border-radius: 4px; box-shadow: var(--shadow); display: block; }
.pub-title { font-weight: 500; font-size: 1.12rem; line-height: 1.3; margin-bottom: 0.25rem; }
.pub-authors { font-size: 0.98rem; color: var(--text); margin-bottom: 0.15rem; }
.pub-authors .me { font-style: italic; font-weight: 500; }
.pub-journal { font-size: 0.96rem; color: var(--text-light); margin-bottom: 0.5rem; }
.pub-journal em { color: var(--text); font-style: italic; }
.pub-links { display: flex; flex-wrap: wrap; gap: 7px; }
.btn-sm {
  font-family: var(--font-head); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; font-size: 0.8rem; color: var(--theme);
  border: 1px solid var(--theme); border-radius: 4px; padding: 2px 9px; cursor: pointer;
  background: none; display: inline-flex; align-items: center; gap: 5px; line-height: 1.5;
}
.btn-sm:hover { background: var(--theme); color: #fff; text-decoration: none; }
.pub-abstract {
  grid-column: 1 / -1; margin-top: 12px; padding: 14px 16px;
  background: var(--code-bg); border-left: 3px solid var(--theme); border-radius: 0 6px 6px 0;
  font-size: 0.98rem; color: var(--text); display: none;
}
.pub-abstract.open { display: block; }

/* pub list — minimal variant (no thumbnails) */
.pub-list[data-style="minimal"] .pub { grid-template-columns: 1fr; }
.pub-list[data-style="minimal"] .pub-thumb { display: none; }

/* pub list — index variant (compact, no thumbnails, no abstract preview button gap) */
.pub-list[data-style="index"] .pub { grid-template-columns: 1fr; gap: 4px; padding: 11px 0; }
.pub-list[data-style="index"] .pub-thumb { display: none; }
.pub-list[data-style="index"] .pub-title { font-size: 1rem; font-weight: 500; }
.pub-list[data-style="index"] .pub-journal { margin-bottom: 0.3rem; }

/* ---- Projects -------------------------------------------------------------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px; }
.proj-card {
  background: var(--card-bg); border: 1px solid var(--divider); border-radius: 8px;
  overflow: hidden; cursor: pointer; transition: transform 0.18s, box-shadow 0.18s;
  display: flex; flex-direction: column;
}
.proj-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.proj-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.proj-card-body { padding: 14px 16px 18px; }
.proj-card-title { font-size: 1.2rem; margin-bottom: 0.4rem; line-height: 1.12; }
.proj-card-desc { font-size: 0.95rem; color: var(--text-light); line-height: 1.45; }
.proj-meta { font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 0.8rem; color: var(--theme); margin-top: 0.7rem; }

.proj-hero-fig { margin: 0 0 1.4rem; }
.proj-detail img.proj-hero { width: 100%; max-height: 360px; object-fit: cover; border-radius: 8px; margin: 0; box-shadow: var(--shadow); display: block; }
.proj-credit { font-family: var(--font-head); font-size: 0.78rem; letter-spacing: 0.02em;
  color: var(--text-light); text-align: right; margin-top: 0.45rem; }
.proj-credit a { color: var(--text-light); text-decoration: underline; text-underline-offset: 2px; }
.proj-credit a:hover { color: var(--theme); }
.proj-detail h2 { margin-top: 1.8rem; padding-bottom: 0.3rem; border-bottom: 2px solid var(--theme); }
.proj-detail table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.proj-detail th, .proj-detail td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--divider); font-size: 0.95rem; }
.proj-detail th { font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.03em; }
.back-link {
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 600; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 1rem;
}

/* ---- Conferences ----------------------------------------------------------- */
#conference-map { height: 460px; width: 100%; border-radius: 8px; margin-bottom: 1.8rem; box-shadow: var(--shadow); z-index: 1; }
.conf-list { list-style: none; margin: 0; padding: 0; }
.conf-item { display: grid; grid-template-columns: 64px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--divider); }
.conf-year { font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; color: var(--theme); line-height: 1; }
.conf-title { font-weight: 500; font-size: 1.06rem; }
.conf-loc { font-size: 0.95rem; color: var(--text-light); margin-bottom: 0.3rem; }
.conf-pres { font-size: 0.97rem; }
.conf-role { display: inline-block; font-family: var(--font-head); text-transform: uppercase;
  letter-spacing: 0.04em; font-size: 0.72rem; color: var(--theme); border: 1px solid var(--theme);
  border-radius: 3px; padding: 0 6px; margin-left: 6px; vertical-align: middle; }

/* ---- Blog list (distill-style writing) ------------------------------------- */
.post-list { display: flex; flex-direction: column; }
.post-row {
  display: grid; grid-template-columns: 1fr; gap: 4px;
  padding: 20px 0; border-top: 1px solid var(--divider);
  color: inherit; text-decoration: none;
}
.post-row:first-child { border-top: none; }
.post-row:hover { text-decoration: none; }
.post-row:has(.post-row-thumb) { grid-template-columns: 150px 1fr; gap: 22px; align-items: start; }
.post-row-thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; box-shadow: var(--shadow); display: block; }
.post-row-date { font-family: var(--font-head); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; font-size: 0.78rem; color: var(--theme); margin-bottom: 0.15rem; }
.post-row-title { font-family: var(--font-head); font-weight: 600; font-size: 1.6rem; line-height: 1.12; margin-bottom: 0.3rem; }
.post-row:hover .post-row-title { color: var(--theme); }
.post-row-sum { color: var(--text-light); line-height: 1.5; font-size: 1rem; }
.article-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.6rem; }
.tag { font-family: var(--font-head); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 0.68rem; color: var(--text-light); background: var(--code-bg); border-radius: 3px; padding: 2px 8px; }

/* ---- Article (distill-style reading) --------------------------------------- */
.page.article { max-width: 760px; }
.article-head { margin-bottom: 1.8rem; }
.article-title { font-family: var(--font-head); font-weight: 700; text-transform: none;
  letter-spacing: 0; font-size: 2.7rem; line-height: 1.08; margin: 0.4rem 0 0.7rem; }
.article-meta { font-family: var(--font-head); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; font-size: 0.82rem; color: var(--theme); }
.article-body { font-size: 1.08rem; line-height: 1.75; }
.article-body > h2 { font-family: var(--font-head); font-weight: 700; text-transform: none; letter-spacing: 0;
  font-size: 1.6rem; margin: 2.2rem 0 0.7rem; padding-bottom: 0.25rem; border-bottom: 2px solid var(--theme); }
.article-body > h3 { font-family: var(--font-head); font-weight: 600; text-transform: none; letter-spacing: 0;
  font-size: 1.25rem; margin: 1.6rem 0 0.5rem; }
.article-body p { margin: 0 0 1.15rem; }
.article-body a { color: var(--theme); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.article-body ul, .article-body ol { padding-left: 1.3rem; margin: 0 0 1.15rem; }
.article-body li { margin-bottom: 0.4rem; }
.article-body blockquote { margin: 0 0 1.15rem; padding: 0.4rem 0 0.4rem 1.1rem;
  border-left: 3px solid var(--theme); color: var(--text-light); font-style: italic; }
.article-loading { color: var(--text-light); }

.article-fig { margin: 1.9rem 0; text-align: center; }
.article-fig .fig-well {
  background: var(--fig-mat); border: 1px solid var(--fig-border);
  border-radius: 8px; box-shadow: var(--fig-shadow); padding: 14px;
}
.article-fig img { width: 100%; border-radius: 4px; display: block; box-shadow: none; }
.article-fig figcaption {
  font-family: var(--font-head); font-size: 0.86rem; color: var(--fig-cap-text);
  line-height: 1.45; margin-top: 0.7rem;
  display: inline-block; max-width: 92%;
  background: var(--fig-cap-bg); border-radius: 6px; padding: 7px 14px;
}

.article-body pre { background: var(--code-bg); border: 1px solid var(--divider); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; margin: 0 0 1.3rem; font-size: 0.92rem; line-height: 1.55; }
.article-body :not(pre) > code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88em;
  background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.article-body pre code { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: none; padding: 0; }

.article-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 2px; margin: 1.4rem 0; }
.article-body table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: 0.95rem; }
.article-body th, .article-body td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--divider); }
.article-body th { font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.03em; }

.article-body .footnotes { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--divider);
  font-size: 0.92rem; color: var(--text-light); }
.article-body .footnotes ol { padding-left: 1.2rem; }
.article-body .footnotes li { margin-bottom: 0.5rem; }
.article-body sup a, .article-body a[data-footnote-ref] { color: var(--theme); text-decoration: none; font-weight: 600; padding: 0 1px; }


/* ---- Footer ---------------------------------------------------------------- */
footer {
  flex-shrink: 0; background: var(--footer-bg); color: var(--footer-text);
  font-size: 0.86rem; padding: 16px 0;
}
footer a { color: var(--footer-text); text-decoration: underline; text-underline-offset: 2px; }
footer a:hover { color: var(--golden); }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.footer-copy { line-height: 1.5; }
.footer-row .updated { opacity: 0.7; white-space: nowrap; }
.footer-social {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
  gap: 18px; font-size: 1.2rem;
}
.footer-social a { color: var(--footer-text); text-decoration: none; display: inline-flex; align-items: center; transition: color 0.15s; }
.footer-social a:hover { color: var(--golden); }
.social-cv {
  font-family: var(--font-head); font-weight: 700; font-size: 0.88rem; letter-spacing: 0.06em;
  border: 1.5px solid currentColor; border-radius: 4px; padding: 1px 7px; line-height: 1.35;
}
@media (max-width: 640px) {
  .footer-row { justify-content: center; text-align: center; }
}

/* ---- Search modal ---------------------------------------------------------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(20, 12, 8, 0.45);
  backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.search-overlay.open { display: flex; }
.search-box { width: 92%; max-width: 560px; background: var(--card-bg); border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4); overflow: hidden; border: 1px solid var(--divider); }
.search-box input {
  width: 100%; border: none; outline: none; background: none; color: var(--text);
  font-family: var(--font-body); font-size: 1.1rem; padding: 18px 20px; border-bottom: 1px solid var(--divider);
}
.search-results { max-height: 50vh; overflow-y: auto; }
.search-result {
  padding: 12px 20px; cursor: pointer; border-bottom: 1px solid var(--divider); display: block;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.sel { background: var(--code-bg); }
.sr-kind { font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 0.72rem; color: var(--theme); }
.sr-title { font-size: 1rem; color: var(--text); }
.search-empty { padding: 22px 20px; color: var(--text-light); text-align: center; }

/* ---- Progress + back-to-top ------------------------------------------------ */
#progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--theme); z-index: 1100; transition: width 0.1s; }
#back-to-top {
  position: fixed; bottom: 26px; right: 26px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(58,34,24,0.5); color: #fff; border: none; cursor: pointer; font-size: 1.1rem;
  display: none; align-items: center; justify-content: center; z-index: 900;
}
#back-to-top.show { display: flex; }
#back-to-top:hover { background: var(--theme); }

/* ---- Responsive ------------------------------------------------------------ */
/* Tablet / small laptop — narrow the measure and trim oversized blocks. */
@media (max-width: 900px) {
  :root { --max-width: 760px; }
  h1 { font-size: 2.3rem; }
  .masthead .post-title { font-size: 2.6rem; }
  #conference-map { height: 400px; }
  .proj-detail img.proj-hero { max-height: 300px; }
}

/* Phones */
@media (max-width: 640px) {
  body { font-size: 16px; }
  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.65rem; }
  .nav-burger { display: inline-flex; }
  .nav-inner { flex-wrap: nowrap; gap: 6px; padding: 7px 14px; }
  .nav-spacer { display: block; }
  .kbd { display: none; }
  #search-toggle { padding: 6px 8px; }
  /* links + language collapse into a tap-to-open menu under the bar */
  .nav-collapse {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 6px;
    background: var(--bg); border-bottom: 1px solid var(--divider);
    box-shadow: var(--shadow); padding: 10px;
  }
  #navbar.menu-open .nav-collapse { display: flex; }
  .nav-links { flex-direction: column; align-items: stretch; gap: 2px; width: 100%; }
  .nav-links .nav-link { width: 100%; text-align: left; padding: 12px 14px; font-size: 1.05rem; border-radius: 6px; }
  .nav-links .nav-link::after { display: none; }
  .nav-links .nav-link.active { background: var(--code-bg); }
  .nav-collapse .lang-switch { justify-content: flex-start; gap: 4px; padding: 9px 14px 3px; margin-top: 2px; border-top: 1px solid var(--divider); }
  main { padding-top: 116px; }
  .profile { float: none; width: 64%; max-width: 240px; margin: 0 auto 1.4rem; }
  .lead-tagline { font-size: 1.55rem; }
  .masthead .post-title { font-size: 2.2rem; }
  .pub { grid-template-columns: 64px 1fr; gap: 12px; }
  .pub-thumb { width: 64px; }
  .lang-switch[data-style="segmented"] .lang-opt { padding: 3px 7px; }
  /* projects + writings + conferences */
  .proj-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .post-row:has(.post-row-thumb) { grid-template-columns: 110px 1fr; gap: 14px; }
  .post-row-title { font-size: 1.3rem; }
  #conference-map { height: 320px; }
  .conf-item { grid-template-columns: 50px 1fr; gap: 12px; }
  .conf-year { font-size: 1.25rem; }
  .proj-detail img.proj-hero { max-height: 230px; }
  .article-fig .fig-well { padding: 10px; }
  /* keep wide tables/code from forcing horizontal page scroll */
  .article-body table, .proj-detail table { display: block; overflow-x: auto; }
}

/* Small phones */
@media (max-width: 400px) {
  h1 { font-size: 1.85rem; }
  .lead-tagline { font-size: 1.35rem; }
  .post-row:has(.post-row-thumb) { grid-template-columns: 1fr; gap: 6px; }
  .post-row-thumb { max-width: 240px; }
  .back-link { font-size: 0.84rem; }
}
