:root {
  --bg: #ffffff;
  --panel: #f8fafc;
  --panel-soft: #eef2f6;
  --text: #111827;
  --muted: #4b5563;
  --rule: #d7dee7;
  --accent: #0645ad;
  --accent-strong: #003a8c;
  --max-width: 1120px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Open Sans', sans-serif;
  line-height: 1.6;
  max-width: var(--max-width);
  margin: auto;
  padding: 24px 32px 48px;
  background: var(--bg);
  color: var(--text);
}

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.15;
}

h1 {
  margin: 0 0 16px;
  font-size: 2.25rem;
  letter-spacing: 0;
}

body > h1:first-of-type {
  margin-bottom: 14px;
  font-size: 1.8rem;
}

h2 {
  margin-top: 32px;
  font-size: 1.55rem;
}

p,
li,
td,
th {
  color: var(--muted);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-strong);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: -4px 0 24px;
}

.nav a {
  margin: 0;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #f0f0f0;
  color: #000000;
  font-weight: 600;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  background: #dcdcdc;
  border-color: #dcdcdc;
  color: #000000;
}

.lede {
  max-width: 860px;
  color: var(--muted);
  font-size: 1.05rem;
}

.profile-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--rule);
  display: block;
}

.home-intro {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 28px;
  align-items: stretch;
}

.home-intro h2 {
  margin-top: 0;
}

.home-intro .lede {
  margin-top: 0;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  padding: 0;
  list-style: none;
}

.home-intro .meta-list {
  grid-template-columns: 1fr;
}

.profile-facts {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
}

.meta-list li,
.course-highlight {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.work-item {
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
}

strong {
  display: inline;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.selected-work,
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px 28px;
}

.course-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.work-item h3,
.course-highlight h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.work-status {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.work-item p,
.course-highlight p {
  margin: 0;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.link-column {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1em;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 10px;
}

th,
td {
  border: 1px solid var(--rule);
  padding: 10px;
  text-align: left;
}

th {
  background-color: var(--panel-soft);
  color: var(--text);
}

code {
  background-color: var(--panel-soft);
  padding: 2px 4px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--text);
  font-family: monospace;
}

details {
  margin-bottom: 1em;
}

summary {
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

img,
video,
embed {
  max-width: 100%;
}

video,
embed {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: #000000;
}

.image-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: center;
  margin: 1em 0;
}

.image-row img {
  width: 100%;
  display: block;
}

.theory-section {
  background: var(--panel);
  border-color: var(--rule);
}

.algo-card {
  background: var(--panel);
  border-color: var(--rule);
}

.algo-card h4 {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.algo-card p,
.algo-card li {
  color: var(--muted);
}

.math {
  background: var(--panel-soft);
  border-color: var(--rule);
  color: var(--accent);
}

@media (max-width: 640px) {
  body {
    padding: 24px 16px 44px;
  }

  .nav {
    gap: 8px;
  }

  .nav a {
    padding: 7px 10px;
    font-size: 0.92rem;
  }

  .home-intro {
    grid-template-columns: 1fr;
  }

  .profile-photo {
    max-width: 430px;
    height: auto;
  }

  .course-grid {
    grid-template-columns: 1fr;
  }

  .image-row {
    grid-template-columns: 1fr;
  }
}
