:root {
  --sidebar-w: 220px;
  --page-bg: #fff;
  --page-text: #222;
  --link: #280F9C;
  --sidebar-hover: #547ca5;
  --dark-bg: #121212;
  --dark-panel: #1e1e1e;
  --dark-text: #f2f2f2;
  --dark-link: #82aaff;
}

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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: var(--page-bg);
  color: var(--page-text);
}

a {
  color: var(--link);
}

img, iframe, video, canvas, table {
  max-width: 100%;
}

iframe {
  display: block;
}

.layout {
  display: flex;
  flex-direction: row;
  min-height: 100%;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10000;
  width: var(--sidebar-w);
  overflow-y: auto;
  background-color: var(--page-bg);
  padding: 12px 10px 10px 16px;
}

.sidebar a {
  display: block;
  color: var(--link);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.sidebar a:hover {
  background-color: var(--sidebar-hover);
  color: #000;
}

.sidebar p,
.sidebar span,
.sidebar img {
  margin: 0;
  padding: 0;
}

.sidebar h4 {
  margin: 14px 0 4px 0;
  padding-left: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #444;
  border-left: 3px solid #ccc;
  text-align: left;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.menu-item .icon {
  width: 20px;
  font-size: 18px;
  line-height: 1;
  text-align: center;
}

.main-content,
main {
  margin-left: var(--sidebar-w);
  width: calc(100vw - var(--sidebar-w));
  max-width: calc(100vw - var(--sidebar-w));
  min-width: 0;
  overflow-x: hidden;
  padding: 6px 1rem 20px 1rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5em 0;
}

#name-heading {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--page-text);
  text-align: left;
}

#menu-toggle {
  display: none;
}

.site-title {
  margin: 0;
  font-size: 1.2em;
}

.name-block {
  display: flex;
  align-items: center;
  gap: 1em;
}

.name-block img {
  flex-shrink: 0;
  border-radius: 4px;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(560px, 1fr);
  grid-template-areas: "bio media";
  gap: 18px;
  align-items: start;
  width: 100%;
  margin: 1em 0 1.5em 0;
}

.intro-media {
  grid-area: media;
  min-width: 0;
}

.intro-bio {
  grid-area: bio;
  min-width: 0;
  max-width: 360px;
  line-height: 1.35;
}

.bio-photo {
  float: none;
  width: 150px;
  height: auto;
  border-radius: 4px;
}

.intro-bio .bio-photo {
  float: left;
  width: clamp(105px, 13vw, 150px);
  margin: 0 1em 0.6em 0;
}

.intro-bio p {
  margin-top: 0;
}

.carousel-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  height: 50vw;
  max-height: 350px;
  margin: auto;
  overflow: hidden;
  background-color: #fff;
}

.intro-media .carousel-container {
  width: 100%;
  max-width: none;
  max-height: none;
  height: auto;
  aspect-ratio: 16 / 9;
  margin: 0;
}

.carousel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.carousel-item {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: #fff;
}

.carousel-item.is-active {
  display: flex;
}

.carousel-item video,
.carousel-item img {
  width: 100%;
  height: calc(100% - 40px);
  object-fit: contain;
  background-color: #fff;
  display: block;
}

.carousel-caption {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  text-align: center;
  font-size: 0.9em;
  line-height: 1.2em;
  color: #333;
  background-color: rgba(255, 255, 255, 0.85);
}

.carousel-control {
  position: absolute;
  top: calc(50% - 20px);
  z-index: 3;
  width: 32px;
  height: 40px;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 4px;
  background: rgba(255,255,255,0.48);
  color: rgba(0,0,0,0.64);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 120ms ease, background 120ms ease;
}

.carousel-control:hover,
.carousel-control:focus {
  opacity: 0.9;
  background: rgba(255,255,255,0.78);
  outline: none;
}

.carousel-control-prev {
  left: 8px;
}

.carousel-control-next {
  right: 8px;
}

.icon-spacer {
  display: inline-block;
  width: 15px;
  height: 18px;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: 100%;
  margin: 0;
}

.icon-link img {
  width: 15px;
  height: 18px;
  vertical-align: middle;
}

main a,
.main-content a,
.pub-title,
.pub-authors,
.pub-meta,
.pub-abstract,
.teach-card,
.news-title,
.news-blurb {
  overflow-wrap: anywhere;
  word-break: normal;
}

.pub-grid,
.teach-grid,
.student-grid,
.news-grid,
.arch-survey-grid {
  min-width: 0;
}

.news-title,
.news-blurb,
.news-meta,
.news-cta {
  overflow-wrap: normal;
  word-break: normal;
}

.pub-filters,
.teach-filters {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}

.pub-filter,
.teach-filter {
  flex: 0 0 auto;
}

body.dark-mode {
  background-color: var(--dark-bg);
  color: var(--dark-text);
}

body.dark-mode a {
  color: var(--dark-link);
}

body.dark-mode a:visited {
  color: #c792ea;
}

body.dark-mode a:hover {
  color: #fff;
  background-color: #333;
  border-radius: 4px;
}

body.dark-mode .sidebar {
  background-color: var(--dark-panel);
}

body.dark-mode .sidebar a {
  color: #a0cfff;
}

body.dark-mode .sidebar a:hover {
  background-color: #2d2d2d;
  color: #fff;
}

body.dark-mode .sidebar h4 {
  color: #bbb;
  border-left-color: #555;
}

body.dark-mode .main-content,
body.dark-mode .main-content p,
body.dark-mode .main-content h1,
body.dark-mode .main-content h2,
body.dark-mode .main-content h3,
body.dark-mode .main-content li,
body.dark-mode .main-content span,
body.dark-mode .main-content div,
body.dark-mode .main-content strong,
body.dark-mode .main-content em {
  color: var(--dark-text);
}

body.dark-mode #name-heading {
  color: var(--dark-text);
}

body.dark-mode .carousel-container,
body.dark-mode .carousel-item,
body.dark-mode .carousel-item img,
body.dark-mode .carousel-item video {
  background-color: var(--dark-bg);
}

body.dark-mode .carousel-caption {
  background-color: rgba(30, 30, 30, 0.85);
  color: var(--dark-text);
}

body.dark-mode .carousel-control {
  border-color: rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.42);
  color: rgba(255,255,255,0.82);
}

body.dark-mode .carousel-control:hover,
body.dark-mode .carousel-control:focus {
  background: rgba(0,0,0,0.68);
}

body.sidebar-open #menu-toggle {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 3000;
}

@media screen and (max-width: 1050px) {
  .intro-grid {
    grid-template-columns: minmax(260px, 340px) minmax(420px, 1fr);
    gap: 16px;
  }

  .intro-bio .bio-photo {
    width: 115px;
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-w: 0px;
  }

  .main-content,
  main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    overflow-x: hidden;
  }

  .header {
    padding-right: 3.25rem;
  }

  #menu-toggle {
    display: inline-block;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10001;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.18);
    border-radius: 10px;
    background: rgba(255,255,255,0.84);
    color: var(--link);
    cursor: pointer;
    backdrop-filter: blur(8px);
  }

  body.dark-mode #menu-toggle {
    background: rgba(0,0,0,0.54);
    border-color: rgba(255,255,255,0.22);
    color: rgba(255,255,255,0.94);
  }

  .sidebar {
    width: min(320px, 86vw);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar,
  .sidebar.open {
    transform: translateX(0);
  }

  .intro-bio .bio-photo {
    float: left;
    display: block;
    width: 115px;
    max-width: 115px;
    margin: 0 1em 0.6em 0;
  }

  #bio {
    overflow: visible;
  }

  #site-search-box,
  iframe {
    width: 100%;
    max-width: 100%;
  }

  #Schedule + p + iframe,
  iframe[src*="outlook.office365.com"] {
    height: min(62vh, 520px);
  }

  .pub-filters,
  .teach-filters,
  .pub-links,
  .teach-chiprow {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding-bottom: 6px;
  }

  .pub-filter,
  .teach-filter,
  .pub-pill,
  .teach-pill,
  .teach-chip {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .teaching-header,
  .teaching-tools {
    display: block;
  }

  .teach-search {
    width: 100%;
    margin: 0.5rem 0;
  }

  .teach-search input {
    width: 100%;
    min-width: 0;
  }

  .pub-grid,
  .teach-grid,
  .student-grid,
  .news-grid,
  .arch-survey-grid {
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
  }

  .pub-card,
  .teach-card,
  .student-card,
  .news-card,
  .arch-survey-card {
    max-width: 100%;
    min-width: 0;
  }

  .student-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .student-card img {
    width: min(220px, 70vw);
    height: auto;
    max-width: 100%;
  }

  .news-link {
    display: flex;
    flex-direction: column;
  }

  .news-thumb {
    width: calc(100% - 24px);
    max-width: calc(100% - 24px);
    height: auto;
    aspect-ratio: 16 / 10;
  }

  .news-body {
    padding: 12px 14px 14px 14px;
  }

  .arch-survey-gallery {
    max-width: 100%;
  }

  .arch-survey-gallery--four {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }
}

@media screen and (max-width: 700px) {
  .intro-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "media"
      "bio";
  }

  .intro-media .carousel-container {
    max-width: 100%;
  }
}

@media (max-width: 520px) {
  .main-content,
  main {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .pub-card,
  .teach-card,
  .student-card {
    padding: 10px 11px;
  }

  .pub-header,
  .teach-card-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .pub-badge,
  .teach-badges {
    align-self: flex-start;
  }

  .pub-title {
    font-size: 1rem;
  }

  .pub-abstract {
    font-size: 0.92rem;
    line-height: 1.5;
  }

  h1 { font-size: 1.55rem; }
  h2 { font-size: 1.35rem; }
}
