/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  /* CN-friendly, fast system font stack with CJK and emoji fallbacks */
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
               "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC",
               "Microsoft YaHei", "WenQuanYi Micro Hei",
               "Noto Sans",
               /* Emoji-capable fonts (ensure icons like 🧠🧭🔭🧑‍🏫💼 render across OS) */
               "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color",
               sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg);
  color: var(--text);
}

img {
  max-width: 100%;
  display: block;
}
 
/* Design tokens */
:root {
  /* Brand (defaults; overridden per theme below) */
  --primary: #2563eb; /* blue-600 for light */
  --primary-600: #1d4ed8; /* blue-700 */
  --primary-700: #1e40af; /* blue-800 */
  --link: var(--primary);
  --secondary: #0ea5e9; /* sky-500 */
  --secondary-600: #0a94d1;
  --secondary-700: #087fb3;
  --accent: #f59e0b; /* amber-500 */
  --success: #10b981; /* emerald-500 */

  /* Neutrals */
  --bg: #f9fafb; /* light neutral per spec */
  --surface: #ffffff;
  --surface-2: #f3f4f6; /* gray-100 */
  --text: #111827; /* gray-900 */
  --muted: #6b7280; /* gray-500 */
  --border: #e5e7eb; /* gray-200 */

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.06);
  --shadow-md: 0 6px 16px rgba(2, 6, 23, 0.08);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.28);
}

/* Manual theme override */
:root[data-theme="light"] {
  /* Light mode palette per spec */
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --link: #2563eb;
  --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.06);
  --shadow-md: 0 6px 16px rgba(2, 6, 23, 0.08);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.28);
}

:root[data-theme="dark"] {
  /* Dark mode palette per spec */
  --bg: #111827;        /* slate-900 */
  --surface: #1f2937;   /* slate-800 for cards */
  --surface-2: #111827; /* page sections */
  --text: #f9fafb;      /* near-white */
  --muted: #9ca3af;     /* gray-400 */
  --border: #374151;    /* slate-700 */
  --primary: #3b82f6;   /* blue-500 */
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --link: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 10px 24px rgba(0,0,0,0.4);
  --ring: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* Dark mode (automatic via OS preference) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    /* Follow OS: use our dark palette */
    --bg: #111827;
    --surface: #1f2937;
    --surface-2: #111827;
    --text: #f9fafb;
    --muted: #9ca3af;
    --border: #374151;
    --primary: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --link: #3b82f6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
    --shadow-md: 0 10px 24px rgba(0,0,0,0.4);
    --ring: 0 0 0 3px rgba(59, 130, 246, 0.35);
  }
}

/* --- Language visibility helpers --- */
.i18n { display: none; }
html[lang="zh"] .i18n.l-zh { display: inline; }
html[lang="en"] .i18n.l-en { display: inline; }
html[lang="es"] .i18n.l-es { display: inline; }

/* Utility classes */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 0;
}

.section {
  padding: 4rem 0;
  scroll-margin-top: 80px;
  /* Sections are initially hidden for a fade‑in effect that triggers as
     they enter the viewport. The transition is defined here and the
     `visible` class will override the opacity and transform once the
     element is observed. */
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

/* When a section has the `visible` class, restore full opacity and
   neutral position. This class is toggled via Intersection Observer in
   script.js. */
.section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Safety: on blog posts, ensure the content section (immediately after page-hero)
  is visible even if IntersectionObserver fails or is delayed */
.blog-post .section + .section { opacity: 1; transform: none; }

.btn {
  display: inline-block;
  padding: 0.8rem 1.6rem;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.2s ease, color 0.2s ease;
  margin-right: 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.btn.primary {
  background-color: var(--primary);
}

.btn.primary:hover {
  background-color: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn.secondary {
  background-color: var(--secondary);
}

.btn.secondary:hover {
  background-color: var(--secondary-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn.outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.outline:hover {
  color: #fff;
  background: var(--text);
}
/* Disabled button appearance */
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

/* Icon button and RSS variant */
.btn.icon-only { padding: 0.5rem; width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 12px; }
.btn.icon-only .icon { width: 1.05rem; height: 1.05rem; }
/* RSS/Email buttons use brand primary for strong contrast in light theme */
.btn.rss { background: var(--primary); color: #fff; font-size: 0.92rem; padding: 0.65rem 1.1rem; }
.btn.rss:hover { background: var(--primary-600); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn.rss.outline { background: transparent; color: var(--primary); border-color: color-mix(in oklab, var(--primary), var(--border) 45%); font-size: 0.92rem; padding: 0.6rem 1rem; }
.btn.rss.outline:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
/* Center the standalone RSS icon perfectly */
#rss-button.icon-only, a#rss-button.icon-only { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; }
#rss-button.icon-only .icon { width: 18px; height: 18px; display: block; }

/* Light theme: boost contrast for outline variant (dark text/border) */
:root[data-theme="light"] .btn.rss.outline {
  color: var(--text);
  border-color: color-mix(in oklab, var(--text), var(--border) 20%);
}
:root[data-theme="light"] .btn.rss.outline:hover {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* Subtle glassmorphism variant for buttons (used when enabled) */
.btn.glass {
  background: color-mix(in oklab, var(--surface) 20%, transparent);
  border: 1px solid color-mix(in oklab, var(--border), white 20%);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  color: #fff;
}
.btn.glass:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Contact page: improve readability of footer links in dark theme */
:root[data-theme="dark"] .contact a {
  color: #e5e7eb; /* near-white text for clarity */
  text-decoration-color: currentColor;
}
:root[data-theme="dark"] .contact a:hover,
:root[data-theme="dark"] .contact a:focus-visible {
  color: #e0e7ff; /* slightly brighter on hover */
}

/* --- Education timeline link styling --- */
.education .timeline h3 a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1.25px;
  text-decoration-color: color-mix(in oklab, var(--primary) 50%, transparent);
}
.education .timeline h3 a:hover,
.education .timeline h3 a:focus-visible {
  color: var(--primary-600);
  text-decoration-color: var(--primary-600);
}

/* Dark theme: brighten link color for readability on deep backgrounds */
:root[data-theme="dark"] .education .timeline h3 a {
  /* Tasteful off‑white with a hint of brand primary for premium feel */
  color: color-mix(in oklab, #ffffff 82%, var(--primary) 18%);
  text-decoration: underline;
  text-decoration-thickness: 1.25px;
  text-decoration-color: currentColor;
}
:root[data-theme="dark"] .education .timeline h3 a:hover,
:root[data-theme="dark"] .education .timeline h3 a:focus-visible {
  color: #ffffff;
  text-decoration-color: currentColor;
}

/* System-follow dark without manual override */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .education .timeline h3 a {
  color: color-mix(in oklab, #ffffff 82%, var(--primary) 18%);
  text-decoration-color: currentColor;
  }
  :root:not([data-theme]) .education .timeline h3 a:hover,
  :root:not([data-theme]) .education .timeline h3 a:focus-visible {
  color: #ffffff;
  text-decoration-color: currentColor;
  }
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #111827;
  color: #fff;
  padding: 8px 12px;
  z-index: 10000;
  border-radius: 0 0 8px 8px;
}
.skip-link:focus { top: 0; box-shadow: var(--ring); }

/* Navbar (scope to top-level page header only) */
body > header {
  position: fixed;
  top: 0;
  width: 100%;
  background-color: color-mix(in oklab, var(--surface) 90%, transparent);
  backdrop-filter: saturate(120%) blur(10px);
  -webkit-backdrop-filter: saturate(120%) blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.navbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.8rem 0;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.brand-logo {
  display: block;
  width: 28px;
  height: 28px;
}
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}
@media (max-width: 768px){ .logo { font-size: 1.25rem; } }

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

/* Right-aligned actions cluster */
.nav-actions { display: flex; align-items: center; gap: .6rem; justify-self: end; position: relative; flex-wrap: nowrap; }
.nav-actions .lang-switcher { position: relative; }
/* Keep equal spacing between language, theme and menu buttons */
.nav-actions .theme-toggle { margin-left: 0; }
.nav-actions .btn { margin-right: 0; }
.lang-switcher .lang-menu { right: 0; left: auto; }

.nav-links li a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.nav-links li a:hover {
  color: var(--primary);
}

/* Ensure inline icons in nav links (e.g., Home) render consistently */
.nav-links li a .icon { width: 1rem; height: 1rem; display: inline-block; vertical-align: -2px; margin-right: .35rem; }
.nav-links li a .icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Ensure sufficient contrast for links in dark theme */
/* System-follow disabled; keep explicit dark styles only */
:root[data-theme="dark"] .nav-links li a { color: #e5e7eb; }
:root[data-theme="dark"] .nav-links li a:hover { color: #93c5fd; }

/* System mode disabled */
/* :root[data-theme-mode="system"] ... commented out */

.icon-btn { display: inline-flex; align-items: center; gap: .45rem; }
.icon-btn .icon { width: 1rem; height: 1rem; }
.lang-switcher select {
  -webkit-appearance: none;
  appearance: none;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.lang-menu { position: absolute; margin-top: .5rem; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); min-width: 160px; padding: .25rem; z-index: 10; }
.lang-menu li { list-style: none; padding: .5rem .75rem; border-radius: 8px; cursor: pointer; color: var(--text); }
.lang-menu li:hover { background: var(--surface-2); }
.lang-switcher select:hover { box-shadow: var(--shadow-md); }
.lang-switcher select:focus-visible { outline: none; box-shadow: var(--ring); }

/* Improve contrast for language select in dark theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .lang-switcher select {
    background-color: color-mix(in oklab, var(--surface), white 10%) !important;
    border-color: color-mix(in oklab, var(--border), white 18%) !important;
    color: #e5e7eb !important;
  }
}
:root[data-theme="dark"] .lang-switcher select {
  background-color: color-mix(in oklab, var(--surface), white 10%) !important;
  border-color: color-mix(in oklab, var(--border), white 18%) !important;
  color: #e5e7eb !important;
}

.theme-toggle {
  margin-left: 0; /* spacing is handled by parent gap */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.2s ease, color 0.2s ease;
}
.theme-toggle .icon { width: 1.1rem; height: 1.1rem; }
.theme-toggle:hover { 
  transform: translateY(-1px); 
  box-shadow: var(--shadow-md);
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.theme-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-bulb { display: none; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-system { display: none; }

/* light theme explicit: show moon to indicate switching to dark */
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: inline; }
[data-theme="light"] .theme-toggle .icon-system { display: none; }

/* dark theme explicit: show bulb to indicate switching to light */
[data-theme="dark"] .theme-toggle .icon-bulb { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-system { display: none; }

/* aesthetic: warm glow when hovering the bulb (dark theme) */
[data-theme="dark"] .theme-toggle:hover .icon-bulb {
  color: #ffea7a; /* warm light */
  filter: drop-shadow(0 0 8px rgba(255, 234, 122, 0.6));
}

/* --- Share toolbar & modal --- */
.share-toolbar { display: flex; gap: 8px; align-items: center; }
.share-toolbar .btn { padding: .5rem .8rem; border-radius: 8px; font-weight: 500; }
.share-toolbar .btn .icon { width: 16px; height: 16px; display: inline-block; vertical-align: -2px; margin-right: .4rem; stroke: currentColor; fill: none; stroke-width: 1.8; }
.share-toolbar .btn span { font-size: 14px; line-height: 1; }
.share-toolbar .share-title { font-size: 14px; color: var(--muted); }
@media (max-width: 480px) {
  .share-toolbar { gap: 6px; }
  .share-toolbar .btn { padding: .45rem .7rem; }
  .share-toolbar .btn span { font-size: 13px; }
  .share-toolbar .btn .icon { width: 16px; height: 16px; margin-right: .35rem; }
}
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 2000; }
.modal[hidden] { display: none; }
.modal .modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: min(480px, 92vw); box-shadow: var(--shadow-md); }
.modal .modal-content canvas, .modal .modal-content img { width: 200px; height: 200px; image-rendering: pixelated; }

/* Slider verification */
.slider-verify.done { outline: 2px solid color-mix(in oklab, var(--success), white 10%); }
.slider-verify .slider-thumb { transition: left 120ms ease; }

/* System-follow icon behavior disabled */

/* System icon disabled */
/* :root[data-theme-mode="system"] .theme-toggle .icon-system { display: inline; } */
/* :root[data-theme-mode="system"] .theme-toggle .icon-sun,
:root[data-theme-mode="system"] .theme-toggle .icon-moon { display: none; } */

/* About: interactive portrait effects */
.about-hero { display: grid; align-items: center; grid-template-columns: 1fr auto; gap: 1rem; }
.about-portrait { position: relative; width: 200px; height: 200px; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-md); }
.about-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx-tilt { transition: transform 300ms ease, box-shadow 300ms ease; transform-style: preserve-3d; }
.fx-tilt:hover { transform: perspective(700px) rotateX(6deg) rotateY(-6deg) translateY(-2px); box-shadow: 0 20px 40px rgba(2,6,23,0.18); }
.fx-tilt:active { transform: perspective(700px) rotateX(2deg) rotateY(-2deg) translateY(0); }
.fx-tilt .fx-glow { position: absolute; inset: -1px; border-radius: 22px; pointer-events: none; }
.fx-tilt .fx-glow::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120px 120px at var(--fx-x, 20%) var(--fx-y, 20%), rgba(255,255,255,0.25), transparent 60%), linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0)); mix-blend-mode: screen; }
.fx-tilt .fx-glow::after { content: ""; position: absolute; inset: 0; border-radius: 22px; box-shadow: 0 0 0 1px rgba(255,255,255,0.35) inset, 0 0 24px rgba(99,102,241,0.25), 0 0 12px rgba(14,165,233,0.25); }

/* Dark theme tuning */
:root[data-theme="dark"] .fx-tilt .fx-glow::before { background: radial-gradient(120px 120px at var(--fx-x, 20%) var(--fx-y, 20%), rgba(255,255,255,0.22), transparent 60%), linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0)); }
:root[data-theme="dark"] .fx-tilt .fx-glow::after { box-shadow: 0 0 0 1px rgba(255,255,255,0.24) inset, 0 0 24px rgba(99,102,241,0.28), 0 0 12px rgba(14,165,233,0.28); }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .fx-tilt, .fx-tilt:hover, .fx-tilt:active { transition: none; transform: none; }
}

/* Programmatic pop animation to draw attention once */
@keyframes fxPopTilt {
  0% { transform: perspective(700px) rotateX(0deg) rotateY(0deg) translateY(0) scale(1); }
  22% { transform: perspective(700px) rotateX(10deg) rotateY(-10deg) translateY(-3px) scale(1.028); }
  60% { transform: perspective(700px) rotateX(4deg) rotateY(-4deg) translateY(-1px) scale(1.012); }
  100% { transform: perspective(700px) rotateX(0deg) rotateY(0deg) translateY(0) scale(1); }
}
@keyframes fxGlowPulse {
  0% { box-shadow: 0 0 0 1px rgba(255,255,255,0.28) inset, 0 0 16px rgba(99,102,241,0.28), 0 0 8px rgba(14,165,233,0.28); }
  22% { box-shadow: 0 0 0 1px rgba(255,255,255,0.5) inset, 0 0 36px rgba(99,102,241,0.45), 0 0 22px rgba(14,165,233,0.45); }
  60% { box-shadow: 0 0 0 1px rgba(255,255,255,0.38) inset, 0 0 26px rgba(99,102,241,0.36), 0 0 14px rgba(14,165,233,0.36); }
  100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.28) inset, 0 0 16px rgba(99,102,241,0.28), 0 0 8px rgba(14,165,233,0.28); }
}
.fx-tilt.fx-pop { animation: fxPopTilt 900ms cubic-bezier(.2,.8,.2,1); }
.fx-tilt.fx-pop .fx-glow::after { animation: fxGlowPulse 900ms ease; }
.fx-tilt.fx-pop .fx-glow::before { filter: brightness(1.15); }

/* System-mode border tweaks disabled */

/* Hamburger for mobile */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  /* ensure comfortable tap target */
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

.hamburger span {
  width: 24px;
  height: 3px;
  background-color: var(--text);
  border-radius: 2px;
}

/* Hero Section */
.hero {
  position: relative;
  height: 100vh; /* fallback */
  min-height: 100svh; /* better on mobile address bar */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  padding-top: calc(80px + env(safe-area-inset-top));
  color: #fff;
}

.hero .hero-content {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  margin-bottom: 1rem;
}

.hero p {
  font-size: clamp(1.02rem, 1.25vw, 1.18rem);
  margin-bottom: 1.6rem;
}

/* Hero actions layout */
.hero-buttons { display:flex; gap:.8rem; flex-wrap:wrap; justify-content:center; }
.hero-buttons .btn { margin-right: 0; }
@media (max-width: 640px) {
  .hero-buttons { flex-direction: column; align-items: stretch; gap:.7rem; }
  .hero-buttons .btn { width: 100%; padding: .95rem 1rem; }
}

/* Page Hero (smaller) */
.page-hero {
  position: relative;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #fff;
}
.page-hero { padding-top: calc(84px + env(safe-area-inset-top)); }
.page-hero .container { position: relative; z-index: 1; }
.page-hero h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

/* About page: round portrait overlay in hero */
.about-hero { display:flex; align-items:center; justify-content: space-between; gap: 1rem; margin-top: clamp(14px, 4.5vh, 36px); }
.about-portrait {
  position: relative; /* inside container */
  width: clamp(96px, 14vw, 160px);
  height: clamp(96px, 14vw, 160px);
  border-radius: 50%;
  padding: 6px; /* soft frame */
  background: color-mix(in oklab, #fff 22%, transparent);
  box-shadow: 0 10px 30px rgba(2,6,23,0.18), 0 0 0 1px color-mix(in oklab, var(--border), white 20%);
  backdrop-filter: blur(2px) saturate(120%);
  -webkit-backdrop-filter: blur(2px) saturate(120%);
}
.about-portrait img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 28%; /* more headroom: move image down inside frame */
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--border), white 30%);
}
/* For reveal variant, remove the soft frame so initial state is visually seamless */
.about-portrait.fx-reveal {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
/* Hide glow until after reveal starts, then fade it in */
.about-portrait.fx-reveal .fx-glow { opacity: 0; transition: opacity 600ms ease 1s; }
.about-portrait.fx-reveal.revealed .fx-glow { opacity: 1; }
/* Reveal effect: use the same animated gradient as the page hero background */
.page-hero ~ .about .about-portrait.fx-reveal::before,
.about-hero .about-portrait.fx-reveal::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--hero-bg);
  background-size: 200% 200%;
  animation: gradientShift 18s ease infinite;
  z-index: 2;
  pointer-events: none;
}
.about-portrait.fx-reveal img { opacity: 0; transition: opacity 1.1s ease .55s; clip-path: circle(0% at 50% 50%); }
.about-portrait.fx-reveal.revealed img { opacity: 1; animation: imgCircleReveal 1400ms ease .4s forwards; }
/* Subtle scale-in for ceremony */
.about-portrait.fx-reveal { transform: scale(0.985); transition: transform 1200ms cubic-bezier(.2,.8,.2,1) .4s; }
.about-portrait.fx-reveal.revealed { transform: scale(1); }
@keyframes circleReveal {
  0% { clip-path: circle(100% at 50% 50%); }
  100% { clip-path: circle(0% at 50% 50%); }
}
.about-portrait.fx-reveal.revealed::before { animation: none; display: none !important; }

/* New: image-based reveal to ensure indistinguishable initial state (no overlay) */
@keyframes imgCircleReveal {
  0% { clip-path: circle(0% at 50% 50%); }
  100% { clip-path: circle(100% at 50% 50%); }
}

/* Disable overlay entirely so the initial view is exactly the page background */
.about-portrait.fx-reveal::before { display: none !important; }

/* Reduced motion: show image immediately, hide overlay */
@media (prefers-reduced-motion: reduce) {
  .about-portrait.fx-reveal img { opacity: 1 !important; clip-path: none !important; animation: none !important; transition: none !important; }
  .about-portrait.fx-reveal::before { display: none !important; }
}
@media (max-width: 640px) {
  .about-hero { gap: .75rem; }
  .about-portrait { width: 84px; height: 84px; padding: 4px; }
}
/* Blog post hero spacing: allow content to grow to avoid clipping on tall titles/meta */
.blog-post .page-hero { min-height: 260px; height: auto; }
.blog-post .page-hero { padding-top: calc(120px + env(safe-area-inset-top)); }
/* Override global overflow to prevent text clipping at the bottom in posts */
.blog-post .page-hero { overflow: visible; }
/* Keep the title comfortably away from the navbar, with symmetric margins */
.blog-post .page-hero .post-title { margin: .6rem 0; }
.blog-post .page-hero .post-meta { opacity: .95; }

/* Blog typography (prose-like) */
.blog-post .i18n-block { font-size: 1.02rem; line-height: 1.75; }
.blog-post .i18n-block h2 { font-size: clamp(1.15rem, 2.2vw, 1.55rem); line-height: 1.35; margin-top: 2.2rem; margin-bottom: .85rem; letter-spacing: .2px; }
.blog-post .i18n-block h3 { font-size: clamp(1.05rem, 1.9vw, 1.25rem); line-height: 1.4; margin-top: 1.6rem; margin-bottom: .6rem; }
.blog-post .i18n-block p,
.blog-post .i18n-block ul,
.blog-post .i18n-block ol,
.blog-post .i18n-block blockquote,
.blog-post .i18n-block pre,
.blog-post .i18n-block table { margin-top: .9rem; margin-bottom: .9rem; }
.blog-post .i18n-block ul,
.blog-post .i18n-block ol { padding-left: 1.25rem; }
.blog-post .i18n-block li + li { margin-top: .35rem; }
.blog-post .i18n-block blockquote { border-left: 3px solid color-mix(in oklab, var(--border), currentColor 10%); background: color-mix(in oklab, var(--surface), white 6%); padding: .75rem .95rem; border-radius: 8px; }
:root[data-theme="dark"] .blog-post .i18n-block blockquote { background: color-mix(in oklab, var(--surface), black 6%); }
.blog-post .i18n-block pre { background: color-mix(in oklab, var(--surface), white 6%); border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1rem; overflow-x: auto; box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .blog-post .i18n-block pre { background: color-mix(in oklab, var(--surface), black 6%); }
.blog-post .i18n-block code:not(pre code) { background: color-mix(in oklab, var(--surface), white 8%); border: 1px solid var(--border); border-radius: 6px; padding: .05rem .35rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .95em; }
:root[data-theme="dark"] .blog-post .i18n-block code:not(pre code) { background: color-mix(in oklab, var(--surface), black 8%); }
.blog-post .i18n-block .muted { color: var(--muted); }
/* Improve contrast of meta line over gradient hero, especially in light theme */
.blog-post .page-hero .post-meta {
  color: color-mix(in oklab, white 94%, var(--text) 6%);
  text-shadow: 0 1px 2px rgba(2, 6, 23, 0.28);
  opacity: 1;
}
:root[data-theme="light"] .blog-post .page-hero .post-meta { color: color-mix(in oklab, white 96%, var(--text) 4%); }
/* Blog links: ensure contrast, especially in dark theme */
.blog-post .i18n-block a { color: color-mix(in oklab, var(--primary), black 10%); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1.2px; }
.blog-post .i18n-block a:hover, .blog-post .i18n-block a:focus-visible { color: var(--primary-600); }
:root[data-theme="dark"] .blog-post .i18n-block a { color: #93c5fd; text-decoration-color: currentColor; }
:root[data-theme="dark"] .blog-post .i18n-block a:visited { color: #a5b4fc; }
:root[data-theme="dark"] .blog-post .i18n-block a:hover, :root[data-theme="dark"] .blog-post .i18n-block a:focus-visible { color: #bfdbfe; }

/* Prose width: match page title container width for consistency */
.blog-post .container.prose { max-width: 1200px; }

/* Magazine-style drop cap for the first paragraph of each language block (content area only) */
.blog-post .container.prose .i18n-block p:first-of-type::first-letter {
  float: left;
  font-size: 3.2em;
  line-height: 0.9;
  padding: 0 .18em 0 0;
  font-weight: 700;
  color: color-mix(in oklab, var(--accent), var(--text) 20%);
}
/* Opt-in class to apply drop cap elsewhere when desired */
.blog-post .i18n-block .dropcap::first-letter { all: unset; }
.blog-post .i18n-block .dropcap:first-letter {
  float: left;
  font-size: 3.2em;
  line-height: 0.9;
  padding: 0 .18em 0 0;
  font-weight: 700;
  color: color-mix(in oklab, var(--accent), var(--text) 20%);
}

/* Background shapes and gradient for hero/page-hero */
.hero, .page-hero { background-size: 200% 200%; animation: gradientShift 18s ease infinite; }
/* Light theme hero */
:root:not([data-theme]), :root[data-theme="light"] {
  --hero-bg: radial-gradient(1000px 600px at 15% 10%, rgba(14,165,233,0.35) 0%, transparent 55%),
             radial-gradient(900px 600px at 85% 30%, rgba(99,102,241,0.35) 0%, transparent 60%),
             linear-gradient(135deg, #0ea5e9 0%, #6366f1 50%, #22d3ee 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --hero-bg: radial-gradient(1000px 600px at 15% 10%, rgba(2,6,23,0.8) 0%, transparent 55%),
               radial-gradient(900px 600px at 85% 30%, rgba(3,7,18,0.8) 0%, transparent 60%),
               linear-gradient(135deg, #0b1220 0%, #0f172a 50%, #111827 100%);
  }
}
:root[data-theme="dark"] {
  --hero-bg: radial-gradient(1000px 600px at 15% 10%, rgba(2,6,23,0.8) 0%, transparent 55%),
             radial-gradient(900px 600px at 85% 30%, rgba(3,7,18,0.8) 0%, transparent 60%),
             linear-gradient(135deg, #0b1220 0%, #0f172a 50%, #111827 100%);
}
.hero, .page-hero { background: var(--hero-bg); }

/* Tables (blog) – refined look with subtle grid lines */
.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); background: var(--surface); }
.table-wrap table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .98rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: .6rem .75rem; }
/* Horizontal separators */
.table-wrap thead th { font-weight: 600; background: color-mix(in oklab, var(--surface), white 6%); position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--border); }
:root[data-theme="dark"] .table-wrap thead th { background: color-mix(in oklab, var(--surface), black 6%); }
.table-wrap tbody td { border-bottom: 1px solid var(--border); }
/* Vertical separators (no double border on first column) */
.table-wrap th + th, .table-wrap td + td { border-left: 1px solid var(--border); }
/* Rounded corners by clipping inner table to wrapper */
.table-wrap { overflow: hidden; }
/* Row striping and hover */
.table-wrap tbody tr:nth-child(odd) { background: color-mix(in oklab, var(--surface), white 3%); }
:root[data-theme="dark"] .table-wrap tbody tr:nth-child(odd) { background: color-mix(in oklab, var(--surface), black 3%); }
.table-wrap tbody tr:hover { background: color-mix(in oklab, var(--surface), white 5%); }
:root[data-theme="dark"] .table-wrap tbody tr:hover { background: color-mix(in oklab, var(--surface), black 5%); }
/* Make standalone tables (if any) look acceptable even without wrapper */
.blog-post .i18n-block table { width: 100%; border-collapse: collapse; font-size: .98rem; margin: 12px 0; }
.blog-post .i18n-block table th, .blog-post .i18n-block table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.blog-post .i18n-block table th + th, .blog-post .i18n-block table td + td { border-left: 1px solid var(--border); }
.blog-post .i18n-block table thead th { background: color-mix(in oklab, var(--surface), white 6%); }
:root[data-theme="dark"] .blog-post .i18n-block table thead th { background: color-mix(in oklab, var(--surface), black 6%); }

/* Code highlight theme hooks (works now; integrates later with Prism/HLJS) */
.blog-post pre code { display: block; color: color-mix(in oklab, var(--text), black 5%); }
/* Prism-like tokens */
.blog-post pre code .token.comment,
.blog-post pre code .token.prolog,
.blog-post pre code .token.doctype,
.blog-post pre code .token.cdata { color: #708090; }
.blog-post pre code .token.punctuation { color: #56677b; }
.blog-post pre code .token.property,
.blog-post pre code .token.tag,
.blog-post pre code .token.constant,
.blog-post pre code .token.symbol,
.blog-post pre code .token.deleted { color: #d14; }
.blog-post pre code .token.boolean,
.blog-post pre code .token.number { color: #b75501; }
.blog-post pre code .token.selector,
.blog-post pre code .token.attr-name,
.blog-post pre code .token.string,
.blog-post pre code .token.char,
.blog-post pre code .token.builtin,
.blog-post pre code .token.inserted { color: #0f7b6c; }
.blog-post pre code .token.operator,
.blog-post pre code .token.entity,
.blog-post pre code .token.url { color: #5a6b7b; }
.blog-post pre code .token.atrule,
.blog-post pre code .token.attr-value,
.blog-post pre code .token.keyword { color: #6f42c1; }
.blog-post pre code .token.function,
.blog-post pre code .token.class-name { color: #005cc5; }
.blog-post pre code .token.regex,
.blog-post pre code .token.important,
.blog-post pre code .token.variable { color: #e36209; }
.blog-post pre code .token.bold { font-weight: 700; }
.blog-post pre code .token.italic { font-style: italic; }

/* HLJS compatibility */
.blog-post pre code.hljs { color: color-mix(in oklab, var(--text), black 5%); }
.blog-post pre code .hljs-comment { color: #708090; }
.blog-post pre code .hljs-keyword { color: #6f42c1; }
.blog-post pre code .hljs-string { color: #0f7b6c; }
.blog-post pre code .hljs-number { color: #b75501; }
.blog-post pre code .hljs-title { color: #005cc5; }

/* Localized hero art in posts */
.post-hero-art { margin: 12px 0 16px; }
.post-hero-art img { width: 100%; display: block; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }

.bg-shapes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bg-shapes .shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: float 30s linear infinite;
}
.shape1 {
  background: color-mix(in oklab, var(--primary), white 10%);
  width: 450px;
  height: 450px;
  top: -150px;
  left: -100px;
  animation-duration: 28s;
}
.shape2 {
  background: color-mix(in oklab, var(--secondary), white 10%);
  width: 350px;
  height: 350px;
  top: 50px;
  right: -150px;
  animation-duration: 32s;
}
.shape3 {
  background: color-mix(in oklab, var(--accent), white 10%);
  width: 400px;
  height: 400px;
  bottom: -120px;
  left: 30%;
  animation-duration: 26s;
}
.shape4 {
  background: color-mix(in oklab, var(--success), white 10%);
  width: 300px;
  height: 300px;
  bottom: 80px;
  right: 40px;
  animation-duration: 34s;
}

/* Dark theme: tone down decorative shapes for clearer differentiation */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .bg-shapes .shape { opacity: 0.25; filter: blur(90px); }
}
:root[data-theme="dark"] .bg-shapes .shape { opacity: 0.25; filter: blur(90px); }

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes float {
  0% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-30px) translateX(20px); }
  100% { transform: translateY(0) translateX(0); }
}

/* About Section */
.about-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr; /* give text a bit more space to reduce wrapping */
  gap: 2rem;
  align-items: start; /* align to top for height consistency */
}
/* Vertically center the photo column relative to the text block for unified alignment */
.about-photo { align-self: center; display: flex; align-items: center; justify-content: center; }
.about-photo img {
  border-radius: 16px;
  background-color: transparent; /* avoid visible fill around image */
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4; /* natural portrait frame, avoids letterboxing */
  height: auto;
  max-height: 640px; /* cap to help align with text height */
  object-fit: cover; /* fill frame with no side bars */
  object-position: 50% 32%; /* lift to show roof while keeping subject */
}
.about-text h2 {
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  margin-bottom: 1rem;
  color: var(--primary);
}
.about-text p {
  margin-bottom: 1rem;
  color: var(--muted);
}
.about-text .lead { font-size: 1.05rem; line-height: 1.75; color: color-mix(in oklab, var(--text), var(--muted) 25%); margin-bottom: 1.1rem; }
.feature-columns { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: .5rem; }
.feature-group { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; box-shadow: var(--shadow-sm); }
.feature-group h3 { font-size: 1.02rem; color: var(--secondary); margin-bottom: .45rem; letter-spacing: .1px; }
.feature-group ul { list-style: disc; padding-left: 1.05rem; display: grid; gap: .25rem; color: var(--text); font-size: .94rem; line-height: 1.5; }
.feature-group li { color: var(--muted); break-inside: avoid; }
/* Prevent overflow on mobile for long English/Spanish tokens */
.feature-group ul, .feature-group li { overflow-wrap: anywhere; word-break: break-word; hyphens: auto; }

/* Desktop: use two wider columns to reduce wrapping (better height balance with photo) */
@media (min-width: 900px) {
  .feature-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* On very wide screens, split the first list into two columns to shorten vertical length */
@media (min-width: 1100px) {
  #home-deliver-list { columns: 2; column-gap: 1.2rem; }
  #home-deliver-list li { break-inside: avoid; }
}
/* (moved above; keeping declarations here removed to avoid duplication) */

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}
.timeline-item h3 {
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
  color: var(--secondary);
}
.timeline-item p {
  color: var(--muted);
}

/* Interests */
.interests-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.interests-list li {
  background-color: var(--surface-2);
  padding: 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Research Summary */
.research-summary h2,
.blog-summary h2,
.contact-summary h2 {
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  margin-bottom: 1rem;
  color: var(--primary);
}
.research-summary p,
.blog-summary p,
.contact-summary p {
  color: var(--muted);
  margin-bottom: 1.5rem;
  max-width: 700px;
}

/* Portfolio */
.portfolio h2 { font-size: clamp(1.8rem, 3vw, 2.2rem); color: var(--primary); margin-bottom: 1rem; }
.portfolio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem; margin-top: 0.5rem; }
.portfolio-item { padding: 1.2rem; }
.portfolio-filters .btn { padding: 0.5rem 0.9rem; }
.portfolio-content h3 { font-size: 1.2rem; margin: 0.6rem 0; color: var(--text); }
.portfolio-content .muted { color: var(--muted); margin-bottom: 0.6rem; }
.portfolio-meta { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Publications */
.pub-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}
.publications h2 { font-size: clamp(1.5rem, 2.3vw, 1.9rem); color: var(--primary); letter-spacing: .2px; margin-bottom: .25rem; }
.pub-item {
  background-color: var(--surface);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  /* Reduce initial flicker by deferring expensive transitions until after first paint */
  transition: box-shadow 0.18s ease, border-color 0.2s ease;
  will-change: transform;
  /* Desktop: lay out content and actions side-by-side */
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 1.25rem;
  align-items: center;
}
.pub-item h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.4rem; color: color-mix(in oklab, var(--text), var(--primary) 12%); letter-spacing: .1px; }
.pub-item p {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  line-height: 1.55;
}
.pub-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in oklab, var(--border), var(--primary) 18%);
}
.pub-actions { display:flex; gap:.6rem; align-self: center; justify-self: end; }
.pub-item .pub-meta { grid-column: 1; }
.pub-item h3, .pub-item p { grid-column: auto; }
.pub-item .pub-actions { grid-column: 2; }
.pub-item .pub-actions .btn { padding: 0.55rem 1rem; font-size: 0.95rem; border-radius: 10px; display: inline-flex; align-items: center; border: 1px solid var(--primary); color: var(--primary); background: transparent; }
.pub-item .pub-actions .btn .icon { margin-right: .4rem; }
.pub-item .pub-actions .btn.outline { color: var(--primary); border-color: var(--primary); background: transparent; }
.pub-item .pub-actions .btn.outline:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  border-color: var(--primary-600);
}
.pub-item .pub-actions .btn.outline:active { transform: translateY(0); }
.pub-item .pub-actions .btn.outline:focus-visible { box-shadow: var(--ring); }

/* Venue and authors polish */
.pub-item .pub-venue { color: color-mix(in oklab, var(--muted), var(--text) 25%); font-weight: 500; font-style: italic; }
.pub-item .pub-authors { color: color-mix(in oklab, var(--muted), var(--text) 20%); font-size: .93rem; }
.pub-item .pub-authors strong { color: color-mix(in oklab, var(--text), var(--muted) 30%); font-weight: 500; }
.pub-item .pub-actions .btn.primary { box-shadow: var(--shadow-sm); }
.pub-item .pub-actions .btn.primary:hover { box-shadow: var(--shadow-md); }

/* Blog post bottom nav: tidy spacing */
.post-nav { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Mobile: stack actions under content with a divider */
@media (max-width: 768px) {
  .pub-item { display: block; }
  .pub-actions { margin-top: .75rem; flex-wrap: wrap; justify-content: flex-start; border-top: 1px solid var(--border); padding-top: .75rem; }
}
@media (max-width: 640px) { .pub-actions .btn { padding: .5rem .85rem; font-size: .92rem; } }

/* Modal viewer */
.modal[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 2000; overscroll-behavior: contain; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,6,23,.6); backdrop-filter: blur(2px); }
.modal-dialog { position: relative; margin: 4vh auto; width: min(92vw, 1100px); height: 88svh; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-md); display:flex; flex-direction: column; overflow:hidden; }
.modal-header { display:flex; align-items:center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.modal-body { position: relative; flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal-close { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: .25rem .5rem; cursor: pointer; color: var(--text); }
.modal-close:hover { box-shadow: var(--shadow-sm); }
.modal-body iframe { width: 100%; height: 100%; min-height: 100%; display: block; border: 0; background: #111; }
.modal-fallback { padding: 1rem; color: var(--muted); }

/* Blog page */
.blog .blog-posts {
  margin-top: 2rem;
  display: grid;
  gap: 14px; /* increase distance between posts for better readability */
}
.blog .post-card h3 { line-height: 1.3; }
/* Override any inline color on old title links to use our new palette */
.blog .post-card h3 a:not(.post-card-title-link) { color: inherit !important; text-decoration: none; }
.blog .post-card h3 a:not(.post-card-title-link):hover { text-decoration: underline; }

/* Blog list/card */
.post-card { display:grid; grid-template-columns:140px 1fr; gap:14px; padding:14px; align-items:center; }
/* Visually nudge thumbnails right a bit so text inside OG covers doesn't hug the left edge */
@media (min-width: 561px){
  .post-card .post-thumb { transform: translateX(2px); }
}
/* Distinct, attractive blog title color to improve affordance */
.post-card-title a.post-card-title-link {
  text-decoration: none;
  color: color-mix(in oklab, var(--text), var(--primary) 22%);
}
.post-card-title a.post-card-title-link:hover,
.post-card-title a.post-card-title-link:focus-visible {
  color: color-mix(in oklab, var(--text), var(--primary) 40%);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1.25px;
}
:root[data-theme="dark"] .post-card-title a.post-card-title-link {
  color: #c7d2fe; /* indigo-200 */
}
:root[data-theme="dark"] .post-card-title a.post-card-title-link:hover,
:root[data-theme="dark"] .post-card-title a.post-card-title-link:focus-visible {
  color: #e0e7ff; /* indigo-100 */
}
@media (max-width: 560px){
  .post-card { grid-template-columns:1fr; }
  .post-card img { width:100%; height:auto; }
}
.post-placeholder {
  background-color: var(--surface-2);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  border: 1px solid var(--border);
}
.post-placeholder h3 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

/* Blog: post navigation */
.post-nav { display:flex; gap:.6rem; align-items:center; flex-wrap: wrap; justify-content: space-between; }
.post-nav .btn[aria-disabled="true"] { opacity:.6; pointer-events:none; }
.post-nav .btn[aria-disabled="true"]:hover { text-decoration: none; }

/* Article TOC */
.toc { background: var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow: var(--shadow-sm); }
.toc strong { display:block; margin-bottom:.35rem; color: var(--primary); }
.toc ol { list-style: decimal; padding-left: 1.2rem; display: grid; gap: .35rem; margin-top:.25rem; }
.toc a { color: color-mix(in oklab, var(--text), var(--primary) 10%); text-decoration: none; }
.toc a:hover { text-decoration: underline; color: var(--primary); }
.toc a.active { color: var(--primary); font-weight: 600; text-decoration: none; }

/* Contact form */
.contact-form {
  display: grid;
  gap: 1rem;
  max-width: 600px;
  margin-top: 1rem;
}
.form-group {
  display: flex;
  flex-direction: column;
}
.form-group label {
  margin-bottom: 0.3rem;
  font-weight: 600;
  color: var(--primary);
}
.form-group input,
.form-group textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}
.contact-form .btn[type="submit"],
.contact-form button[type="submit"] {
  width: 100%;
  justify-self: stretch;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* Footer */
footer {
  background: var(--surface-2);
  color: var(--text);
  text-align: center;
  padding: 1rem 0;
  font-size: 0.9rem;
}
.footer-cta { max-width: 800px; margin: 0 auto 1rem; padding: 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); color: var(--text); }
.footer-cta h3 { margin-bottom: 0.4rem; color: var(--text); }
.footer-cta .muted { color: var(--muted); margin-bottom: 0.8rem; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) footer {
    background: linear-gradient(180deg, rgba(15,23,42,1) 0%, rgba(2,6,23,1) 100%);
    color: #eef2ff;
  }
}
:root[data-theme="dark"] footer {
  background: linear-gradient(180deg, rgba(15,23,42,1) 0%, rgba(2,6,23,1) 100%);
  color: #eef2ff;
}

/* Pretty number counters (PV/UV) */
.site-footer-center { display: grid; justify-content: center; text-align: center; }
.counter {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 0.98rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.25rem;
}
.counter .counter-item { white-space: normal; }
.counter .counter-number { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .3px; color: #0ea5e9; }

/* Subscribe page: improve email input ergonomics */
.embeddable-buttondown-form { display: grid; gap: 10px; }
.embeddable-buttondown-form #bd-email {
  width: 100%;
  padding: 0.7rem 0.9rem; /* increase height */
  line-height: 1.25;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}
.embeddable-buttondown-form #bd-email:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.embeddable-buttondown-form .btn.primary { width: 100%; }

/* ---------- Design system: badges, tags, utilities ---------- */
.icon { display: inline-block; width: 1.1rem; height: 1.1rem; vertical-align: -0.2rem; color: currentColor; }
.icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.75; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: color-mix(in oklab, var(--secondary) 16%, transparent);
  color: color-mix(in oklab, var(--secondary), black 10%);
  border: 1px solid color-mix(in oklab, var(--border), var(--secondary) 18%);
}
.badge.success {
  background: color-mix(in oklab, var(--success) 16%, transparent);
  color: color-mix(in oklab, var(--success), black 10%);
  border-color: color-mix(in oklab, var(--border), var(--success) 18%);
}
.tag {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow-md); }

/* AI Lab grid */
.lab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.lab-card { display: flex; flex-direction: column; min-height: 180px; padding: 16px; border-radius: 12px; }
.lab-card-header { margin-bottom: 8px; }
.lab-title { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.lab-sub { font-size: .95rem; color: var(--muted); margin-top: 4px; }
.lab-body { margin-top: 8px; }
.lab-actions { margin-top: auto; display: flex; gap: .6rem; flex-wrap: wrap; }
.lab-card--active { border-color: color-mix(in oklab, var(--primary) 35%, var(--border)); box-shadow: 0 6px 18px rgba(99,102,241,0.12); }
.lab-card--coming { background: color-mix(in oklab, var(--surface) 86%, var(--surface-2)); }
:root[data-theme="dark"] .lab-card--coming { background: color-mix(in oklab, var(--surface), black 6%); }

@media (max-width: 1024px) { .lab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .lab-grid { grid-template-columns: 1fr; } }

/* Responsive styles */
@media (max-width: 768px) {
  .navbar { grid-template-columns: 1fr auto auto; }
  .nav-links {
    position: absolute;
    top: 60px;
    right: 0;
    background-color: var(--surface);
    flex-direction: column;
    width: 200px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    padding: 1rem;
    box-shadow: var(--shadow-md);
    border-left: 1px solid var(--border);
  }
  .nav-links.open {
    transform: translateX(0);
  }
  .hamburger {
    display: flex;
  }
  /* shrink language button on narrow screens and avoid overlap with brand */
  .icon-btn .label { display: none; }
  .icon-btn { padding: .5rem; }
  .nav-actions { gap: .5rem; }
  .theme-toggle { width: 34px; height: 34px; }
  /* ensure minimum tap size for buttons */
  .btn { min-height: 42px; }
  .about-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem; /* slightly tighter gap on mobile */
  }
  /* Reset photo alignment on mobile to avoid odd spacing when stacked */
  .about-photo { align-self: start; }
  .about-text .lead { font-size: 1rem; line-height: 1.7; }
  /* tighter vertical rhythm on mobile */
  .section { padding: 3rem 0; }
  .page-hero { padding-top: 78px; }
  /* Keep extra space on blog hero too for small screens */
  /* Ensure blog title clears the fixed navbar and safe area on iOS */
  .blog-post .page-hero { padding-top: calc(128px + env(safe-area-inset-top)); }
  .blog-post .page-hero { min-height: 260px; height: auto; overflow: visible; }
  .blog-post .page-hero .post-title { font-size: clamp(1.25rem, 5.6vw, 1.5rem); margin-top: .25rem; }
  .blog-post .page-hero .post-meta { margin-bottom: .25rem; }
  /* Post navigation: wrap and prevent overflow */
  .post-nav { flex-wrap: wrap; justify-content: space-between; gap: .5rem; }
  .post-nav .btn { flex: 1 1 calc(50% - .5rem); text-align: center; }
  .post-nav .btn[aria-disabled="true"] { flex-basis: calc(50% - .5rem); }
  .post-nav .btn:first-child { flex-basis: 100%; }
  .post-nav .muted { display: none; }
  .about-photo img { max-height: min(85vh, 560px); object-position: 50% 36%; }
  .interests-list {
    grid-template-columns: 1fr;
  }
  .timeline-item h3 {
    font-size: 1rem;
  }
  /* On mobile, bypass fade-in to avoid rare IO timing issues: show sections immediately */
  .section { opacity: 1; transform: none; }
}

/* Very small devices: further cap image height */
@media (max-width: 380px) {
  .about-photo img { max-height: min(70vh, 480px); }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .section { transition: none; }
  .hero, .page-hero { animation: none; }
  .bg-shapes .shape { animation: none; }
}

/* --- AI Radar additions: grid, Top 5 section, card polish --- */
.grid { display: grid; gap: 16px; }
.grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid--two { grid-template-columns: 1fr; } }
/* four-column responsive grid for Top 8 */
.grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid--four { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid--four { grid-template-columns: 1fr; } }

.top5-wrap { background: color-mix(in oklab, var(--primary) 6%, transparent); border: 1px solid color-mix(in oklab, var(--primary) 15%, var(--border)); padding: 16px; border-radius: 16px; margin: 24px 0; }
.top5-title { font-weight: 700; font-size: 1.05rem; display:flex; align-items:center; gap:8px; color: color-mix(in oklab, var(--text), var(--primary) 18%); }
.top5-title::after { content: ""; flex: 1; height: 1px; background: color-mix(in oklab, var(--primary) 25%, var(--border)); margin-left: 12px; border-radius: 1px; }

.rad-card.card { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.rad-card.card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.card--top { border-left: 4px solid var(--primary); }

.rad-title { line-height: 1.35; }
.rad-title, .rad-title a { overflow-wrap: anywhere; word-break: break-word; }
/* Title/link colors per theme */
.rad-title a { color: var(--link); text-decoration: none; }
.rad-title a:hover, .rad-title a:focus-visible { text-decoration: underline; text-underline-offset: 2px; }
.rad-meta { font-size: .85rem; color: var(--muted); display:flex; align-items:center; gap:6px; }
.rad-meta .dot::before { content: "•"; color: #9ca3af; }
.rad-excerpt { margin: 10px 0 0; color: color-mix(in oklab, var(--text), var(--muted) 50%); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-height: 4.9em; }
/* tighter card padding for Top grid to prevent overcrowding */
.top5-wrap .rad-card { padding: 12px 12px; }
/* Expand button styling for contrast */
/* expand button styles removed (feature deprecated) */

/* Colored badges for categories */
.badge { border-color: color-mix(in oklab, var(--border), var(--secondary) 18%); }
.badge.badge-trending { background: #fee2e2; color: #dc2626; border-color: color-mix(in oklab, #fee2e2, #dc2626 30%); }
.badge.badge-policy { background: #dbeafe; color: #1d4ed8; border-color: color-mix(in oklab, #dbeafe, #1d4ed8 30%); }
.badge.badge-funding { background: #d1fae5; color: #059669; border-color: color-mix(in oklab, #d1fae5, #059669 30%); }
.badge.badge-research { background: #ede9fe; color: #9333ea; border-color: color-mix(in oklab, #ede9fe, #9333ea 30%); }

/* Dark theme: keep hues but reduce intensity via alpha */
:root[data-theme="dark"] .badge.badge-trending { background: rgba(220,38,38,0.12); color: #fecaca; border-color: rgba(220,38,38,0.35); }
:root[data-theme="dark"] .badge.badge-policy { background: rgba(29,78,216,0.12); color: #bfdbfe; border-color: rgba(29,78,216,0.35); }
:root[data-theme="dark"] .badge.badge-funding { background: rgba(5,150,105,0.12); color: #bbf7d0; border-color: rgba(5,150,105,0.35); }
:root[data-theme="dark"] .badge.badge-research { background: rgba(147,51,234,0.12); color: #e9d5ff; border-color: rgba(147,51,234,0.35); }