/* Design tokens shared by light mode. Dark-mode overrides are near the end. */
:root {
  color-scheme: light dark;
  --background: #fafafa;
  --text: #171717;
  --muted: #5f5f5f;
  --link: #383838;
  --line: #dedede;
  --focus: #d87b28;
  --ambient-line: rgba(32, 42, 80, 0.045);
  --ambient-dot: rgba(32, 42, 80, 0.1);
  --paper: #ffffff;
  --paper-line: #e4e4e4;
  --project-line: #c9c9c9;
  --action-line: rgba(23, 23, 23, 0.08);
  --paper-shadow: rgba(20, 20, 20, 0.08);
  --width: 640px;
}

* { box-sizing: border-box; }
img { max-width: 100%; }

/* Base document and animated background. */
html { overflow-x: clip; background: var(--background); }
body {
  position: relative;
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: Inter, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  transition: background-color 240ms ease, color 240ms ease;
  overflow-x: clip;
}

body::before {
  position: fixed;
  inset: -16%;
  z-index: 0;
  background-image:
    linear-gradient(var(--ambient-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ambient-line) 1px, transparent 1px),
    radial-gradient(circle, var(--ambient-dot) 1px, transparent 1.4px);
  background-size: 64px 64px, 64px 64px, 16px 16px;
  content: "";
  opacity: 0.72;
  pointer-events: none;
  transform: rotate(-6deg) scale(1.12);
  animation: ambient-drift 22s linear infinite;
}

@keyframes ambient-drift {
  to { transform: translate3d(64px, 64px, 0) rotate(-6deg) scale(1.12); }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 240ms;
  animation-timing-function: ease;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: color 240ms ease;
}
a:hover { color: var(--text); }
a:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.25; }
h1 { margin-bottom: 1.6rem; font-size: 2rem; font-weight: 650; }
h2 { margin: 3.5rem 0 1.25rem; font-size: 1.12rem; font-weight: 650; }
h3 { margin-bottom: 0.35rem; font-size: 1.05rem; font-weight: 650; }
p { margin-bottom: 1.15rem; }
ul { padding-left: 1.25rem; }

/* Shared accessibility and hand-drawn artwork behavior. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.drawing {
  display: block;
  transition: transform 180ms ease, filter 240ms ease;
  transform-origin: center;
}

a:hover .drawing,
button:hover .drawing,
.drawing:hover {
  transform: scale(1.045) rotate(-1.25deg);
}

.skip-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  transform: translateY(-200%);
  padding: 0.35rem 0.6rem;
  background: var(--text);
  color: var(--background);
}
.skip-link:focus { transform: translateY(0); }

/* Site-wide header, navigation, main column, and theme switch. */
.site-header, main, .site-footer {
  position: relative;
  z-index: 1;
  width: min(var(--width), calc(100% - 40px));
  margin-inline: auto;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: min(820px, calc(100% - 40px));
  padding-top: clamp(2rem, 8vw, 5rem);
}
.mobile-brand { display: none; }
.mobile-brand__drawing { display: block; width: auto; height: 30px; max-width: 100%; object-fit: contain; object-position: left center; }
.site-nav ul {
  display: flex;
  align-items: center;
  gap: 2.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  position: relative;
  display: block;
  padding-bottom: 0.65rem;
  color: var(--text);
  text-decoration: none;
  opacity: 0.56;
  transition: opacity 180ms ease;
}
.nav-drawing { width: auto; height: 30px; max-width: 98px; object-fit: contain; }
.nav-underline {
  position: absolute;
  bottom: -0.1rem;
  left: 50%;
  width: 116%;
  height: 12px;
  object-fit: fill;
  transform: translateX(-50%);
}
.site-nav a:hover .nav-underline {
  transform: translateX(-50%) scale(1.045) rotate(-1.25deg);
}
.site-nav a:hover,
.site-nav a[aria-current="page"] { opacity: 1; }

.theme-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 32px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.theme-toggle__image { width: 64px; height: 28px; object-fit: contain; transition: width 240ms ease, transform 180ms ease, filter 240ms ease; }
.theme-toggle__image[data-mode="dark"] { width: 58px; }
.theme-toggle__image[data-mode="light"] { width: 68px; }

main { min-height: 65vh; padding: clamp(3.5rem, 9vw, 6.5rem) 0 5rem; }

/* Home page: identity, journal paper, and contact links. */
.intro { width: 100%; max-width: 39rem; min-width: 0; }
.identity-drawing {
  width: min(100%, 390px);
  height: auto;
}
.journal { position: relative; margin-top: clamp(2.75rem, 6vw, 4rem); }
.journal-toggle {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 3;
  display: grid;
  width: 34px;
  height: 34px;
  border: 0;
  padding: 0;
  place-items: center;
  background: transparent;
  cursor: pointer;
  transform-origin: center;
  transition: transform 180ms ease;
}
.journal-toggle img { width: 30px; height: 30px; object-fit: contain; }
.journal:hover .journal-toggle { transform: scale(1.06); }
.journal .journal-toggle:hover { transform: scale(1.18); }
.journal-paper {
  width: 100%;
  margin-top: 0;
  padding: clamp(1.75rem, 5vw, 3rem);
  border: 1px solid var(--paper-line);
  border-radius: 3px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 18px 50px var(--paper-shadow);
  transition: background-color 240ms ease, border-color 240ms ease, box-shadow 240ms ease, transform 180ms ease;
  transform-origin: center;
}
.journal-paper:hover { transform: scale(1.015); }
.journal-drawing {
  width: 100%;
  max-width: 100%;
  height: auto;
}
.journal-paper .journal-drawing:hover { transform: none; }
.journal-dialog {
  width: min(780px, calc(100% - 40px), calc(100dvh - 145px));
  max-width: none;
  max-height: none;
  border: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  color: var(--text);
}
.journal-dialog[open] { animation: journal-open 220ms cubic-bezier(0.22, 1, 0.36, 1); }
.journal-dialog:focus { outline: none; }
.journal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  animation: journal-backdrop-in 220ms ease-out;
}
.journal-dialog.is-closing { animation: journal-close 160ms ease-in forwards; }
.journal-dialog.is-closing::backdrop { animation: journal-backdrop-out 160ms ease-in forwards; }
@keyframes journal-open {
  from { opacity: 0; }
}
@keyframes journal-close {
  to { opacity: 0; }
}
@keyframes journal-backdrop-in { from { background: rgba(0, 0, 0, 0); } }
@keyframes journal-backdrop-out { to { background: rgba(0, 0, 0, 0); } }
.journal-dialog__content { position: relative; }
.journal-dialog__close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 3;
  display: grid;
  width: 36px;
  height: 36px;
  border: 0;
  padding: 0;
  place-items: center;
  background: transparent;
  cursor: pointer;
  transform-origin: center;
  transition: transform 180ms ease;
}
.journal-dialog__close img { width: 32px; height: 32px; object-fit: contain; }
.journal-dialog__content:hover .journal-dialog__close { transform: scale(1.06); }
.journal-dialog__content .journal-dialog__close:hover { transform: scale(1.18); }
.journal-paper--expanded {
  padding: clamp(2rem, 6vw, 4.5rem);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}
.journal-history {
  display: grid;
  margin-top: 2.5rem;
  padding: 0 0 0.5rem;
  place-items: center;
}
.journal-history__empty { width: min(100%, 240px); height: auto; }
.intro__role, .page-description, .meta, .project-tech { color: var(--muted); }
.intro__role { margin-bottom: 1.5rem; }
.reach-out {
  display: grid;
  justify-items: center;
  margin-top: clamp(5rem, 10vw, 7rem);
  padding-top: 1rem;
  text-align: center;
}
.reach-out__title {
  width: min(100%, 290px);
  height: auto;
  margin-bottom: 1.75rem;
}
.social-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 570px);
  gap: 1.25rem 3.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}
.social-list a {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  width: 100%;
  min-height: 52px;
  padding: 0.35rem 0;
}
.social-list__email { grid-column: 1 / -1; justify-self: center; width: min(100%, 370px); }
.social-icon { width: 22px; height: 22px; object-fit: contain; }
.social-drawing { width: auto; height: 31px; max-width: 100%; object-fit: contain; object-position: left center; }

/* Shared page headings and Work page. */
.page-header { margin-bottom: 3.5rem; }
.page-header h1 { margin-bottom: 0.75rem; }
.page-description { max-width: 36rem; }
.section-drawing { width: auto; height: 66px; max-width: min(100%, 310px); margin-bottom: 1.4rem; object-fit: contain; object-position: left center; }
.work-list { display: grid; gap: 3.25rem; }
.work-item h2 {
  margin: 0 0 0.3rem;
  font-size: 1.12rem;
}
.work-item p { margin-bottom: 0.65rem; }
.work-item ul { margin: 0.9rem 0 0; }
.work-item li + li { margin-top: 0.35rem; }
.work-item__drawing { display: block; width: auto; max-width: min(100%, 300px); max-height: 64px; }
.work-item__read-more { display: inline-flex; min-height: 44px; align-items: center; margin-top: 1.25rem; }
.work-item__action { display: block; width: auto; height: 38px; max-width: 170px; }
.work-detail > a { display: inline-flex; min-height: 44px; align-items: center; margin-bottom: 2rem; }
.work-detail__back { width: auto; height: 26px; }
.work-detail h1 { margin: 0 0 1rem; }

/* Projects index: responsive cards generated from data/projects.js. */
.projects-view main {
  width: min(1040px, calc(100% - 40px));
}
.projects-view .page-header { max-width: var(--width); }
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}
.project-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border: 1px solid var(--project-line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 14px 36px var(--paper-shadow);
  transform: rotate(var(--card-tilt, 0deg));
  transform-origin: 50% 0;
  transition: transform 180ms ease-out, border-color 240ms ease, background-color 240ms ease, box-shadow 240ms ease;
}
.project-card__cover {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 3;
  border-bottom: 1px solid var(--project-line);
  object-fit: cover;
}
.project-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 1.3rem;
}
.project-card h2 { margin: 0 0 0.55rem; font-size: 1.18rem; }
.project-card p { margin-bottom: 1rem; color: var(--muted); }
.project-tag {
  width: 100%;
  margin: 0 auto 0.85rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}
.project-card .project-tag { margin-bottom: 0.85rem; }
.project-tech-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  width: 100%;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: center;
}
.project-tech-list li {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  padding: 0.25rem 0.72rem;
  background: var(--background);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}
.project-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.8rem 1rem;
  margin-top: auto;
  padding-top: 1.35rem;
}
.project-action { display: inline-flex; width: fit-content; min-height: 44px; align-items: center; justify-content: center; }
.project-action__drawing { width: auto; height: 26px; max-width: 112px; object-fit: contain; }
.project-action__label { display: none; }

/* Automatically generated project detail pages. */
.project-detail-view main { width: min(760px, calc(100% - 40px)); }
.project-detail__toolbar {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 3rem;
}
.project-detail__back { display: inline-flex; align-items: center; flex: none; }
.project-detail__back img { width: auto; height: 31px; max-width: 112px; object-fit: contain; }
.project-detail__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.75rem 1rem; }
.project-detail__actions:empty { display: none; }
.project-detail__actions .project-action__drawing { height: 28px; max-width: 118px; }
.project-detail h1 { margin-bottom: 0.8rem; }
.project-detail__summary { color: var(--muted); font-size: 1.08rem; }
.project-detail__copy { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.75rem; margin: 2.75rem 0; }
.project-detail__section { min-width: 0; }
.project-detail__section h2 { margin: 0 0 1rem; font-size: 1.2rem; }
.project-detail__section p:last-of-type { margin-bottom: 0; }
.architecture-flow {
  position: relative;
  left: 50%;
  width: min(calc(100vw - 3rem), 940px);
  margin: 1.5rem 0 0;
  transform: translateX(-50%);
}
.architecture-flow ol {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 1.6rem;
  row-gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.architecture-flow li {
  position: relative;
  min-width: 0;
  padding: 1rem 0.9rem;
  border: 1px solid var(--project-line);
  border-radius: 6px;
  background: var(--paper);
}
.architecture-flow li:not(:last-child)::after {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.3rem);
  width: 1rem;
  color: var(--muted);
  content: "→";
  text-align: center;
  transform: translateY(-55%);
}
.architecture-flow strong,
.architecture-flow span { display: block; }
.architecture-flow strong { margin-bottom: 0.35rem; font-size: 0.92rem; text-wrap: balance; }
.architecture-flow span { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.architecture-flow figcaption {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}
.project-code {
  max-width: 100%;
  margin: 1.35rem 0 0;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: var(--paper);
  color: var(--text);
  font: 0.82rem/1.6 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  tab-size: 4;
}
.project-code code { font: inherit; }

/* Page not found. */
.not-found { width: 100%; padding: clamp(0.5rem, 4vw, 2rem) 0; }
.not-found__message { display: block; width: 100%; height: auto; margin-inline: auto; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 1.25rem 0 3.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  transition: border-color 240ms ease, color 240ms ease;
}
.footer-signature { width: 200px; height: 52px; object-fit: contain; object-position: left center; }
.smiley-easter-egg { position: relative; display: block; flex: none; width: 36px; height: 36px; }
.footer-drawing {
  position: relative;
  z-index: 2;
  width: 36px;
  height: 36px;
  object-fit: contain;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.footer-drawing.is-loose { z-index: 10; margin: 0; }
.footer-drawing.is-dragging { cursor: grabbing; }
.smiley-hint {
  position: absolute;
  top: 50%;
  right: calc(100% + 0.7rem);
  width: 120px;
  max-width: none;
  height: auto;
  opacity: 0;
  pointer-events: none;
  transform: translate(5px, -50%);
  transition: opacity 160ms ease, transform 160ms ease, filter 240ms ease;
}
.footer-drawing:hover + .smiley-hint { opacity: 1; transform: translate(0, -50%); }
.footer-drawing.is-loose:hover + .smiley-hint { opacity: 0; }

/* Responsive layouts. */
@media (max-width: 520px) {
  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 0.75rem 1rem;
    padding-top: 1.35rem;
  }
  .mobile-brand { display: inline-flex; width: fit-content; min-width: 0; min-height: 48px; align-items: center; text-decoration: none; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; min-width: 0; border-bottom: 1px solid var(--line); }
  .site-nav ul { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
  .site-nav li { position: relative; min-width: 0; }
  .site-nav li:not(:last-child)::after {
    position: absolute;
    top: 50%;
    right: 0;
    width: 1px;
    height: 42%;
    background: var(--line);
    content: "";
    transform: translateY(-50%);
  }
  .site-nav a { display: flex; min-width: 0; min-height: 56px; align-items: center; justify-content: center; padding: 0.45rem 0.2rem 0.8rem; opacity: 0.66; }
  .nav-drawing { width: auto; height: 29px; max-width: calc(100% - 4px); }
  .nav-underline { bottom: 0.35rem; width: min(88%, 82px); height: 8px; }
  .theme-toggle { grid-column: 2; grid-row: 1; width: 48px; height: 48px; }
  .theme-toggle__image, .theme-toggle__image[data-mode="dark"], .theme-toggle__image[data-mode="light"] { width: 48px; height: 28px; }
}

@media (max-width: 520px) {
  .site-header, main, .site-footer { width: calc(100% - 28px); }

  main { min-height: 60vh; padding: 2.75rem 0 4rem; }
  .identity-drawing { width: min(100%, 315px); }
  .journal { margin-top: 2.25rem; }
  .journal-toggle { top: -16px; right: -12px; width: 44px; height: 44px; }
  .journal-toggle img { width: 26px; height: 26px; }
  .journal-paper {
    max-width: 100%;
    margin-top: 0.6rem;
    padding: clamp(1rem, 5vw, 1.4rem);
    box-shadow: 0 12px 34px var(--paper-shadow);
  }
  .journal-dialog { width: calc(100% - 24px); max-height: calc(100dvh - 32px); overflow-y: auto; }
  .journal-dialog__close { top: -10px; right: -8px; width: 44px; height: 44px; }
  .journal-paper--expanded { padding: clamp(1rem, 5vw, 1.75rem); }
  .journal-history { margin-top: 1.75rem; }
  .journal-history__empty { width: min(100%, 190px); }

  .page-header { margin-bottom: 2.5rem; }
  .section-drawing { height: 52px; margin-bottom: 1rem; }
  .work-list { gap: 2.5rem; }
  .work-item ul { padding-left: 1.1rem; }

  .reach-out { margin-top: 3.5rem; padding-top: 0.5rem; }
  .reach-out__title { width: min(100%, 220px); margin-bottom: 1.15rem; }
  .social-list { grid-template-columns: 1fr; width: min(100%, 245px); gap: 0.35rem; }
  .social-list a {
    grid-template-columns: 21px minmax(0, 1fr);
    gap: 0.65rem;
    min-height: 44px;
    padding: 0.2rem 0;
  }
  .social-icon { width: 19px; height: 19px; }
  .social-drawing { height: 27px; }
  .social-list__email { grid-column: auto; justify-self: stretch; width: 100%; }

  .projects-view main,
  .project-detail-view main { width: calc(100% - 32px); }
  .project-grid { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .project-card { width: 100%; max-width: 100%; }
  .project-card__body { min-width: 0; }
  .project-card h2,
  .project-card p { overflow-wrap: anywhere; }
  .project-card__body { padding: 1.1rem; }
  .project-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; padding-top: 1.1rem; }
  .project-actions .project-action { flex: 0 0 72px; }
  .project-action { width: 72px; min-width: 0; min-height: 56px; gap: 0.35rem; border: 1px solid var(--action-line); border-radius: 8px; padding: 0.4rem; color: var(--text); font-size: 0.9rem; font-weight: 600; text-decoration: none; }
  .project-action--readMore { background: var(--background); }
  .project-action__drawing { display: block; width: auto; height: 34px; max-width: 100%; object-fit: contain; object-position: center; margin: auto; }
  .project-action--readMore .project-action__drawing { height: 36px; }
  .project-action--liveDemo .project-action__drawing { height: 37px; }
  .project-action__label { display: none; }
  .project-detail__toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 0.7rem 1rem; margin-bottom: 2.25rem; }
  .project-detail__back img { height: 25px; max-width: 88px; }
  .project-detail__back { min-height: 44px; }
  .project-detail__actions { width: auto; justify-content: flex-end; justify-self: end; gap: 0.55rem; }
  .project-detail__actions .project-action { width: 58px; min-height: 48px; padding: 0.2rem 0.35rem; border-color: var(--action-line); background: transparent; }
  .project-detail__actions .project-action__drawing { height: 38px; max-width: 100%; }
  .project-detail__copy { margin: 1.75rem 0; }
  .site-footer { padding: 1rem 0 2.25rem; }
  .footer-signature { width: 155px; height: 44px; }
  .smiley-easter-egg { width: 32px; height: 32px; }
  .footer-drawing { width: 32px; height: 32px; }
  .smiley-hint { right: calc(100% + 0.4rem); width: 92px; }
}

@media (max-width: 760px) {
  .architecture-flow { left: auto; width: 100%; transform: none; }
  .architecture-flow ol { grid-template-columns: 1fr; gap: 1.35rem; }
  .architecture-flow li { padding: 0.8rem 0.9rem; }
  .architecture-flow li:not(:last-child)::after {
    top: calc(100% + 0.12rem);
    left: 50%;
    width: auto;
    transform: translate(-50%, 0);
  }
  .architecture-flow span { font-size: 0.84rem; }
}

@media (max-width: 360px) {
  .site-header, main, .site-footer { width: calc(100% - 24px); }
  .site-nav ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-nav li::after { display: none; }
  .site-nav li:nth-child(odd)::after { display: block; }
  .site-nav li:nth-child(n + 3)::before {
    position: absolute;
    top: 0;
    left: 12%;
    width: 76%;
    height: 1px;
    background: var(--line);
    content: "";
  }
  .site-nav a { min-height: 50px; }
  .nav-drawing { height: 29px; max-width: 112px; }
  .social-drawing { height: 24px; }
}

@media (min-width: 521px) and (max-width: 860px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 521px) and (max-width: 700px) {
  .project-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Theme values and drawing inversion. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --background: #050505;
    --text: #f2f2f2;
    --muted: #9d9d9d;
    --link: #c4c4c4;
    --line: #262626;
    --focus: #ffad61;
    --ambient-line: rgba(154, 167, 255, 0.045);
    --ambient-dot: rgba(154, 167, 255, 0.1);
    --paper: #0e0e0e;
    --paper-line: #242424;
    --project-line: #242424;
    --action-line: rgba(242, 242, 242, 0.08);
    --paper-shadow: rgba(0, 0, 0, 0.38);
  }
}

:root[data-theme="dark"] {
  --background: #050505;
  --text: #f2f2f2;
  --muted: #9d9d9d;
  --link: #c4c4c4;
  --line: #262626;
  --focus: #ffad61;
  --ambient-line: rgba(154, 167, 255, 0.045);
  --ambient-dot: rgba(154, 167, 255, 0.1);
  --paper: #0e0e0e;
  --paper-line: #242424;
  --project-line: #242424;
  --action-line: rgba(242, 242, 242, 0.08);
  --paper-shadow: rgba(0, 0, 0, 0.38);
}

:root[data-theme="dark"] .drawing,
:root:not([data-theme]) .drawing {
  filter: invert(1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .drawing { filter: none; }
}

:root[data-theme="light"] .drawing { filter: none; }

:root[data-theme="light"] {
  --background: #fafafa;
  --text: #171717;
  --muted: #5f5f5f;
  --link: #383838;
  --line: #dedede;
  --focus: #d87b28;
  --ambient-line: rgba(32, 42, 80, 0.045);
  --ambient-dot: rgba(32, 42, 80, 0.1);
  --paper: #ffffff;
  --paper-line: #e4e4e4;
  --project-line: #c9c9c9;
  --action-line: rgba(23, 23, 23, 0.08);
  --paper-shadow: rgba(20, 20, 20, 0.08);
}

/* Accessibility: respect visitors who disable animation. */
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .drawing,
  .journal-paper,
  .journal-toggle,
  .journal-dialog__close { transition: none; }
  .journal-dialog[open],
  .journal-dialog::backdrop,
  .journal-dialog.is-closing,
  .journal-dialog.is-closing::backdrop { animation: none; }
}
