:root {
  color-scheme: light;
  --page-background: #fff;
  --page-text: #000;
  --muted-text: #666;
  --menu-text: #333;
  --menu-icon: #555;
  --surface: #fff;
  --border: #ddd;
  --table-background: #f8f8f8;
  --code-background: #f5f5f5;
  --code-text: #24292e;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page-background: #121212;
    --page-text: #fff;
    --muted-text: #bbb;
    --menu-text: #fff;
    --menu-icon: #fff;
    --surface: #222;
    --border: #555;
    --table-background: #222;
    --code-background: #2a2a2a;
    --code-text: #fff;
  }
}

html, body {
  background-color: var(--page-background);
  color: var(--page-text);
}

a {
  color: var(--page-text);
}

.subtitle {
  color: var(--muted-text);
}

.masthead, .main {
  border-color: var(--page-text);
}

blockquote, table, table thead th {
  border-color: var(--border);
}

thead, tfoot, tr:nth-child(even) {
  background: var(--table-background);
}

/* Hugo's inline syntax colors use a light palette. Keep code blocks readable. */
pre {
  color-scheme: light;
  background: #f5f5f5;
  color: #24292e;
}

pre code {
  box-shadow: none;
}

/* =============================================================================
   Fixed Sidebar Layout & Responsive Design
   ============================================================================= */

/* Fixed Left Sidebar Configuration */
.masthead {
  position: fixed !important;
  top: 30px !important;
  left: calc(50% - 480px) !important; /* Center align: 50% - (960px/2) */
  height: calc(100vh - 60px) !important;
  overflow-y: auto !important;
  z-index: 1000 !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Vertically center sidebar content using auto margins */
.masthead h1 {
  margin-top: auto !important;
}

.masthead .tagline {
  font-size: 0.8em !important;
  line-height: 1.4 !important;
}

.hero-photo > a {
  display: block !important;
  border-bottom: none !important;
}

.hero-photo > div a {
  font-size: 1em !important;
}

/* Research updates beneath the introduction. */
.news-section {
  margin: 28px 0 72px;
}

.news-section h3 {
  margin: 0 0 16px;
}

.news-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-timeline li {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  column-gap: 20px;
  margin: 0;
}

.news-date {
  padding-top: 2px;
  color: var(--muted-text);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.news-description {
  position: relative;
  margin: 0;
  padding: 0 0 20px 20px;
  border-left: 1px solid var(--border);
}

.news-description::before {
  content: '';
  position: absolute;
  top: 0.6em;
  left: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--page-text);
}

.news-timeline li:last-child .news-description {
  padding-bottom: 0;
}

@media screen and (max-width: 480px) {
  .news-timeline li {
    grid-template-columns: 72px minmax(0, 1fr);
    column-gap: 12px;
  }

  .news-description {
    padding-left: 16px;
  }
}

.masthead .menu {
  margin-bottom: auto !important;
}

.mobile-blog-link {
  display: none;
}

@media screen and (max-width: 960px) {
  .mobile-blog-link {
    position: absolute;
    top: 8px;
    left: 40px;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 8px;
    border-bottom: 0;
    font-size: 13px;
    font-weight: 600;
  }
}

/* Independent language control in the upper-right utility area. */
.language-switcher {
  position: fixed;
  top: 12px;
  right: 24px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  line-height: 20px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.language-switcher a,
.language-switcher [aria-current] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 6px 4px;
  border: 0;
}

.language-switcher a,
.language-switcher .language-separator {
  color: var(--muted-text);
}

.language-switcher [aria-current] {
  color: var(--page-text);
  font-weight: 600;
}

.language-switcher a:hover,
.language-switcher a:focus-visible {
  color: var(--page-text);
  text-decoration: underline;
}

.language-switcher a:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

@media screen and (max-width: 960px) {
  .language-switcher {
    position: absolute;
    top: 8px;
    right: 12px;
  }

  .masthead h1 {
    padding-top: 28px;
  }
}

/* Main Content Area Adjustments */
.main {
  margin-left: calc(50% - 220px) !important; /* Center align: 50% - (960px/2) + 260px */
  min-height: 100vh !important;
  padding-top: 32px !important;
  border-left: none !important; /* Remove original border */
}

/* Fixed Sidebar Separator Line */
.masthead::after {
  content: '';
  position: absolute;
  right: 0; /* Right edge of masthead */
  top: 5px; /* Top margin for visual spacing */
  bottom: 10px; /* Bottom margin for visual spacing */
  width: 3px;
  background-color: var(--page-text);
  z-index: 1001;
}

/* Desktop Layout Optimizations */
@media screen and (min-width: 961px) {
  body {
    padding: 0 !important; /* Remove default body padding */
  }
}

/* Medium Screen Protection (iPad & small desktops) */
@media screen and (max-width: 1200px) {
  .masthead {
    left: 10px !important; /* Simple left offset for smaller screens */
  }

  .main {
    margin-left: 280px !important; /* Adjust main content accordingly */
  }
}

/* Mobile Responsive Layout */
@media screen and (max-width: 960px) {
  /* Restore original layout for mobile */
  .masthead {
    position: static !important;
    height: auto !important;
    overflow-y: visible !important;
    z-index: auto !important;
    top: auto !important;
    left: auto !important;
    display: block !important;
    position: relative !important;
    text-align: center !important;
    padding: 16px 16px 12px !important;
  }

  .masthead h1 {
    margin-top: 0 !important;
    text-align: center !important;
    font-size: clamp(36px, 11vw, 46px) !important;
    line-height: 1.2 !important;
    margin-bottom: 10px !important;
  }

  .masthead .tagline {
    text-align: center !important;
  }

  /* Menu pinned to top-left */
  .masthead .menu {
    position: absolute !important;
    top: 16px !important;
    left: 12px !important;
    margin: 0 !important;
    direction: ltr !important;
    max-width: none !important;
  }

  /* Hamburger button: no box, smaller */
  #menu-label {
    display: inline-block !important;
    border: none !important;
    padding: 0 !important;
    height: auto !important;
    line-height: 1 !important;
    font-size: 15px !important;
    margin-top: 0 !important;
    color: var(--menu-icon) !important;
  }

  #menu-label:hover, #menu-label:focus {
    border: none !important;
  }

  #menu-label .icon {
    padding-right: 0 !important;
    width: auto !important;
  }

  /* Hide "Menu" text, keep icon only */
  #menu-label .text {
    display: none !important;
  }

  /* Dropdown: opaque background matching the active color scheme */
  #menu-check:checked ~ ul {
    display: block !important;
    margin-top: 8px !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    min-width: 120px !important;
    padding: 4px 0 !important;
    position: relative !important;
    z-index: 200 !important;
  }

  .masthead .menu li {
    border-bottom: none !important;
    border-top: none !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .masthead .menu li:first-child {
    border-top: none !important;
  }

  .masthead .menu a {
    display: block !important;
    padding: 8px 16px !important;
    color: var(--menu-text) !important;
  }

  .main {
    margin-left: 0 !important;
    min-height: auto !important;
    padding-top: 24px !important;
    border-left: none !important;
  }

  /* Hide separator line on mobile */
  .masthead::after {
    display: none !important;
  }
}

/* =============================================================================
   Hero Photo — fluid on mobile, fixed 180px on desktop
   ============================================================================= */

@media screen and (max-width: 960px) {
  .hero-photo {
    width: min(80vw, 300px) !important;
  }

  .hero-photo img {
    width: 100% !important;
  }

  /* Links row: scale proportionally with photo (80vw), stay on one line */
  .hero-photo > div {
    font-size: clamp(11px, 3.8vw, 15px) !important;
    gap: clamp(4px, 2vw, 8px) !important;
    flex-wrap: nowrap !important;
  }
}

/* =============================================================================
   Scroll Indicator Arrow
   ============================================================================= */

.scroll-indicator {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  color: #999;
  text-decoration: none;
  animation: scroll-bounce 2s ease-in-out infinite;
  transition: color 0.2s;
  line-height: 0;
}

.scroll-indicator:hover {
  color: var(--page-text);
}

@keyframes scroll-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%       { transform: translateX(-50%) translateY(7px); }
}

@media screen and (max-width: 960px) {
  .scroll-indicator {
    display: none;
  }

  .hero-section {
    justify-content: flex-start !important;
  }

  body.home .main {
    padding-top: 0 !important;
  }

  .hero-container {
    flex-direction: column !important;
    gap: 16px !important;
    align-items: center !important;
  }

  .hero-text > p:first-child {
    margin-top: 0 !important;
  }

  .hero-photo {
    order: -1 !important;
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    padding-top: 16px !important;
    align-items: stretch !important;
  }
}

/* =============================================================================
   Code Styling - Clean and Simple
   ============================================================================= */

/* Inline Code Styling */
p code,
li code,
td code,
h1 code,
h2 code,
h3 code,
h4 code,
h5 code,
h6 code,
.main code,
body code {
  background: var(--code-background) !important;
  border: none !important;
  border-radius: 4px !important;
  padding: 3px 6px !important;
  font-size: 0.9em !important;
  color: var(--code-text) !important;
  font-weight: normal !important;
}

/* Code Blocks Styling */
.hljs {
  padding: 1em;
  border: none !important;
}

/* Code Block Content Reset */
pre code {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  color: inherit !important;
}

/* Ensure No Bold Text in Code Blocks */
pre code,
pre code *,
.highlight pre code,
.highlight pre code *,
.hljs,
.hljs *,
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt,
.highlight .nb, .highlight .nc, .highlight .no, .highlight .nd, .highlight .ni, .highlight .ne,
.highlight .nf, .highlight .nl, .highlight .nn, .highlight .nt, .highlight .nv, .highlight .ow,
.highlight .w, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .mo, .highlight .sb,
.highlight .sc, .highlight .sd, .highlight .s2, .highlight .se, .highlight .sh, .highlight .si,
.highlight .sx, .highlight .sr, .highlight .s1, .highlight .ss, .highlight .bp, .highlight .vc,
.highlight .vg, .highlight .vi, .highlight .il {
  font-weight: normal !important;
}

/* Project titles, supporting details, descriptions and links share one rhythm. */
.selected-projects > h3 {
  margin-bottom: 24px;
}

.selected-project + .selected-project {
  margin-top: 32px;
}

.selected-project h4 {
  margin: 0 0 8px;
  font-size: 1.05em;
  line-height: 1.55;
  font-weight: 600;
}

.selected-project .project-details {
  margin: 4px 0;
  color: var(--muted-text);
  font-size: 0.88em;
  font-style: normal;
  line-height: 1.6;
}

.selected-project > p:not([class]) {
  margin: 14px 0 12px;
}

.selected-project .project-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  font-size: 0.88em;
  line-height: 1.6;
}

.selected-project .project-resources a {
  color: var(--muted-text);
}

.selected-project .project-resources a:hover,
.selected-project .project-resources a:focus-visible {
  color: var(--page-text);
}

.home-blog {
  margin-top: 48px;
}

.home-blog h3 {
  margin: 0 0 12px;
}

.home-blog p {
  margin: 0;
}

.home-blog a {
  margin-left: 0.5em;
  white-space: nowrap;
}
