/* Dark theme (default) — dark grey + lavender purple */
:root {
  --background: #2a282d;
  --background-soft: #3b3642;
  --surface: #343139;
  --foreground: #e9e5ef;
  --muted: #a79fb3;
  --border: #453f4e;
  --border-strong: #6b6277;
  --accent: #b491d9;
  --accent-strong: #cdb4e8;
  --accent-soft: rgba(123, 74, 168, 0.3);
  --link-underline: rgba(180, 145, 217, 0.55);
  --grid-line: rgba(233, 229, 239, 0.035);
  --overlay: linear-gradient(90deg, rgba(42, 40, 45, 0.86), rgba(42, 40, 45, 0.96));
  --card-hover: rgba(123, 74, 168, 0.14);
  --card-soft: rgba(255, 255, 255, 0.04);
  --card-soft-hover: rgba(123, 74, 168, 0.18);
  --pill-border: rgba(180, 145, 217, 0.35);
  --pill-bg: rgba(123, 74, 168, 0.26);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --panel: rgba(255, 255, 255, 0.045);
  --logo-chip: #f2f0f5;
  --shadow-color: rgba(0, 0, 0, 0.45);
  --shadow: 0 16px 44px var(--shadow-color);
  --portrait-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* Light theme — white + pink (#FFFFFF / #E699B9) */
:root[data-theme="light"] {
  --background: #ffffff;
  --background-soft: #f9e7f0;
  --surface: #fffcfe;
  --foreground: #373737;
  --muted: #857581;
  --border: #eddce6;
  --border-strong: #373737;
  --accent: #e699b9;
  --accent-strong: #b25c82;
  --accent-soft: #f7dce8;
  --link-underline: rgba(230, 153, 185, 0.7);
  --grid-line: rgba(178, 92, 130, 0.05);
  --overlay: linear-gradient(90deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.96));
  --card-hover: rgba(247, 220, 232, 0.4);
  --card-soft: rgba(247, 220, 232, 0.22);
  --card-soft-hover: rgba(247, 220, 232, 0.5);
  --pill-border: rgba(178, 92, 130, 0.3);
  --pill-bg: rgba(247, 220, 232, 0.75);
  --chip-bg: rgba(247, 220, 232, 0.3);
  --panel: rgba(247, 220, 232, 0.22);
  --logo-chip: #ffffff;
  --shadow-color: rgba(178, 92, 130, 0.14);
  --shadow: 0 16px 44px var(--shadow-color);
  --portrait-shadow: 0 14px 34px rgba(178, 92, 130, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--background);
  background-size: 28px 28px;
  color: var(--foreground);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.58;
  text-rendering: optimizeLegibility;
  transition: background-color 160ms ease, color 160ms ease;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--overlay);
  content: "";
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

img,
video,
iframe {
  display: block;
  max-width: 100%;
}

.page {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 22px 18px 58px;
}

.masthead {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 42px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0;
}

.nav,
.link-row,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--foreground);
}

.nav {
  align-items: center;
  padding-top: 5px;
}

.nav a,
.link-row a,
.footer-links a,
.back-link,
.intro-copy a,
.project-body a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 6px;
}

.nav a:hover,
.link-row a:hover,
.footer-links a:hover,
.back-link:hover,
.intro-copy a:hover,
.project-body a:hover {
  text-decoration-thickness: 2px;
}

.theme-toggle {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--foreground);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  margin-bottom: 26px;
  padding: 4px 0 20px;
}

.intro-copy {
  max-width: 760px;
}

.intro-copy strong {
  color: var(--accent);
  font-weight: 400;
}

.eyebrow,
.meta,
.section-heading span,
time {
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 400;
  line-height: 1.08;
}

.intro p:not(.eyebrow) {
  max-width: 680px;
  margin-bottom: 16px;
  font-size: 15px;
  line-height: 1.62;
}

.portrait {
  align-self: start;
  width: 200px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--portrait-shadow);
  padding: 6px;
}

.portrait img {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 3px;
  object-fit: cover;
  filter: saturate(0.92);
}

.section {
  margin-top: 46px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding-top: 0;
}

.section-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 400;
  line-height: 1;
}

.section-heading span {
  color: var(--accent-strong);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rail {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 0;
}

.rail-card {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--foreground);
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

a.rail-card:hover {
  background: var(--card-hover);
  transform: translateX(4px);
}

.rail-card.soft {
  background: var(--card-soft);
}

a.rail-card.soft:hover {
  border-color: var(--accent);
  background: var(--card-soft-hover);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.card-head h3 {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.28;
}

.research-title-link {
  text-decoration: none;
}

.research-title-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.card-head time {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  white-space: nowrap;
}

.title-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.badge {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 28px;
  height: 16px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 1px solid var(--pill-border);
  background: var(--accent-soft);
  color: var(--foreground);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.badge.quiet {
  background: var(--background-soft);
}

.rail-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
}

.rail-card p.authors {
  margin-top: 4px;
  font-size: 12px;
}

.rail-card p.authors strong {
  color: var(--accent-strong);
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.keywords span {
  display: inline-flex;
  min-height: 18px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 2px 6px;
  white-space: nowrap;
}

.research-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.research-links a,
.research-links span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 9px;
}

.research-links a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.research-links span {
  cursor: default;
  opacity: 0.54;
}

.rail-card.media {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.rail-card.media img {
  width: 178px;
  height: 100px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  object-fit: cover;
}

.research-section .rail-card.media img {
  cursor: zoom-in;
  transition: border-color 0.2s ease;
}

.research-section .rail-card.media img:hover {
  border-color: var(--accent);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.lightbox[hidden] {
  display: none;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox img {
  max-width: min(1080px, 100%);
  max-height: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.lightbox .lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 8px 10px;
  cursor: pointer;
}

.lightbox .lightbox-close:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.news-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.news-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.news-row:last-child,
details .news-row:last-child {
  border-bottom: 0;
}

.news-copy {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 6px;
}

.news-copy strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
}

.news-row.compact {
  padding-left: 18px;
}

.news-copy a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.news-copy a:hover {
  text-decoration-thickness: 2px;
}

details summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

details .summary-open {
  display: none;
}

details[open] .summary-open {
  display: inline;
}

details[open] .summary-closed {
  display: none;
}

.skills-grid {
  display: grid;
  gap: 12px;
}

.skill-group {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.skill-group h3 {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.skill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-chips span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--foreground);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 9px;
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filters button {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--foreground);
  cursor: pointer;
  padding: 4px 11px;
  font-size: 12px;
}

.filters button:hover,
.filters button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: none;
}

.project-card.is-hidden {
  display: none;
}

.compact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.grid-divider {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.grid-divider::after {
  flex: 1;
  height: 1px;
  background: var(--border);
  content: "";
}

.mini-card {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  padding: 12px;
}

.mini-card img {
  width: 50px;
  height: 50px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--logo-chip);
  object-fit: contain;
  padding: 3px;
}

.mini-card h3 {
  font-size: 13px;
  line-height: 1.3;
}

.mini-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mini-card p span {
  display: block;
}

.mini-card p span + span {
  color: var(--foreground);
}

.back-link {
  display: inline-block;
  margin-bottom: 22px;
}

.project-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.project-hero img {
  width: 100%;
  max-height: 280px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  object-fit: cover;
}

.project-body {
  max-width: 780px;
}

.project-body h1,
.project-body h2,
.project-body h3 {
  margin: 28px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  line-height: 1.2;
}

.project-body h1 {
  font-size: 26px;
}

.project-body h2 {
  font-size: 22px;
}

.project-body h3 {
  font-size: 18px;
}

.project-body p,
.project-body ul,
.project-body ol,
.project-body table,
.project-body iframe,
.project-body .video-frame {
  margin: 0 0 14px;
}

.project-body ul,
.project-body ol {
  padding-left: 20px;
}

.project-body li + li {
  margin-top: 4px;
}

.project-body img {
  width: 100%;
  height: auto;
  margin: 14px 0 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.project-body .video-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
}

.project-body iframe {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.project-body code {
  background: var(--background-soft);
  padding: 1px 4px;
}

.project-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.project-body th,
.project-body td {
  border: 1px solid var(--border);
  padding: 6px;
  text-align: left;
  vertical-align: top;
}

.footer {
  display: flex;
  flex-direction: column;
  align-items: baseline;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 54px;
  padding-top: 20px;
  border-top: 1px solid var(--border-strong);
}

.footer-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.footer-note a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

@media (min-width: 720px) {
  .page {
    padding: 48px;
  }

  .masthead {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .intro {
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: start;
  }

  .compact-grid {
    grid-template-columns: 1fr 1fr;
  }

  .project-hero {
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: start;
  }

  .project-hero img {
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 560px) {
  .card-head,
  .news-row {
    grid-template-columns: 1fr;
  }

  .card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .title-line,
  .news-copy {
    align-items: flex-start;
  }

  .rail-card.media {
    grid-template-columns: 1fr;
  }

  .rail-card.media img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .footer {
    flex-direction: column;
  }
}
