:root {
  --bg: #f7f6f1;
  --panel: #ffffff;
  --panel-soft: #fbfaf6;
  --ink: #1f2328;
  --muted: #5d6670;
  --line: rgba(31, 35, 40, 0.13);
  --blue: #0a4778;
  --blue-soft: #e8f1f8;
  --blue-soft-hover: #dcebf5;
  --link-blue: #2b7dbd;
  --green: #2c6b4f;
  --amber: #9a6518;
  --alert: #b3261e;
  --alert-soft: rgba(179, 38, 30, 0.1);
  --band: rgba(10, 71, 120, 0.1);
  --grid: rgba(31, 35, 40, 0.08);
  --header-bg: rgba(247, 246, 241, 0.9);
  --shadow: 0 14px 34px rgba(31, 35, 40, 0.07);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --panel: #161d24;
    --panel-soft: #131a20;
    --ink: #e6e8eb;
    --muted: #9aa5b1;
    --line: rgba(230, 232, 235, 0.12);
    --blue: #8cc1ec;
    --blue-soft: rgba(140, 193, 236, 0.12);
    --blue-soft-hover: rgba(140, 193, 236, 0.2);
    --link-blue: #8cc1ec;
    --green: #7cc3a0;
    --amber: #e0a85a;
    --alert: #ff7b72;
    --alert-soft: rgba(255, 123, 114, 0.14);
    --band: rgba(140, 193, 236, 0.16);
    --grid: rgba(230, 232, 235, 0.08);
    --header-bg: rgba(15, 20, 25, 0.86);
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1419;
  --panel: #161d24;
  --panel-soft: #131a20;
  --ink: #e6e8eb;
  --muted: #9aa5b1;
  --line: rgba(230, 232, 235, 0.12);
  --blue: #8cc1ec;
  --blue-soft: rgba(140, 193, 236, 0.12);
  --blue-soft-hover: rgba(140, 193, 236, 0.2);
  --link-blue: #8cc1ec;
  --green: #7cc3a0;
  --amber: #e0a85a;
  --alert: #ff7b72;
  --alert-soft: rgba(255, 123, 114, 0.14);
  --band: rgba(140, 193, 236, 0.16);
  --grid: rgba(230, 232, 235, 0.08);
  --header-bg: rgba(15, 20, 25, 0.86);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
}

.brand {
  margin-right: auto;
  font-weight: 750;
  color: var(--blue);
}

nav {
  display: flex;
  gap: 18px;
  font-size: 0.94rem;
}

nav a {
  color: var(--muted);
  transition: color 0.2s ease;
}

nav a:hover {
  color: var(--ink);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.theme-toggle .icon-moon {
  fill: currentColor;
  stroke: none;
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
}

/* Layout and type */

main {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 4.6vw, 4.2rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.1;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.04rem;
}

.section-band,
.projects,
.contact {
  padding: 56px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
  margin-bottom: 30px;
}

.section-heading .eyebrow {
  margin-bottom: 0;
}

/* Intro */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
  align-items: center;
  gap: clamp(28px, 5vw, 64px);
  padding: clamp(40px, 7vw, 80px) 0 56px;
}

.role {
  margin-bottom: 18px;
  color: var(--blue);
  font-size: 1.16rem;
  font-weight: 700;
}

.summary {
  max-width: 640px;
  color: var(--muted);
  font-size: 1.03rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid var(--band);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 650;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.button:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
  background: var(--blue-soft-hover);
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--bg);
}

.button.primary:hover {
  background: var(--blue);
  filter: brightness(1.1);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink);
  font-size: 0.92rem;
}

.facts span {
  display: block;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Live early-warning panel */

.live-panel {
  margin: 0;
  padding: 20px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 var(--green);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(44, 107, 79, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(44, 107, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(44, 107, 79, 0); }
}

.live-title {
  color: var(--ink);
  font-weight: 700;
}

.live-budget {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 650;
  white-space: nowrap;
}

.token-row {
  display: flex;
  gap: 6px;
  min-height: 30px;
  margin: 14px 0 10px;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent 0, #000 28px);
  justify-content: flex-end;
}

.token {
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.74rem;
  animation: token-in 0.35s ease both;
}

.token.hot {
  border-color: var(--alert);
  color: var(--alert);
  background: var(--alert-soft);
}

.token.good {
  border-color: var(--green);
  color: var(--green);
}

@keyframes token-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

.risk-canvas {
  display: block;
  width: 100%;
  height: 210px;
}

.live-status {
  min-height: 1.5em;
  margin-top: 10px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
  transition: color 0.3s ease;
}

.live-status.alert {
  color: var(--alert);
}

.live-status.ok {
  color: var(--green);
}

.live-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

/* Same click, different moment */

.perspective-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: center;
}

.perspective-copy p {
  color: var(--muted);
}

.perspective-copy strong,
.perspective-copy em {
  color: var(--ink);
}

.beta-figure {
  margin: 0;
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.beta-intro {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.beta-intro strong,
.beta-intro em {
  color: var(--ink);
}

.beta-svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: ew-resize;
  user-select: none;
}

.beta-svg text {
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  fill: var(--muted);
  font-size: 15px;
}

.beta-slider-label {
  display: block;
  padding: 2px 44px 0 50px;
}

.beta-slider {
  width: 100%;
  accent-color: var(--blue);
}

.beta-readout {
  min-height: 3em;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.beta-readout strong {
  color: var(--ink);
}

.beta-readout .pos {
  color: var(--green);
  font-weight: 700;
}

.beta-readout .neg {
  color: var(--alert);
  font-weight: 700;
}

/* Research interests */

.interest-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.interest-list > div,
.pub {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.interest-list > div:hover {
  transform: translateY(-3px);
  border-color: var(--band);
  box-shadow: var(--shadow);
}

.interest-list p,
.pub p,
.contact p {
  color: var(--muted);
}

.interest-list p {
  margin-bottom: 0;
}

/* Projects */

.projects {
  display: grid;
  gap: 14px;
}

.project {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.project:hover,
.project[open] {
  border-color: var(--band);
  box-shadow: var(--shadow);
}

.project summary {
  position: relative;
  padding: 22px 24px 20px;
  cursor: pointer;
  list-style: none;
}

.project summary::-webkit-details-marker {
  display: none;
}

.project-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.project-top h3 {
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.meta {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 650;
}

.lede {
  margin: 0;
  padding-right: 80px;
  color: var(--muted);
}

.more {
  position: absolute;
  right: 24px;
  bottom: 20px;
  color: var(--link-blue);
  font-size: 0.86rem;
  font-weight: 650;
}

.more::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-3px) rotate(45deg);
  transition: transform 0.25s ease;
}

.project[open] .more::after {
  transform: translateY(1px) rotate(225deg);
}

.project-body {
  padding: 0 24px 22px;
  animation: open-body 0.3s ease both;
}

.project-body p {
  margin: 0;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
}

@keyframes open-body {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* Publications and contact */

.compact-section {
  padding-bottom: 48px;
}

.pub-list {
  display: grid;
  gap: 14px;
}

.pub p {
  margin-bottom: 0;
}

.pub .pub-kind {
  margin-bottom: 6px;
  color: var(--green);
  font-size: 0.86rem;
  font-weight: 700;
}

.contact {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-start;
  padding-bottom: 40px;
}

.contact-links {
  display: grid;
  gap: 9px;
  min-width: min(100%, 320px);
}

.contact-links a {
  font-weight: 650;
}

.contact-links a:hover {
  text-decoration: underline;
}

.footer {
  margin: 0;
  padding: 0 0 36px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Scroll reveal */

.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.js .reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .live-dot,
  .token,
  .project-body {
    animation: none;
  }
}

/* Tablet */

@media (max-width: 900px) {
  .intro,
  .perspective-grid {
    grid-template-columns: 1fr;
  }
}

/* Phone */

@media (max-width: 600px) {
  html {
    scroll-padding-top: 64px;
  }

  main {
    width: calc(100% - 32px);
  }

  .site-header {
    gap: 12px;
    padding: 11px 16px;
  }

  .brand {
    font-size: 0.98rem;
  }

  nav {
    gap: 12px;
    font-size: 0.8rem;
  }

  nav a[href="#research"] {
    display: none;
  }

  .theme-toggle {
    width: 30px;
    height: 30px;
  }

  .intro {
    gap: 26px;
    padding: 30px 0 34px;
  }

  h1 {
    font-size: 2.4rem;
  }

  .role {
    font-size: 1.04rem;
    margin-bottom: 12px;
  }

  .summary {
    font-size: 0.98rem;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 20px;
  }

  .button {
    min-height: 40px;
    padding: 8px 6px;
    font-size: 0.92rem;
  }

  .facts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
    font-size: 0.82rem;
  }

  .live-panel,
  .beta-figure {
    padding: 14px 14px 12px;
  }

  .live-budget {
    font-size: 0.68rem;
  }

  .risk-canvas {
    height: 170px;
  }

  .section-band,
  .projects,
  .contact {
    padding: 38px 0;
  }

  .section-heading {
    margin-bottom: 22px;
  }

  .interest-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .interest-list > div,
  .pub {
    padding: 16px;
  }

  .project summary {
    padding: 16px 16px 14px;
  }

  .project-top {
    flex-direction: column;
    gap: 4px;
  }

  .project-top h3 {
    font-size: 1rem;
  }

  .lede {
    padding-right: 0;
  }

  .more {
    position: static;
    display: inline-block;
    margin-top: 8px;
  }

  .project-body {
    padding: 0 16px 16px;
  }

  .beta-slider-label {
    padding: 2px 12px 0 34px;
  }

  .beta-svg text {
    font-size: 19px;
  }

  .beta-svg .y-label {
    display: none;
  }

  .contact {
    display: grid;
    gap: 16px;
  }
}
