:root {
  --bg: #f6f5f1;
  --bg-alt: #ece9e2;
  --text: #262521;
  --text-dim: #6f6c64;
  --border: #ddd8cd;
  --accent: #3457d5;
  --accent-soft: #e6eafb;
  --code-bg: #eae7de;
  --shadow: 0 1px 2px rgba(40, 35, 20, 0.05), 0 6px 20px rgba(40, 35, 20, 0.06);
}

[data-theme="dark"] {
  --bg: #0e0f12;
  --bg-alt: #17181c;
  --text: #eceef1;
  --text-dim: #9a9ea6;
  --border: #26282e;
  --accent: #7c9bff;
  --accent-soft: #1a2036;
  --code-bg: #1c1d21;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}
html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.65;
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

header.site {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 0;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  z-index: 10;
}

header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav.main a {
  color: var(--text-dim);
  text-decoration: none;
  margin-right: 1.25rem;
  font-size: 0.95rem;
}

nav.main a:last-child {
  margin-right: 0;
}

nav.main a:hover,
nav.main a.active {
  color: var(--text);
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}

nav.main {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

nav.main a {
  padding: 0.3rem 0.1rem;
  margin-right: 1rem;
  border-bottom: 2px solid transparent;
}

nav.main a.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

button#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  margin-left: 0.5rem;
}

button#theme-toggle:hover {
  background: var(--bg-alt);
  border-color: var(--accent);
}

.bg-binary {
  position: fixed;
  inset: 0;
  top: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bg-binary span {
  position: absolute;
  top: 100%;
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  animation-name: drift-up;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform;
}

@keyframes drift-up {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-120vh);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-binary {
    display: none;
  }
}

main {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 3.5rem 0 2.5rem;
}

h1 {
  font-size: 2.1rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
}

h2 {
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 2.75rem 0 1.1rem;
  padding-bottom: 0;
  border-bottom: none;
}

.title {
  color: var(--accent);
  font-weight: 500;
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

p.lead {
  color: var(--text-dim);
  max-width: 48ch;
}

.avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
  object-fit: cover;
}

.avatar-lg {
  width: 168px;
  height: 168px;
  margin-bottom: 1.75rem;
}

.title-lg {
  font-size: 1.65rem;
  margin-bottom: 1.6rem;
}

.lead-lg {
  font-size: 1.2rem;
  max-width: 58ch;
}

.social {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.9rem;
}

.social a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.social a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.social a svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.entry {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 1.9rem;
  background: var(--bg);
  position: relative;
  z-index: 1;
}

.logo-text {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.entry .logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 6px;
  flex-shrink: 0;
  object-fit: contain;
}

.entry .role {
  font-weight: 600;
}

.entry .org a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.entry ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: var(--text-dim);
}

.entry li {
  margin: 0.25rem 0;
}

.entry li a,
.post-body a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.entry .period {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.sub-roles {
  margin-top: 1rem;
  padding-left: 1.1rem;
  border-left: 2px solid var(--border);
}

.sub-role {
  position: relative;
  padding-bottom: 1.2rem;
}

.sub-role:last-child {
  padding-bottom: 0;
}

.sub-role::before {
  content: "";
  position: absolute;
  left: -1.45rem;
  top: 0.35rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.sub-role-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.sub-role ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  color: var(--text-dim);
}

.sub-role li {
  margin: 0.2rem 0;
}

.project {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  position: relative;
  z-index: 1;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease, background 0.15s ease;
}

.project:hover {
  background: var(--accent-soft);
  box-shadow: var(--shadow);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.project .logo {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 5px;
  flex-shrink: 0;
  object-fit: contain;
}

.project .body {
  flex: 1;
  min-width: 0;
}

.project h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  color: var(--text);
  transition: color 0.15s ease;
}

.project:hover h3 {
  color: var(--accent);
}

.project p {
  margin: 0 0 0.5rem;
  color: var(--text-dim);
}

.project .meta {
  font-size: 0.82rem;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
}

.post-list {
  padding: 0;
}

.post-list li {
  list-style: none;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  z-index: 1;
}

.post-list li:first-child {
  padding-top: 0;
}

.post-list a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
}

.post-list a:hover {
  color: var(--accent);
}

.post-list .date {
  display: block;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.post-body {
  background: var(--bg);
  position: relative;
  z-index: 1;
}

.post-body pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 6px;
}

.post-body code {
  background: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.post-body blockquote {
  border-left: 3px solid var(--border);
  margin: 0;
  padding-left: 1rem;
  color: var(--text-dim);
}

.post-meta {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: -0.5rem;
  margin-bottom: 2rem;
}

footer.site {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0.75rem 0;
}

.back-link {
  display: inline-block;
  margin-top: 2rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--accent);
}

@media (max-width: 640px) {
  .wrap {
    padding: 0 1.1rem;
  }

  header.site .wrap {
    flex-wrap: wrap;
    row-gap: 0.6rem;
  }

  nav.main {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  nav.main a {
    margin-right: 0;
    font-size: 0.88rem;
  }

  button#theme-toggle {
    margin-left: 0;
  }

  main {
    padding: 2.25rem 0 2rem;
  }

  h1 {
    font-size: 1.7rem;
  }

  .avatar-lg {
    width: 120px;
    height: 120px;
  }

  .title-lg {
    font-size: 1.35rem;
  }

  .lead-lg {
    font-size: 1.05rem;
  }

  .entry,
  .project {
    flex-direction: column;
  }

  .entry .logo,
  .project .logo {
    margin-bottom: 0.3rem;
  }

  .entry .org,
  .entry .period,
  .project .meta {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .project .meta {
    white-space: normal;
  }

  .sub-roles {
    padding-left: 0.9rem;
  }

  .sub-role::before {
    left: -1.25rem;
  }

  .social {
    flex-wrap: wrap;
  }
}
