:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #252a30;
  --body: #394149;
  --secondary: #626b74;
  --link: #365c76;
  --line: #e0e5e9;
  --focus: #426e8c;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171b1f;
  --ink: #eef0f2;
  --body: #d0d6dc;
  --secondary: #a7b1ba;
  --link: #accbdc;
  --line: #343c44;
  --focus: #accbdc;
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

main {
  width: min(100% - 48px, 600px);
  margin: 0 auto;
  padding: 90px 0 64px;
}

header { margin-bottom: 38px; }

.heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.65px;
  line-height: 1.35;
}

.tagline {
  margin: 10px 0 0;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1.65;
}

p { margin: 0 0 22px; }

a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 42%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a:hover { text-decoration-color: currentColor; }

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 5px;
  border-radius: 2px;
}

.theme-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
}

.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--ink); }
.theme-toggle:focus-visible { border-radius: 50%; }
.theme-toggle svg { display: block; }
.theme-toggle .dial { transform-origin: 10px 10px; }
:root.theme-ready .theme-toggle .dial {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
:root[data-theme="dark"] .theme-toggle .dial { transform: rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  :root.theme-ready .theme-toggle .dial { transition: none; }
}

.projects {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
}

.projects > div { margin-bottom: 17px; }
.projects > div:last-child { margin-bottom: 0; }
.projects dt {
  margin-bottom: 2px;
  font-weight: 500;
}
.projects dd { color: var(--secondary); }

.record { margin-top: 33px; }

.academic-header .heading-row { margin-bottom: 26px; }
.academic-back { color: var(--secondary); font-size: 14px; }
.academic-entry { margin-top: 32px; }
.academic-entry h2 {
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
}
.academic-meta {
  margin-bottom: 8px;
  color: var(--secondary);
  font-size: 13px;
}
.academic-entry p:last-child { margin-bottom: 0; }

details { margin: 0; }

summary {
  width: fit-content;
  min-height: 36px;
  padding: 5px 0;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1.8;
  cursor: pointer;
}

summary::marker { font-size: 10px; }

summary:hover,
details[open] > summary { color: var(--ink); }

.detail-content {
  padding: 21px 0 23px 16px;
  font-size: 14px;
  line-height: 1.75;
}

h2 {
  margin: 0 0 17px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.history { margin: 0 0 30px; }
.history:last-child { margin-bottom: 0; }

.history > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  margin-bottom: 17px;
}

dt {
  color: var(--ink);
  font-weight: 600;
}

dt a { color: inherit; }

dd { margin: 0; }

.date {
  color: var(--secondary);
  font-size: 13px;
  white-space: nowrap;
  align-self: baseline;
}

.history dd:not(.date) {
  grid-column: 1 / -1;
  color: var(--secondary);
}

.profile-links {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px 22px;
  font-size: 14px;
  line-height: 1.7;
}

.profile-links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  text-decoration: none;
}

.profile-links a span {
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 42%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.profile-links a:hover span { text-decoration-color: currentColor; }

.profile-icon {
  display: block;
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  object-fit: contain;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: 1;
  padding: 8px 12px;
  background: var(--paper);
  transform: translateY(-200%);
}

.skip-link:focus { transform: translateY(0); }

@media (max-width: 600px) {
  main {
    width: calc(100% - 44px);
    padding: 56px 0 48px;
  }

  header { margin-bottom: 30px; }
  h1 { font-size: 25px; }
  .heading-row { gap: 16px; }
  body { font-size: 15px; }
  .tagline { font-size: 14px; }
  .profile-links { flex-wrap: nowrap; gap: 4px; }
  .profile-links a { width: 44px; height: 44px; justify-content: center; }
  .profile-links a span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .profile-links .profile-icon { flex-basis: 18px; width: 18px; height: 18px; }
  .profile-page {
    --profile-gap: clamp(4px, calc(8svh - 38.4px), 30px);
    font-size: clamp(14px, 2.3svh, 15px);
  }
  .profile-page main {
    display: flex;
    flex-direction: column;
    gap: var(--profile-gap);
    padding-top: clamp(8px, calc(18svh - 94px), 56px);
    padding-bottom: max(clamp(8px, calc(4svh - 16px), 24px), env(safe-area-inset-bottom));
  }
  .profile-page header { margin-bottom: 0; }
  .profile-page .tagline { margin-top: clamp(4px, 1svh, 10px); line-height: 1.55; }
  .profile-page .profile-links { margin-top: clamp(4px, 1.5svh, 18px); }
  .profile-page .introduction {
    display: grid;
    gap: min(var(--profile-gap), 22px);
    line-height: clamp(1.55em, 3.7svh, 1.8em);
  }
  .profile-page .introduction p { margin: 0; }
  .profile-page .record { margin-top: 0; }
  .profile-page .record > details > summary { padding: 4px 0; line-height: 1.6; }
  .history > div { grid-template-columns: 1fr; }
  .date { margin-bottom: 1px; }
  .detail-content { padding-left: 13px; }
}

@media (max-width: 360px) {
  .profile-page main { width: calc(100% - 32px); }
}
