:root {
  --bg-light: #f4f5f9;
  --bg-dark: #05070b;
  --card-light: #ffffff;
  --card-dark: #111522;
  --text-light: #16181d;
  --text-dark: #e4e8f6;
  --muted-light: #5b606d;
  --muted-dark: #aab3cc;
  --accent: #2a6cf4;
  --accent-strong: #174cbc;
  --accent-dark: #8fb2ff;
  --border: #d8dbe3;
  --content-width: 660px;
}

html {
  font-size: 17px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-light);
  color: var(--text-light);
  overflow-x: hidden;
}

.page-container {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 4rem 20px 6rem;
  word-break: normal;
  overflow-wrap: break-word;
}

/* Avoid breaking long URLs/strings while wrapping text at small widths */
a,
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: manual;
}

.page-container a {
  word-break: keep-all;
  overflow-wrap: anywhere;
  hyphens: manual;
}

html {
  scrollbar-gutter: stable both-edges;
}

html[data-theme="dark"] body {
  background: var(--bg-dark);
  color: var(--text-dark);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.page-shell {
  flex: 1;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-light);
}

html[data-theme="dark"] .site-header {
  background: var(--bg-dark);
}

.site-header-inner {
  width: 100%;
  max-width: calc(var(--content-width) + 40px);
  margin: 0 auto;
  padding: 1rem 20px 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  font-family: "SF Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: inherit;
  text-decoration: none;
  font-size: 1.15rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 0 auto;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-end;
  flex: 1 1 auto;
}

.nav-toggle {
  display: none;
  width: 32px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  cursor: pointer;
  appearance: none;
  box-shadow: none;
  z-index: 32;
  color: inherit;
}

.nav-toggle:focus {
  outline: none;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 12px;
  background: currentColor;
}

.site-nav a {
  color: inherit;
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
}

.site-nav a.active {
  color: var(--accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.15rem;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

.theme-toggle__icon svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
}

/* Show moon in light mode, sun in dark mode (match Hugo behavior) */
.theme-toggle__sun {
  display: none;
}

.theme-toggle__moon {
  display: inline-flex;
}

html[data-theme="dark"] .theme-toggle__sun {
  display: inline-flex;
}

html[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

/* Titles and text */
.page-title {
  font-size: clamp(2.4rem, 4vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 0.75rem;
  color: inherit;
}

.tagline {
  font-family: "SF Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  color: var(--muted-light);
  margin: 0 0 1.2rem;
}

html[data-theme="dark"] .tagline {
  color: var(--muted-dark);
}

p {
  margin: 0 0 1.1rem;
  line-height: 1.55;
}

/* Hero */
.hero {
  margin-bottom: 1.2rem;
}

.social-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 1.2rem;
}

.social-links a {
  color: var(--accent);
}

/* Page content */
.page-content {
  font-size: 0.97rem;
}

/* Research */
.research-intro {
  font-size: 0.95rem;
}

.research-section {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 1.5rem;
  margin: 2.8rem 0 2.8rem;
}

.section-label {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted-light);
  line-height: 1.4;
}

html[data-theme="dark"] .section-label {
  color: var(--muted-dark);
}

.section-body > *:first-child {
  margin-top: 1.6rem;
}

.thesis-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.thesis-title,
.pub-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.45rem;
  line-height: 1.3;
}

.thesis-meta {
  margin: 0.02rem 0;
  line-height: 1.3;
  font-size: 0.92rem;
}

.thesis-org {
  margin: 0.1rem 0 0.05rem;
  color: var(--muted-light);
}

html[data-theme="dark"] .thesis-org {
  color: var(--muted-dark);
}

.pub {
  margin: 1.6rem 0 2.0rem;
}

.pub-authors {
  margin: 0.02rem 0;
  line-height: 1.3;
}

.pub-author-me {
  font-style: italic;
  font-weight: 600;
  color: inherit;
}

.pub-venue {
  margin: 0.02rem 0 0.02rem;
  font-size: 0.9rem;
  color: var(--muted-light);
}

html[data-theme="dark"] .pub-venue {
  color: var(--muted-dark);
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.4rem;
}

.pub-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

.pub-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.pub-link-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

/* Projects */
.projects-placeholder {
  font-family: "SF Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: inherit;
  border-left: 3px solid #ddd;
  padding-left: 1rem;
  max-width: 720px;
  margin-top: 0.5rem;
  font-size: 0.97rem;
}

html[data-theme="dark"] .projects-placeholder {
  border-color: #444;
}

.project-link {
  font-weight: 500;
}

/* Footer */
.site-footer {
  padding: 0.75rem 0 1.25rem;
  background: transparent;
}

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  color: var(--muted-light);
  font-size: 0.9rem;
}

html[data-theme="dark"] .footer-inner {
  color: var(--muted-dark);
}

.footer-inner a {
  color: inherit;
}

.footer-inner .social-links {
  gap: 0.8rem;
}

.footer-inner .social-links a {
  color: inherit;
}

/* Responsive */
@media (max-width: 768px) {
  .page-container {
    padding-top: 3rem;
  }

  .research-section {
    grid-template-columns: 1fr;
    gap: 0.9rem;
    margin: 2.4rem 0 2.4rem;
  }

  .section-body {
    margin-top: 0;
  }

  .section-body > *:first-child {
    margin-top: 1.4rem;
  }

  .page-title {
    font-size: clamp(2.1rem, 6vw, 2.8rem);
  }

  .site-header-inner {
    padding: 0.9rem 16px 0.5rem;
    position: relative;
  }

  .site-nav {
    display: none;
    position: absolute;
    right: 16px;
    top: calc(100% + 8px);
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--card-light);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    min-width: auto;
    width: auto;
    z-index: 30;
  }

  html[data-theme="dark"] .site-nav {
    background: var(--card-dark);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav a {
    font-size: 0.95rem;
    white-space: normal;
    text-align: right;
    width: 100%;
  }

  .theme-toggle__icon svg {
    width: 18px;
    height: 18px;
  }

  .nav-toggle {
    display: inline-flex;
  }
}

@media (max-width: 480px) {
  .page-container {
    padding: 2.5rem 18px 5rem;
  }
}
