:root {
  --bg: #ffffff;
  --text: #1b2438;
  --muted: #66728a;
  --line: #e1e6f2;
  --link: #4a74dd;
  --accent-1: #5f82d6;
  --accent-2: #47a8c2;
  --accent-3: #6d61b2;
  --accent-4: #60a66a;
  --max-width: 1000px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-weight: 300;
  text-transform: lowercase;
  position: relative;
  overflow-x: hidden;
}

mjx-container,
.MathJax {
  text-transform: none !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      -18deg,
      color-mix(in srgb, var(--line) 22%, transparent) 0,
      color-mix(in srgb, var(--line) 22%, transparent) 1px,
      transparent 1px,
      transparent 5px
    ),
    radial-gradient(circle at 15% 12%, color-mix(in srgb, var(--accent-3) 6%, transparent), transparent 35%),
    radial-gradient(circle at 82% 80%, color-mix(in srgb, var(--accent-2) 6%, transparent), transparent 36%);
  opacity: 0.35;
  z-index: -1;
}

body.glitching > * {
  animation:
    glitch-shift 190ms steps(12, end),
    glitch-hue 190ms steps(10, end);
}

body[data-theme="dark"] {
  --bg: #101521;
  --text: #e2e8f2;
  --muted: #9aa7be;
  --line: #2a3347;
  --link: #7ea7f0;
  --accent-1: #6f86c8;
  --accent-2: #4f9fb6;
  --accent-3: #8578bc;
  --accent-4: #6aa371;
  background:
    radial-gradient(circle at 14% 8%, rgba(126, 167, 240, 0.08), transparent 30%),
    radial-gradient(circle at 84% 78%, rgba(133, 120, 188, 0.09), transparent 34%),
    var(--bg);
}

body[data-theme="dark"]::before {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 3px
    ),
    repeating-linear-gradient(
      -17deg,
      rgba(122, 97, 255, 0.07) 0,
      rgba(122, 97, 255, 0.07) 1px,
      transparent 1px,
      transparent 6px
    ),
    radial-gradient(circle at 8% 14%, rgba(0, 214, 255, 0.11), transparent 28%),
    radial-gradient(circle at 89% 82%, rgba(111, 134, 200, 0.11), transparent 32%);
  opacity: 0.72;
  z-index: 0;
  animation: dark-noise-drift 8s steps(9, end) infinite;
}

body[data-theme="dark"]::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.012) 0,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 4px
    ),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.34), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.3));
  mix-blend-mode: screen;
  opacity: 0.35;
  z-index: 1;
  animation: dark-scan-flicker 1.9s steps(3, end) infinite;
}

body[data-theme="dark"] .site-header,
body[data-theme="dark"] main,
body[data-theme="dark"] footer {
  position: relative;
  z-index: 2;
}

body[data-theme="dark"] .theme-toggle {
  z-index: 8;
}

body[data-theme="dark"] .site-header {
  transform: rotate(-0.35deg);
  filter: contrast(108%) saturate(108%);
}

body[data-theme="dark"] h1 {
  text-shadow:
    -1.5px 0 rgba(122, 97, 255, 0.75),
    1.5px 0 rgba(82, 219, 255, 0.72),
    0 0 11px rgba(82, 219, 255, 0.34);
  animation:
    header-glitch 2.2s steps(2, end) infinite,
    dark-neon-pulse 1.8s steps(3, end) infinite;
}

body[data-theme="dark"] .subtitle {
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
  text-shadow:
    -0.9px 0 rgba(133, 120, 188, 0.6),
    0.9px 0 rgba(82, 219, 255, 0.52);
}

body[data-theme="dark"] section {
  border-left: 1px dashed color-mix(in srgb, var(--accent-2) 32%, var(--line));
  padding-left: 0.55rem;
}

body[data-theme="dark"] #about {
  border: 1px dashed color-mix(in srgb, var(--accent-3) 65%, var(--line));
  background:
    linear-gradient(165deg, rgba(111, 134, 200, 0.12), rgba(79, 159, 182, 0.08) 38%, rgba(106, 163, 113, 0.08)),
    repeating-linear-gradient(-13deg, rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 2px, transparent 2px, transparent 8px),
    rgba(7, 11, 19, 0.72);
  box-shadow:
    5px 5px 0 rgba(79, 159, 182, 0.28),
    -3px -3px 0 rgba(133, 120, 188, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.03);
}

body[data-theme="dark"] .about-photo {
  border-color: color-mix(in srgb, var(--accent-2) 74%, var(--line));
  filter: contrast(120%) saturate(125%) grayscale(8%);
  box-shadow:
    0 0 0 2px rgba(133, 120, 188, 0.33),
    7px 7px 0 rgba(79, 159, 182, 0.33);
}

body[data-theme="dark"] .paper-title {
  color: color-mix(in srgb, var(--text) 92%, white 8%);
  text-shadow: 0 0 8px rgba(82, 219, 255, 0.14);
}

body[data-theme="dark"] .paper-meta {
  color: color-mix(in srgb, var(--muted) 90%, var(--text));
}

body[data-theme="dark"] .publication-list li::before {
  color: color-mix(in srgb, var(--accent-2) 60%, var(--accent-3));
  text-shadow: 0 0 6px rgba(82, 219, 255, 0.2);
}

body[data-theme="dark"] .paper-synopsis {
  border-style: solid;
  border-width: 1px;
}

body[data-theme="dark"] .paper-synopsis.open {
  border-color: rgba(111, 134, 200, 0.72);
  background:
    repeating-linear-gradient(-10deg, rgba(106, 163, 113, 0.12) 0, rgba(106, 163, 113, 0.12) 2px, rgba(79, 159, 182, 0.08) 2px, rgba(79, 159, 182, 0.08) 6px),
    rgba(7, 11, 19, 0.65);
  box-shadow:
    4px 4px 0 rgba(133, 120, 188, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.03);
}

body[data-theme="dark"] .theme-toggle {
  border-color: color-mix(in srgb, var(--accent-3) 55%, var(--line));
  background: linear-gradient(135deg, rgba(10, 14, 23, 0.95), rgba(27, 38, 56, 0.92));
}

body[data-theme="dark"] a {
  color: color-mix(in srgb, var(--link) 86%, #b8d5ff);
  text-shadow: 0 0 6px rgba(126, 167, 240, 0.22);
}

body[data-theme="dark"] a:hover,
body[data-theme="dark"] a:focus-visible {
  background: rgba(79, 159, 182, 0.16);
  text-shadow:
    -1px 0 rgba(111, 134, 200, 0.58),
    1px 0 rgba(82, 219, 255, 0.55),
    0 0 9px rgba(82, 219, 255, 0.3);
}

body[data-theme="dark"] footer {
  color: color-mix(in srgb, var(--muted) 85%, var(--text));
  letter-spacing: 0.015em;
}

.theme-toggle {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid color-mix(in srgb, var(--accent-2) 28%, var(--line));
  border-radius: 0;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--bg) 84%, white),
    color-mix(in srgb, var(--accent-2) 12%, var(--bg))
  );
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 1000;
  touch-action: manipulation;
  transition: transform 140ms ease, border-color 180ms ease, background 180ms ease;
}

.toggle-mark {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1;
  transition: transform 220ms ease, filter 220ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: color-mix(in srgb, var(--accent-2) 58%, var(--link));
  transform: translateY(-1px) scale(1.03);
}

.theme-toggle:hover .toggle-mark,
.theme-toggle:focus-visible .toggle-mark {
  transform: rotate(-10deg) scale(1.04);
}

.theme-toggle:active {
  transform: translateY(0) scale(0.98);
}

body[data-theme="dark"] .theme-toggle {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, #0f1420 88%, var(--bg)),
    color-mix(in srgb, var(--accent-3) 18%, #121a2b)
  );
}

.site-header,
main,
footer {
  width: min(var(--max-width), 92vw);
  margin-inline: auto;
}

.site-header {
  padding: 3rem 0 2rem;
  text-align: center;
  transform: rotate(-0.15deg);
}

.profile-wrap {
  display: block;
}

h1,
h2 {
  line-height: 1.2;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5.4vw, 2.8rem);
  font-weight: 500;
  display: inline-block;
  transform: rotate(-2.1deg) skewX(-3deg);
  transform-origin: center;
  text-shadow: -1px 0 color-mix(in srgb, var(--accent-3) 65%, transparent), 1px 0 color-mix(in srgb, var(--accent-2) 70%, transparent);
  animation: header-glitch 2.4s steps(2, end) infinite;
}

h1:hover {
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
}

h2 {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 0.7rem;
  display: inline-block;
  padding: 0.05rem 0.35rem;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-1) 14%, transparent), color-mix(in srgb, var(--accent-2) 10%, transparent));
}

body.index-page:not([data-theme="dark"]) main section .section-line {
  width: 100%;
  height: 1px;
  margin: 0.14rem 0 0.72rem;
  background: color-mix(in srgb, var(--link) 20%, transparent);
}

body.index-page:not([data-theme="dark"]) main #about .section-line {
  display: none;
}

h3 {
  font-size: 1rem;
  font-weight: 500;
  margin: 1rem 0 0.5rem;
  color: var(--accent-3);
}

.subtitle {
  margin: 0.2rem auto;
  color: var(--muted);
  display: block;
  width: fit-content;
  transform: rotate(-1.2deg) skewX(-2deg);
  transform-origin: center;
  text-shadow: -0.6px 0 color-mix(in srgb, var(--accent-3) 55%, transparent), 0.6px 0 color-mix(in srgb, var(--accent-2) 55%, transparent);
  animation: header-glitch-sub 2.9s steps(2, end) infinite;
}

body:not([data-theme="dark"]) .site-header .nav-links a {
  margin-inline: 0.22rem;
}

.tag-matcauthon:hover {
  color: #ff9f1c;
  transform: translateX(6px);
}

.tag-irif:hover {
  color: #35c759;
  transform: translateX(-6px);
}

.tag-matcauthon,
.tag-irif {
  display: inline-block;
}

main {
  padding: 1.5rem 0 2.5rem;
}

section {
  margin-top: 2rem;
}

#about {
  border: 1px dashed color-mix(in srgb, var(--accent-3) 55%, var(--line));
  padding: 1.1rem 1.2rem;
  background:
    linear-gradient(
      160deg,
      color-mix(in srgb, var(--accent-1) 10%, transparent),
      color-mix(in srgb, var(--accent-2) 8%, transparent) 42%,
      color-mix(in srgb, var(--accent-4) 10%, transparent)
    ),
    repeating-linear-gradient(
      -14deg,
      color-mix(in srgb, var(--line) 45%, transparent) 0,
      color-mix(in srgb, var(--line) 45%, transparent) 2px,
      transparent 2px,
      transparent 7px
    );
  box-shadow:
    4px 4px 0 color-mix(in srgb, var(--accent-2) 28%, transparent),
    -3px -3px 0 color-mix(in srgb, var(--accent-1) 20%, transparent);
  transform: rotate(-0.18deg);
}

#about::after {
  content: "";
  display: table;
  clear: both;
}

#about h2 {
  font-size: 1.35rem;
  margin-bottom: 0.9rem;
  display: inline-block;
  padding: 0.28rem 0.78rem;
  border: 1px dashed color-mix(in srgb, var(--accent-3) 55%, var(--line));
  background:
    linear-gradient(
      100deg,
      color-mix(in srgb, var(--accent-1) 16%, transparent),
      color-mix(in srgb, var(--accent-2) 14%, transparent) 45%,
      color-mix(in srgb, var(--accent-4) 14%, transparent)
    );
  letter-spacing: 0.04em;
  box-shadow: 2px 2px 0 color-mix(in srgb, var(--accent-3) 35%, transparent);
  transform: rotate(-0.7deg);
}

.about-photo {
  width: 148px;
  height: 148px;
  object-fit: cover;
  border-radius: 0;
  float: right;
  margin: 0 0 0.35rem 0.55rem;
  border: 2px solid color-mix(in srgb, var(--accent-2) 55%, var(--line));
  filter: contrast(112%) saturate(115%);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent-3) 30%, transparent),
    5px 5px 0 color-mix(in srgb, var(--accent-1) 32%, transparent);
}

#about .about-photo {
  width: 250px;
  height: 250px;
  transform: rotate(3deg);
}

#hobbies .bio-gallery {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.35rem;
  padding: 0;
  transform: none;
}

#hobbies p {
  margin-bottom: 0;
}

#hobbies .bio-photo {
  width: min(44vw, 460px);
  max-width: 100%;
  height: auto;
  display: block;
  border: 0;
  box-shadow: none;
  filter: contrast(112%) saturate(115%);
}

body[data-theme="dark"] #hobbies .bio-photo {
  border: 1px solid color-mix(in srgb, var(--accent-2) 62%, var(--line));
}

#hobbies .bio-photo:first-child {
  transform: rotate(-0.9deg) translateY(-6px);
}

#hobbies .bio-photo:last-child {
  transform: rotate(3.8deg) translateY(4px);
}

#hobbies .bio-caption {
  margin-top: 1.15rem;
}

#hobbies .travel-gallery {
  margin: 1rem 0 1rem;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.45rem;
}

#hobbies .travel-photo {
  width: clamp(90px, 16vw, 170px);
  max-width: 100%;
  height: auto;
  display: block;
  border: 0;
  box-shadow: none;
  filter: contrast(112%) saturate(115%);
}

#hobbies .travel-photo--wide {
  width: clamp(110px, 20vw, 210px);
}

#hobbies .travel-photo--square {
  width: clamp(100px, 17vw, 180px);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  height: auto;
}

#hobbies .travel-gallery .travel-photo:first-child {
  transform: rotate(-2.2deg) translateY(-4px);
}

#hobbies .travel-gallery .travel-photo:nth-child(2) {
  transform: rotate(1.8deg) translateY(3px);
}

#hobbies .travel-gallery .travel-photo:nth-child(3) {
  transform: rotate(-1.1deg) translateY(2px);
}

#hobbies .travel-gallery .travel-photo:last-child {
  transform: rotate(2.5deg) translateY(-2px);
}

body[data-theme="dark"] #hobbies .travel-photo {
  border: 1px solid color-mix(in srgb, var(--accent-2) 62%, var(--line));
}

#sports .sports-gallery {
  margin-top: 0.9rem;
  display: flex;
  justify-content: center;
  gap: 0.55rem;
}

#sports .sports-photo {
  width: clamp(130px, 24vw, 300px);
  max-width: 100%;
  height: auto;
  display: block;
  border: 0;
  box-shadow: none;
  filter: contrast(112%) saturate(115%);
}

#sports .sports-photo--square {
  width: clamp(140px, 24vw, 280px);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
}

#sports .sports-photo:first-child {
  transform: rotate(-1.4deg) translateY(-2px);
}

#sports .sports-photo:last-child {
  transform: rotate(1.6deg) translateY(2px);
}

body[data-theme="dark"] #sports .sports-photo {
  border: 1px solid color-mix(in srgb, var(--accent-2) 62%, var(--line));
}

#music .music-gallery {
  margin-top: 0.9rem;
  display: flex;
  justify-content: center;
}

#music .topster-photo {
  width: min(92vw, 780px);
  max-width: 100%;
  height: auto;
  display: block;
  border: 0;
  box-shadow: none;
  filter: contrast(112%) saturate(115%);
}

body[data-theme="dark"] #music .topster-photo {
  border: 1px solid color-mix(in srgb, var(--accent-2) 62%, var(--line));
}

a {
  color: var(--link);
  text-decoration: none;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  display: inline-block;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
  background: color-mix(in srgb, var(--accent-2) 8%, transparent);
  animation: link-chaos 700ms steps(2, end) 1;
  text-shadow:
    -1px 0 color-mix(in srgb, var(--accent-1) 72%, transparent),
    1px 0 color-mix(in srgb, var(--accent-3) 72%, transparent),
    0 0 6px color-mix(in srgb, var(--accent-2) 42%, transparent);
}

body:not([data-theme="dark"]) a:hover,
body:not([data-theme="dark"]) a:focus-visible {
  background: transparent;
  animation: none;
  text-shadow: none;
  transform: none;
  filter: none;
  letter-spacing: normal;
}

.fire-strip {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background-image: url("pics/fire.gif");
  background-repeat: repeat-x;
  background-size: auto 56px;
  background-position: bottom left;
  pointer-events: none;
  opacity: 0;
  filter: saturate(1.2) brightness(1.08);
  mix-blend-mode: normal;
  z-index: 2147483646;
}

body[data-theme="dark"] .fire-strip {
  opacity: 1;
}

.publication-list {
  margin: 0;
  padding-left: 1.1rem;
  list-style: none;
}

#interests ul {
  list-style: none;
  padding-left: 0;
}

.publication-list li {
  margin-bottom: 0.9rem;
}

.paper-head {
  display: block;
}

.synopsis-toggle {
  border: 0;
  background: transparent;
  color: var(--text);
  width: 1rem;
  height: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  vertical-align: baseline;
  margin-left: 0.28rem;
  color: var(--accent-4);
}

.synopsis-toggle[aria-expanded="true"] {
  transform: rotate(90deg);
}

.paper-synopsis {
  margin: 0 0 0 1.65rem;
  padding: 0 1rem 0 1rem;
  border: 1px dashed transparent;
  color: color-mix(in srgb, var(--text) 80%, var(--muted));
  font-size: 0.96rem;
  line-height: 1.75;
  letter-spacing: 0.01em;
  font-style: italic;
  transform: rotate(-0.35deg);
  transform-origin: left top;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 320ms cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 260ms ease,
    margin-top 320ms cubic-bezier(0.22, 0.61, 0.36, 1),
    border-color 260ms ease,
    padding 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.paper-synopsis.open {
  margin-top: 0.65rem;
  padding: 0.95rem 1.1rem 1rem;
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent-1) 50%, var(--accent-4));
  background:
    repeating-linear-gradient(
      -12deg,
      color-mix(in srgb, var(--accent-4) 11%, transparent) 0,
      color-mix(in srgb, var(--accent-4) 11%, transparent) 2px,
      color-mix(in srgb, var(--accent-2) 7%, transparent) 2px,
      color-mix(in srgb, var(--accent-2) 7%, transparent) 6px
    );
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--accent-3) 40%, transparent);
}

.publication-list li {
  position: relative;
}

.publication-list li::before {
  content: "//";
  position: absolute;
  left: -0.95rem;
  top: 0.08rem;
  color: color-mix(in srgb, var(--accent-3) 55%, var(--muted));
  font-size: 0.7rem;
  letter-spacing: -0.04em;
}

.paper-title {
  display: block;
  font-weight: 700;
  text-transform: none;
}

.paper-meta {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
  text-transform: none;
}

.conf-name {
  color: var(--accent-4);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.paper-meta a {
  text-transform: none;
}

footer {
  padding: 1rem 0 2rem;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.footer-note {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  font-style: italic;
}

@media (max-width: 560px) {
  .theme-toggle {
    top: 0.65rem;
    right: 0.65rem;
    width: 2.5rem;
    height: 2.5rem;
  }

  .about-photo {
    float: none;
    display: block;
    margin: 0.2rem 0 1rem;
    width: 110px;
    height: 110px;
  }
}

@keyframes glitch-shift {
  0% { transform: translate(0, 0); }
  12% { transform: translate(-6px, 2px) skewX(1.2deg); }
  24% { transform: translate(7px, -3px) skewX(-1.3deg); }
  36% { transform: translate(-5px, 2px) skewY(0.9deg); }
  50% { transform: translate(6px, -2px) skewY(-1deg); }
  66% { transform: translate(-7px, 2px); }
  82% { transform: translate(4px, -2px); }
  92% { transform: translate(-3px, 1px); }
  100% { transform: translate(0, 0); }
}

@keyframes glitch-hue {
  0% { filter: hue-rotate(0deg) saturate(100%) contrast(100%); }
  18% { filter: hue-rotate(65deg) saturate(165%) contrast(125%); }
  36% { filter: hue-rotate(-40deg) saturate(175%) contrast(130%); }
  58% { filter: hue-rotate(90deg) saturate(185%) contrast(135%); }
  80% { filter: hue-rotate(-55deg) saturate(160%) contrast(120%); }
  100% { filter: hue-rotate(0deg) saturate(100%) contrast(100%); }
}

@keyframes header-glitch {
  0%, 85%, 100% {
    transform: rotate(-2.1deg) skewX(-3deg) translate(0, 0);
  }
  88% {
    transform: rotate(-2.1deg) skewX(-3deg) translate(-1px, 0.5px);
  }
  92% {
    transform: rotate(-2.1deg) skewX(-3deg) translate(1.2px, -0.5px);
  }
  96% {
    transform: rotate(-2.1deg) skewX(-3deg) translate(-0.8px, 0.4px);
  }
}

@keyframes header-glitch-sub {
  0%, 88%, 100% {
    transform: rotate(-1.2deg) skewX(-2deg) translate(0, 0);
  }
  90% {
    transform: rotate(-1.2deg) skewX(-2deg) translate(-0.8px, 0.3px);
  }
  95% {
    transform: rotate(-1.2deg) skewX(-2deg) translate(0.9px, -0.3px);
  }
}

@keyframes link-chaos {
  0% {
    transform: translate(0, 0) rotate(0deg) skewX(0deg);
    filter: hue-rotate(0deg) saturate(110%);
    letter-spacing: 0;
  }
  20% {
    transform: translate(1px, -1px) rotate(-1.2deg) skewX(-6deg);
    filter: hue-rotate(70deg) saturate(175%);
    letter-spacing: 0.01em;
  }
  40% {
    transform: translate(-1px, 1px) rotate(1.4deg) skewX(8deg);
    filter: hue-rotate(-55deg) saturate(190%);
    letter-spacing: 0.015em;
  }
  60% {
    transform: translate(1.2px, 0.5px) rotate(-0.8deg) skewX(-5deg);
    filter: hue-rotate(95deg) saturate(180%);
    letter-spacing: 0.01em;
  }
  80% {
    transform: translate(-1px, -0.8px) rotate(0.9deg) skewX(6deg);
    filter: hue-rotate(-80deg) saturate(170%);
    letter-spacing: 0.012em;
  }
  100% {
    transform: translate(0, 0) rotate(0deg) skewX(0deg);
    filter: hue-rotate(0deg) saturate(110%);
    letter-spacing: 0;
  }
}

body[data-theme="dark"] {
  --bg: #040404;
  --text: #d8dde3;
  --muted: #7f8896;
  --line: #1f222a;
  --link: #8ed0da;
  --accent-1: #ff2d2d;
  --accent-2: #4ea7b5;
  --accent-3: #7d8aa0;
  --accent-4: #b8c26b;
  background:
    radial-gradient(circle at 8% 10%, rgba(255, 45, 45, 0.11), transparent 28%),
    radial-gradient(circle at 88% 82%, rgba(78, 167, 181, 0.1), transparent 32%),
    radial-gradient(circle at 50% 50%, rgba(125, 138, 160, 0.06), transparent 48%),
    var(--bg);
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0.01em;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Crect x='1' y='1' width='9' height='9' fill='%2300e5ff'/%3E%3Crect x='2' y='2' width='7' height='7' fill='%23000911'/%3E%3Crect x='3' y='3' width='5' height='5' fill='%23ff2d2d'/%3E%3Crect x='12' y='12' width='2' height='2' fill='%23ffffff'/%3E%3Crect x='14' y='12' width='2' height='2' fill='%2300e5ff'/%3E%3Crect x='16' y='12' width='2' height='2' fill='%23ffffff'/%3E%3Crect x='18' y='12' width='2' height='2' fill='%2300e5ff'/%3E%3Crect x='20' y='12' width='2' height='2' fill='%23ffffff'/%3E%3C/svg%3E") 2 2, auto;
}

body[data-theme="dark"] main {
  animation: dark-crush-pulse 5.5s steps(2, end) infinite;
}

body[data-theme="dark"] a,
body[data-theme="dark"] button,
body[data-theme="dark"] .synopsis-toggle {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Crect x='1' y='1' width='12' height='12' fill='%23ff2d2d'/%3E%3Crect x='2' y='2' width='10' height='10' fill='%23070a10'/%3E%3Crect x='4' y='4' width='6' height='6' fill='%2300e5ff'/%3E%3Crect x='14' y='14' width='3' height='3' fill='%23ffffff'/%3E%3Crect x='18' y='14' width='3' height='3' fill='%23ffffff'/%3E%3Crect x='14' y='18' width='3' height='3' fill='%23ffffff'/%3E%3Crect x='18' y='18' width='3' height='3' fill='%23ffffff'/%3E%3C/svg%3E") 6 6, pointer;
}

body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3 {
  cursor: crosshair;
}

body[data-theme="dark"]::before {
  background:
    repeating-radial-gradient(circle at center, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 4px
    ),
    repeating-linear-gradient(
      to right,
      rgba(0, 209, 255, 0.045) 0,
      rgba(0, 209, 255, 0.045) 2px,
      transparent 2px,
      transparent 8px
    ),
    linear-gradient(122deg, transparent 0 46.5%, rgba(255, 52, 52, 0.45) 49.2%, rgba(255, 52, 52, 0.2) 50%, transparent 51.5%),
    linear-gradient(58deg, transparent 0 39.5%, rgba(0, 229, 255, 0.46) 42.2%, rgba(0, 229, 255, 0.2) 43%, transparent 44.5%),
    linear-gradient(98deg, transparent 0 33%, rgba(172, 255, 71, 0.32) 35.2%, rgba(172, 255, 71, 0.14) 36%, transparent 38.5%);
  background-size: auto, auto, auto, 250% 250%, 230% 230%, 240% 240%;
  background-position: 0 0, 0 0, 0 0, 0% 50%, 100% 50%, 0% 50%;
  opacity: 1;
  mix-blend-mode: screen;
  filter: contrast(118%) saturate(136%);
  z-index: 0;
  animation: dark-grid-jitter 2.6s steps(14, end) infinite, laser-dance 2.2s linear infinite, laser-hue-cycler 1.1s steps(3, end) infinite;
}

body[data-theme="dark"]::after {
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.65)),
    repeating-linear-gradient(
      -14deg,
      rgba(255, 45, 45, 0.05) 0,
      rgba(255, 45, 45, 0.05) 1px,
      transparent 1px,
      transparent 6px
    );
  opacity: 0.9;
  mix-blend-mode: screen;
  z-index: 1;
  animation: dark-vhs-flicker 0.75s steps(4, end) infinite, dark-invert-flash 4.8s steps(1, end) infinite, laser-strobe 260ms steps(2, end) infinite;
}

body[data-theme="dark"] .site-header,
body[data-theme="dark"] main,
body[data-theme="dark"] footer {
  position: relative;
  z-index: 3;
}

body[data-theme="dark"] .site-header {
  border: 1px solid rgba(125, 249, 255, 0.28);
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.015) 0,
      rgba(255, 255, 255, 0.015) 2px,
      transparent 2px,
      transparent 8px
    ),
    rgba(7, 8, 10, 0.88);
  padding: 2.4rem 1rem 1.8rem;
  transform: skewY(-0.5deg);
  box-shadow:
    0 0 0 1px rgba(255, 45, 45, 0.22),
    0 0 22px rgba(78, 167, 181, 0.14);
}

body[data-theme="dark"] h1 {
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  letter-spacing: 0.06em;
  text-shadow:
    -2px 0 rgba(255, 51, 102, 0.86),
    2px 0 rgba(0, 209, 255, 0.86),
    0 0 14px rgba(159, 123, 255, 0.42);
  animation:
    header-glitch 1.75s steps(2, end) infinite,
    dark-title-fry 1.3s steps(2, end) infinite;
}

body[data-theme="dark"] .subtitle {
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  text-shadow: -1px 0 rgba(255, 51, 102, 0.6), 1px 0 rgba(0, 209, 255, 0.56);
}

body[data-theme="dark"] main {
  padding-top: 2rem;
  animation: dark-main-warp 7s ease-in-out infinite;
}

body[data-theme="dark"] section {
  border: 1px dashed rgba(125, 249, 255, 0.26);
  background:
    linear-gradient(165deg, rgba(255, 45, 45, 0.08), rgba(78, 167, 181, 0.06) 45%, rgba(184, 194, 107, 0.05)),
    rgba(8, 8, 9, 0.94);
  padding: 0.8rem 0.9rem 1rem;
  box-shadow:
    4px 4px 0 rgba(159, 123, 255, 0.28),
    -2px -2px 0 rgba(255, 51, 102, 0.2);
  transition: transform 180ms steps(2, end), box-shadow 180ms steps(2, end), filter 180ms steps(2, end);
}

body[data-theme="dark"] section:nth-of-type(odd) {
  transform: rotate(-0.18deg);
}

body[data-theme="dark"] section:nth-of-type(even) {
  transform: rotate(0.16deg);
}

body[data-theme="dark"] section:hover {
  transform: rotate(-0.6deg) skewX(-0.9deg) translateX(-2px);
  filter: contrast(112%) saturate(112%);
  box-shadow:
    6px 6px 0 rgba(255, 51, 102, 0.3),
    -3px -3px 0 rgba(0, 209, 255, 0.26);
}

body[data-theme="dark"] h2 {
  border: 1px solid rgba(255, 51, 102, 0.35);
  background: linear-gradient(90deg, rgba(255, 51, 102, 0.24), rgba(0, 209, 255, 0.18));
  padding: 0.18rem 0.52rem;
  text-shadow: 0 0 8px rgba(125, 249, 255, 0.2);
  position: relative;
  animation: dark-heading-snap 2.4s steps(2, end) infinite;
}

body[data-theme="dark"] h2::before {
  content: "[! ]";
  display: inline-block;
  margin-right: 0.35rem;
  color: rgba(255, 51, 102, 0.92);
  letter-spacing: 0.02em;
  animation: dark-warning-blink 1.1s steps(2, end) infinite;
}

body[data-theme="dark"] h3 {
  color: #c6b4ff;
  text-shadow: 0 0 8px rgba(159, 123, 255, 0.28);
}

body[data-theme="dark"] #about {
  transform: rotate(-0.2deg);
  border-style: solid;
}

body[data-theme="dark"] #about h2 {
  transform: rotate(-0.3deg);
}

body[data-theme="dark"] .about-photo {
  border: 2px solid rgba(0, 209, 255, 0.72);
  box-shadow:
    0 0 0 2px rgba(255, 51, 102, 0.33),
    8px 8px 0 rgba(159, 123, 255, 0.33);
  filter: contrast(126%) saturate(136%) grayscale(5%);
}

body[data-theme="dark"] a {
  color: #9ef5ff;
  text-decoration-thickness: 2px;
  text-shadow: 0 0 8px rgba(125, 249, 255, 0.25);
}

body[data-theme="dark"] a:hover,
body[data-theme="dark"] a:focus-visible {
  background: rgba(255, 51, 102, 0.2);
  text-shadow:
    -1px 0 rgba(255, 51, 102, 0.8),
    1px 0 rgba(0, 209, 255, 0.8),
    0 0 12px rgba(125, 249, 255, 0.45);
}

body[data-theme="dark"] .publication-list li {
  margin-bottom: 1.05rem;
  padding-left: 0.1rem;
}

body[data-theme="dark"] .publication-list li::before {
  content: "##";
  color: rgba(255, 51, 102, 0.78);
  text-shadow: 0 0 7px rgba(255, 51, 102, 0.28);
}

body[data-theme="dark"] .paper-title {
  color: #f0f6ff;
  letter-spacing: 0.01em;
  animation: dark-title-twitch 3.6s steps(2, end) infinite;
}

body[data-theme="dark"] .paper-meta {
  color: #a8b5ca;
}

body[data-theme="dark"] .conf-name {
  color: #d2ff36;
  text-shadow: 0 0 10px rgba(210, 255, 54, 0.35);
}

body[data-theme="dark"] .synopsis-toggle {
  color: #ff4a76;
  font-weight: 700;
  transform-origin: center;
}

body[data-theme="dark"] .synopsis-toggle[aria-expanded="true"] {
  color: #7df9ff;
}

body[data-theme="dark"] .paper-synopsis {
  border: 1px dashed rgba(125, 249, 255, 0.26);
  color: #d4e2f8;
  background: rgba(8, 11, 19, 0.48);
  transform: rotate(-0.6deg);
}

body[data-theme="dark"] .paper-synopsis.open {
  background:
    repeating-linear-gradient(
      -10deg,
      rgba(255, 51, 102, 0.12) 0,
      rgba(255, 51, 102, 0.12) 2px,
      rgba(0, 209, 255, 0.08) 2px,
      rgba(0, 209, 255, 0.08) 6px
    ),
    rgba(8, 11, 19, 0.82);
  border-color: rgba(159, 123, 255, 0.66);
  box-shadow:
    4px 4px 0 rgba(255, 51, 102, 0.3),
    -2px -2px 0 rgba(0, 209, 255, 0.22);
  animation: dark-synopsis-breathe 2.2s ease-in-out infinite;
}

body[data-theme="dark"] .theme-toggle {
  border-color: rgba(184, 194, 107, 0.45);
  background:
    repeating-linear-gradient(-45deg, rgba(255, 45, 45, 0.18) 0, rgba(255, 45, 45, 0.18) 2px, rgba(78, 167, 181, 0.16) 2px, rgba(78, 167, 181, 0.16) 6px),
    rgba(8, 8, 10, 0.98);
  color: #f3fbff;
  z-index: 20;
  animation: dark-toggle-shiver 2.7s steps(2, end) infinite;
}

body[data-theme="dark"] .toggle-mark {
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-shadow: -1px 0 rgba(255, 51, 102, 0.7), 1px 0 rgba(0, 209, 255, 0.7);
}

body[data-theme="dark"] footer {
  opacity: 0.95;
  text-shadow: 0 0 8px rgba(159, 123, 255, 0.22);
}

body[data-theme="dark"] .footer-note {
  animation: dark-footer-blink 1.9s steps(2, end) infinite;
}

body[data-theme="dark"] ::selection {
  background: rgba(255, 51, 102, 0.55);
  color: #ffffff;
}

@keyframes dark-grid-jitter {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-1px, 0.6px); }
  40% { transform: translate(0.8px, -0.4px); }
  60% { transform: translate(-0.7px, -0.6px); }
  80% { transform: translate(0.9px, 0.5px); }
}

@keyframes laser-dance {
  0% {
    background-position: 0 0, 0 0, 0 0, 0% 50%, 100% 50%;
  }
  25% {
    background-position: 0 0, 0 0, 0 0, 95% 42%, 10% 64%, 70% 34%;
  }
  50% {
    background-position: 0 0, 0 0, 0 0, 100% 46%, 0% 54%, 5% 60%;
  }
  75% {
    background-position: 0 0, 0 0, 0 0, 15% 64%, 92% 40%, 100% 52%;
  }
  100% {
    background-position: 0 0, 0 0, 0 0, 0% 50%, 100% 50%, 0% 50%;
  }
}

@keyframes laser-hue-cycler {
  0%, 100% { filter: contrast(118%) saturate(136%) hue-rotate(0deg); }
  33% { filter: contrast(126%) saturate(152%) hue-rotate(18deg); }
  66% { filter: contrast(122%) saturate(146%) hue-rotate(-14deg); }
}

@keyframes laser-strobe {
  0%, 100% { opacity: 0.9; }
  40% { opacity: 0.55; }
  70% { opacity: 1; }
}

@keyframes dark-vhs-flicker {
  0%, 100% { opacity: 0.66; }
  14% { opacity: 0.48; }
  36% { opacity: 0.73; }
  58% { opacity: 0.44; }
  79% { opacity: 0.69; }
}

@keyframes dark-title-fry {
  0%, 100% { filter: contrast(102%) brightness(100%); }
  28% { filter: contrast(125%) brightness(108%); }
  51% { filter: contrast(108%) brightness(103%); }
  74% { filter: contrast(132%) brightness(110%); }
}

@keyframes dark-main-warp {
  0%, 100% { transform: translateX(0) skewX(0deg); }
  22% { transform: translateX(-0.8px) skewX(-0.25deg); }
  48% { transform: translateX(0.7px) skewX(0.22deg); }
  71% { transform: translateX(-0.5px) skewX(-0.18deg); }
}

@keyframes dark-warning-blink {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.25; }
}

@keyframes dark-heading-snap {
  0%, 86%, 100% { transform: translate(0, 0); }
  89% { transform: translate(-1px, 0.6px); }
  93% { transform: translate(1px, -0.5px); }
}

@keyframes dark-title-twitch {
  0%, 90%, 100% { transform: translate(0, 0); }
  92% { transform: translate(-0.8px, 0.4px); }
  95% { transform: translate(1px, -0.4px); }
}

@keyframes dark-synopsis-breathe {
  0%, 100% { filter: contrast(100%) saturate(100%); }
  50% { filter: contrast(112%) saturate(117%); }
}

@keyframes dark-toggle-shiver {
  0%, 93%, 100% { transform: translate(0, 0); }
  95% { transform: translate(-1px, 0); }
  97% { transform: translate(1px, 0); }
}

@keyframes dark-footer-blink {
  0%, 100% { opacity: 0.95; }
  42% { opacity: 0.42; }
  58% { opacity: 0.82; }
}

@keyframes dark-noise-drift {
  0% { transform: translate(0, 0); opacity: 0.72; }
  25% { transform: translate(-0.5px, 0.8px); opacity: 0.76; }
  50% { transform: translate(0.8px, -0.6px); opacity: 0.7; }
  75% { transform: translate(-0.7px, -0.4px); opacity: 0.74; }
  100% { transform: translate(0, 0); opacity: 0.72; }
}

@keyframes dark-scan-flicker {
  0%, 100% { opacity: 0.28; }
  12% { opacity: 0.39; }
  37% { opacity: 0.22; }
  58% { opacity: 0.42; }
  79% { opacity: 0.27; }
}

@keyframes dark-neon-pulse {
  0%, 100% { filter: brightness(100%) contrast(102%); }
  30% { filter: brightness(111%) contrast(108%); }
  58% { filter: brightness(103%) contrast(105%); }
}

@keyframes dark-crush-pulse {
  0%, 100% { filter: contrast(102%) saturate(95%); }
  35% { filter: contrast(110%) saturate(102%); }
  68% { filter: contrast(106%) saturate(98%); }
}

@keyframes dark-invert-flash {
  0%, 93%, 100% { filter: none; }
  94% { filter: invert(1) hue-rotate(180deg) contrast(1.3); }
  95% { filter: none; }
  96% { filter: invert(1) hue-rotate(180deg) contrast(1.2); }
}
