:root {
  color-scheme: light;
  --page-background: #f7ece2;
  background: var(--page-background);
  color: #282724;
  font-family: var(--font-mono);
  --letter-gold: #a47827;
  --letter-green: #5e7545;
  --letter-blue: #6ca0bb;
  --letter-red: #a73a35;
  --letter-yellow: #d5ad00;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page-background: #202320;
  background: var(--page-background);
  color: #e6dfd2;
  --letter-gold: #d2ac60;
  --letter-green: #a2b887;
  --letter-blue: #98c5df;
  --letter-red: #e28e82;
  --letter-yellow: #f2d854;
}

* { box-sizing: border-box; }
html { overscroll-behavior: none; }
body { background-color: var(--page-background); margin: 0; min-height: 100svh; overscroll-behavior: none; }
#graph-paper { position: fixed; top: 0; left: 0; width: 100vw; height: 100%; height: 100lvh; pointer-events: none; }
main { position: relative; min-height: 100svh; min-height: 100dvh; touch-action: pinch-zoom; }

.identity {
  position: absolute;
  top: var(--grid-top, calc(env(safe-area-inset-top, 0px) + clamp(40px, 7vw, 96px)));
  right: var(--grid-right, calc(env(safe-area-inset-right, 0px) + clamp(40px, 7vw, 104px)));
  width: max-content;
  max-width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 80px);
  text-align: right;
}

.identity h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(22px, 2.5vw, 34px);
  font-weight: 400;
  line-height: 48px;
  letter-spacing: -0.045em;
  white-space: nowrap;
  transform-origin: top left;
}
.identity-copy { width: max-content; max-width: 100%; margin-left: auto; }

.identity p {
  font-family: var(--font-mono);
  margin: 0;
  font-size: clamp(11px, 1.1vw, 14px);
  font-weight: 400;
  line-height: 24px;
  letter-spacing: 0.025em;
}

@media (max-width: 600px) {
  .identity {
    top: max(var(--grid-top, 16px), env(safe-area-inset-top, 0px));
    right: var(--grid-right, calc(env(safe-area-inset-right, 0px) + 20px));
  }
  .identity h3 { line-height: 24px; }
}

.identity-letter {
  cursor: pointer;
}

.theme-switch {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: 64px;
  height: 48px;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.switch-track {
  flex-shrink: 0;
  display: block;
  width: 38px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 99px;
  padding: 3px;
}
.switch-thumb {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: currentColor;
  transition: transform 180ms ease;
}
.theme-switch[aria-checked='true'] .switch-thumb { transform: translateX(16px); }
.switch-moon { display: none; }
.theme-switch[aria-checked='true'] .switch-moon { display: block; }
.theme-switch[aria-checked='true'] .switch-sun { display: none; }
.theme-switch:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 5px; }
@media (prefers-reduced-motion: reduce) {
  .switch-thumb { transition: none; }
}

:root { --work-fill: #fff; }
:root[data-theme='dark'] { --work-fill: #000; }
html, body { width: 100%; max-width: 100vw; height: 100%; overflow: hidden; }
main { width: 100%; min-width: 0; height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }
.identity { z-index: 3; transition: opacity 350ms ease; }
main:not([data-view='home']) .identity p { visibility: hidden; }
main:not([data-view='home']) .identity-copy { position: absolute; top: -24px; right: 0; width: max-content; max-width: none; text-align: right; }
main:not([data-view='home']) .identity h3 { font-size: clamp(14px, 1.25vw, 16px); line-height: 24px; letter-spacing: -.025em; }
main:not([data-view='home']) .identity { pointer-events: none; }
main:not([data-view='home']) .theme-switch { pointer-events: auto; }
main:not([data-view='home']) .identity h3 { pointer-events: auto; }
.identity-snapshot { position: fixed; z-index: 4; pointer-events: none; text-align: right; }
.identity-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  width: max-content;
  margin-left: auto;
}
.identity-controls > .theme-switch { margin: 0; position: relative; z-index: 2; }
.ball-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0;
}
main:not([data-view='home']) .ball-control-unit { visibility: hidden; pointer-events: none; }
main:not([data-view='home']) .ball-controls .control-tooltip { visibility: hidden; }
.ball-control-unit { position: relative; display: flex; align-items: center; gap: 10px; width: 64px; }
.control-icon { display: flex; align-items: center; justify-content: center; width: 16px; flex-shrink: 0; cursor: pointer; }
.ball-control {
  position: relative;
  margin: 0;
  height: 48px;
  min-height: 48px;
  width: 38px;
}
.control-tooltip {
  --tooltip-inset: 10px;
  position: absolute;
  right: 0;
  bottom: calc(100% - var(--tooltip-inset));
  transform: translateY(4px);
  white-space: nowrap;
  padding: 0;
  background: none;
  color: inherit;
  font: 400 12px/24px var(--font-mono);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}
.ball-control:focus-visible .control-tooltip,
.identity-controls > .theme-switch:focus-visible .control-tooltip { opacity: .55; transform: translateY(0); }
@media (hover: hover) {
  .ball-control-unit:hover .control-tooltip,
  .identity-controls > .theme-switch:hover .control-tooltip { opacity: .55; transform: translateY(0); }
}
main:not([data-view='home']) .identity-controls > .theme-switch .control-tooltip { bottom: auto; top: calc(100% - var(--tooltip-inset)); }
.ball-control:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; border-radius: 4px; }
.count-dial { order: -1; width: 16px; flex-shrink: 0; text-align: center; font: 400 14px/24px var(--font-mono); cursor: ns-resize; touch-action: none; user-select: none; -webkit-user-select: none; }
.count-dial:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }
.count-input { position: absolute; left: -6px; width: 28px; height: 24px; padding: 0; border: 0; border-bottom: 1px solid currentColor; border-radius: 0; outline: none; color: inherit; background: transparent; text-align: center; font: 400 14px/24px var(--font-mono); appearance: textfield; -moz-appearance: textfield; }
.count-input::-webkit-inner-spin-button, .count-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ball-control-unit.is-editing .ball-control { visibility: hidden; pointer-events: none; }
.ball-control-unit.is-editing .count-input { left: 0; width: 100%; }
@media (max-width: 600px) {
  .identity {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 80px);
    min-width: 0;
  }
  .identity-copy { order: 0; }
  .identity-controls { order: 1; margin-top: 12px; max-width: 100%; }
  .identity-controls { flex-direction: column-reverse; align-items: flex-end; gap: 0; }
  .ball-controls { flex-direction: column; align-items: flex-end; gap: 0; }
  main:not([data-view='home']) .identity-copy { position: static; }
  main:not([data-view='home']) .identity p { display: none; }
  .count-input { font-size: 16px; }
}
.ball-size-preview {
  position: fixed;
  z-index: 2;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  -webkit-backdrop-filter: invert(1);
  backdrop-filter: invert(1);
  opacity: .05;
  pointer-events: none;
}
.work-stage {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  max-width: 100%;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  padding: var(--work-top, max(72px, env(safe-area-inset-top))) clamp(24px, 7vw, 104px) calc(144px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}
.work-stage::-webkit-scrollbar { display: none; }
.page-snapshot { z-index: 4; pointer-events: none; }
main:not([data-view='home']) { touch-action: pan-y pinch-zoom; }
.work-index, .play-index, .project-view, .about-view { width: var(--work-width, 100%); max-width: 1200px; margin-left: var(--work-left, auto); margin-right: auto; }
.section-label, .project-title { margin: 0 0 24px; font: 400 14px/24px var(--font-mono); }
.section-label:focus, .project-title:focus { outline: none; }
.work-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px 24px; }
.work-card { display: block; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; min-width: 0; touch-action: pan-y pinch-zoom; }
.work-box { display: block; width: 100%; aspect-ratio: 1.5; transform-origin: center; }
.work-slot { display: flex; align-items: center; width: 100%; aspect-ratio: 1.5; }
.work-card[data-project='astra'] .work-box { aspect-ratio: 3642 / 1454; }
.work-card[data-project='supio'] .work-box { width: 96%; margin-inline: auto; aspect-ratio: 1600 / 944; }
.work-card[data-project='supio'] .work-surface { border-radius: 10px; }
.work-caption { display: block; margin-top: 12px; font-size: 14px; line-height: 24px; }
.work-detail { display: block; font-size: 12px; line-height: 24px; opacity: .65; }
.work-card:focus-visible { outline: 1px solid currentColor; outline-offset: 8px; }
.work-box { position: relative; overflow: visible; isolation: isolate; }
.work-surface {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--work-fill);
}
.work-surface img, .work-surface video { display: block; width: 100%; height: 100%; object-fit: cover; }
.work-surface::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grain-color, var(--letter-green));
  opacity: 0;
  pointer-events: none;
  -webkit-mask-image: var(--work-mask, linear-gradient(#000, #000)), url('/public/effects/hover-pluses.svg');
  mask-image: var(--work-mask, linear-gradient(#000, #000)), url('/public/effects/hover-pluses.svg');
  -webkit-mask-size: var(--work-mask-fit, cover), 96px 96px;
  mask-size: var(--work-mask-fit, cover), 96px 96px;
  -webkit-mask-position: center, 0 0;
  mask-position: center, 0 0;
  -webkit-mask-repeat: no-repeat, repeat;
  mask-repeat: no-repeat, repeat;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
.is-distorting .work-surface::after {
  animation: grain-fade 1600ms ease-out both, grain-buzz 160ms steps(1) infinite;
}
@keyframes grain-fade {
  0% { opacity: 0; }
  8% { opacity: .35; }
  100% { opacity: 0; }
}
@keyframes grain-buzz {
  0%, 100% {
    -webkit-mask-image: var(--work-mask, linear-gradient(#000, #000)), url('/public/effects/hover-pluses.svg');
    mask-image: var(--work-mask, linear-gradient(#000, #000)), url('/public/effects/hover-pluses.svg');
  }
  50% {
    -webkit-mask-image: var(--work-mask, linear-gradient(#000, #000)), url('/public/effects/hover-pluses-alt.svg');
    mask-image: var(--work-mask, linear-gradient(#000, #000)), url('/public/effects/hover-pluses-alt.svg');
  }
}
.project-hero { position: relative; overflow: hidden; width: 100%; height: min(58dvh, 640px); min-height: 240px; background: var(--work-fill); }
.project-hero[data-project='supio'] { width: 96%; margin-inline: auto; height: auto; min-height: 0; aspect-ratio: 1600 / 944; border-radius: 12px; }
.project-hero img, .project-hero video, .morph-box img, .morph-box canvas,
.page-snapshot .work-surface canvas, .page-snapshot .project-hero canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.project-title { margin-top: 24px; font-size: clamp(18px, 3vw, 32px); line-height: 48px; }
.morph-box { position: fixed; z-index: 5; overflow: hidden; contain: layout paint; background: var(--work-fill); pointer-events: none; }
.bottom-nav {
  position: fixed;
  z-index: 10;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: var(--nav-right, clamp(40px, 7vw, 104px));
  display: flex;
  gap: 24px;
  padding: 0 24px;
  background: transparent;
  color: #282724;
  border-radius: 999px;
}
:root[data-theme='dark'] .bottom-nav { color: #e6dfd2; }
.nav-backdrop {
  position: fixed;
  z-index: 9;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: var(--nav-right, clamp(40px, 7vw, 104px));
  width: var(--nav-width, calc(13ch + 96px));
  height: var(--nav-height, 48px);
  font: 400 14px/24px var(--font-mono);
  border-radius: 999px;
  background: #fff;
  opacity: .6;
  mix-blend-mode: screen;
  mix-blend-mode: plus-lighter;
  pointer-events: none;
}
:root[data-theme='dark'] .nav-backdrop {
  background: #000;
  mix-blend-mode: multiply;
  mix-blend-mode: plus-darker;
}
.bottom-nav button { min-height: 48px; padding: 0; border: 0; font: 400 14px/24px var(--font-mono); color: inherit; background: none; cursor: pointer; }
.bottom-nav button:disabled { opacity: .4; cursor: default; }
.bottom-nav button[aria-current] { text-decoration: underline; text-underline-offset: 6px; }
.bottom-nav button:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }
.bottom-nav button:focus:not(:focus-visible) { outline: none; }
.linkedin-link { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin-bottom: 24px; color: #fff; background: #000; border-radius: 4px; }
.linkedin-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.about-view {
  width: calc(100% + var(--stage-right-padding, 24px) - var(--nav-right, 40px) - var(--work-left, 0px));
  max-width: none;
}
.about-copy { max-width: 720px; font-size: 16px; line-height: 24px; }
.about-copy p { margin: 0 0 24px; }
.about-copy p:last-child { margin-bottom: 0; }
.resume-section { margin-top: 48px; padding-top: 24px; position: relative; }
.resume-section::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: color-mix(in srgb, currentColor 20%, transparent); }
.resume-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 24px; min-height: 48px; }
.resume-heading h2 { margin: 0; font: 400 18px/24px var(--font-mono); }
.resume-download { display: inline-flex; align-items: center; justify-content: center; height: 48px; padding: 0 24px; background: none; color: inherit; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); border-radius: 99px; font: 400 14px/24px var(--font-mono); text-decoration: none; }
.resume-download:hover { background: color-mix(in srgb, currentColor 7%, transparent); }
.resume-download:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.resume-content { max-width: 720px; margin-top: 48px; }
.resume-role { display: grid; grid-template-columns: 144px minmax(0, 1fr); gap: 24px; margin-bottom: 48px; }
.resume-role > div { min-width: 0; }
.resume-role p { margin: 0; font-size: 16px; line-height: 24px; }
.resume-role .resume-dates { font-size: 14px; line-height: 24px; opacity: .65; }
.resume-role h3 { margin: 0; font: 400 20px/24px var(--font-mono); }
.resume-role .resume-job-title { margin: 0 0 24px; font-size: 14px; opacity: .75; }
@media (max-width: 600px) {
  .resume-role { grid-template-columns: 1fr; gap: 24px; }
}
.resume-download:disabled { opacity: .4; cursor: default; }
@media (max-width: 800px) {
  .work-stage { padding-left: 16px; }
  .work-index, .play-index, .project-view { width: 100%; margin-left: 0; }
  .about-view { margin-left: 0; }
  .work-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .work-stage { padding-top: var(--work-top, calc(env(safe-area-inset-top) + 96px)); }
  .work-grid { gap: 24px; }
  .work-box { aspect-ratio: 1; }
  .work-slot { aspect-ratio: 1; }
  .work-caption { font-size: 13px; line-height: 20px; }
  .work-detail { line-height: 20px; }
  .project-hero { height: 48dvh; }
}
@media (prefers-reduced-motion: reduce) {
  .is-distorting .work-surface::after { animation: none; }
  main[data-view='home'] .identity { translate: none; }
}

.project-hero[data-project='splice'] { height: auto; min-height: 0; aspect-ratio: 16 / 9; border-radius: 12px; }

.project-content { min-width: 0; padding-top: 24px; }
.case-section { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 3fr); column-gap: 48px; margin: 0 0 64px; }
.case-section h3 { grid-column: 1; grid-row: 1 / span 20; margin: 4px 0 0; font: 400 14px/24px var(--font-mono); }
.case-section p, .case-section h4 { grid-column: 2; max-width: 760px; margin: 0 0 24px; font: 300 16px/1.65 var(--font-mono); overflow-wrap: break-word; }
.case-section h4 { font-size: 14px; margin-top: 16px; }
.case-section .case-headline { grid-column: 1 / -1; max-width: 900px; font-size: clamp(24px, 4vw, 44px); line-height: 1.3; }
.case-section .case-meta { font-size: 14px; }
.case-gallery { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 36px 24px; margin: 0 0 72px; align-items: start; }
.case-gallery figure { margin: 0; min-width: 0; }
.case-landscape { grid-column: span 6; }
.case-portrait { grid-column: span 2; }
.case-gallery img, .case-gallery video { display: block; width: 100%; height: auto; border-radius: 8px; }
.case-gallery figcaption { margin-top: 12px; font: 400 14px/24px var(--font-mono); opacity: .7; }
@media (max-width: 600px) {
  .project-content { padding-top: 12px; }
  .case-section { display: block; margin-bottom: 40px; }
  .case-section h3 { margin-bottom: 16px; }
  .case-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 16px; margin-bottom: 40px; }
  .case-landscape { grid-column: span 2; }
  .case-portrait { grid-column: span 1; }
}

.case-video { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; margin: 0 0 64px; }

.project-back {
  position: fixed;
  z-index: 8;
  top: max(24px, env(safe-area-inset-top));
  left: clamp(24px, 7vw, 104px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.project-back[hidden] { display: none; }
.project-back:hover { opacity: .65; }
.project-back:focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }

/* Replaced media must shrink with the viewport, including in Safari. */
.work-index, .play-index, .project-view, .about-view, .work-slot, .work-surface,
.project-hero, .project-content, .case-section, .case-gallery { min-width: 0; }
.project-hero img, .project-hero video, .case-gallery img,
.case-gallery video, .case-video { max-width: 100%; }
@media (max-width: 600px) {
  .identity { max-width: calc(100% - 32px); }
}

/* Let Safari's document scroll drive its collapsing browser controls. */
@media (max-width: 800px), (pointer: coarse) {
  html { height: auto; min-height: 100%; overflow-x: clip; overflow-y: auto; }
  body { height: auto; min-height: 100lvh; overflow: visible; }
  main { height: auto; min-height: 100lvh; overflow: clip; touch-action: pan-y pinch-zoom; }
  .identity { position: absolute; }
  .work-stage { position: relative; inset: auto; min-height: 100lvh; overflow: visible; overscroll-behavior: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .work-stage.page-snapshot { position: fixed; inset: 0; height: 100dvh; min-height: 0; overflow: hidden; }
}

.project-hero[data-project='astra'] { height: auto; min-height: 0; aspect-ratio: 3642 / 1454; border-radius: 8px; }

.home-link { color: inherit; text-decoration: none; cursor: pointer; }
.home-link:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; border-radius: 2px; }
.case-copy-panel, .case-gallery figcaption { position: relative; padding: 24px; border-radius: 8px; }
.case-copy-panel { margin-bottom: 64px; }
.case-copy-panel::before, .case-gallery figcaption::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 8px;
  pointer-events: none;
  background: #fff;
  opacity: .5;
  mix-blend-mode: screen;
  mix-blend-mode: plus-lighter;
}
:root[data-theme='dark'] .case-copy-panel::before,
:root[data-theme='dark'] .case-gallery figcaption::before {
  background: #000;
  mix-blend-mode: multiply;
  mix-blend-mode: plus-darker;
}
.case-copy-panel > *, .case-gallery figcaption > span { position: relative; z-index: 1; }
.case-copy-panel .project-title { margin: 0 0 24px; }
.case-copy-panel .project-title:last-child { margin-bottom: 0; }
.case-copy-panel .case-section { margin-bottom: 40px; }
.case-copy-panel .case-section:last-child { margin-bottom: 0; }
.case-section p:last-child { margin-bottom: 0; }
.case-section .case-headline { font-weight: 400; }
.case-gallery figcaption { padding: 8px 12px; opacity: 1; }
@media (max-width: 600px) {
  .case-copy-panel { padding: 16px; margin-bottom: 40px; }
}

.project-hero[data-project='output'] img { object-position: center 40%; }

@media (max-width: 800px) {
  .work-card .work-slot { aspect-ratio: auto; }
  .work-card[data-project] .work-box { aspect-ratio: var(--project-aspect); }
  .work-caption { margin-top: 16px; text-align: right; }
  .work-card {
    padding-bottom: 24px;
    border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent);
  }
}

@media (max-width: 800px), (pointer: coarse) {
  .bottom-nav, .nav-backdrop { bottom: env(safe-area-inset-bottom, 0px); }
  .nav-backdrop { opacity: 1; mix-blend-mode: normal; }
  :root[data-theme='dark'] .nav-backdrop { mix-blend-mode: normal; }
}

@media (max-width: 800px), (pointer: coarse) {
  .project-back {
    position: absolute;
    top: var(--project-back-top, env(safe-area-inset-top, 0px));
    /* The SVG stroke starts 14px inside its 44px touch target. */
    left: 2px;
    margin-left: 0;
  }
}

.mobile-header { display: none; }
@media (max-width: 800px), (pointer: coarse) {
  main:not([data-view='home']) > .identity { display: none; }
  .mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 8;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    align-items: center;
    min-height: calc(44px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
    background: color-mix(in srgb, #f7ece2 55%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transform: translateY(0);
    transition: transform 240ms cubic-bezier(.22, 1, .36, 1);
  }
  :root[data-theme='dark'] .mobile-header { background: color-mix(in srgb, #202320 55%, transparent); }
  .mobile-header.is-scrolled-away { transform: translateY(-100%); }
  .mobile-header:has(:focus-visible) { transform: translateY(0); }
  .mobile-header-name { grid-column: 2; grid-row: 1; display: flex; align-items: center; justify-content: center; justify-self: center; height: 44px; margin: 0; white-space: nowrap; font: 400 14px/24px var(--font-mono); letter-spacing: -.025em; }
  .mobile-header-back, .mobile-header-theme { display: flex; align-items: center; min-height: 44px; }
  .mobile-header-back { grid-column: 1; grid-row: 1; }
  .mobile-header-theme { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  .mobile-header .project-back { position: static; margin: 0 0 0 -14px; }
  .mobile-header .theme-switch { height: 44px; margin: 0; }
  .mobile-header .control-tooltip { display: none; }
  main:not([data-view='home']) .work-stage:not(.page-snapshot) { padding-top: calc(68px + env(safe-area-inset-top, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-header { transition: none; }
}

.work-assets { margin-top: 72px; padding-top: 32px; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.work-assets-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1px; gap: 0 24px; align-items: start; }
.work-asset { margin: 0; min-width: 0; }
.work-asset img, .work-asset video, .work-asset canvas { display: block; width: 100%; max-width: 100%; height: auto; border-radius: 8px; }
@media (max-width: 800px) {
  .work-assets { margin-top: 48px; padding-top: 24px; }
  .work-assets-grid { grid-template-columns: minmax(0, 1fr); }
}

.project-placeholder { display: block; width: 100%; height: 100%; background: var(--work-fill); }

.project-hero[data-project='hairtracker'] { height: auto; min-height: 0; overflow: visible; border-radius: 24px; background: transparent; }
.hairtracker {
  --hair-paper: #dfb09c;
  --hair-ink: #3b2921;
  --hair-edge: #3b292133;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid var(--hair-edge);
  background: var(--hair-paper);
  color: var(--hair-ink);
  overflow: hidden;
}
:root[data-theme='dark'] .hairtracker { --hair-paper: #795750; --hair-ink: #f3e2d1; --hair-edge: #f3e2d133; }
.hair-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--hair-edge); }
.hair-title { margin: 0 0 8px; font: 400 24px/1.2 var(--font-mono); letter-spacing: -.05em; }
.hair-title:focus { outline: none; }
.hair-heading p { margin: 0; font-size: 12px; opacity: .7; }
.hair-meter { text-align: right; min-width: 0; }
.hair-meter > span { display: block; font-size: 12px; margin-bottom: 4px; opacity: .7; }
.hair-meter output { display: block; font: 300 clamp(28px, 4vw, 48px)/1.1 var(--font-mono); letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.hair-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 24px; }
.hair-scene { position: relative; min-width: 0; height: clamp(420px, 60dvh, 620px); overflow: hidden; border-radius: 16px; background: #ffffff0b; }
.hair-scene canvas { display: block; width: 100%; height: 100%; touch-action: pan-y pinch-zoom; cursor: default; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.hair-hint { position: absolute; left: 16px; top: 16px; width: 170px; margin: 0; text-align: left; font: 400 11px/18px var(--font-mono); opacity: .55; pointer-events: none; }
.hair-settings { display: flex; flex-direction: column; min-width: 0; gap: 12px; }
.hair-settings > label, .hair-control-label { font-size: 14px; }
.hair-settings button, .hair-settings select { min-height: 40px; border: 1px solid var(--hair-edge); border-radius: 8px; padding: 8px 12px; background: transparent; color: inherit; font: 400 14px/20px var(--font-mono); cursor: pointer; }
.hair-settings select { width: 100%; font-size: 16px; appearance: none; padding-right: 28px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%233b2921'/%3E%3C/svg%3E") right 8px center / 16px no-repeat; }
.hair-settings select option { background: var(--hair-paper); color: var(--hair-ink); }
.hair-settings button:hover { background-color: #ffffff12; }
.hair-settings button:focus-visible, .hair-settings select:focus-visible, .hair-scene canvas:focus-visible, .hair-model summary:focus-visible { outline: 2px solid var(--hair-ink); outline-offset: 3px; }
.hair-settings button:disabled { opacity: .35; cursor: default; }
.hair-rate { margin: 0 0 12px; display: grid; gap: 4px; font-size: 12px; line-height: 18px; }
.hair-rate > span + span { opacity: .6; }
.hair-colors { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.hair-colors .hair-swatch { width: 28px; height: 28px; min-height: 28px; padding: 0; border-radius: 50%; background: var(--swatch); border: 2px solid transparent; }
.hair-colors .hair-swatch:hover { background: var(--swatch); }
.hair-swatch[aria-pressed='true'] { outline: 1px solid var(--hair-ink); outline-offset: 3px; }
.hair-custom-color { position: relative; width: 28px; height: 28px; display: grid; place-items: center; font-size: 18px; border: 1px solid var(--hair-edge); border-radius: 50%; overflow: hidden; }
.hair-custom-color input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; opacity: 0; cursor: pointer; }
.hair-custom-color:focus-within { outline: 2px solid var(--hair-ink); outline-offset: 3px; }
.hair-clippings { margin: 0; font-size: 11px; line-height: 18px; opacity: .65; }
.hair-model { margin-top: 24px; border-top: 1px solid var(--hair-edge); padding-top: 20px; font-size: 12px; line-height: 1.7; }
.hair-model summary { cursor: pointer; width: fit-content; }
.hair-model p { max-width: 780px; font-size: 16px; }
.hair-model table { border-collapse: collapse; font-size: 12px; max-width: 100%; }
.hair-model th, .hair-model td { padding: 8px 16px 8px 0; text-align: left; font-weight: 400; border-bottom: 1px solid var(--hair-edge); }
.hair-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 800px) {
  .project-hero[data-project='hairtracker'] { border-radius: 18px; }
  .hairtracker { padding: 16px; border-radius: 18px; }
  .hair-hint { width: 90px; }
  .hair-heading { gap: 12px; padding-bottom: 16px; margin-bottom: 16px; }
  .hair-title { font-size: 20px; }
  .hair-heading p { max-width: 125px; line-height: 18px; }
  .hair-workspace { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .hair-scene { height: clamp(360px, 55dvh, 520px); }
  .hair-settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; align-items: start; }
  .hair-settings > label { grid-column: 1; }
  .hair-settings select { grid-column: 1; grid-row: 2; }
  .hair-rate { grid-column: 1; grid-row: 3; }
  #hair-color-label { grid-column: 2; grid-row: 1; }
  .hair-colors { grid-column: 2; grid-row: 2 / span 2; margin-bottom: 0; }
  .hair-clippings { grid-column: 1 / -1; }
}

.work-type-tools { margin-top: 64px; padding-top: 24px; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.typography-link { display: flex; justify-content: space-between; gap: 24px; color: inherit; padding: 24px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); border-radius: 8px; text-decoration: none; }
.typography-link:hover { background: color-mix(in srgb, currentColor 5%, transparent); }
.typography-link:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

.work-asset-frame { position: relative; width: 100%; margin-inline: auto; min-width: 0; }
.work-asset-frame.is-cropped { overflow: hidden; border-radius: var(--bit-radius, 8px); }
.work-asset-frame.is-cropped > img, .work-asset-frame.is-cropped > video, .work-asset-frame.is-cropped > canvas { position: absolute; left: 0; max-width: none; border-radius: 0; }

/* Independent tilt and flip layers keep the touch-selected axis stable. */
.work-asset { perspective: 1600px; }
.bit-card { display: block; position: relative; width: 100%; margin: 0 auto; padding: 0; border: 0; border-radius: var(--bit-radius, 8px); background: transparent; color: inherit; text-align: left; cursor: pointer; touch-action: pan-y pinch-zoom; transform-style: preserve-3d; transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)); transition: transform 200ms ease-out; -webkit-tap-highlight-color: transparent; }
.bit-card:focus-visible { outline: 2px solid currentColor; outline-offset: 6px; }
.bit-rotor { display: block; position: relative; transform-style: preserve-3d; transition: transform 650ms cubic-bezier(.22,.7,.22,1); }
.bit-card.is-flipped .bit-rotor { transform: rotate3d(var(--flip-x, 0), var(--flip-y, 1), 0, 180deg); }
.bit-front, .bit-back { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bit-front { transform: translateZ(.1px); pointer-events: none; }
.bit-back { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: clamp(16px, 2vw, 24px); border-radius: var(--bit-radius, 8px); background: var(--bit-color); color: #171c17; transform: rotate3d(var(--flip-x, 0), var(--flip-y, 1), 0, 180deg) translateZ(.1px); overflow-y: auto; gap: 16px; }
.bit-title { display: block; font: 400 clamp(18px, 2vw, 28px)/1.25 var(--font-mono); letter-spacing: -.025em; }
.bit-description { display: block; width: 100%; max-width: none; font: 300 14px/1.65 var(--font-mono); }
.bit-hint { display: block; margin-top: 8px; font: 400 11px/1.4 var(--font-mono); opacity: .7; }
.bit-card:not(.is-flipped) .bit-back { pointer-events: none; }
.bit-card.is-flipped .bit-front { pointer-events: none; }
@media(prefers-reduced-motion: reduce) { .bit-card, .bit-rotor { transition: none; } }
:root:not([data-theme='dark']) .bit-card[data-color='red'] .bit-back,
:root:not([data-theme='dark']) .bit-card[data-color='green'] .bit-back,
:root:not([data-theme='dark']) .bit-card[data-color='gold'] .bit-back { color: #fff9ef; }
.bit-back { justify-content: safe center; }
.bit-card-wide .bit-back { padding: 12px 16px; gap: 8px; }
.bit-card-wide .bit-title { font-size: 18px; }
.bit-card-wide .bit-description { max-width: none; }
.bit-card-wide .bit-hint { display: none; }

.bit-description { white-space: pre-line; margin: 0 !important; }
.bit-title, .bit-description, .bit-hint { flex-shrink: 0; }

.bit-hint { opacity: 0; transition: opacity 150ms ease; }
@media (hover: hover) {
  .bit-card.is-flipped:hover .bit-hint { opacity: .7; }
}
@media (prefers-reduced-motion: reduce) {
  .bit-hint { transition: none; }
}

/* Keep Safari's initial layout and text scale tied to the device viewport. */
html { width: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.bit-card { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.bit-rotor { transition: transform 650ms cubic-bezier(.22,.7,.22,1), height 650ms cubic-bezier(.22,.7,.22,1); }
.bit-front { position: absolute; left: 0; top: 50%; transform: translateY(-50%) translateZ(.1px); }
.bit-back { overflow: hidden; }
@media (max-width: 800px), (pointer: coarse) {
  body { width: 100%; max-width: 100%; }
  input, select, textarea { font-size: max(16px, 1rem); }
  .identity-copy { min-width: 0; }
  main[data-view='home'] .identity h3 { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { .bit-rotor { transition: none; } }

.case-section .case-list { grid-column: 2; max-width: 760px; margin: 0 0 24px; padding-left: 1.5em; font: 300 16px/1.65 var(--font-mono); }
.case-list li + li { margin-top: 8px; }

.text-wash {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: .06em .15em;
  border-radius: .2em;
}

/* Keep the sticky anchor viewport-sized; overscan only its absolute canvas. */
.sticky-grid-layer { --background-height: 100lvh; position: sticky; top: 0; width: 100%; height: var(--background-height); margin-bottom: calc(0px - var(--background-height)); z-index: 0; pointer-events: none; }
.sticky-grid-layer canvas { display: block; width: 100%; height: 100%; }
.sticky-grid-test #graph-paper { position: absolute; top: -60px; bottom: auto; left: 0; width: 100%; height: calc(100% + 120px); }
.sticky-grid-test main { z-index: 2; }

/* Two little games, sharing the portfolio's liquid color field. */
.project-hero[data-project='metaball-painting'] { height: auto; min-height: 0; overflow: visible; border-radius: 24px; background: transparent; }
.metaball-painting { --paint-paper: #e9e1d5; --paint-ink: #302e28; --paint-edge: #302e282b; padding: 28px; border-radius: 24px; background: var(--paint-paper); color: var(--paint-ink); border: 1px solid var(--paint-edge); min-width: 0; }
:root[data-theme='dark'] .metaball-painting { --paint-paper: #30372f; --paint-ink: #e6dfd2; --paint-edge: #e6dfd22b; }
.paint-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--paint-edge); padding-bottom: 24px; margin-bottom: 24px; }
.paint-title { margin: 0 0 8px; font: 400 24px/1.25 var(--font-mono); letter-spacing: -.04em; }
.paint-title:focus { outline: none; }
.paint-heading p { margin: 0; font: 400 12px/1.6 var(--font-mono); opacity: .65; }
.paint-round { flex-shrink: 0; font: 400 11px/1.6 var(--font-mono); opacity: .6; padding-top: 4px; }
.paint-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 228px; gap: 28px; }
.paint-main, .paint-controls { min-width: 0; }
.paint-board-wrap { width: 100%; max-width: 640px; margin-inline: auto; aspect-ratio: 1; position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--paint-edge); background: #f2e9dd; }
:root[data-theme='dark'] .paint-board-wrap { background: #242924; }
.paint-board { display: block; width: 100%; height: 100%; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; cursor: crosshair; }
.paint-board-tag, .paint-hold-hint { position: absolute; pointer-events: none; font: 400 10px/1.5 var(--font-mono); opacity: .55; }
.paint-board-tag { left: 16px; top: 14px; }
.paint-hold-hint { left: 0; right: 0; bottom: 14px; text-align: center; }
.metaball-painting[data-holding='true'] .paint-hold-hint { opacity: .85; }
.paint-instruction { font: 400 12px/1.65 var(--font-mono); min-height: 3.3em; margin: 16px 0; max-width: 60ch; }
.paint-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.paint-actions button, .paint-controls button, .paint-controls select { min-height: 42px; padding: 9px 12px; border: 1px solid var(--paint-edge); border-radius: 8px; color: inherit; background: transparent; font: 400 12px/1.5 var(--font-mono); cursor: pointer; }
.paint-actions button:hover, .paint-controls button:hover { background: #ffffff12; }
.paint-actions button:disabled { opacity: .35; cursor: default; }
.paint-actions [data-action='next'], .paint-actions [data-action='finish']:not(:disabled) { background: var(--paint-ink); color: var(--paint-paper); border-color: var(--paint-ink); }
.paint-controls { display: flex; flex-direction: column; gap: 20px; }
.paint-controls fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.paint-controls legend, .paint-shape-settings > label { display: block; font: 400 11px/1.5 var(--font-mono); margin-bottom: 10px; opacity: .7; }
.paint-modes { display: grid; gap: 8px; }
.paint-modes button { display: block; width: 100%; text-align: left; padding: 12px; }
.paint-modes button small { display: block; font: 400 10px/1.5 var(--font-mono); opacity: .6; margin-top: 4px; }
.paint-modes button[aria-pressed='true'] { border-color: currentColor; background: #ffffff12; }
.paint-controls select { width: 100%; font-size: 16px; margin-bottom: 16px; }
.paint-controls option { color: var(--paint-ink); background: var(--paint-paper); }
.paint-ball-modes label { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; font: 400 12px/1.5 var(--font-mono); cursor: pointer; }
.paint-controls input { accent-color: var(--paint-ink); }
.paint-score { padding: 18px; border-radius: 12px; background: #ffffff15; border: 1px solid var(--paint-edge); }
.paint-score > span { font: 400 11px/1.5 var(--font-mono); opacity: .7; }
.paint-score-value { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 12px; }
.paint-score-value output { font: 300 36px/1.1 var(--font-mono); letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.paint-score-value > span { font: 400 25px/1.1 var(--font-display); opacity: .8; }
.paint-score p { margin: 12px 0 0; font: 400 11px/1.5 var(--font-mono); }
.paint-score-details { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; font: 400 10px/1.5 var(--font-mono); opacity: .7; }
.paint-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font: 400 11px/1.6 var(--font-mono); opacity: .65; }
.paint-difference { font: 400 11px/1.5 var(--font-mono); display: flex; align-items: center; gap: 8px; }
.paint-help { border-top: 1px solid var(--paint-edge); padding-top: 16px; font: 400 11px/1.7 var(--font-mono); }
.paint-help summary { cursor: pointer; }
.paint-help p { font: inherit; margin: 12px 0 0; }
.paint-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.paint-board:focus-visible, .metaball-painting button:focus-visible, .metaball-painting select:focus-visible, .paint-help summary:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.paint-card-preview { position: relative; display: grid; place-items: center; width: 100%; height: 100%; border: 1px solid color-mix(in srgb, currentColor 14%, transparent); border-radius: 16px; background: color-mix(in srgb, var(--letter-green) 8%, transparent); }
.paint-card-preview::before { content: ''; width: 48%; aspect-ratio: 1; border-radius: 50%; border: 1px dashed currentColor; opacity: .5; }
.paint-card-preview::after { content: ''; position: absolute; width: 38%; aspect-ratio: 1; border-radius: 46% 54% 48% 52%; background: linear-gradient(135deg, var(--letter-green), var(--letter-blue)); opacity: .65; transform: translate(14%, 9%); }
.paint-board-result { position: absolute; right: 14px; top: 12px; pointer-events: none; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--paint-edge); color: var(--paint-ink); background: var(--paint-paper); font: 400 12px/1.5 var(--font-mono); font-variant-numeric: tabular-nums; }
.paint-main { width: 100%; max-width: 640px; justify-self: center; }
@media (max-width: 800px) {
  .project-hero[data-project='metaball-painting'] { border-radius: 18px; }
  .metaball-painting { padding: 16px; border-radius: 18px; }
  .paint-heading { gap: 12px; padding-bottom: 16px; margin-bottom: 16px; }
  .paint-title { font-size: 20px; }
  .paint-heading p { max-width: 26ch; font-size: 11px; }
  .paint-workspace { display: flex; flex-direction: column; gap: 20px; }
  .paint-controls { display: contents; }
  .paint-controls > .paint-modes { order: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .paint-modes legend { grid-column: 1 / -1; }
  .paint-shape-settings { order: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 16px; align-items: start; }
  .paint-shape-settings > label { grid-column: 1; margin: 0; }
  .paint-shape-settings select { grid-column: 1; margin-bottom: 0; }
  .paint-shape-settings .paint-ball-modes { grid-column: 2; grid-row: 1 / span 2; }
  .paint-ball-modes label { display: flex; margin: 0 0 5px; }
  .paint-main { order: 1; }
  .paint-score, .paint-stats, .paint-difference, .paint-help { order: 2; }
  .paint-score { padding: 14px; }
  .paint-score-value { justify-content: flex-start; gap: 16px; margin-top: 4px; }
  .paint-score-value output { font-size: 32px; }
  .paint-score p { margin-top: 8px; }
  .paint-instruction { font-size: 11px; }
  .paint-board-tag { font-size: 9px; left: 12px; top: 10px; }
  .paint-actions button { flex: 1 0 auto; }
}

/* Declare the drawing gesture before a touch starts, as in the painting game.
   The homepage's own swipe navigation still handles deliberate drags. */
:root[data-hold-to-grow='true'] main[data-view='home'] {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.contact-diagnostics { position: fixed; z-index: 30; left: 12px; bottom: calc(68px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 24px); padding: 10px 12px; border: 1px solid #28272440; border-radius: 8px; background: #f7ece2ed; color: #282724; font: 10px/1.5 'IBM Plex Mono', monospace; white-space: pre-line; pointer-events: none; }

.bit-card { transition: transform 200ms ease-out, width 650ms cubic-bezier(.22,.7,.22,1); }
@media (max-width: 800px), (pointer: coarse) {
  .bit-card.is-flipped { width: 100% !important; }
}
@media (prefers-reduced-motion: reduce) { .bit-card { transition: none; } }

@media (max-width: 800px), (pointer: coarse) {
  :root main[data-view='home'] .mobile-header { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; pointer-events: none; }
  main[data-view='home'] .mobile-header-theme { pointer-events: auto; }
  main:not([data-view='home']) .mobile-ball-controls { pointer-events: none; }
  .mobile-ball-controls { position: fixed; z-index: 7; right: var(--nav-right, 16px); width: 64px; margin: 0; flex-direction: column; align-items: flex-end; gap: 0; }
}

/* Give Safari's edge-color sampler a live painted surface on theme changes.
   One pixel avoids covering the animated background with an opaque header. */
@media (max-width: 800px), (pointer: coarse) {
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    z-index: 1;
    pointer-events: none;
    background-color: #f7ece2;
  }
  :root[data-theme='dark'] body::before { background-color: #202320; }
}
