:root {
  color-scheme: light;
  --background: #ffffff;
  --foreground: #171717;
  --muted-foreground: #666666;
  --border: #dddddd;
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #171717;
    --foreground: #eeeeee;
    --muted-foreground: #aaaaaa;
    --border: #3a3a3a;
  }
}

@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --background: #171717;
    --foreground: #eeeeee;
    --muted-foreground: #aaaaaa;
    --border: #3a3a3a;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 4px;
}

::selection {
  background: var(--foreground);
  color: var(--background);
}

.page-width {
  width: min(100% - 40px, 900px);
  margin-inline: auto;
}

.site-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}

nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}

nav a,
.text-link,
.contact-links a,
.output-links a,
footer a {
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.nav-cv {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--foreground);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.nav-cv:hover {
  background: var(--foreground);
  color: var(--background);
}

.theme-control {
  position: relative;
  margin-left: auto;
}

.theme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--foreground);
  border-radius: 0;
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.theme-button:hover {
  background: var(--foreground);
  color: var(--background);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-options {
  position: absolute;
  z-index: 1;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
}

.theme-options fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.theme-options legend {
  margin-bottom: 4px;
  padding: 0;
  color: var(--muted-foreground);
  font-size: 12px;
}

.theme-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.theme-options input {
  margin: 0;
  accent-color: var(--foreground);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 56px;
  padding-block: 96px 104px;
}

.profile-photo {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  display: block;
  object-fit: cover;
  object-position: center;
}

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

h1 {
  margin-bottom: 24px;
  font-size: clamp(30px, 4.5vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.summary {
  max-width: 620px;
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.75;
}

.section {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 40px;
  padding-block: 56px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 24px;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.5;
}

.prose p {
  max-width: 560px;
  margin-bottom: 0;
}

.item-list {
  display: grid;
  gap: 40px;
}

.item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
}

.item-period {
  margin-bottom: 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

.item h3 {
  margin-bottom: 2px;
  font-size: 16px;
  line-height: 1.5;
}

.item-organisation {
  margin-bottom: 10px;
  color: var(--muted-foreground);
}

.item-summary {
  margin-bottom: 0;
}

.item-supervision {
  margin: 6px 0 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

.output-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  font-size: 14px;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-block: 32px 48px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 13px;
}

footer p {
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .intro {
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 24px;
  }

  .intro-copy {
    display: contents;
  }

  .intro h1 {
    margin-bottom: 0;
  }

  .summary {
    grid-column: 1 / -1;
  }

  .profile-photo {
    grid-column: 2;
    grid-row: 1;
    width: 88px;
    height: auto;
  }
}

@media (max-width: 640px) {
  .page-width {
    width: min(100% - 32px, 900px);
  }

  .site-header {
    min-height: 72px;
  }

  nav > a:not(.nav-cv) {
    display: none;
  }

  .intro {
    padding-block: 72px 80px;
  }

  .section {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-block: 44px;
  }

  .item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media print {
  .theme-control {
    display: none;
  }
}

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