:root {
  --accent: #e8462a;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: "Charter", "Iowan Old Style", "Iowan", Georgia, "Times New Roman", serif;
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --fg: #18181b;
  --fg-body: #27272a;
  --fg-soft: #3f3f46;
  --meta: #52525b;
  --border: #e4e4e7;
  --border-soft: #d4d4d8;
  --footer: #71717a;
  --claim: #09090b;
  --nav-bg: rgba(250, 250, 250, 0.85);
}

:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #111418;
  --fg: #f4f4f5;
  --fg-body: #e4e4e7;
  --fg-soft: #c4c4c7;
  --meta: #a1a1aa;
  --border: #1f2227;
  --border-soft: #27292f;
  --footer: #71717a;
  --claim: #ffffff;
  --nav-bg: rgba(11, 13, 16, 0.85);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

::selection {
  background: var(--accent);
  color: #ffffff;
}

/* --- Navigation --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 16px;
}

.nav-brand {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  font-size: 17px;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.nav-brand:hover { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav-links a {
  color: var(--fg-soft);
  text-decoration: none;
  font-size: 15px;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-links a:hover { color: var(--accent); }
.nav-links a.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* --- Layout --- */
main {
  max-width: 820px;
  margin: 0 auto;
  padding: 56px 24px 24px;
}

.page-title {
  margin: 0 0 8px;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--claim);
}
.page-subtitle {
  margin: 0 0 36px;
  color: var(--meta);
  font-size: 17px;
}

/* --- About / profile hero --- */
.profile {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 40px;
  align-items: start;
  margin: 12px 0 40px;
}
.profile-text h1 {
  margin: 0 0 8px;
  font-size: 40px;
  line-height: 1.1;
  color: var(--claim);
  letter-spacing: -0.01em;
}
.profile-text .role {
  margin: 0 0 20px;
  color: var(--fg-soft);
  font-size: 18px;
}
.profile-text .quick-links {
  margin: 0;
  font-size: 15px;
}
.profile-text .quick-links a {
  color: var(--fg);
  margin-right: 18px;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.profile-text .quick-links a:hover { color: var(--accent); }
.profile-photo {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  justify-self: end;
}

/* --- Typography --- */
p { font-size: 18px; color: var(--fg-body); margin: 0 0 16px; }
.lead { font-size: 19px; }
.muted { color: var(--meta); }

h2.section-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--fg);
  margin: 44px 0 18px;
  letter-spacing: -0.005em;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
a:hover { color: var(--fg); }

.more-line {
  margin-top: 28px;
  color: var(--meta);
  font-size: 16px;
}
.more-line a { margin: 0 4px; }

/* --- Cards / project list --- */
.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
}
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--border-soft);
}
.card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
}
.card h3 a {
  color: var(--fg);
  text-decoration: none;
}
.card h3 a::after {
  content: " \2197";
  color: var(--meta);
  font-weight: 400;
}
.card h3 a:hover { color: var(--accent); }
.card p {
  margin: 0;
  font-size: 16px;
  color: var(--fg-body);
  line-height: 1.55;
}

/* --- CV-style rows (bio, awards) --- */
.cv-section { margin-bottom: 16px; }
.cv-section h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 36px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.08em;
  color: var(--meta);
  text-transform: uppercase;
}
.cv-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.cv-row:last-child { border-bottom: 0; }
.cv-year {
  color: var(--meta);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.cv-content { font-size: 17px; color: var(--fg-body); line-height: 1.55; }
.cv-content strong { color: var(--fg); font-weight: 600; }
.cv-content .cv-meta {
  color: var(--meta);
  font-size: 15px;
  display: block;
  margin-top: 4px;
}

/* --- Publications --- */
.pub-group { margin-bottom: 24px; }
.pub-group h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 36px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.08em;
  color: var(--meta);
  text-transform: uppercase;
}
.pub-list { list-style: none; padding: 0; margin: 0; }
.pub-list li {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.pub-list li:last-child { border-bottom: 0; }
.pub-title {
  color: var(--fg);
  font-weight: 600;
  display: block;
  font-size: 17px;
  margin-bottom: 4px;
}
.pub-authors {
  display: block;
  color: var(--fg-body);
  font-size: 15px;
  margin-bottom: 2px;
}
.pub-venue {
  display: block;
  color: var(--meta);
  font-style: italic;
  font-size: 15px;
}

/* --- Contact block --- */
.contact-block {
  margin-top: 24px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.contact-block p {
  margin: 0 0 8px;
  font-size: 17px;
}
.contact-block p:last-child { margin-bottom: 0; }
.contact-block .consulting {
  color: var(--meta);
  font-size: 15px;
  margin-top: 14px;
}

/* --- Footer --- */
footer {
  max-width: 820px;
  margin: 64px auto 0;
  padding: 24px 24px 56px;
  color: var(--footer);
  font-size: 14px;
  border-top: 1px solid var(--border);
}
footer a {
  color: var(--meta);
  margin-right: 18px;
  text-decoration: none;
}
footer a:hover { color: var(--accent); }

/* --- Theme toggle --- */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font: inherit;
  line-height: 1;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--meta);
  color: var(--accent);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .theme-toggle .icon-moon,
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }

/* --- Legal pages --- */
.legal h1 {
  margin: 0 0 12px;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--claim);
}
.legal h2 {
  margin: 36px 0 10px;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--fg);
}
.legal p, .legal li {
  font-size: 17px;
  color: var(--fg-body);
}
.legal ul { padding-left: 22px; }
.legal .meta {
  color: var(--meta);
  font-size: 15px;
}

/* --- Responsive --- */
@media (max-width: 720px) {
  .nav-inner { padding: 12px 16px; gap: 12px; }
  .nav-links { gap: 14px; }
  .nav-links a { font-size: 14px; }
  main { padding: 32px 18px 16px; }
  .profile {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .profile-photo {
    width: 132px;
    height: 132px;
    justify-self: start;
    order: -1;
  }
  .profile-text h1 { font-size: 32px; }
  .cv-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .cv-year { font-size: 14px; }
  .page-title { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  body, a, .theme-toggle, .card, .nav-links a { transition: none; }
}
